/* ==========================================================================
   WebScour — Modern Search Engine Stylesheet
   ========================================================================== */

:root {
    /* Color Palette - Dark Theme (Default) */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.75);
    --bg-card-hover: rgba(24, 34, 53, 0.95);
    --bg-glass: rgba(17, 24, 39, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.6);

    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent-blue: #3b82f6;
    --accent-indigo: #6366f1;
    --accent-purple: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
    --card-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0) 100%);

    --badge-bg: rgba(99, 102, 241, 0.15);
    --badge-text: #a5b4fc;
    --mark-bg: rgba(234, 179, 8, 0.28);
    --mark-text: #fef08a;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.8);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-focus: rgba(99, 102, 241, 0.5);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --accent-blue: #2563eb;
    --accent-indigo: #4f46e5;
    --badge-bg: rgba(79, 70, 229, 0.1);
    --badge-text: #4338ca;
    --mark-bg: rgba(254, 240, 138, 0.8);
    --mark-text: #854d0e;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Header Navigation */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.logo-badge {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: var(--shadow-glow);
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-sub {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text-muted);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 13px;
    color: var(--text-secondary);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981;
    box-shadow: 0 0 8px #10b981;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.stat-count {
    font-weight: 700;
    color: var(--text-primary);
}

.theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    border-color: var(--border-focus);
    transform: translateY(-1px);
}

[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }

/* Main Content Area */
.main-content {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Home State Centering */
body.is-home .main-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 60px;
}

/* Search Hero */
.search-hero {
    margin-bottom: 36px;
}

.hero-welcome {
    text-align: center;
    margin-bottom: 32px;
}

.hero-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    background: var(--badge-bg);
    color: var(--badge-text);
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}

.hero-title {
    font-size: 44px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.15;
    margin-bottom: 16px;
}

.gradient-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 580px;
    margin: 0 auto;
}

/* Search Box Container */
.search-box-wrapper {
    width: 100%;
    margin-bottom: 20px;
}

.search-bar-container {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 6px 8px 6px 18px;
    box-shadow: var(--shadow-md);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-bar-container:focus-within {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-glow), var(--shadow-md);
    transform: translateY(-1px);
}

.search-icon-wrapper {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    margin-right: 12px;
}

.search-svg {
    width: 20px;
    height: 20px;
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    padding: 8px 0;
    font-family: inherit;
}

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

.clear-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 15px;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 50%;
    transition: color 0.15s ease;
}

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

.search-submit-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-gradient);
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-submit-btn:hover {
    opacity: 0.92;
    transform: scale(1.02);
}

.arrow-icon {
    width: 16px;
    height: 16px;
}

/* Suggestion Chips */
.chips-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 0 4px;
}

.chips-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.chips-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip-item {
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 5px 12px;
    border-radius: var(--radius-full);
    transition: all 0.2s ease;
}

.chip-item:hover {
    color: var(--accent-indigo);
    border-color: var(--accent-indigo);
    background: var(--badge-bg);
    transform: translateY(-1px);
}

/* Results Section */
.results-meta-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px 18px 4px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
    font-size: 14px;
}

.meta-label {
    color: var(--text-muted);
}

.meta-query {
    font-weight: 700;
    color: var(--text-primary);
}

.meta-stats {
    color: var(--text-secondary);
    font-size: 13px;
}

/* Result Cards */
.cards-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.result-card {
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.result-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.result-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(99, 102, 241, 0.35);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.result-card:hover::before {
    opacity: 1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.card-url-box {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 75%;
}

.globe-icon {
    font-size: 13px;
}

.card-url {
    font-size: 12.5px;
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-url:hover {
    color: var(--accent-blue);
    text-decoration: underline;
}

.external-indicator {
    font-size: 11px;
    color: var(--text-muted);
}

.score-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--badge-bg);
    border: 1px solid rgba(99, 102, 241, 0.25);
    padding: 3px 10px;
    border-radius: var(--radius-full);
}

.score-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--badge-text);
}

.score-val {
    font-size: 12px;
    font-weight: 700;
    color: var(--badge-text);
    font-family: 'JetBrains Mono', monospace;
}

.card-title {
    font-size: 19px;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: -0.3px;
}

.card-title a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.card-title a:hover {
    color: var(--accent-blue);
}

.card-snippet {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

/* Keyword Highlighting */
.card-snippet mark {
    background-color: var(--mark-bg);
    color: var(--mark-text);
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 4px;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
}

.card-tags {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tag-item {
    color: var(--text-muted);
    font-size: 11.5px;
}

.tag-item.code-font {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.cached-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--accent-indigo);
    font-weight: 600;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    background: var(--badge-bg);
    border: 1px solid rgba(99, 102, 241, 0.2);
    transition: all 0.2s ease;
}

.cached-btn:hover {
    background: rgba(99, 102, 241, 0.25);
    transform: translateY(-1px);
}

.mini-icon {
    width: 14px;
    height: 14px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
}

.empty-icon {
    font-size: 40px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 14.5px;
    max-width: 480px;
    margin: 0 auto 20px auto;
}

.empty-suggestions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.action-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-blue);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.action-link:hover {
    border-color: var(--accent-blue);
}

/* Footer */
.main-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 20px 32px;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: auto;
}

.footer-content {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .top-nav {
        padding: 12px 18px;
    }

    .hero-title {
        font-size: 32px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .card-url-box {
        max-width: 100%;
    }

    .card-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .footer-content {
        flex-direction: column;
        align-items: flex-start;
    }
}
