/* PriceWaka - Clean, modern dashboard */

/* ─── Theme Variables ─── */
:root {
    /* Light mode (default) */
    --bg: #ffffff;
    --bg-alt: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --text: #1a202c;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --accent-dim: #d1fae5;
    --danger: #ef4444;
    --danger-dim: #fee2e2;
    --warning: #f59e0b;
    --chart-line: #10b981;
    --chart-fill: rgba(16, 185, 129, 0.1);
    --header-bg: rgba(255, 255, 255, 0.85);
}

[data-theme="dark"] {
    --bg: #0a0a0a;
    --bg-alt: #111111;
    --surface: #1a1a1a;
    --surface-hover: #222222;
    --border: #2a2a2a;
    --text: #e5e5e5;
    --text-secondary: #888888;
    --text-muted: #555555;
    --accent: #10b981;
    --accent-dim: #065f46;
    --danger: #ef4444;
    --danger-dim: #7f1d1d;
    --warning: #f59e0b;
    --chart-line: #10b981;
    --chart-fill: rgba(16, 185, 129, 0.1);
    --header-bg: rgba(10, 10, 10, 0.85);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ─── Header ─── */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 20px;
}

.logo-icon { font-size: 24px; }

#desktop-nav {
    display: flex;
    gap: 28px;
}

#desktop-nav a,
.mobile-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

#desktop-nav a:hover { color: var(--text); }

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Theme Toggle */
.theme-toggle {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
}

.theme-toggle:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    width: 40px;
    height: 40px;
    position: relative;
}

.hamburger {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text);
    position: relative;
    transition: all 0.3s;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 2px;
    background: var(--text);
    transition: all 0.3s;
}

.hamburger::before { top: -7px; }
.hamburger::after { top: 7px; }

.mobile-menu-toggle.active .hamburger {
    background: transparent;
}

.mobile-menu-toggle.active .hamburger::before {
    transform: rotate(45deg);
    top: 0;
}

.mobile-menu-toggle.active .hamburger::after {
    transform: rotate(-45deg);
    top: 0;
}

/* Mobile Nav */
.mobile-nav {
    display: none;
    flex-direction: column;
    gap: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.mobile-nav.active {
    display: flex;
}

.mobile-nav a {
    padding: 16px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-top: 1px solid var(--border);
    transition: all 0.2s;
}

.mobile-nav a:hover,
.mobile-nav a:active {
    background: var(--surface-hover);
    color: var(--text);
}

.mobile-nav .btn {
    margin: 8px 24px 16px;
    text-align: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: #000;
}

.btn-primary:hover {
    background: #34d399;
}

.btn-sm {
    padding: 6px 16px;
    font-size: 13px;
}

/* ─── Hero ─── */
.hero {
    padding: 60px 0 48px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

/* New summary version */
.hero-headline {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.2;
    margin-bottom: 16px;
    color: var(--text);
}

.hero-basket {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.hero-pills {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}

.hero-pill {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.hero-date {
    font-size: 13px;
    color: var(--text-muted);
}

/* Fallback index version */
.hero-label {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.index-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 16px;
    margin-bottom: 12px;
}

.index-value {
    font-size: 72px;
    font-weight: 800;
    letter-spacing: -2px;
    line-height: 1;
}

.index-change {
    font-size: 24px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 6px;
}

.index-change.up {
    color: var(--danger);
    background: var(--danger-dim);
}

.index-change.down {
    color: var(--accent);
    background: var(--accent-dim);
}

.index-change.flat {
    color: var(--text-secondary);
    background: var(--surface);
}

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

/* ─── Price Lookup Section ─── */
.price-lookup-section {
    background: var(--accent-dim);
    border-top: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
}

[data-theme="dark"] .price-lookup-section {
    background: var(--accent-dim);
}

.price-lookup {
    max-width: 700px;
    margin: 0 auto;
}

.lookup-controls {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.lookup-select {
    flex: 1;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    font-size: 15px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
}

.lookup-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.btn-lookup {
    padding: 14px 32px;
    font-size: 15px;
    white-space: nowrap;
}

.lookup-result {
    margin-top: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    min-height: 120px;
    display: none;
}

.lookup-result.active {
    display: block;
}

.lookup-commodity-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.lookup-price {
    font-size: 56px;
    font-weight: 800;
    letter-spacing: -2px;
    color: var(--accent);
    margin-bottom: 8px;
}

.lookup-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 12px;
}

.lookup-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.lookup-change {
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
}

.lookup-change.up {
    color: var(--danger);
    background: var(--danger-dim);
}

.lookup-change.down {
    color: var(--accent);
    background: var(--accent-dim);
}

/* ─── Sections ─── */
.section {
    padding: 48px 0;
}

.section-alt {
    background: var(--bg-alt);
}

.section-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.section-sub {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ─── Chart ─── */
.chart-container {
    position: relative;
    height: 320px;
    margin-top: 20px;
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
}

.chart-note {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 12px;
}

/* ─── Commodity Current Price ─── */
.commodity-price-current {
    margin-top: 16px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: center;
    display: none;
}

.commodity-price-current.active {
    display: block;
}

.commodity-current-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.commodity-current-price {
    font-size: 32px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -1px;
}

/* ─── Metrics Grid ─── */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

.metric-card h3 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -1px;
}

.metric-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ─── Top Movers Table ─── */
.movers-table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 20px;
}

.movers-table table {
    width: 100%;
    border-collapse: collapse;
}

.movers-table th,
.movers-table td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.movers-table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    background: var(--bg-alt);
}

.movers-table td {
    font-size: 14px;
}

.movers-table tr:last-child td {
    border-bottom: none;
}

.change-up { color: var(--danger); font-weight: 600; }
.change-down { color: var(--accent); font-weight: 600; }

/* ─── Commodity Controls ─── */
.commodity-controls {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.commodity-controls select {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    min-width: 180px;
}

.commodity-controls select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ─── State Legend ─── */
.state-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
    font-size: 14px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.high { background: var(--danger); }
.legend-dot.medium { background: var(--warning); }
.legend-dot.low { background: var(--accent); }

/* ─── States Grid ─── */
.states-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    margin-top: 20px;
}

.state-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    transition: all 0.2s;
}

.state-card:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.state-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.state-index {
    font-size: 20px;
    font-weight: 700;
}

.state-index.high { color: var(--danger); }
.state-index.medium { color: var(--warning); }
.state-index.low { color: var(--accent); }

.state-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ─── Newsletter CTA ─── */
.section-cta {
    background: linear-gradient(135deg, #065f46, #064e3b);
    text-align: center;
    padding: 64px 0;
}

.section-cta h2 {
    font-size: 28px;
    margin-bottom: 8px;
    color: #ffffff;
}

.section-cta p {
    color: rgba(255,255,255,0.7);
    margin-bottom: 24px;
}

.newsletter-form {
    display: flex;
    gap: 8px;
    max-width: 440px;
    margin: 0 auto;
}

.newsletter-form input {
    flex: 1;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 14px;
    font-family: inherit;
}

.newsletter-form input::placeholder {
    color: rgba(255,255,255,0.4);
}

.newsletter-form input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255,255,255,0.15);
}

.newsletter-note {
    font-size: 12px;
    color: rgba(255,255,255,0.4) !important;
    margin-top: 12px;
}

/* ─── Footer ─── */
footer {
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 48px 0 24px;
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 48px;
}

.footer-brand {
    flex: 1;
    min-width: 200px;
}

.footer-brand p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

.footer-links {
    display: flex;
    gap: 64px;
}

.footer-links h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.footer-links a {
    display: block;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 8px;
    transition: color 0.2s;
}

.footer-links a:hover { color: var(--text); }

.footer-bottom {
    width: 100%;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    margin-top: 24px;
}

.footer-bottom p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.loading {
    color: var(--text-secondary);
    padding: 20px;
    text-align: center;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    #desktop-nav { display: none; }
    #desktop-subscribe { display: none; }
    .mobile-menu-toggle { display: block; }
    
    .hero-headline { font-size: 28px; }
    .hero-basket { font-size: 16px; }
    .hero-pills { gap: 8px; }
    .hero-pill { font-size: 13px; padding: 6px 12px; }
    
    .index-value { font-size: 48px; }
    .index-change { font-size: 18px; }
    
    .lookup-controls {
        flex-direction: column;
    }
    
    .lookup-price {
        font-size: 42px;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .states-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-container {
        height: 240px;
        padding: 12px;
    }
    
    .commodity-controls {
        flex-direction: column;
    }
    
    .newsletter-form {
        flex-direction: column;
    }
    
    .footer-links {
        gap: 32px;
    }
    
    .movers-table {
        overflow-x: auto;
    }
    
    .movers-table th,
    .movers-table td {
        padding: 10px 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 16px;
    }
    
    .hero {
        padding: 40px 0 32px;
    }
    
    .section {
        padding: 32px 0;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── Grid Status Widget ─── */

.grid-widget {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    max-width: 600px;
    margin: 0 auto;
}

.grid-widget-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.grid-score-badge {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.grid-score-badge.score-good { background: #10b981; }
.grid-score-badge.score-warning { background: #f59e0b; }
.grid-score-badge.score-alert { background: #f97316; }
.grid-score-badge.score-critical { background: #ef4444; }

.grid-header-text {
    flex: 1;
}

.grid-level {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.grid-updated {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.grid-generation {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 12px 0;
    padding: 12px;
    background: var(--bg-alt);
    border-radius: 8px;
}

.grid-mw {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.grid-mw-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.grid-trend-arrow {
    font-size: 1.1rem;
    margin-left: auto;
}

.grid-avgs {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.grid-bottom-line {
    font-size: 0.95rem;
    color: var(--text);
    margin: 12px 0 8px;
    line-height: 1.5;
}

.grid-diesel {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 8px 12px;
    background: var(--bg-alt);
    border-radius: 6px;
    margin-top: 8px;
}

.grid-widget-unavailable {
    text-align: center;
    color: var(--text-muted);
    padding: 24px 0;
    font-size: 0.95rem;
}
