/* ==========================================
   Value Research Smart Search — CSS
   ========================================== */

:root {
    /* Colors */
    /* --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-overlay: rgba(0, 0, 0, 0.03);
    --text-primary: #1a1a2e;
    --text-secondary: #555770;
    --text-muted: #8e8ea0;
    --accent-blue: #2563eb;
    --accent-blue-light: #eff6ff;
    --accent-orange: #e97a2b;
    --border-light: #e5e7eb;
    --border-medium: #d1d5db;
    --star-gold: #f59e0b;
    --star-empty: #d1d5db;
    --success: #10b981;
    --badge-in: #1e40af;
    --badge-us: #7c3aed;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 50px -12px rgba(0, 0, 0, 0.12); */

    /* Backgrounds */
    --bg-primary: #0f172a;
    /* main page background */
    --bg-secondary: #1e293b;
    /* cards / panels */
    --bg-overlay: rgba(255, 255, 255, 0.05);

    /* Text */
    --text-primary: #f1f5f9;
    /* main text */
    --text-secondary: #cbd5f5;
    /* secondary text */
    --text-muted: #94a3b8;
    /* muted labels */

    /* Accents */
    --accent-blue: #3b82f6;
    /* slightly brighter for dark UI */
    --accent-blue-light: #1e3a8a;

    --accent-orange: #fb923c;

    /* Borders */
    --border-light: #334155;
    --border-medium: #475569;

    /* Ratings */
    --star-gold: #fbbf24;
    --star-empty: #475569;

    /* Status */
    --success: #22c55e;

    /* Badges */
    --badge-in: #3b82f6;
    --badge-us: #8b5cf6;

    /* Shadows (lighter because background is dark) */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.6);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.55);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);
    /* Typography */
    --font-primary: 'Inter', 'Noto Sans Devanagari', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 50px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-secondary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- Search Overlay ---- */
.search-overlay {
    min-height: 100vh;
    background: var(--bg-primary);
}

/* ---- Search Header ---- */
.search-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    padding: 16px 24px;
}

.search-bar-container {
    max-width: 900px;
    margin: 0 auto;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-full);
    padding: 0 20px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input-wrapper:focus-within {
    border-color: var(--accent-blue);
    background: var(--bg-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-primary);
    font-size: 16px;
    padding: 14px 12px;
    color: var(--text-primary);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.clear-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-muted);
    transition: color 0.2s;
    flex-shrink: 0;
}

.clear-btn:hover {
    color: var(--text-primary);
}

.clear-btn svg {
    width: 20px;
    height: 20px;
}

/* ---- Tabs ---- */
.tabs-container {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    padding: 0 24px;
    position: sticky;
    top: 65px;
    z-index: 99;
}

.tabs {
    display: flex;
    gap: 4px;
    max-width: 900px;
    margin: 0 auto;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 18px;
    border: none;
    background: transparent;
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    border-radius: var(--radius-full);
    margin-bottom: 4px;
}

.tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.tab.active {
    color: var(--bg-primary);
    background: var(--accent-blue);
    border-bottom-color: transparent;
}

.tab-icon {
    font-size: 14px;
}

/* ---- Autocomplete Dropdown ---- */
.autocomplete-dropdown {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
}

.autocomplete-dropdown ul {
    list-style: none;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.autocomplete-dropdown li {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
}

.autocomplete-dropdown li:last-child {
    border-bottom: none;
}

.autocomplete-dropdown li:hover {
    background: var(--accent-blue-light);
}

.autocomplete-dropdown li.active {
    background: var(--accent-blue-light);
}

.autocomplete-dropdown .suggestion-category {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-blue);
    background: var(--accent-blue-light);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.autocomplete-dropdown .suggestion-name {
    font-size: 14px;
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Results Grid (All Tab) ---- */
.results-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

@media (max-width: 1024px) {
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
}

.result-column {
    min-width: 0;
}

.column-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    padding-bottom: 12px;
    margin-bottom: 8px;
    border-bottom: 2px solid var(--text-primary);
}

/* ---- Result Items ---- */
.result-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    animation: resultFadeIn 0.3s ease forwards;
    opacity: 0;
}

@keyframes resultFadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-item:last-child {
    border-bottom: none;
}

.result-item a {
    text-decoration: none;
    color: var(--accent-blue);
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.4;
    display: block;
    transition: color 0.15s;
}

.result-item a:hover {
    color: var(--accent-orange);
}

/* Star Rating */
.star-rating {
    display: inline-flex;
    gap: 1px;
    margin-top: 3px;
}

.star-rating .star {
    font-size: 12px;
    color: var(--star-empty);
}

.star-rating .star.filled {
    color: var(--star-gold);
}

/* Erstwhile Text */
.erstwhile-text {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 2px;
}

/* Exchange Badge */
.exchange-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 3px;
    color: white;
    margin-right: 6px;
    vertical-align: middle;
}

.exchange-badge.badge-in {
    background: var(--badge-in);
}

.exchange-badge.badge-us {
    background: var(--badge-us);
}

/* Story result */
.result-item.story-item a {
    color: var(--text-primary);
    font-weight: 400;
}

.result-item.story-item a:hover {
    color: var(--accent-blue);
}

/* NPS result */
.result-item.nps-item .tier-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---- Single Column Results ---- */
.results-single {
    max-width: 700px;
}

.results-single .result-item {
    padding: 14px 0;
}

/* ---- Empty / Loading / No Results ---- */
.empty-state,
.loading,
.no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    text-align: center;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state p {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 400px;
}

.empty-hint {
    margin-top: 8px;
    font-size: 14px !important;
    color: var(--text-muted) !important;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading p,
.no-results p {
    font-size: 15px;
    color: var(--text-muted);
}

/* ---- Status Bar ---- */
.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--text-primary);
    color: white;
    padding: 8px 24px;
    font-size: 12px;
    text-align: center;
    z-index: 200;
}

/* ---- Utilities ---- */
.hidden {
    display: none !important;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---- Search all link ---- */
.search-all-link {
    display: inline-block;
    margin-top: 12px;
    padding: 8px 16px;
    background: var(--accent-blue-light);
    color: var(--accent-blue);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent-blue);
    transition: all 0.2s;
}

.search-all-link:hover {
    background: var(--accent-blue);
    color: white;
}

/* ---- Engine Toggle ---- */
.tabs-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.engine-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.toggle-switch {
    position: relative;
    width: 140px;
    height: 32px;
}

.toggle-switch input {
    display: none;
}

.toggle-switch label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    padding: 0 4px;
    cursor: pointer;
    position: relative;
}

.switch-option {
    flex: 1;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    z-index: 1;
    transition: color 0.3s;
    color: var(--text-muted);
}

.toggle-switch input:not(:checked)+label .switch-option.standard {
    color: white;
}

.toggle-switch input:checked+label .switch-option.optimized {
    color: white;
}

.switch-slider {
    position: absolute;
    top: 3px;
    left: 4px;
    width: 66px;
    height: 24px;
    background: var(--accent-blue);
    border-radius: var(--radius-full);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-switch input:checked+label .switch-slider {
    transform: translateX(66px);
}

@media (max-width: 768px) {
    .tabs-container {
        flex-direction: column;
        align-items: flex-start;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .engine-toggle {
        margin-top: 8px;
        margin-left: 12px;
    }
}