/*
|--------------------------------------------------------------------------
| SIAGA AIR BOGOR
|--------------------------------------------------------------------------
| File: assets/css/map.css
| Style khusus halaman public/map.php dan komponen Leaflet
|--------------------------------------------------------------------------
*/

/* ==============================
   Page Base
============================== */

.map-page {
    overflow-x: hidden;
    background: #f8fafc;
}

.map-page * {
    box-sizing: border-box;
}

/* ==============================
   Hero
============================== */

.map-hero {
    position: relative;
    overflow: hidden;
    padding: 72px 0 54px;
    background:
        radial-gradient(circle at 12% 20%, rgba(240,180,41,.18), transparent 34%),
        radial-gradient(circle at 88% 5%, rgba(15,107,79,.20), transparent 32%),
        linear-gradient(135deg, #f7faf8 0%, #ecf8f2 62%, #ffffff 100%);
}

.map-hero-pattern {
    position: absolute;
    inset: 0;
    opacity: .35;
    background-image:
        linear-gradient(rgba(15,107,79,.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15,107,79,.06) 1px, transparent 1px);
    background-size: 42px 42px;
    pointer-events: none;
}

.map-hero-grid {
    position: relative;
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    gap: 36px;
    align-items: end;
}

.map-breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 13px;
    border-radius: 999px;
    background: rgba(255,255,255,.84);
    border: 1px solid var(--border, #dbe7e1);
    color: var(--muted, #64748b);
    font-size: 13px;
    font-weight: 800;
}

.map-breadcrumb a {
    color: var(--primary, #0f6b4f);
    text-decoration: none;
}

.map-breadcrumb strong {
    color: var(--primary-dark, #064e3b);
}

.map-hero-copy h1 {
    margin: 20px 0 14px;
    max-width: 760px;
    color: var(--text, #0f172a);
    font-size: clamp(34px, 4.6vw, 62px);
    line-height: 1.05;
    letter-spacing: -2px;
}

.map-hero-copy p {
    max-width: 720px;
    margin: 0;
    color: var(--muted, #64748b);
    font-size: 17px;
    line-height: 1.8;
}

.map-hero-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.map-hero-stats div {
    padding: 20px;
    border-radius: 24px;
    background: rgba(255,255,255,.82);
    border: 1px solid rgba(255,255,255,.84);
    box-shadow: 0 14px 38px rgba(12, 62, 47, .08);
    backdrop-filter: blur(16px);
}

.map-hero-stats strong,
.map-hero-stats span {
    display: block;
}

.map-hero-stats strong {
    color: var(--primary-dark, #064e3b);
    font-size: 32px;
    line-height: 1.05;
}

.map-hero-stats span {
    margin-top: 6px;
    color: var(--muted, #64748b);
    font-size: 13px;
}

/* ==============================
   Layout
============================== */

.map-main-section {
    padding: 32px 0 82px;
}

.map-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.map-sidebar {
    position: sticky;
    top: 96px;
    display: grid;
    gap: 16px;
    z-index: 20;
    min-width: 0;
}

.map-content {
    min-width: 0;
    background: #fff;
    border: 1px solid var(--border, #dbe7e1);
    box-shadow: 0 18px 50px rgba(12, 62, 47, .08);
    border-radius: 30px;
    overflow: hidden;
}

.filter-card,
.legend-card,
.public-note-card {
    background: #fff;
    border: 1px solid var(--border, #dbe7e1);
    box-shadow: 0 18px 50px rgba(12, 62, 47, .08);
    border-radius: 28px;
    padding: 20px;
}

/* ==============================
   Filter
============================== */

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
}

.filter-header span,
.filter-header strong {
    display: block;
}

.filter-header span {
    color: var(--muted, #64748b);
    font-size: 13px;
    margin-bottom: 4px;
}

.filter-header strong {
    color: var(--text, #0f172a);
    font-size: 20px;
}

.filter-reset {
    border: 0;
    cursor: pointer;
    border-radius: 999px;
    padding: 8px 12px;
    background: var(--primary-soft, #e8f6ef);
    color: var(--primary-dark, #064e3b);
    font-weight: 900;
}

.filter-group {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.filter-group label {
    color: var(--text, #0f172a);
    font-weight: 900;
    font-size: 13px;
}

.filter-group input,
.filter-group select {
    width: 100%;
    min-height: 46px;
    border-radius: 16px;
    border: 1px solid var(--border, #dbe7e1);
    background: #f8fbf9;
    padding: 0 14px;
    color: var(--text, #0f172a);
    outline: none;
}

.filter-group input:focus,
.filter-group select:focus {
    border-color: rgba(15,107,79,.45);
    box-shadow: 0 0 0 4px rgba(15,107,79,.08);
    background: #fff;
}

.btn-map-filter {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary, #0f6b4f), var(--primary-dark, #064e3b));
    color: #fff;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 14px 34px rgba(15, 107, 79, .20);
    transition: .22s ease;
}

.btn-map-filter:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 42px rgba(15, 107, 79, .25);
}

/* ==============================
   Legend & Note
============================== */

.legend-card h3 {
    margin: 0 0 16px;
    color: var(--text, #0f172a);
    font-size: 18px;
}

.legend-list {
    display: grid;
    gap: 12px;
}

.legend-list div {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-list strong {
    color: var(--text, #0f172a);
    font-size: 14px;
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    box-shadow: 0 0 0 4px rgba(0,0,0,.04);
    flex: 0 0 auto;
}

.status-aman {
    background: var(--safe, #16a34a);
}

.status-waspada {
    background: var(--warning, #f59e0b);
}

.status-parah {
    background: #ea580c;
}

.status-kritis {
    background: var(--danger, #dc2626);
}

.status-bantuan {
    background: var(--water, #0284c7);
}

.public-note-card strong {
    display: block;
    color: var(--primary-dark, #064e3b);
    margin-bottom: 6px;
}

.public-note-card p {
    margin: 0;
    color: var(--muted, #64748b);
    line-height: 1.7;
    font-size: 14px;
}

/* ==============================
   Map Toolbar
============================== */

.map-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border, #dbe7e1);
    background: #fff;
    position: relative;
    z-index: 15;
}

.map-toolbar span,
.map-toolbar strong {
    display: block;
}

.map-toolbar span {
    color: var(--muted, #64748b);
    font-size: 13px;
    margin-bottom: 4px;
}

.map-toolbar strong {
    color: var(--text, #0f172a);
    font-size: 18px;
}

.map-toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-btn {
    border: 1px solid var(--border, #dbe7e1);
    min-height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    background: #f8fbf9;
    color: var(--primary-dark, #064e3b);
    font-weight: 900;
    cursor: pointer;
    transition: .22s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn:hover {
    background: #fff;
    transform: translateY(-1px);
}

.toolbar-btn.primary {
    border-color: transparent;
    background: var(--primary, #0f6b4f);
    color: #fff;
}

/* ==============================
   LEAFLET MAP FIX UTAMA
============================== */

.map-wrapper {
    position: relative !important;
    width: 100% !important;
    height: 650px !important;
    min-height: 650px !important;
    overflow: hidden !important;
    background: #dbeafe !important;
    border-radius: 0 !important;
    isolation: isolate;
}

#publicMap {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 650px !important;
    min-height: 650px !important;
    display: block !important;
    z-index: 1 !important;
    background: #dbeafe !important;
}

.leaflet-container {
    width: 100% !important;
    height: 100% !important;
    min-height: 650px !important;
    display: block !important;
    font-family: inherit !important;
    z-index: 1 !important;
    background: #dbeafe !important;
}

.leaflet-pane,
.leaflet-map-pane,
.leaflet-tile-pane,
.leaflet-overlay-pane,
.leaflet-marker-pane,
.leaflet-shadow-pane,
.leaflet-popup-pane {
    position: absolute;
}

.leaflet-tile-container,
.leaflet-tile {
    max-width: none !important;
    max-height: none !important;
}

.leaflet-control-container {
    position: relative;
    z-index: 25;
}

/* ==============================
   Loading & Empty State
============================== */

.map-loading {
    position: absolute !important;
    inset: 0 !important;
    z-index: 30 !important;
    display: grid;
    place-items: center;
    width: 100% !important;
    height: 100% !important;
    transform: none !important;
    padding: 18px;
    background: rgba(248,250,252,.78);
    border: 0;
    box-shadow: none;
    text-align: center;
    backdrop-filter: blur(5px);
}

.map-loading[hidden],
.map-loading.is-hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.map-loading > div,
.map-loading > span {
    grid-column: 1;
}

.map-loading span {
    display: block;
    margin-top: 50px;
    color: var(--muted, #64748b);
    font-size: 14px;
    font-weight: 800;
}

/*
   Empty state dibuat kecil di bawah, tidak lagi menutup map kiri/tengah.
   Ini memperbaiki area putih yang muncul di sisi kiri map.
*/
.map-empty {
    position: absolute !important;
    left: 24px !important;
    bottom: 24px !important;
    top: auto !important;
    right: auto !important;
    transform: none !important;
    z-index: 35 !important;
    width: min(360px, calc(100% - 48px)) !important;
    padding: 16px 18px !important;
    border-radius: 20px !important;
    background: rgba(255,255,255,.94) !important;
    border: 1px solid var(--border, #dbe7e1) !important;
    box-shadow: 0 18px 50px rgba(12, 62, 47, .16) !important;
    text-align: left !important;
}

.map-empty[hidden] {
    display: none !important;
}

.map-empty strong,
.map-empty span {
    display: block;
}

.map-empty strong {
    color: var(--text, #0f172a);
    margin-bottom: 6px;
}

.map-empty span {
    color: var(--muted, #64748b);
    font-size: 14px;
    line-height: 1.5;
}

.loader {
    width: 34px;
    height: 34px;
    margin: 0 auto 10px;
    border-radius: 999px;
    border: 4px solid #dbeee6;
    border-top-color: var(--primary, #0f6b4f);
    animation: mapSpin 1s linear infinite;
}

/* ==============================
   Bottom Info
============================== */

.map-bottom-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--border, #dbe7e1);
    background: #fff;
    position: relative;
    z-index: 10;
}

.map-bottom-info div {
    padding: 18px 20px;
    border-right: 1px solid var(--border, #dbe7e1);
}

.map-bottom-info div:last-child {
    border-right: 0;
}

.map-bottom-info strong,
.map-bottom-info span {
    display: block;
}

.map-bottom-info strong {
    color: var(--primary-dark, #064e3b);
    font-size: 20px;
}

.map-bottom-info span {
    color: var(--muted, #64748b);
    margin-top: 4px;
    font-size: 13px;
}

/* ==============================
   Leaflet Custom
============================== */

.leaflet-control-zoom {
    border: 0 !important;
    box-shadow: 0 14px 34px rgba(12, 62, 47, .14) !important;
}

.leaflet-control-zoom a {
    border: 0 !important;
    color: var(--primary-dark, #064e3b) !important;
    font-weight: 900;
}

.leaflet-popup-content-wrapper {
    border-radius: 22px !important;
    box-shadow: 0 20px 50px rgba(12, 62, 47, .18) !important;
}

.leaflet-popup-content {
    margin: 16px !important;
}

.leaflet-popup-tip {
    box-shadow: none !important;
}

.siaga-marker {
    background: transparent !important;
    border: 0 !important;
}

.siaga-marker span {
    position: relative;
}

.siaga-marker span::after {
    content: "";
    position: absolute;
    width: 7px;
    height: 7px;
    left: 50%;
    top: 50%;
    border-radius: 999px;
    background: #fff;
    transform: translate(-50%, -50%);
}

.siaga-popup {
    min-width: 240px;
}

.siaga-popup h3 {
    margin: 0 0 8px;
    color: var(--text, #0f172a);
    font-size: 17px;
    line-height: 1.25;
}

.siaga-popup p {
    margin: 0 0 8px;
    color: var(--muted, #64748b);
    line-height: 1.55;
}

.siaga-popup .popup-meta {
    display: grid;
    gap: 5px;
    margin: 10px 0;
    font-size: 13px;
}

.siaga-popup .popup-meta span {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px dashed rgba(15, 107, 79, .18);
    padding-bottom: 5px;
}

.siaga-popup .popup-meta b {
    color: var(--text, #0f172a);
}

.siaga-popup .popup-link {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--primary, #0f6b4f);
    color: #fff;
    font-weight: 900;
    margin-top: 6px;
    text-decoration: none;
}

.siaga-popup .popup-link:hover {
    background: var(--primary-dark, #064e3b);
}

@keyframes mapSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ==============================
   Responsive
============================== */

@media (max-width: 1080px) {
    .map-layout,
    .map-hero-grid {
        grid-template-columns: 1fr;
    }

    .map-sidebar {
        position: static;
        z-index: 1;
    }

    .map-hero-stats {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 760px) {
    .map-hero {
        padding: 52px 0 38px;
    }

    .map-hero-copy h1 {
        letter-spacing: -1.4px;
    }

    .map-hero-copy p {
        font-size: 15px;
    }

    .map-hero-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .map-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .map-toolbar-actions,
    .toolbar-btn {
        width: 100%;
    }

    .toolbar-btn {
        justify-content: center;
    }

    .map-wrapper,
    #publicMap,
    .leaflet-container {
        height: 520px !important;
        min-height: 520px !important;
    }

    .map-bottom-info {
        grid-template-columns: 1fr;
    }

    .map-bottom-info div {
        border-right: 0;
        border-bottom: 1px solid var(--border, #dbe7e1);
    }

    .map-bottom-info div:last-child {
        border-bottom: 0;
    }

    .map-empty {
        left: 16px !important;
        right: 16px !important;
        bottom: 16px !important;
        width: auto !important;
    }
}

@media (max-width: 480px) {
    .map-hero-stats {
        grid-template-columns: 1fr;
    }

    .filter-card,
    .legend-card,
    .public-note-card,
    .map-content {
        border-radius: 22px;
    }

    .map-wrapper,
    #publicMap,
    .leaflet-container {
        height: 480px !important;
        min-height: 480px !important;
    }
}