/* Enhanced Live Search — Frontend Styles v1.7.0 */

/* Block wrapper — full width in editor and frontend */
.wp-block-enhanced-search-search-block {
    width: 100%;
    box-sizing: border-box;
}

.els-search-wrapper {
    position: relative;
    font-family: inherit;
    font-size: inherit;
    width: 100%;
    box-sizing: border-box;
}

.els-search-inner {
    width: 100%;
    box-sizing: border-box;
    font-size: inherit;
}

/* Input wrapper */
.els-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.els-search-input {
    width: 100%;
    padding: 12px 44px 12px 16px;
    font-size: inherit;
    border: 1px solid #ddd;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.els-search-input:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.els-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    pointer-events: none;
    display: flex;
    align-items: center;
}

.els-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
}

.els-search-clear:hover { color: #333; }

/* Label */
.els-search-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

/* Button variants */
.els-button-wrapper {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.els-search-button {
    padding: 10px 18px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    white-space: nowrap;
    transition: background 0.2s;
}

.els-search-button:hover { background: #135e96; }

/* Category pills — full reset so theme button styles don't interfere */
.els-category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.els-category-pill {
    /* Reset theme button styles */
    appearance: none;
    -webkit-appearance: none;
    box-shadow: none;
    text-shadow: none;
    text-transform: none;
    letter-spacing: normal;
    font-family: inherit;
    cursor: pointer;
    /* Our styles */
    padding: 6px 16px;
    border: 1px solid var(--wp--preset--color--contrast, #1d2327);
    border-radius: 20px;
    background: transparent;
    color: var(--wp--preset--color--contrast, #1d2327);
    font-size: 14px;
    transition: all 0.15s;
    line-height: 1.4;
    display: inline-block;
}

.els-category-pill:hover,
.els-category-pill.active {
    background: var(--wp--preset--color--contrast, #1d2327);
    color: var(--wp--preset--color--base, #ffffff);
    border-color: var(--wp--preset--color--contrast, #1d2327);
    box-shadow: none;
}

/* Dropdown */
.els-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 9999;
    max-height: 480px;
    overflow-y: auto;
}

/* Status messages */
.els-status {
    padding: 12px 16px;
    font-size: 14px;
    color: #666;
}

/* Results header */
.els-results-header {
    padding: 8px 16px;
    font-size: 14px;
    color: #555;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
}

/* Result item */
/* Result item is the clickable link */
.els-result-item {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    padding: 16px !important;
    text-decoration: none !important;
    color: inherit !important;
    gap: 16px !important;
    border-bottom: 1px solid #f0f0f0 !important;
    padding-bottom: 20px !important;
}

.els-result-item:last-child { border-bottom: none !important; }
.els-result-item:hover { background: #f8f9fa; text-decoration: none; }

.els-result-thumbnail {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.els-result-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.els-result-title {
    font-weight: 600;
    font-size: 16px;
    margin: 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #1d2327;
}

.els-result-title mark {
    background: #fff3cd;
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

.els-result-excerpt {
    font-size: 14px;
    color: #666;
    margin: 0 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Responsive */
@media (max-width: 480px) {
    .els-result-thumbnail { display: none; }
    .els-result-item { padding: 10px 12px; }
}

/* WC actions inside result content */
.els-wc-actions {
    margin-top: 4px !important;
}

.els-wc-price {
    margin: 0 !important;
}

/* WooCommerce — price */
.els-wc-price {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.els-wc-price del {
    color: #999;
    font-weight: 400;
    margin-right: 4px;
}

.els-wc-price ins {
    text-decoration: none;
    color: #c0392b;
}

/* WooCommerce — stock badge */
.els-stock-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 3px;
    margin-top: 3px;
}

.els-stock-badge.out-of-stock {
    background: #fce8e6;
    color: #c0392b;
}

/* WooCommerce — action buttons */
.els-add-to-cart-btn,
.els-view-product-btn {
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 3px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.els-add-to-cart-btn {
    background: var(--wp--preset--color--contrast, #1d2327);
    color: var(--wp--preset--color--base, #ffffff);
    border: none;
    font-size: 14px;
    padding: 8px 18px;
}

.els-add-to-cart-btn:hover { opacity: 0.85; }

.els-add-to-cart-btn.els-added {
    background: #2d7a2d;
    color: #fff;
}

.els-add-to-cart-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.els-view-product-btn {
    background: transparent;
    color: var(--wp--preset--color--contrast, #1d2327);
    border: 1px solid var(--wp--preset--color--contrast, #1d2327);
}

.els-view-product-btn:hover { opacity: 0.7; }

/* Footer */
.els-results-footer {
    padding: 10px 16px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
    text-align: center;
}

.els-view-all-link {
    font-size: 13px;
    color: #2271b1;
    text-decoration: none;
}

.els-view-all-link:hover { text-decoration: underline; }

/* Loading */
.els-loading { display: none; }

/* ---- Overlay mode ---- */
.els-overlay-trigger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: opacity 0.15s;
}
.els-overlay-trigger:hover { opacity: 0.7; }

.els-overlay-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0);
    z-index: 99999;
    transition: background 0.2s;
}
.els-overlay-backdrop.els-overlay-open {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: rgba(0,0,0,0.55);
    animation: els-backdrop-in 0.2s ease forwards;
}

@keyframes els-backdrop-in {
    from { background: rgba(0,0,0,0); }
    to   { background: rgba(0,0,0,0.55); }
}

.els-overlay-panel {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin-top: 80px;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    animation: els-panel-in 0.2s ease forwards;
}

@keyframes els-panel-in {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.els-overlay-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #888;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
}
.els-overlay-close:hover { color: #333; background: #f0f0f0; }

.els-overlay-dropdown {
    position: static !important;
    border-radius: 4px !important;
    border: 1px solid #ddd !important;
    border-top: 1px solid #ddd !important;
    margin-top: 8px;
    box-shadow: none !important;
}

/* ---- Loading skeleton ---- */
.els-skeleton { padding: 8px 0; }

.els-skeleton-item {
    display: flex;
    gap: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}
.els-skeleton-item:last-child { border-bottom: none; }

.els-skeleton-thumb {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: els-shimmer 1.2s infinite;
    flex-shrink: 0;
}

.els-skeleton-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
}

.els-skeleton-line {
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: els-shimmer 1.2s infinite;
}
.els-skeleton-title { width: 55%; height: 14px; }
.els-skeleton-excerpt { width: 85%; }

@keyframes els-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Keyboard focused result */
.els-result-item.els-result-focused {
    background: #f0f4f8 !important;
    outline: 2px solid #2271b1;
    outline-offset: -2px;
}

/* Overlay close button — sits above search field, not overlapping it */
.els-overlay-panel {
    position: relative;
}
.els-overlay-close {
    display: block !important;
    position: relative !important;
    top: auto !important;
    right: auto !important;
    margin-left: auto;
    margin-bottom: 10px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #888;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
}
.els-overlay-close:hover { color: #333; background: #f0f0f0; }

/* Search History */
.els-history-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    z-index: 9999;
    max-height: 300px;
    overflow-y: auto;
}
.els-history-header {
    padding: 8px 12px 4px;
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid #f0f0f0;
}
.els-history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    color: #333;
    font-size: 14px;
    transition: background .15s;
}
.els-history-item:hover { background: #f6f6f6; }
.els-history-icon {
    color: #aaa;
    flex-shrink: 0;
    font-size: 13px;
}
.els-history-term { flex: 1; }
.els-history-remove {
    background: none;
    border: none;
    color: #bbb;
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
}
.els-history-remove:hover { color: #666; }

/* Go to cart button */
.els-go-to-cart-btn {
    display: inline-block;
    margin-left: 12px;
    padding: 6px 14px;
    font-size: 13px;
    color: #2271b1;
    background: #fff;
    border: 1px solid #2271b1;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
}
.els-go-to-cart-btn:hover { background: #f0f6fc; color: #135e96; border-color: #135e96; }
