/* =====================================================================
   GeoPORTAL BPTD Jabar — Modul Early Warning & Pemantauan Anomali (early-warning.css)
   Sistem Kewaspadaan Dini, Ambang Batas Metodologi & Pulsing Markers
   ===================================================================== */

/* =====================================================================
   1. MAP SECTION & PULSING MARKERS
   ===================================================================== */
.early-warning-map-card {
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.early-warning-map-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.early-warning-map-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-map-control {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.4rem 0.85rem;
    border-radius: 0.375rem;
    background: #ffffff;
    color: #334155;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-map-control:hover {
    background: #f1f5f9;
    color: var(--blue-700);
    border-color: #cbd5e1;
}

.early-warning-map {
    width: 100%;
    height: 480px;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: #f8fafc;
    position: relative;
    z-index: 1;
}

/* Pulsing radar animations */
@keyframes alertPulseCritical {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.8);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 14px rgba(239, 68, 68, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

@keyframes alertPulseWarning {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.8);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 12px rgba(245, 158, 11, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

@keyframes alertPulseAdvisory {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

/* Marker DOM structure */
.early-warning-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
}

.marker-pin {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.marker-pin:hover {
    transform: scale(1.2);
    z-index: 1000;
}

.marker-pin.is-critical {
    background: #ef4444;
    border: 2px solid #ffffff;
    animation: alertPulseCritical 1.6s infinite ease-out;
}

.marker-pin.is-warning {
    background: #f59e0b;
    border: 2px solid #ffffff;
    animation: alertPulseWarning 2s infinite ease-out;
}

.marker-pin.is-advisory {
    background: #3b82f6;
    border: 2px solid #ffffff;
    animation: alertPulseAdvisory 2.4s infinite ease-out;
}

.marker-pin svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2.2;
    fill: none;
}

/* Map legend & filter bar */
.severity-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.65rem 0.85rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.severity-filter-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.severity-toggle-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.severity-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    background: #ffffff;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s ease;
}

.severity-chip:hover {
    border-color: #94a3b8;
    background: #f1f5f9;
}

.severity-chip.is-active {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.severity-chip .chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.chip-dot-all { background: #64748b; }
.chip-dot-critical { background: #ef4444; }
.chip-dot-warning { background: #f59e0b; }
.chip-dot-advisory { background: #3b82f6; }

/* =====================================================================
   2. ANALYTICS TABS & CONTROLS
   ===================================================================== */
.early-warning-analytics-card {
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.early-warning-tabs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.early-warning-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #64748b;
    border: none;
    background: transparent;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.tab-btn:hover {
    color: #0f172a;
}

.tab-btn.is-active {
    color: var(--blue-700);
    border-bottom-color: var(--blue-700);
}

.tab-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.45rem;
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: 9999px;
    background: #e2e8f0;
    color: #475569;
}

.tab-btn.is-active .tab-count-badge {
    background: #dbeafe;
    color: #1d4ed8;
}

/* Tab Panels */
.early-warning-tabpanel {
    display: block;
}

.early-warning-tabpanel[hidden] {
    display: none !important;
}

/* Toolbar & Filters */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.table-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    flex: 1;
}

.search-input-wrap {
    position: relative;
    min-width: 260px;
    max-width: 380px;
    flex: 1;
}

.search-input-wrap svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    color: #94a3b8;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 0.45rem 0.75rem 0.45rem 2.2rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: #ffffff;
    color: #0f172a;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 2px rgba(47, 92, 191, 0.15);
}

.select-filter {
    padding: 0.45rem 2rem 0.45rem 0.75rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 0.5rem center / 1rem;
    appearance: none;
    color: #334155;
    outline: none;
    cursor: pointer;
}

.select-filter:focus {
    border-color: var(--blue-500);
}

.table-count-info {
    font-size: 0.8125rem;
    color: #64748b;
    font-weight: 500;
}

/* =====================================================================
   3. TABLES & BADGES
   ===================================================================== */
.table-wrap {
    width: 100%;
    max-height: 520px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #ffffff;
}

.early-warning-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    text-align: left;
}

.early-warning-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    box-shadow: 0 1px 0 var(--border);
}

.early-warning-table tbody td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    vertical-align: middle;
}

.early-warning-table tbody tr:hover {
    background: #f8fafc;
}

.early-warning-table .th-center { text-align: center; }
.early-warning-table .th-right { text-align: right; }

/* Severity Badges */
.badge-critical {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-critical::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ef4444;
}

.badge-warning {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-warning::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #f59e0b;
}

.badge-advisory {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-advisory::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #3b82f6;
}

/* Domain Badges */
.domain-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.725rem;
    font-weight: 600;
}

.domain-terminal {
    background: #e0f2fe;
    color: #0369a1;
}

.domain-uppkb {
    background: #fef3c7;
    color: #92400e;
}

.domain-perintis {
    background: #dcfce7;
    color: #15803d;
}

.domain-koridor {
    background: #f3e8ff;
    color: #6b21a8;
}

/* Temporal Badges & Patterns */
.temporal-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.725rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.temporal-badge svg {
    width: 12px;
    height: 12px;
    flex: none;
}

.temporal-pattern-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.12rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.temporal-pattern-peak { background: #fee2e2; color: #b91c1c; }
.temporal-pattern-night { background: #e0e7ff; color: #4338ca; }
.temporal-pattern-weekend { background: #fef3c7; color: #b45309; }
.temporal-pattern-weather { background: #ecfdf5; color: #047857; }
.temporal-pattern-offpeak { background: #f1f5f9; color: #475569; }

.status-badge-inline {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.725rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}

/* Action button in table */
.btn-table-action {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.25rem;
    background: #ffffff;
    color: var(--blue-700);
    border: 1px solid #cbd5e1;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-table-action:hover {
    background: #eff6ff;
    border-color: var(--blue-500);
}

/* Formula & Code pill */
.code-pill {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 0.25rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.725rem;
    background: #f1f5f9;
    color: #0f172a;
    border: 1px solid #e2e8f0;
}

/* Trend bars in History Tab */
.history-bar-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.history-bar-track {
    flex: 1;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.history-bar-fill {
    height: 100%;
    border-radius: 4px;
}

/* =====================================================================
   4. MODAL DIALOG STYLES
   ===================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 9998;
}

.modal-backdrop[hidden] {
    display: none !important;
}

.modal-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 680px;
    max-height: 88vh;
    background: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.08);
    border: 1px solid #cbd5e1;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-dialog[hidden] {
    display: none !important;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.modal-title-group {
    flex: 1;
}

.modal-badge-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 0.25rem 0;
    line-height: 1.3;
}

.modal-sub {
    font-size: 0.8125rem;
    color: #64748b;
    margin: 0;
}

.modal-close-btn {
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: color 0.15s ease;
}

.modal-close-btn:hover {
    color: #0f172a;
    background: #e2e8f0;
}

.modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-section {
    margin-bottom: 1.25rem;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 0.65rem 0;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.35rem;
}

.modal-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

@media (max-width: 640px) {
    .modal-stats-grid {
        grid-template-columns: 1fr;
    }
}

.modal-stat-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
}

.modal-stat-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.modal-stat-val {
    font-size: 0.875rem;
    font-weight: 700;
    margin: 0 0 0.15rem 0;
}

.modal-stat-sub {
    font-size: 0.6875rem;
    color: #94a3b8;
}

.modal-desc-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-left: 3px solid var(--blue-500);
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: #334155;
    margin: 0;
}

.modal-mitigation-box {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-left: 3px solid #22c55e;
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: #14532d;
    margin: 0;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: #f8fafc;
}

/* Text utility classes */
.text-red { color: #dc2626 !important; }
.text-amber { color: #d97706 !important; }
.text-blue { color: #2563eb !important; }
.text-green { color: #16a34a !important; }
.text-muted { color: #64748b !important; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

/* Custom Leaflet popup overrides */
.early-warning-popup .leaflet-popup-content-wrapper {
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 0;
    overflow: hidden;
}

.early-warning-popup .leaflet-popup-content {
    margin: 0.75rem 1rem;
    line-height: 1.4;
    font-size: 0.8125rem;
}

.popup-title {
    font-weight: 700;
    font-size: 0.875rem;
    color: #0f172a;
    margin-bottom: 0.35rem;
}

.popup-param {
    font-size: 0.75rem;
    color: #475569;
    margin-bottom: 0.25rem;
}

.popup-btn {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.25rem 0.65rem;
    font-size: 0.725rem;
    font-weight: 600;
    border-radius: 0.25rem;
    background: #0f172a;
    color: #ffffff;
    border: none;
    cursor: pointer;
}
