/* ═══════════════════════════════════════
   BallotPulse — Style System
   Dark theme, blue accent, red alerts
   ═══════════════════════════════════════ */

:root {
    --bg: #0a0f1a;
    --bg-card: #111827;
    --bg-card-hover: #1a2332;
    --bg-input: #0d1420;
    --border: #1e293b;
    --border-hover: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --accent: #4a9eff;
    --accent-hover: #3b8de6;
    --accent-glow: rgba(74, 158, 255, 0.15);
    --red: #ff4444;
    --red-bg: rgba(255, 68, 68, 0.1);
    --orange: #ff9800;
    --orange-bg: rgba(255, 152, 0, 0.1);
    --green: #00c853;
    --green-bg: rgba(0, 200, 83, 0.1);
    --yellow: #ffd600;
    --yellow-bg: rgba(255, 214, 0, 0.1);
    --purple: #b388ff;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

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

/* ── NAVBAR ── */
.navbar {
    position: sticky; top: 0; z-index: 100;
    background: rgba(10, 15, 26, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
}
.nav-inner {
    max-width: 1200px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    height: 60px;
}
.nav-brand {
    font-size: 1.3rem; font-weight: 800; color: var(--text);
    display: flex; align-items: center; gap: 8px;
}
.brand-icon { color: var(--accent); font-size: 1.5rem; }
.nav-links {
    display: flex; align-items: center; gap: 8px;
}
.nav-links a {
    color: var(--text-muted); padding: 8px 14px; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 500; transition: all var(--transition);
}
.nav-links a:hover { color: var(--text); background: var(--bg-card); }
.nav-btn {
    border: 1px solid var(--border) !important; font-weight: 600 !important;
}
.nav-btn.primary {
    background: var(--accent) !important; color: #fff !important;
    border-color: var(--accent) !important;
}
.nav-btn.primary:hover { background: var(--accent-hover) !important; }
.nav-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.5rem; cursor: pointer; }

/* ── HERO ── */
.hero {
    text-align: center; padding: 80px 20px 60px;
    background: linear-gradient(180deg, rgba(74,158,255,0.08) 0%, transparent 60%);
}
.hero h1 {
    font-size: 3rem; font-weight: 800; line-height: 1.15;
    color: #ffffff;
    -webkit-text-fill-color: #ffffff;
}
.hero .tagline {
    font-size: 1.25rem; color: #cbd5e1; margin-top: 16px; max-width: 600px; margin-inline: auto;
}
.hero-stats {
    display: flex; justify-content: center; gap: 40px; margin-top: 40px; flex-wrap: wrap;
}
.hero-stat {
    text-align: center; padding: 16px 24px; border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.hero-stat:hover { background: rgba(74, 158, 255, 0.08); transform: translateY(-2px); }
.hero-stat .num { font-size: 2.5rem; font-weight: 800; color: var(--accent); }
.hero-stat .label { font-size: 0.85rem; color: var(--text); margin-top: 4px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; margin-top: 32px; flex-wrap: wrap; }

/* ── BUTTONS ── */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 24px; border-radius: var(--radius-sm);
    font-size: 0.95rem; font-weight: 600; border: none; cursor: pointer;
    transition: all var(--transition); text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-danger { background: var(--red); color: #fff; }

/* ── CARDS ── */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    transition: all var(--transition);
}
.card:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 1.1rem; font-weight: 700; }

/* ── SECTIONS ── */
.section {
    padding: 60px 0;
}
.section-header {
    text-align: center; margin-bottom: 40px;
}
.section-header h2 {
    font-size: 2rem; font-weight: 800;
}
.section-header p {
    color: var(--text-muted); margin-top: 8px; font-size: 1.05rem;
}

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── SEVERITY BADGES ── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 20px;
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
}
.badge-critical { background: var(--red-bg); color: var(--red); }
.badge-warning { background: var(--orange-bg); color: var(--orange); }
.badge-info { background: var(--accent-glow); color: var(--accent); }

/* ── SCORE COLORS ── */
.score-green { color: var(--green); }
.score-yellow { color: var(--yellow); }
.score-orange { color: var(--orange); }
.score-red { color: var(--red); }
.score-bar {
    height: 8px; border-radius: 4px; background: var(--border);
    overflow: hidden; margin-top: 8px;
}
.score-bar-fill {
    height: 100%; border-radius: 4px; transition: width 0.5s ease;
}

/* ── CHANGE TIMELINE ITEMS ── */
.change-item {
    display: flex; gap: 16px; padding: 20px;
    border-left: 3px solid var(--border); position: relative;
}
.change-item.critical { border-left-color: var(--red); }
.change-item.warning { border-left-color: var(--orange); }
.change-item.info { border-left-color: var(--accent); }
.change-meta { font-size: 0.8rem; color: var(--text-dim); margin-top: 6px; }

/* ── FORMS ── */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block; font-size: 0.85rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 12px 16px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-size: 0.95rem; font-family: inherit;
    transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-textarea { resize: vertical; min-height: 100px; }

/* ── AUTH PAGES ── */
.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: calc(100vh - 160px); padding: 40px 20px;
}
.auth-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 40px; width: 100%; max-width: 440px;
}
.auth-card h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: 8px; }
.auth-card .subtitle { color: var(--text-muted); margin-bottom: 28px; }
.auth-footer { text-align: center; margin-top: 24px; color: var(--text-dim); font-size: 0.9rem; }

/* ── MAP ── */
#map-container { width: 100%; height: calc(100vh - 140px); border-radius: var(--radius); overflow: hidden; }
.map-controls {
    display: flex; gap: 12px; padding: 20px; flex-wrap: wrap; align-items: center;
}

/* ── CHAT ── */
.chat-container {
    max-width: 800px; margin: 0 auto; padding: 20px;
    display: flex; flex-direction: column; height: calc(100vh - 140px);
}
.chat-messages {
    flex: 1; overflow-y: auto; padding: 20px 0;
    display: flex; flex-direction: column; gap: 16px;
}
.chat-msg {
    max-width: 80%; padding: 14px 18px;
    border-radius: var(--radius); font-size: 0.95rem; line-height: 1.6;
}
.chat-msg.user {
    align-self: flex-end; background: var(--accent); color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
    align-self: flex-start; background: var(--bg-card); border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chat-input-row {
    display: flex; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border);
}
.chat-input-row input { flex: 1; }
.chat-input-row button { flex-shrink: 0; }

/* ── DASHBOARD ── */
.dash-header {
    padding: 40px 0 20px; display: flex; align-items: center; justify-content: space-between;
}
.dash-header h1 { font-size: 1.8rem; font-weight: 800; }
.dash-state-badge {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-card); border: 1px solid var(--border);
    padding: 10px 18px; border-radius: var(--radius-sm);
}
.dash-score {
    font-size: 1.5rem; font-weight: 800;
}

/* ── SCORE EXPLORER ── */
.score-map-section { padding: 40px 0; }
.state-score-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 16px;
    display: flex; align-items: center; justify-content: space-between;
    transition: all var(--transition);
}
.state-score-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.state-name { font-weight: 600; }
.state-score { font-size: 1.3rem; font-weight: 800; }

/* ── ADMIN ── */
.admin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin: 30px 0; }
.admin-stat {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; text-align: center;
}
.admin-stat .num { font-size: 2rem; font-weight: 800; color: var(--accent); }
.admin-stat .label { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* ── TABLE ── */
.data-table {
    width: 100%; border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border);
}
.data-table th {
    font-size: 0.8rem; font-weight: 600; text-transform: uppercase;
    color: var(--text-dim); background: var(--bg);
}
.data-table tr:hover td { background: var(--bg-card-hover); }

/* ── FILTERS ── */
.filter-bar {
    display: flex; gap: 12px; padding: 20px 0; flex-wrap: wrap; align-items: center;
}
.filter-bar select, .filter-bar input {
    padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); font-size: 0.9rem;
}

/* ── DEADLINE CARD ── */
.deadline-item {
    display: flex; align-items: center; gap: 16px; padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.deadline-date {
    background: var(--accent-glow); color: var(--accent);
    padding: 8px 12px; border-radius: var(--radius-sm);
    font-weight: 700; font-size: 0.85rem; text-align: center; min-width: 70px;
}
.deadline-info .deadline-type { font-weight: 600; font-size: 0.95rem; }
.deadline-info .deadline-state { font-size: 0.8rem; color: var(--text-dim); }

/* ── TOAST ── */
.toast {
    position: fixed; bottom: 24px; right: 24px; z-index: 1000;
    padding: 14px 24px; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 500;
    background: var(--bg-card); border: 1px solid var(--border);
    box-shadow: var(--shadow); transform: translateY(100px); opacity: 0;
    transition: all 0.3s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }

/* ── LOADING ── */
.spinner {
    width: 24px; height: 24px; border: 3px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
    display: flex; align-items: center; justify-content: center;
    padding: 60px; color: var(--text-muted);
}

/* ── FOOTER ── */
.site-footer {
    border-top: 1px solid var(--border); padding: 30px 20px;
    text-align: center; color: var(--text-dim); font-size: 0.85rem;
}
.footer-note { margin-top: 4px; font-size: 0.8rem; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .nav-toggle { display: block; }
    .nav-links {
        display: none; position: absolute; top: 60px; left: 0; right: 0;
        background: var(--bg); border-bottom: 1px solid var(--border);
        flex-direction: column; padding: 16px;
    }
    .nav-links.open { display: flex; }
    .hero h1 { font-size: 2rem; }
    .hero-stats { gap: 24px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .admin-grid { grid-template-columns: 1fr; }
    .dash-header { flex-direction: column; gap: 16px; align-items: flex-start; }
    .chat-msg { max-width: 90%; }
}
@media (max-width: 480px) {
    .hero { padding: 50px 16px 40px; }
    .hero h1 { font-size: 1.7rem; }
    .card { padding: 18px; }
    .auth-card { padding: 28px 20px; }
}
