/* --- BASE STYLES & VARIABLES --- */
:root {
    --bg-color: #010401;
    --text-color: #00ff00;
    --border-color: #00ff00;
    --dim-text: #00aa00;
    --panel-bg: rgba(0, 15, 0, 0.75);
    --glow-spread: 8px;
    --accent: #55ff55;
    --danger: #ff5555;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #000;
    background-image: radial-gradient(circle, #001100 0%, #000000 100%);
    color: var(--text-color);
    font-family: 'Share Tech Mono', monospace;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- CRT & SCANLINE EFFECTS --- */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, 0.2) 50%, rgba(0, 0, 0, 0.2));
    background-size: 100% 4px;
    z-index: 100;
    pointer-events: none;
}

.scanlines::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(18, 16, 16, 0.1);
    opacity: 0;
    z-index: 100;
    pointer-events: none;
    animation: flicker 0.15s infinite;
}

/* Moving scan bar */
.crt-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 255, 0, 0.05) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 2px, 3px 100%;
    z-index: 99;
    pointer-events: none;
}

.crt-overlay::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 2;
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
}

.crt-overlay::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.1);
    opacity: 0;
    z-index: 2;
    pointer-events: none;
    animation: flicker 0.15s infinite;
}

body::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    /* Heavy CRT vignette curve */
    background: radial-gradient(circle, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.6) 100%);
    z-index: 101;
    pointer-events: none;
}

/* The actual scrolling bar */
.dashboard-grid::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 10px;
    background: rgba(0, 255, 0, 0.2);
    opacity: 0.15;
    z-index: 98;
    pointer-events: none;
    animation: scanbar 8s linear infinite;
}

@keyframes scanbar {
    0% {
        top: -10%;
    }

    100% {
        top: 110%;
    }
}

.crt-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    box-shadow: inset 0 0 120px rgba(0, 255, 0, 0.15);
    z-index: 99;
    pointer-events: none;
    animation: flicker 0.12s infinite;
    opacity: 0.08;
}

@keyframes flicker {
    0% {
        opacity: 0.05;
    }

    5% {
        opacity: 0.1;
    }

    10% {
        opacity: 0.05;
    }

    15% {
        opacity: 0.2;
    }

    20% {
        opacity: 0.05;
    }

    25% {
        opacity: 0.1;
    }

    30% {
        opacity: 0.05;
    }

    35% {
        opacity: 0.1;
    }

    40% {
        opacity: 0.05;
    }

    45% {
        opacity: 0;
    }

    50% {
        opacity: 0.15;
    }

    55% {
        opacity: 0.05;
    }

    60% {
        opacity: 0;
    }

    65% {
        opacity: 0.1;
    }

    70% {
        opacity: 0.05;
    }

    75% {
        opacity: 0.2;
    }

    80% {
        opacity: 0.05;
    }

    85% {
        opacity: 0.1;
    }

    90% {
        opacity: 0.05;
    }

    95% {
        opacity: 0.1;
    }

    100% {
        opacity: 0.05;
    }
}

/* --- GRID LAYOUT (2 COLUMNS) --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 15px;
    width: 98vw;
    height: 96vh;
    z-index: 10;
}

.panel {
    background: var(--panel-bg);
    padding: 15px;
    border: 1px solid var(--border-color);
    box-shadow: 0 0 var(--glow-spread) var(--dim-text) inset;
    display: flex;
    flex-direction: column;
    position: relative;
    backdrop-filter: blur(4px);
}

/* TECH CLIP PATHS (Angled Corners) */
.clip-corners-header {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
}

.clip-corners-left {
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 30px), calc(100% - 30px) 100%, 0 100%);
}

.clip-corners-right {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 30px 100%, 0 calc(100% - 30px));
}

.clip-corners-center {
    clip-path: polygon(20px 0, calc(100% - 20px) 0, 100% 20px, 100% calc(100% - 20px), calc(100% - 20px) 100%, 20px 100%, 0 calc(100% - 20px), 0 20px);
}

.clip-corners-footer {
    grid-column: 1 / -1;
    clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 15px, 100% 100%, 15px 100%, 0 calc(100% - 15px));
    padding: 10px 15px;
    height: 40px;
}

/* --- TEXT & UTILITIES --- */
.glow-text {
    text-shadow: 0 0 4px var(--text-color);
    letter-spacing: 2px;
    font-size: 1.3em;
    font-weight: bold;
}

.sys-info,
.time-info {
    font-size: 0.9em;
    display: flex;
    gap: 15px;
}

.highlight {
    color: #fff;
    text-shadow: 0 0 5px #fff;
}

.blink {
    animation: slowblink 1.5s infinite alternate;
}

@keyframes slowblink {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0.2;
    }
}

/* --- SIDEBAR MODULES --- */
.panel-header {
    border-bottom: 2px solid var(--text-color);
    padding-bottom: 5px;
    margin-bottom: 12px;
}

.panel-header h2 {
    font-size: 1.1em;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.module {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
    min-height: 0;
}

.module:last-child {
    margin-bottom: 0;
}

.data-block p {
    font-size: 0.9em;
    margin: 5px 0;
    border-bottom: 1px dotted var(--dim-text);
    padding-bottom: 3px;
}

.tech-border {
    border-left: 3px solid var(--accent);
    padding-left: 10px;
    background: linear-gradient(90deg, rgba(0, 255, 0, 0.1) 0%, transparent 100%);
}

ul.ticker {
    list-style: none;
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 5px;
}

ul.ticker li {
    font-size: 0.85em;
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    border-bottom: 1px dashed var(--dim-text);
    padding-bottom: 3px;
}

ul.ticker li span.up {
    color: #55ff55;
}

ul.ticker li span.down {
    color: #ff5555;
}

/* --- MAP AREA (QUAD-MATRIX) --- */
.map-panel {
    position: relative;
    padding: 2px;
    display: flex;
    flex-direction: column;
}

.hexa-maps-grid {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 4px;
    background: var(--dim-text);
    /* Forms a thin grid line separating quads */
    padding: 2px;
}

.sub-map-container {
    position: relative;
    background: #000;
    overflow: hidden;
}

.sub-map {
    width: 100%;
    height: 100%;
    /* Default radar-style filter applied to all submaps */
    filter: invert(1) hue-rotate(180deg) brightness(0.6) contrast(1.7) sepia(0.5) hue-rotate(85deg);
    z-index: 1;
}

/* Alter specific maps slightly to differentiate them */
#map-incidents {
    filter: invert(1) hue-rotate(180deg) brightness(0.7) contrast(1.4) sepia(0.6) hue-rotate(140deg);
}

/* More bluish tint */
#map-cctv {
    filter: invert(1) hue-rotate(180deg) brightness(0.5) contrast(1.2) sepia(0.8) hue-rotate(10deg);
}

/* Yellowish tint */

.sub-map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 2;
    box-shadow: inset 0 0 20px rgba(0, 255, 0, 0.2);
}

.sub-map-label {
    position: absolute;
    top: 5px;
    left: 10px;
    background: rgba(0, 50, 0, 0.7);
    padding: 2px 8px;
    font-size: 0.8em;
    border: 1px solid var(--dim-text);
    text-shadow: 0 0 2px #000;
}

/* Local Crosshairs inside each submap */
.crosshair {
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--text-color);
    border-style: solid;
    opacity: 0.6;
}

.top-left {
    top: 10px;
    left: 10px;
    border-width: 2px 0 0 2px;
}

.top-right {
    top: 10px;
    right: 10px;
    border-width: 2px 2px 0 0;
}

.bottom-left {
    bottom: 10px;
    left: 10px;
    border-width: 0 0 2px 2px;
}

.bottom-right {
    bottom: 10px;
    right: 10px;
    border-width: 0 2px 2px 0;
}

.radar-scan {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 150%;
    height: 150%;
    transform-origin: center;
    background: conic-gradient(from 0deg, transparent 70%, rgba(0, 255, 0, 0.5) 100%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: scan 3s linear infinite;
    mix-blend-mode: screen;
    pointer-events: none;
}

@keyframes scan {
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.map-controls {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
    z-index: 10;
    background: rgba(0, 20, 0, 0.9);
    padding: 5px;
    border: 1px solid var(--text-color);
    box-shadow: 0 0 10px #000;
}

.btn {
    background: rgba(0, 20, 0, 0.8);
    border: 1px solid var(--text-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.8em;
    padding: 6px 12px;
    cursor: pointer;
    transition: 0.2s;
}

.btn:hover,
.btn.active-btn {
    background: var(--text-color);
    color: #000;
    box-shadow: 0 0 10px var(--text-color);
    font-weight: bold;
}

/* --- NETWORK SIMULATOR & PROFILE --- */
.network-sim {
    flex-grow: 1;
    border: 1px solid var(--dim-text);
    background: #000;
    position: relative;
    overflow: hidden;
}

.threat-line {
    animation: dash 1s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: -20;
    }
}

.network-sim .leaflet-container {
    background: #000 !important;
}

.profile-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: rgba(0, 20, 0, 0.5);
}

.profile-img {
    width: 70px;
    height: 90px;
    border: 1px solid var(--text-color);
    background: url('https://upload.wikimedia.org/wikipedia/commons/3/36/Unknown_person.jpg') center/cover;
    filter: invert(1) hue-rotate(180deg) sepia(1) hue-rotate(80deg) contrast(1.5);
}

.profile-info {
    flex-grow: 1;
    font-size: 0.85em;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
}

.profile-info p {
    margin-bottom: 2px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    border: 1px solid var(--dim-text);
    margin-top: 5px;
}

.fill {
    height: 100%;
    width: 75%;
    background: var(--text-color);
    animation: pulseWidth 3s infinite alternate ease-in-out;
}

.alert-fill {
    background: red;
    box-shadow: 0 0 5px red;
}

@keyframes pulseWidth {
    0% {
        width: 50%;
    }

    100% {
        width: 98%;
    }
}

/* --- CONSOLE & FOOTER --- */
.console-box {
    background: rgba(0, 5, 0, 0.9);
    border: 1px solid var(--dim-text);
    padding: 10px;
    font-size: 0.75em;
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.console-box p {
    margin: 3px 0;
}

.marquee-container {
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    display: flex;
    align-items: center;
    height: 100%;
}

.marquee {
    display: inline-block;
    padding-left: 100%;
    animation: marquee 35s linear infinite;
    font-size: 1.1em;
}

@keyframes marquee {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(-100%, 0);
    }
}

/* SCROLLBAR */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-left: 1px solid var(--dim-text);
}

::-webkit-scrollbar-thumb {
    background: var(--dim-text);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-color);
}

/* LEAFLET OVERRIDES */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: #000 !important;
    color: var(--text-color) !important;
    border: 1px solid var(--text-color);
    border-radius: 0;
    box-shadow: 0 0 15px var(--text-color);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9em;
}

.leaflet-container a.leaflet-popup-close-button {
    color: var(--text-color) !important;
    padding-right: 5px;
}

/* Specific style for iframe wrapped popups (CCTV) */
.cctv-popup .leaflet-popup-content {
    margin: 5px;
    width: auto !important;
}

/* Global Webcam Modal (Bypasses all CRT effects) */
#global-webcam-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 640px;
    height: 400px;
    background: #000;
    border: 2px solid var(--accent);
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.4);
    z-index: 9999;
    padding: 10px;
    flex-direction: column;
}

#global-webcam-modal.active {
    display: flex;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--accent);
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.modal-header h2 {
    font-size: 14px;
    color: var(--accent);
}

.close-btn {
    background: none;
    border: 1px solid var(--accent);
    color: var(--accent);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
}

.close-btn:hover {
    background: var(--accent);
    color: #000;
}

.modal-body {
    flex-grow: 1;
    position: relative;
    border: 1px solid var(--border-color);
}