/* ==========================================================================
   MITIGASI.COM — Lapisan desain (dimuat setelah global.css)
   Karakter: papan informasi publik — tenang, tepercaya, cepat dibaca.
   Warna mencolok hanya untuk tingkat bahaya. Warna utama tetap dari tema admin (--primary).
   ========================================================================== */

:root {
    --ink: #10283d;
    --ink-2: #183a57;
    --text: #1d3246;
    --muted: #5b7083;
    --line: #dfe5ec;
    --surface: #f3f6f9;
    --card: #ffffff;

    --lv-normal: #2e7d32;
    --lv-waspada: #f2a900;
    --lv-siaga: #e8710a;
    --lv-awas: #c62828;

    --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --radius-lg: 16px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(16, 40, 61, .06);
    --shadow: 0 1px 2px rgba(16, 40, 61, .05), 0 6px 20px rgba(16, 40, 61, .06);

    /* Garis kontur topografi (motif tunggal di area biru tinta) */
    --topo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='320' viewBox='0 0 640 320'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.07' stroke-width='1.2'%3E%3Cpath d='M-20 60 C80 20 160 100 260 70 S440 10 540 60 S660 90 680 70'/%3E%3Cpath d='M-20 90 C90 50 170 130 270 100 S450 40 550 90 S660 120 680 100'/%3E%3Cpath d='M-20 120 C100 80 180 160 280 130 S460 70 560 120 S660 150 680 130'/%3E%3Cpath d='M-20 175 C70 140 150 205 250 185 S420 120 520 170 S640 210 680 190'/%3E%3Cpath d='M-20 205 C80 170 160 235 260 215 S430 150 530 200 S650 240 680 220'/%3E%3Cpath d='M-20 260 C110 230 200 290 300 265 S470 215 570 255 S660 280 680 270'/%3E%3Cpath d='M-20 290 C120 260 210 320 310 295 S480 245 580 285 S665 305 680 300'/%3E%3Cellipse cx='470' cy='150' rx='38' ry='16'/%3E%3Cellipse cx='470' cy='150' rx='70' ry='34'/%3E%3C/g%3E%3C/svg%3E");
}

/* ---------- Dasar ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--surface);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { color: var(--ink); font-weight: 700; letter-spacing: -0.015em; line-height: 1.25; }
h1 { font-size: clamp(1.6rem, 1.15rem + 1.9vw, 2.35rem); font-weight: 800; letter-spacing: -0.025em; }
h2 { font-size: clamp(1.2rem, 1.05rem + .6vw, 1.45rem); }
h3 { font-size: 1.08rem; }
p { max-width: 75ch; }
img, svg, video { max-width: 100%; }
a { color: var(--primary); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 70%, white); outline-offset: 2px; border-radius: 4px; }
button, input, select, textarea { font-family: inherit; }
.container { padding-left: 20px; padding-right: 20px; }
main { display: block; min-height: 50vh; }
.leaflet-container { font-family: var(--font-sans); }
.leaflet-popup-content { line-height: 1.5; }

/* ---------- Header halaman ---------- */
.page-header,
.page-header.teal, .page-header.blue, .page-header.orange {
    --hdr-accent: var(--primary);
    position: relative;
    background: var(--ink) var(--topo) center / 640px 320px repeat;
    color: #fff;
    text-align: left;
    padding: 34px 0 40px;
}
/* Ruang ekstra hanya bila kartu statistik menumpuk di bawah header */
.page-header:has(+ .container > .stats-row:first-child) { padding-bottom: 72px; }
.page-header.teal { --hdr-accent: #00897b; }
.page-header.blue { --hdr-accent: #1e88e5; }
.page-header.orange { --hdr-accent: #f57c00; }
.page-header::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
    background: var(--hdr-accent);
}
.page-header .breadcrumb { font-size: .85rem; opacity: .75; margin-bottom: 14px; }
.page-header .breadcrumb a { color: #fff; }
.page-header h1 { color: #fff; margin: 0 0 8px; }
.page-header p { color: rgba(255, 255, 255, .78); font-size: 1.02rem; margin: 0; max-width: 62ch; }

/* ---------- Kartu statistik (menumpuk di bawah header halaman) ---------- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: -44px 0 26px;
    position: relative;
    z-index: 10;
}
.stats-row .stat-card,
main .stats-grid .stat-card {
    display: grid;
    grid-template-columns: 44px 1fr;
    grid-template-rows: auto auto;
    column-gap: 12px;
    align-items: center;
    text-align: left;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    transform: none;
}
.stats-row .stat-card:hover, main .stats-grid .stat-card:hover { transform: none; box-shadow: var(--shadow); }
.stats-row .stat-card .icon, main .stats-grid .stat-card .icon {
    grid-row: 1 / span 2;
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.35rem; margin: 0;
    background: color-mix(in srgb, var(--primary) 10%, white);
}
.stats-row .stat-card .value, main .stats-grid .stat-card .value {
    font-size: 1.55rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums; color: var(--ink);
}
.stats-row .stat-card .label, main .stats-grid .stat-card .label {
    font-size: .8rem; line-height: 1.35; color: var(--muted); margin: 2px 0 0;
}
.stat-card .delta { grid-column: 2; }

/* ---------- Tombol ---------- */
.btn { border-radius: 10px; font-weight: 700; letter-spacing: -0.005em; transition: background-color .15s, box-shadow .15s, color .15s; }
.btn:hover { transform: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: none; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-white { background: #fff; color: var(--ink); }
.btn-white:hover { transform: none; background: #eef3f7; }
.btn-outline-white { border: 1.5px solid rgba(255, 255, 255, .55); color: #fff; background: transparent; }
.btn-outline-white:hover { background: rgba(255, 255, 255, .1); color: #fff; }

/* ---------- Kartu & panel ---------- */
.card { border: 1px solid var(--line); box-shadow: var(--shadow-sm); border-radius: var(--radius); }
.card-header { background: var(--ink); }
main :is(.k-section, .b-section, .v-section, .marine-section, .marine-detail, .l-box, .eq-section, .side-box,
         .eq-list, .eq-list-home, .weather-legend, .map-container, .port-search) {
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-lg);
}
main :is(.news-item, .art-card, .v-card, .air-card, .bnpb-card, .report, .r-card, .river, .warn-card, .alert-item, .vessel-card) {
    box-shadow: none;
    border: 1px solid var(--line);
}
main :is(.news-item, .art-card, .v-card):hover { transform: none; border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); }
main :is(.k-section, .b-section, .v-section, .marine-section, .marine-detail, .l-box, .eq-section) h2 { font-size: 1.22rem; }

/* Kartu peringatan cuaca: garis atas sesuai tingkat, tanpa kepala berwarna tebal */
main .alert-card {
    border: 1px solid var(--line);
    border-top: 4px solid var(--muted);
    border-left: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column;
}
main .alert-card:hover { transform: none; box-shadow: var(--shadow); }
main .alert-card:has(.alert-header.info) { border-top-color: #1e88e5; }
main .alert-card:has(.alert-header.warning), main .alert-card:has(.badge.WASPADA) { border-top-color: var(--lv-waspada); }
main .alert-card:has(.alert-header.danger), main .alert-card:has(.badge.SIAGA) { border-top-color: var(--lv-siaga); }
main .alert-card:has(.alert-header.critical), main .alert-card:has(.badge.AWAS) { border-top-color: var(--lv-awas); }
main .alert-card .alert-header,
main .alert-card .alert-header.info, main .alert-card .alert-header.warning,
main .alert-card .alert-header.danger, main .alert-card .alert-header.critical {
    background: none; color: var(--ink); padding: 16px 18px 0; font-size: 1rem; line-height: 1.4;
}
main .alert-card .alert-body { padding: 8px 18px 14px; flex: 1; }
main .alert-card .alert-footer { background: transparent; border-top: 1px solid var(--line); padding: 10px 18px; }
main .alert-type { background: var(--surface); color: var(--muted); border-radius: 6px; }

/* Halaman Peringatan: global.css lama mewarnai seluruh kartu (.waspada/.siaga/.awas !important).
   Kartu dikembalikan putih; level ditunjukkan garis atas + badge. */
main .alert-card:is(.waspada, .siaga, .awas, .alert-waspada, .alert-siaga, .alert-awas, .expired),
main .alert-card-header:is(.waspada, .siaga, .awas, .alert-waspada, .alert-siaga, .alert-awas, .expired) {
    background: var(--card) !important;
    color: var(--text) !important;
}
main .alert-card.waspada, main .alert-card.alert-waspada { border-top-color: var(--lv-waspada); }
main .alert-card.siaga, main .alert-card.alert-siaga { border-top-color: var(--lv-siaga); }
main .alert-card.awas, main .alert-card.alert-awas { border-top-color: var(--lv-awas); }
main .alert-card .alert-card-header { color: var(--ink) !important; }
main .alert-card :is(.alert-card-body, .alert-card-body *) { color: var(--text) !important; }
main .alert-card .alert-card-footer { background: transparent !important; border-top: 1px solid var(--line); }
main .severity-badge.waspada, main .severity-badge.alert-waspada { background: var(--lv-waspada) !important; color: #2b1d00 !important; }
main .severity-badge.siaga, main .severity-badge.alert-siaga { background: var(--lv-siaga) !important; color: #fff !important; }
main .severity-badge.awas, main .severity-badge.alert-awas { background: var(--lv-awas) !important; color: #fff !important; }

/* Badge tingkat */
.badge { border-radius: 6px; letter-spacing: .01em; }
.badge.WASPADA { background: var(--lv-waspada); color: #2b1d00; }
.badge.SIAGA { background: var(--lv-siaga); color: #fff; }
.badge.AWAS { background: var(--lv-awas); color: #fff; }

/* Tabel */
.data-table { box-shadow: none; border: 1px solid var(--line); }
.data-table thead { background: var(--surface); color: var(--ink); }
.data-table th { font-size: .82rem; font-weight: 700; color: var(--muted); }

/* Banner sumber data */
main .data-source-banner {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    font-size: .9rem; color: var(--muted);
}

/* Kondisi kosong: arahkan, jangan muram */
.empty-state { border: 1px dashed var(--line); background: var(--card); padding: 40px 20px; }
.empty-state .icon { font-size: 2.4rem; opacity: .8; }
.empty-state h3 { color: var(--ink); }

/* Ajakan (CTA) */
.cta-box, main .cta-section {
    background: var(--ink) var(--topo) center / 640px 320px repeat !important;
    border-radius: var(--radius-lg);
}

/* Formulir */
.form-control { border-color: var(--line); border-radius: 10px; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }

/* ---------- Responsif ---------- */
@media (max-width: 992px) {
    .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: -40px; }
}
@media (max-width: 576px) {
    .container { padding-left: 16px; padding-right: 16px; }
    .page-header { padding: 24px 0 30px; }
    .page-header:has(+ .container > .stats-row:first-child) { padding-bottom: 64px; }
    .page-header p { font-size: .95rem; }
    .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: -44px 0 20px; }
    .stats-row .stat-card, main .stats-grid .stat-card { grid-template-columns: 1fr; padding: 13px 14px; row-gap: 2px; }
    .stats-row .stat-card .icon, main .stats-grid .stat-card .icon { grid-row: auto; width: 34px; height: 34px; font-size: 1.05rem; border-radius: 9px; margin-bottom: 6px; }
    .stats-row .stat-card .value, main .stats-grid .stat-card .value { font-size: 1.3rem; }
    .stat-card .delta { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
