/* --- Global Sci-Fi System Resets --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #060d0a; /* Ultra-deep green-black console canvas */
    color: #e2e8f0;
    line-height: 1.6;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(22, 101, 52, 0.15) 0%, transparent 80%),
        linear-gradient(rgba(18, 24, 21, 0.4) 1px, transparent 1px),
        linear-gradient(90deg, rgba(18, 24, 21, 0.4) 1px, transparent 1px);
    background-size: 100% 100%, 20px 20px, 20px 20px;
}

/* --- Tech Header Layout --- */
header {
    text-align: center;
    padding: 20px;
    background: rgba(4, 15, 10, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 2px solid #22c55e;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.2);
    position: relative;
}

header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #22c55e, #bbf7d0, #22c55e, transparent);
}

h1 {
    font-size: 2.2em;
    letter-spacing: 4px;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(34, 197, 94, 0.6);
    font-weight: 800;
}

header p {
    color: #a7f3d0;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 5px;
    opacity: 0.8;
}

/* --- Main Layout Grid --- */
.container {
    display: flex;
    max-width: 1600px;
    margin: 25px auto;
    gap: 25px;
    padding: 0 20px;
    flex-wrap: wrap;
}

/* --- High-Visibility Sci-Fi Map Terminal Area --- */
.map-container {
    flex: 2;
    min-width: 600px;
    padding: 20px;
    background: #111e17 !important; /* Muted tactical olive-drab bezel */
    border: 2px solid #22c55e; /* Crisp high-vis green structural border */
    border-radius: 4px;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
    position: relative;
}

/* Tactical Corner Brackets */
.map-container::before {
    content: '';
    position: absolute;
    top: -1px; left: -1px; width: 12px; height: 12px;
    border-top: 2px solid #4ade80; border-left: 2px solid #4ade80;
    z-index: 5;
}
.map-container::after {
    content: '';
    position: absolute;
    bottom: -1px; right: -1px; width: 12px; height: 12px;
    border-bottom: 2px solid #4ade80; border-right: 2px solid #4ade80;
    z-index: 5;
}

/* --- Balanced High-Visibility Viewport --- */
#map {
    width: 100%;
    height: 580px;
    background-color: #f4f6f8 !important; /* Pure light base canvas fallback */
    border: 1px solid rgba(34, 197, 94, 0.4);
    position: relative;
    overflow: hidden;
    
    mix-blend-mode: normal !important; 
    filter: none !important;
    opacity: 1 !important;
}

/* --- Clean Technical Grid Lines --- */
#map::before {
    content: '';
    position: absolute;
    inset: 0;
    /* Soft slate-green matrix lines that sit subtly over the light map layout */
    background-image: linear-gradient(rgba(22, 101, 52, 0.04) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(22, 101, 52, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 1000; /* Keeps the technical grid cleanly visible over Leaflet layers */
}

/* --- Smooth Scanning Laser Sweep --- */
#map::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    /* Uses a richer emerald gradient bar that tracks clearly across light colors */
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(22, 163, 74, 0.15) 20%, 
        rgba(22, 163, 74, 0.7) 50%, 
        rgba(22, 163, 74, 0.15) 80%, 
        transparent 100%
    );
    animation: scanLine 7s linear infinite;
    pointer-events: none;
    z-index: 1001;
}

/* Target update for Leaflet specific overlay markers to maximize map contrast */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: #09150f !important;
    color: #ffffff !important;
    border: 1px solid #22c55e;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

/* --- Control Side Panel Console --- */
.controls {
    flex: 1;
    min-width: 360px;
    padding: 25px;
    background: rgba(6, 18, 12, 0.8);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 4px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(34, 197, 94, 0.05);
    position: relative;
    backdrop-filter: blur(4px);
}

.controls::before {
    content: '';
    position: absolute;
    top: -1px; left: -1px; width: 12px; height: 12px;
    border-top: 2px solid #22c55e; border-left: 2px solid #22c55e;
}
.controls::after {
    content: '';
    position: absolute;
    bottom: -1px; right: -1px; width: 12px; height: 12px;
    border-bottom: 2px solid #22c55e; border-right: 2px solid #22c55e;
}

.controls h2 {
    color: #4ade80;
    font-size: 1.1em;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(34, 197, 94, 0.3);
    padding-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Cyber Scrollbar and Selector Buttons --- */
.barangay-list {
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 25px;
    padding-right: 5px;
}

/* Custom Tactical Scrollbars */
.barangay-list::-webkit-scrollbar, .log::-webkit-scrollbar {
    width: 4px;
}
.barangay-list::-webkit-scrollbar-track, .log::-webkit-scrollbar-track {
    background: rgba(6, 18, 12, 0.5);
}
.barangay-list::-webkit-scrollbar-thumb, .log::-webkit-scrollbar-thumb {
    background: #16a34a;
    border-radius: 2px;
}

.barangay-btn {
    display: block;
    width: 100%;
    padding: 10px 14px;
    margin: 6px 0;
    background: rgba(22, 101, 52, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.25);
    color: #cbd5e1;
    border-radius: 3px;
    text-align: left;
    cursor: pointer;
    transition: all 0.25s ease-in-out;
    font-size: 0.9em;
}

.barangay-btn:hover {
    background: rgba(34, 197, 94, 0.15);
    color: #ffffff;
    border-color: #4ade80;
    padding-left: 18px; /* Smooth slide out micro-interaction */
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.1);
}

.barangay-btn.active {
    background: rgba(34, 197, 94, 0.25);
    color: #ffffff;
    border-color: #4ade80;
    box-shadow: inset 0 0 8px rgba(74, 222, 128, 0.4);
    font-weight: bold;
    padding-left: 18px;
}

/* --- Parameter Configuration Inputs --- */
.slider-container { 
    margin: 20px 0; 
}

label { 
    display: flex; 
    justify-content: space-between; 
    margin-bottom: 8px; 
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #a7f3d0; 
}

.value { 
    font-family: monospace; 
    color: #4ade80; 
    font-weight: bold; 
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid rgba(34,197,94,0.3);
}

/* Dark range slider track configuration styling */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: #111827;
    height: 6px;
    border-radius: 3px;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #4ade80;
    cursor: pointer;
    box-shadow: 0 0 8px #22c55e;
}

/* --- Live Feed/Stats Display --- */
.stats {
    background: rgba(11, 27, 18, 0.9) !important;
    padding: 20px;
    margin-top: 20px;
    border: 1px solid rgba(34, 197, 94, 0.4);
    box-shadow: inset 0 0 15px rgba(22, 101, 52, 0.2);
}

.stats h3 {
    color: #4ade80;
    font-size: 1.1em;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 15px;
    text-align: center;
}

.stat-line {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    font-size: 0.95em;
    border-bottom: 1px solid rgba(22, 101, 52, 0.15);
    padding-bottom: 4px;
}

.stat-line span:first-child {
    color: #94a3b8;
}

.stat-line span:last-child {
    font-family: monospace;
    font-weight: bold;
    color: #ffffff;
}

/* --- System Diagnostics Logs --- */
.log {
    max-height: 140px;
    height: 130px;
    overflow-y: auto;
    background: #020617;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: #4ade80;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85em;
    margin: 20px 0;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}

/* --- Tactical Command Activation Buttons --- */
button {
    padding: 12px 24px;
    font-size: 0.95em;
    margin: 5px 2px;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
}

#startBtn {
    background: rgba(22, 101, 52, 0.8);
    color: #ffffff;
    border-color: #22c55e;
    width: 100%;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.2);
}

#startBtn:hover { 
    background: #22c55e; 
    color: #000;
    box-shadow: 0 0 15px #22c55e;
}

#stopBtn, #resetBtn {
    background: rgba(153, 27, 27, 0.2);
    color: #fca5a5;
    border-color: #ef4444;
}

#stopBtn:hover, #resetBtn:hover {
    background: #ef4444;
    color: #ffffff;
    box-shadow: 0 0 15px #ef4444;
}

/* UI Simulation Alarm State Trigger System Override */
.simulating-active .map-container {
    animation: alertPulse 3s infinite alternate !important;
}

/* --- Footer Elements --- */
footer {
    text-align: center;
    padding: 20px;
    background: #040f0a;
    color: #64748b;
    border-top: 1px solid rgba(34, 197, 94, 0.2);
    font-size: 0.85em;
    margin-top: 40px;
    letter-spacing: 1px;
}

/* --- Keyframe Animations --- */
@keyframes scanLine {
    0% { top: 0%; opacity: 0.8; }
    50% { opacity: 0.3; }
    100% { top: 100%; opacity: 0.8; }
}

@keyframes alertPulse {
    0% { border-color: #16a34a; box-shadow: 0 0 5px rgba(22, 163, 74, 0.2); }
    100% { border-color: #ef4444; box-shadow: 0 0 25px rgba(239, 68, 68, 0.5); }
}

