/**
 * Voice Search - Frontend Styles
 *
 * Mobile/tablet only (max-width: 1024px).
 * BEM naming convention: .voice-search__[element]--[modifier]
 */

/* Hide everything on desktop */
.voice-search__icon,
.voice-search__overlay {
    display: none;
}

@media (max-width: 1024px) {

    /* =========================================================
       Search Icon (FAB)
       ========================================================= */

    .voice-search__icon {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 20px;
        left: 20px;
        width: 56px;
        height: 56px;
        border: none;
        border-radius: 50%;
        background: #1a1a2e;
        color: #fff;
        cursor: pointer;
        z-index: 9999;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        padding: 0;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .voice-search__icon:active {
        transform: scale(0.92);
    }

    .voice-search__icon:focus {
        outline: 2px solid #4a90d9;
        outline-offset: 2px;
    }

    .voice-search__icon svg {
        width: 24px;
        height: 24px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    /* =========================================================
       Overlay
       ========================================================= */

    .voice-search__overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10000;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }

    .voice-search__overlay--visible {
        visibility: visible;
    }

    .voice-search__overlay--open {
        opacity: 1;
        visibility: visible;
    }

    /* Backdrop */
    .voice-search__backdrop {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.85);
    }

    /* Main container */
    .voice-search__container {
        position: relative;
        z-index: 1;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    /* White panel background when results are showing */
    .voice-search__overlay--has-query .voice-search__container::after {
        content: '';
        position: absolute;
        top: 56px;
        left: 8px;
        right: 8px;
        bottom: 8px;
        background: #fff;
        border-radius: 14px;
        z-index: 0;
    }

    .voice-search__overlay--admin-bar.voice-search__overlay--has-query .voice-search__container::after {
        top: 102px;
    }

    /* =========================================================
       Close Button
       ========================================================= */

    .voice-search__close {
        position: absolute;
        top: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: #fff;
        cursor: pointer;
        padding: 0;
        z-index: 2;
        border-radius: 50%;
        -webkit-tap-highlight-color: transparent;
    }

    .voice-search__overlay--admin-bar .voice-search__close {
        top: 58px;
    }

    .voice-search__overlay--admin-bar.voice-search__overlay--has-query .voice-search__input-wrapper {
        top: 110px;
    }

    .voice-search__overlay--admin-bar.voice-search__overlay--has-query .voice-search__results-wrapper {
        top: 170px;
    }

    .voice-search__close:focus {
        outline: 2px solid #4a90d9;
        outline-offset: 2px;
    }

    .voice-search__close svg {
        width: 24px;
        height: 24px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    /* =========================================================
       Input Wrapper (animated position)
       ========================================================= */

    .voice-search__input-wrapper {
        position: absolute;
        left: 16px;
        right: 16px;
        top: 50%;
        transform: translateY(-50%);
        transition: top 0.3s ease, transform 0.3s ease;
        z-index: 1;
    }

    .voice-search__overlay--has-query .voice-search__input-wrapper {
        top: 64px;
        transform: none;
    }

    .voice-search__input {
        display: block;
        width: 90%;
        padding: 14px 16px;
        font-size: 17px;
        line-height: 1.4;
        border: none;
        border-radius: 10px;
        background: #fff;
        color: #1a1a2e;
        outline: none;
        box-sizing: border-box;
        -webkit-appearance: none;
        appearance: none;
    }

    .voice-search__input:focus {
        box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.4);
    }

    .voice-search__input::placeholder {
        color: #999;
    }

    /* Hide native search clear on WebKit */
    .voice-search__input::-webkit-search-cancel-button {
        -webkit-appearance: none;
        appearance: none;
    }

    /* =========================================================
       Clear Button (inside input wrapper)
       ========================================================= */

    .voice-search__clear {
        display: none;
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: #999;
        cursor: pointer;
        padding: 0;
        -webkit-tap-highlight-color: transparent;
    }

    .voice-search__clear--visible {
        display: flex;
    }

    .voice-search__clear svg {
        width: 18px;
        height: 18px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .voice-search__clear:focus {
        outline: 2px solid #4a90d9;
        outline-offset: 2px;
    }

    /* Input adjustments when on white panel */
    .voice-search__overlay--has-query .voice-search__input {
        border: 1px solid #e0e0e0;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    }

    /* =========================================================
       Results Area
       ========================================================= */

    .voice-search__results-wrapper {
        position: absolute;
        top: 124px;
        left: 8px;
        right: 8px;
        bottom: 8px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease;
        padding: 0 8px 16px;
    }

    .voice-search__overlay--has-query .voice-search__results-wrapper {
        opacity: 1;
        visibility: visible;
        z-index: 1;
    }

    /* Result item */
    .voice-search__item {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        padding: 12px 0;
        border-bottom: 1px solid #eee;
        text-decoration: none;
        color: #1a1a2e;
    }

    .voice-search__item:last-child {
        border-bottom: none;
    }

    .voice-search__item:active {
        background: rgba(0, 0, 0, 0.04);
    }

    /* Thumbnail */
    .voice-search__item-thumb {
        flex-shrink: 0;
        width: 72px;
        height: 72px;
        border-radius: 6px;
        object-fit: cover;
        background: #f0f0f0;
    }

    .voice-search__item-thumb--empty {
        width: 72px;
        height: 72px;
    }

    /* Text content */
    .voice-search__item-content {
        flex: 1;
        min-width: 0;
    }

    .voice-search__item-title {
        font-size: 15px;
        font-weight: 600;
        line-height: 1.3;
        margin-bottom: 4px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .voice-search__item-excerpt {
        font-size: 13px;
        line-height: 1.4;
        color: #666;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* =========================================================
       No Results
       ========================================================= */

    .voice-search__no-results {
        display: none;
        text-align: center;
        color: #999;
        font-size: 15px;
        padding: 40px 16px;
    }

    .voice-search__no-results--visible {
        display: block;
    }

    /* =========================================================
       Loading Spinner
       ========================================================= */

    .voice-search__loading {
        display: none;
        text-align: center;
        padding: 24px 0;
    }

    .voice-search__loading--active {
        display: block;
    }

    .voice-search__spinner {
        display: inline-block;
        width: 28px;
        height: 28px;
        border: 3px solid rgba(0, 0, 0, 0.1);
        border-top-color: #1a1a2e;
        border-radius: 50%;
        animation: voice-search-spin 0.7s linear infinite;
    }

    @keyframes voice-search-spin {
        to { transform: rotate(360deg); }
    }

    /* =========================================================
       Load More Button
       ========================================================= */

    .voice-search__load-more {
        display: none;
        width: 100%;
        padding: 12px;
        margin-top: 8px;
        background: #f5f5f5;
        color: #1a1a2e;
        border: none;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .voice-search__load-more--visible {
        display: block;
    }

    .voice-search__load-more:active {
        background: #e8e8e8;
    }

    .voice-search__load-more:focus {
        outline: 2px solid #4a90d9;
        outline-offset: 2px;
    }

    /* =========================================================
       Accessibility: Reduced Motion
       ========================================================= */

    @media (prefers-reduced-motion: reduce) {
        .voice-search__overlay {
            transition: none;
        }
        .voice-search__input-wrapper {
            transition: none;
        }
        .voice-search__results-wrapper {
            transition: none;
        }
        .voice-search__icon {
            transition: none;
        }
        .voice-search__spinner {
            animation-duration: 1.5s;
        }
    }

} /* end @media (max-width: 1024px) */
