/* Algolia Global Search - Minimal Spotlight Style */

/* ===== Navbar Search Button ===== */
.global-navbar__search {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    color: #64748b;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-right: 0.75rem;
}

.global-navbar__search:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}

.global-navbar__search i {
    font-size: 0.875rem;
}

.global-navbar__search-hint {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.global-navbar__search-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.25rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.25rem;
    font-size: 0.6875rem;
    font-weight: 500;
    font-family: inherit;
    color: #94a3b8;
}

@media (max-width: 768px) {
    .global-navbar__search-hint {
        display: none;
    }
    .global-navbar__search {
        padding: 0.5rem;
    }
}

/* ===== Modal Overlay ===== */
.search-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 8vh 1.5rem 2rem;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.search-modal.is-open {
    display: flex;
    opacity: 1;
}

.search-modal.is-closing {
    opacity: 0;
}

/* ===== Modal Container ===== */
.search-modal__container {
    width: 100%;
    max-width: 860px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.96);
    transition: transform 0.15s ease;
}

.search-modal.is-open .search-modal__container {
    transform: scale(1);
}

/* ===== Search Header ===== */
.search-modal__header {
    display: flex;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.search-modal__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 1.375rem;
    margin-right: 1rem;
    flex-shrink: 0;
}

.search-modal__input-wrapper {
    flex: 1;
}

.search-modal__input {
    width: 100%;
    padding: 0;
    border: none;
    outline: none;
    font-size: 1.375rem;
    font-weight: 400;
    color: #1e293b;
    background: transparent;
    letter-spacing: -0.01em;
}

.search-modal__input::placeholder {
    color: #cbd5e1;
}

.search-modal__shortcuts {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 1rem;
}

.search-modal__kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.375rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #94a3b8;
    font-family: inherit;
}

.search-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-left: 0.75rem;
    border: none;
    background: #f8fafc;
    border-radius: 0.5rem;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.1s ease;
}

.search-modal__close:hover {
    background: #f1f5f9;
    color: #64748b;
}

/* ===== Filters Section ===== */
.search-modal__filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    background: #fafbfc;
    border-bottom: 1px solid #f1f5f9;
    overflow-x: auto;
}

.search-modal__filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.search-modal__filter-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #64748b;
}

.search-modal__subject-select {
    padding: 0.375rem 0.75rem;
    padding-right: 1.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #ffffff;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1rem;
    min-width: 140px;
}

.search-modal__subject-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-modal__filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.625rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.1s ease;
    white-space: nowrap;
}

.search-modal__filter-chip:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.search-modal__filter-chip.is-active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.search-modal__filter-chip i {
    font-size: 0.6875rem;
}

.search-modal__filter-divider {
    width: 1px;
    height: 1.25rem;
    background: #e2e8f0;
    margin: 0 0.25rem;
}

/* ===== Results Section ===== */
.search-modal__body {
    flex: 1;
    overflow-y: auto;
    max-height: 420px;
}

.search-modal__section {
    padding: 0.75rem 0;
}

.search-modal__section-title {
    padding: 0.5rem 1.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
}

/* ===== Result Items ===== */
.search-modal__result {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.5rem;
    cursor: pointer;
    transition: background 0.1s ease;
}

.search-modal__result:hover,
.search-modal__result.is-focused {
    background: #f8fafc;
}

.search-modal__result-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background: #f1f5f9;
    border-radius: 0.5rem;
    font-size: 1rem;
    color: #64748b;
    flex-shrink: 0;
}

.search-modal__result-icon--math { background: #eff6ff; color: #3b82f6; }
.search-modal__result-icon--science { background: #f0fdf4; color: #22c55e; }
.search-modal__result-icon--english { background: #fefce8; color: #eab308; }
.search-modal__result-icon--reading { background: #fdf4ff; color: #d946ef; }

.search-modal__result-content {
    flex: 1;
    min-width: 0;
}

.search-modal__result-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
}

.search-modal__result-subject {
    font-size: 0.75rem;
    font-weight: 600;
    color: #2563eb;
}

.search-modal__result-topic {
    font-size: 0.75rem;
    color: #64748b;
}

.search-modal__result-topic::before {
    content: "›";
    margin-right: 0.5rem;
    color: #cbd5e1;
}

.search-modal__result-title {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #1e293b;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-modal__result-title mark {
    background: #fef08a;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.search-modal__result-badges {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.375rem;
}

.search-modal__badge {
    display: inline-flex;
    padding: 0.125rem 0.375rem;
    background: #f1f5f9;
    border-radius: 0.25rem;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #64748b;
}

.search-modal__badge--easy { background: #dcfce7; color: #166534; }
.search-modal__badge--medium { background: #fef3c7; color: #92400e; }
.search-modal__badge--hard { background: #fee2e2; color: #991b1b; }
.search-modal__badge--mcq { background: #dbeafe; color: #1e40af; }
.search-modal__badge--short { background: #f3e8ff; color: #7c3aed; }
.search-modal__badge--extended { background: #fce7f3; color: #be185d; }

.search-modal__result-arrow {
    color: #cbd5e1;
    font-size: 0.875rem;
    opacity: 0;
    transition: opacity 0.1s ease;
}

.search-modal__result:hover .search-modal__result-arrow,
.search-modal__result.is-focused .search-modal__result-arrow {
    opacity: 1;
}

/* ===== Empty & Loading States ===== */
.search-modal__empty,
.search-modal__loading,
.search-modal__error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.search-modal__empty-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.search-modal__empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.5rem;
}

.search-modal__empty-text {
    font-size: 0.875rem;
    color: #94a3b8;
    max-width: 300px;
}

.search-modal__clear-filters-btn {
    margin-top: 1.25rem;
    padding: 0.5rem 1rem;
    background: #2563eb;
    border: none;
    border-radius: 0.5rem;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.1s ease;
}

.search-modal__clear-filters-btn:hover {
    background: #1d4ed8;
}

.search-modal__loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 2px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: search-spin 0.6s linear infinite;
    margin-bottom: 1rem;
}

.search-modal__loading-text {
    font-size: 0.875rem;
    color: #94a3b8;
}

@keyframes search-spin {
    to { transform: rotate(360deg); }
}

/* ===== Footer ===== */
.search-modal__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid #f1f5f9;
    background: #fafbfc;
}

.search-modal__footer-hint {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    font-size: 0.75rem;
    color: #94a3b8;
}

.search-modal__footer-hint span {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.search-modal__powered {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.1s ease;
}

.search-modal__powered:hover {
    opacity: 1;
}

.search-modal__powered-text {
    font-size: 0.6875rem;
    color: #94a3b8;
}

.search-modal__powered-logo {
    height: 0.875rem;
    width: auto;
}

.search-modal__powered-brand {
    font-size: 0.75rem;
    font-weight: 600;
    color: #003DFF;
}

/* ===== Scrollbar ===== */
.search-modal__body::-webkit-scrollbar {
    width: 6px;
}

.search-modal__body::-webkit-scrollbar-track {
    background: transparent;
}

.search-modal__body::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 3px;
}

.search-modal__body::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* ===== Mobile ===== */
@media (max-width: 640px) {
    .search-modal {
        padding: 0;
    }

    .search-modal__container {
        max-width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .search-modal__body {
        max-height: none;
        flex: 1;
    }

    .search-modal__shortcuts {
        display: none;
    }

    .search-modal__footer-hint {
        display: none;
    }

    .search-modal__header {
        padding: 1rem;
    }

    .search-modal__input {
        font-size: 1.125rem;
    }

    .search-modal__filters {
        padding: 0.75rem 1rem;
    }

    .search-modal__result {
        padding: 0.75rem 1rem;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    .search-modal,
    .search-modal__container,
    .search-modal__loading-spinner {
        transition: none;
        animation: none;
    }
}
