/* ==========================================================================
   Algeria Forest Guard AI - Stylesheet
   Theme: Dark Tactical Command Center / Forest Wildfire Management
   Version: 1.0 (MVP)
   ========================================================================== */

:root {
    --bg-primary: #0a0f18;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.85);
    --bg-card-hover: rgba(31, 41, 55, 0.95);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-active: rgba(16, 185, 129, 0.4);

    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --brand-forest: #10b981;
    --brand-forest-dark: #065f46;
    --brand-forest-glow: rgba(16, 185, 129, 0.25);

    --risk-low: #10b981;
    --risk-moderate: #eab308;
    --risk-high: #f97316;
    --risk-extreme: #ef4444;

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 15px rgba(239, 68, 68, 0.4);
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    font-size: 14px;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ================= Topbar ================= */
.topbar {
    background: rgba(11, 17, 30, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #059669, #10b981);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 12px var(--brand-forest-glow);
}

.brand-logo svg {
    width: 24px;
    height: 24px;
    fill: #ffffff;
}

.brand-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-badge {
    background: var(--brand-forest-dark);
    color: #6ee7b7;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.brand-subtitle {
    font-size: 11.5px;
    color: var(--text-secondary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.04);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--brand-forest);
    box-shadow: 0 0 8px var(--brand-forest);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

/* ================= Navigation Tabs ================= */
.nav-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    overflow-x: auto;
    white-space: nowrap;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 12px 18px;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
    color: var(--brand-forest);
    border-bottom-color: var(--brand-forest);
    background: rgba(16, 185, 129, 0.05);
}

.tab-btn .badge {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

/* ================= Main Container ================= */
.main-content {
    padding: 20px 24px 60px 24px;
    max-width: 1700px;
    margin: 0 auto;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.25s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================= KPIs Row ================= */
.kpis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--brand-forest);
}

.kpi-card.warning::before { background: var(--risk-moderate); }
.kpi-card.danger::before { background: var(--risk-extreme); }
.kpi-card.info::before { background: #3b82f6; }

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: #ffffff;
    font-family: var(--font-mono);
}

.kpi-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ================= Map & Explorer Split ================= */
.map-explorer-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 1200px) {
    .map-explorer-grid {
        grid-template-columns: 1fr;
    }
}

.map-container-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 560px;
}

.map-toolbar {
    background: rgba(17, 24, 39, 0.95);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.map-toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.map-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

#leaflet-map {
    width: 100%;
    height: 520px;
    background: #0d1624;
}

.map-side-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 600px;
    overflow-y: auto;
}

.panel-title {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

/* ================= Badges & Indicators ================= */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-low { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-moderate { background: rgba(234, 179, 8, 0.15); color: #facc15; border: 1px solid rgba(234, 179, 8, 0.3); }
.badge-high { background: rgba(249, 115, 22, 0.15); color: #fb923c; border: 1px solid rgba(249, 115, 22, 0.3); }
.badge-extreme { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); animation: glow 2s infinite; }

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 12px rgba(239, 68, 68, 0.6); }
}

/* ================= Tables ================= */
.custom-table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.custom-table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.custom-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font-size: 13px;
}

.custom-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* ================= Forms & Inputs ================= */
.form-control, .form-select {
    background: #1f2937;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
    transition: border 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand-forest);
}

.btn {
    background: #1f2937;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn:hover {
    background: #374151;
}

.btn-primary {
    background: var(--brand-forest);
    color: #ffffff;
    border-color: var(--brand-forest);
}

.btn-primary:hover {
    background: #059669;
}

.btn-danger {
    background: var(--risk-extreme);
    color: #ffffff;
    border-color: var(--risk-extreme);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* ================= Cards & Grids ================= */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-card);
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ================= Alert Feed Items ================= */
.alert-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s;
}

.alert-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.15);
}

.alert-item.priority-critique {
    border-left: 4px solid var(--risk-extreme);
}
.alert-item.priority-elevee {
    border-left: 4px solid var(--risk-high);
}
.alert-item.priority-moyenne {
    border-left: 4px solid var(--risk-moderate);
}

.alert-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-item-title {
    font-weight: 600;
    color: #ffffff;
}

.alert-item-meta {
    font-size: 11.5px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
}

/* ================= Range Sliders ================= */
.range-container {
    margin-bottom: 16px;
}

.range-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.range-slider {
    width: 100%;
    accent-color: var(--brand-forest);
}

/* ================= Confusion Matrix ================= */
.confusion-matrix-grid {
    display: grid;
    grid-template-columns: 120px 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
    text-align: center;
}

.matrix-header {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    padding: 8px;
}

.matrix-cell {
    background: #1f2937;
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: var(--radius-sm);
}

.matrix-cell.tp { background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.4); }
.matrix-cell.tn { background: rgba(59, 130, 246, 0.15); border-color: rgba(59, 130, 246, 0.4); }
.matrix-cell.fp { background: rgba(234, 179, 8, 0.15); border-color: rgba(234, 179, 8, 0.4); }
.matrix-cell.fn { background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.4); }

.matrix-val {
    font-size: 24px;
    font-weight: 700;
    font-family: var(--font-mono);
}

.matrix-sub {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ================= Modal ================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-overlay.open {
    display: flex;
}

.modal-card {
    background: #111827;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
    margin-bottom: 16px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

.modal-close:hover {
    color: #ffffff;
}

/* Leaflet Custom Hotspot Animation */
.leaflet-hotspot-marker {
    background: #ef4444;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 12px #ef4444;
    animation: hotspotPulse 1.5s infinite;
}

@keyframes hotspotPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* RTL Mode (Arabic / العربية) */
[dir="rtl"] {
    font-family: 'Amiri', 'Segoe UI', Tahoma, sans-serif;
}

[dir="rtl"] .topbar-actions {
    margin-right: auto;
    margin-left: 0;
}

[dir="rtl"] .map-toolbar-left {
    border-left: none;
    border-right: 3px solid var(--brand-forest);
    padding-left: 0;
    padding-right: 8px;
}

[dir="rtl"] .custom-table th, 
[dir="rtl"] .custom-table td {
    text-align: right;
}

[dir="rtl"] .badge {
    direction: ltr;
    display: inline-block;
}

