/* F9 Weather Compare - Stylesheet */
:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #0f172a;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --warn: #f59e0b;
    --ok: #16a34a;
    --hot: #fff3bf;
    --veryhot: #ffc9c9;
    --cold: #dbeafe;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.04);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --surface: #1e293b;
        --border: #334155;
        --text: #f1f5f9;
        --muted: #94a3b8;
        --hot: #78350f;
        --veryhot: #7f1d1d;
        --cold: #1e3a8a;
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.container { max-width: 1400px; margin: 0 auto; padding: 0 16px; }

/* ---- Header ---- */
.top, .admin-top {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky; top: 0; z-index: 100;
}
.top .container, .admin-top .container {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
}
.top h1, .admin-top h1 { margin: 0; font-size: 18px; font-weight: 600; }
.filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filters select { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.filters label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

/* ---- Admin Nav ---- */
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-nav a {
    padding: 6px 12px; border-radius: var(--radius);
    color: var(--muted); text-decoration: none; font-size: 14px;
}
.admin-nav a:hover { background: var(--bg); color: var(--text); }
.admin-nav a.active { background: var(--primary); color: white; }
.admin-nav a.logout { color: var(--danger); margin-left: auto; }

/* ---- Main ---- */
main { padding: 24px 0; }
h2 { font-size: 20px; margin: 24px 0 12px; }
h3 { font-size: 16px; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.empty { background: var(--surface); padding: 40px; text-align: center; border-radius: var(--radius); border: 1px dashed var(--border); }

/* ---- Buttons ---- */
.btn {
    display: inline-block; padding: 8px 14px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    cursor: pointer; text-decoration: none; font-size: 14px; line-height: 1.2;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-small { padding: 4px 8px; font-size: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

/* ---- Forms ---- */
input[type=text], input[type=password], input[type=email], input:not([type]), select, textarea {
    padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary);
}
label { display: block; margin: 8px 0; }
label input, label select { display: block; margin-top: 4px; width: 100%; }
.row-form {
    display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; align-items: center;
    background: var(--surface); padding: 12px; border-radius: var(--radius); border: 1px solid var(--border);
}

/* ---- Tables ---- */
.data-table, .forecast {
    width: 100%; border-collapse: collapse; background: var(--surface);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.data-table th { background: var(--bg); font-weight: 600; font-size: 13px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table input { width: 100%; }

/* ---- Forecast Table ---- */
.table-wrap { overflow-x: auto; margin-top: 16px; }
.forecast caption { caption-side: top; text-align: left; padding: 8px 0; font-weight: 600; }
.forecast th, .forecast td {
    border: 1px solid var(--border); padding: 8px 10px; text-align: right; white-space: nowrap; vertical-align: top;
}
.forecast th { background: var(--bg); font-weight: 600; }
.forecast th small, .forecast td small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }
.forecast .sticky-l { position: sticky; left: 0; background: var(--surface); text-align: left; z-index: 1; }
.forecast th.sticky-l { background: var(--bg); z-index: 2; }
.forecast .cell-hot { background: var(--hot); }
.forecast .cell-veryhot { background: var(--veryhot); }
.forecast .cell-cold { background: var(--cold); }
.forecast .spread { color: var(--muted); font-size: 11px; }
.forecast .details summary { cursor: pointer; color: var(--muted); font-size: 11px; margin-top: 4px; }
.forecast .src-list { list-style: none; padding: 4px 0 0; margin: 0; font-size: 11px; text-align: left; }
.forecast .src-list li { padding: 1px 0; }
.forecast .src-name { color: var(--muted); margin-right: 4px; }

/* ---- Cards ---- */
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card {
    background: var(--surface); padding: 20px; border-radius: var(--radius);
    border: 1px solid var(--border); box-shadow: var(--shadow);
}
.card-num { font-size: 32px; font-weight: 700; line-height: 1; }
.card-label { color: var(--muted); margin-top: 6px; font-size: 13px; }
.card-link { display: inline-block; margin-top: 12px; color: var(--primary); text-decoration: none; font-size: 13px; }

/* ---- Map ---- */
.map-wrap { margin: 16px 0; }
#map { height: 480px; border-radius: var(--radius); box-shadow: var(--shadow); }
.map-label { background: rgba(255,255,255,0.95); border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; font-size: 11px; text-align: center; pointer-events: none; }
@media (prefers-color-scheme: dark) {
    .map-label { background: rgba(30,41,59,0.95); color: var(--text); }
}

/* ---- Flash / Alerts ---- */
.flash, .alert {
    padding: 12px 16px; border-radius: var(--radius); margin: 12px 0;
    border: 1px solid var(--border); background: var(--surface);
}
.flash-success, .alert-ok { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.flash-warn, .alert-warn { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.flash-error, .alert-error { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
@media (prefers-color-scheme: dark) {
    .flash-success, .alert-ok { background: #064e3b; color: #d1fae5; border-color: #047857; }
    .flash-warn, .alert-warn { background: #78350f; color: #fef3c7; border-color: #b45309; }
    .flash-error, .alert-error { background: #7f1d1d; color: #fee2e2; border-color: #b91c1c; }
}

/* ---- Badges ---- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); font-size: 11px; color: var(--muted); }
.badge-ok { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }

/* ---- Switch ---- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { display: none; }
.switch span { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 22px; transition: 0.2s; }
.switch span:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: 0.2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span:before { transform: translateX(18px); }

/* ---- Login ---- */
body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-box { background: var(--surface); padding: 32px; border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 380px; }
.login-box h1 { margin-top: 0; font-size: 22px; }

/* ---- Footer ---- */
.foot { padding: 24px 0; text-align: center; color: var(--muted); border-top: 1px solid var(--border); margin-top: 32px; }

/* ---- Mobile ---- */
@media (max-width: 768px) {
    .row-form { grid-template-columns: 1fr; }
    .top .container, .admin-top .container { flex-direction: column; align-items: stretch; }
    .filters { justify-content: stretch; }
    #map { height: 320px; }
    .forecast th, .forecast td { padding: 6px 8px; font-size: 12px; }
}
