/* Native viewport canvas & scrollbar theme synchronization */
html.dark, :root { color-scheme: dark; background-color: #070a13; }
html.light { color-scheme: light; background-color: #f1f5f9; }

/* Immediate theme icon synchronization without JS DOM queries */
html.light .theme-sun-icon { display: none !important; }
html.light .theme-moon-icon { display: block !important; }
html.light span.theme-moon-icon { display: inline-flex !important; }

html:not(.light) .theme-moon-icon { display: none !important; }
html:not(.light) .theme-sun-icon { display: block !important; }
html:not(.light) span.theme-sun-icon { display: inline-flex !important; }

/* ── Autocomplete Dropdown ────────────────────────── */
.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #161823;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 1rem;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    max-height: 420px;
    overflow-y: auto;
    z-index: 1000;
    backdrop-filter: blur(16px);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.light .autocomplete-dropdown, [data-theme="light"] .autocomplete-dropdown {
    background: #ffffff;
    border-color: #e5e7eb;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
}
.ac-item {
    display: flex;
    align-items: center;
    padding: 9px 12px;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.15s ease;
    text-decoration: none;
    color: inherit;
}
.light .ac-item, [data-theme="light"] .ac-item {
    border-bottom-color: #f3f4f6;
}
.ac-item:last-child {
    border-bottom: none;
}
.ac-item:hover, .ac-item.active {
    background: rgba(0, 122, 255, 0.12);
}
.ac-thumb {
    width: 42px;
    height: 42px;
    border-radius: 0.5rem;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.light .ac-thumb, [data-theme="light"] .ac-thumb {
    background: #f9fafb;
    border-color: #e5e7eb;
}
.ac-info {
    flex: 1;
    min-width: 0;
}
.ac-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #f3f4f6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}
.light .ac-title, [data-theme="light"] .ac-title {
    color: #111827;
}
.ac-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 2px;
}
.ac-badge {
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #cbd5e1;
}
.light .ac-badge, [data-theme="light"] .ac-badge {
    background: #f1f5f9;
    color: #475569;
}
.ac-price {
    font-size: 0.85rem;
    font-weight: 800;
    color: #34d399;
    white-space: nowrap;
    padding: 2px 8px;
    background: rgba(52, 211, 153, 0.12);
    border-radius: 6px;
}
.ac-tag {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.02em;
}
.ac-tag-ad { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.ac-tag-deal { background: rgba(249, 115, 22, 0.15); color: #fb923c; }
.ac-tag-email { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.ac-footer {
    padding: 10px 14px;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: #60a5fa;
    cursor: pointer;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    transition: background 0.15s ease;
}
.light .ac-footer, [data-theme="light"] .ac-footer {
    border-top-color: #f3f4f6;
    color: #2563eb;
}
.ac-footer:hover, .ac-footer.active {
    background: rgba(59, 130, 246, 0.15);
}

/* ── Autocomplete Suggestion Items & Chips ─────────── */
.ac-header {
    padding: 8px 14px 6px;
    font-size: 0.70rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.light .ac-header, [data-theme="light"] .ac-header {
    color: #64748b;
    border-bottom-color: #f1f5f9;
}
.ac-suggest-item {
    display: flex;
    align-items: center;
    padding: 9px 14px;
    gap: 10px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.15s ease;
}
.ac-suggest-item:hover, .ac-suggest-item.active {
    background: rgba(0, 122, 255, 0.12);
}
.light .ac-suggest-item, [data-theme="light"] .ac-suggest-item {
    border-bottom-color: #f3f4f6;
}
.ac-suggest-icon {
    font-size: 0.82rem;
    color: #64748b;
    flex-shrink: 0;
}
.ac-suggest-text {
    flex: 1;
    font-size: 0.84rem;
    font-weight: 500;
    color: #f3f4f6;
}
.light .ac-suggest-text, [data-theme="light"] .ac-suggest-text {
    color: #111827;
}
.ac-suggest-arrow {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: bold;
}
.ac-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px;
}
.ac-chip {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    padding: 5px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}
.ac-chip:hover, .ac-chip.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
    color: #93c5fd;
    transform: translateY(-1px);
}
.light .ac-chip, [data-theme="light"] .ac-chip {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #334155;
}
.light .ac-chip:hover, [data-theme="light"] .ac-chip:hover, .light .ac-chip.active, [data-theme="light"] .ac-chip.active {
    background: #e0f2fe;
    border-color: #93c5fd;
    color: #0284c7;
}

/* ── Mobile Autocomplete Optimization (< 640px) ─────────────────── */
@media (max-width: 639px) {
    #globalSearchInput {
        font-size: 16px !important; /* Prevents iOS Safari auto-zoom on input focus */
    }
    .autocomplete-dropdown {
        position: fixed;
        left: 8px;
        right: 8px;
        top: 58px;
        width: auto;
        max-height: 55vh;
        border-radius: 0.75rem;
        box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65);
    }
    .ac-item {
        padding: 7px 10px;
        gap: 8px;
    }
    .ac-suggest-item {
        padding: 7px 10px;
        gap: 8px;
    }
    .ac-suggest-text {
        font-size: 0.78rem;
    }
    .ac-chips-container {
        gap: 5px;
        padding: 8px 10px;
    }
    .ac-chip {
        padding: 4px 10px;
        font-size: 0.70rem;
    }
    .ac-header {
        font-size: 0.65rem;
        padding: 6px 10px 4px;
    }
    .ac-thumb {
        width: 32px;
        height: 32px;
        border-radius: 5px;
    }
    .ac-title {
        font-size: 0.78rem;
        line-height: 1.25;
    }
    .ac-meta {
        font-size: 0.68rem;
        gap: 4px;
        margin-top: 1px;
    }
    .ac-tag {
        font-size: 0.60rem;
        padding: 0.5px 4px;
        border-radius: 3px;
    }
    .ac-badge {
        font-size: 0.62rem;
        padding: 0.5px 4px;
    }
    .ac-price {
        font-size: 0.78rem;
        padding: 1.5px 5px;
        border-radius: 4px;
    }
    .ac-footer {
        padding: 8px 12px;
        font-size: 0.72rem;
    }
}
