/* ==========================================
   CPOM BRANDING & VARIABLES
   ========================================== */
:root {
    --cpom-blue: #4682b4; /* Deep Steel Blue - Professional & Scientific */
    --cpom-dark: #0e2a47; 
}

/* ==========================================
   CORE LAYOUT
   ========================================== */
html, body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    margin: 0;
}

main {
    flex: 1 0 auto;
}

.bg-cpom-dark {
    background-color: var(--cpom-dark) !important;
}

/* ==========================================
   HEADER SECTION
   ========================================== */
.branding-header {
    padding: 12px 0;
    position: relative;
    z-index: 1060;
}

.main-logo {
    height: 72px !important; 
    width: auto;
    display: block;
}

.site-title {
    font-size: 1.8rem;
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: 0.5px;
}

.site-subtitle {
    font-size: 0.7rem;
    letter-spacing: 1px;
    margin-top: 5px;
    text-transform: uppercase;
}

/* ==========================================
   NAVIGATION (Accent Line Style)
   ========================================== */
.nav-bar-secondary {
    background-color: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.navbar .nav-link {
    text-transform: uppercase;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 12px 20px !important;
    color: rgba(255, 255, 255, 0.75) !important;
    transition: all 0.2s ease-in-out;
    border-bottom: 3px solid transparent; /* The "Accent Line" placeholder */
}

/* Hover state: Text brightens and thin line appears */
.navbar .nav-link:hover {
    color: #fff !important;
    background-color: rgba(255, 255, 255, 0.05);
    border-bottom: 3px solid rgba(70, 130, 180, 0.5); /* Faint version of Steel Blue */
}

/* Active state: Bold line at bottom */
.navbar .nav-link.active {
    color: #fff !important;
    background-color: transparent;
    border-bottom: 3px solid var(--cpom-blue) !important;
}

/* ==========================================
   FOOTER SECTION
   ========================================== */
footer {
    flex-shrink: 0;
    border-top: 2px solid var(--cpom-blue);
}

/* ==========================================
   SERVICE STATUS UI
   ========================================== */
.status-link {
    transition: all 0.2s ease;
    border-radius: 4px;
    cursor: pointer;
}

.status-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.status-link:hover span.text-dark {
    color: var(--cpom-blue) !important;
}

/* ==========================================
   RESPONSIVENESS
   ========================================== */

@media (max-width: 991.98px) {
    .main-logo {
        height: 52px !important; 
    }

    .site-title {
        font-size: 1.25rem !important; 
        font-weight: 600;
    }

    .site-subtitle {
        font-size: 0.6rem !important;
        margin-top: 2px;
    }

    /* Mobile Menu Dropdown */
    .navbar-collapse {
        position: absolute;
        top: 100%; 
        left: 0;
        right: 0;
        background-color: var(--cpom-dark);
        z-index: 1050;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* On mobile, remove the bottom border and use a left border instead */
    .navbar .nav-link {
        border-bottom: none;
        border-left: 4px solid transparent;
        padding: 15px 25px !important;
    }
    
    .navbar .nav-link.active {
        border-left: 4px solid var(--cpom-blue) !important;
        background-color: rgba(255, 255, 255, 0.05);
    }
}

@media (min-width: 992px) {
    .navbar-collapse {
        position: static !important;
        display: flex !important;
    }
}

/* ==========================================
   MAP CONTAINER & OVERLAYS
   ========================================== */
.map-container {
    position: relative;
    width: 100%;
    max-width: 1000px;
    aspect-ratio: 1 / 1;
    margin: 20px auto;
    border: 1px solid #ccc;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    background-color: #fff;
}
.map-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    object-fit: contain;
}
.overlay-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none; /* Let clicks pass through empty space of the SVG viewBox */
}
/* Make the polygons interactable and style the hover effects */
.overlay-svg polygon {
    pointer-events: all; /* Restore pointer events on the actual polygon shapes */
    fill: rgba(0, 0, 0, 0) !important; /* Transparent fill to catch hover events */
    stroke: var(--cpom-dark) !important; /* Default dark blue outline */
    stroke-width: 2 !important; /* Normal line width */
    transition: fill 0.2s ease-in-out, stroke-width 0.2s ease-in-out, stroke 0.2s;
}
.map-container.uncert-mode .overlay-svg polygon {
    stroke: #444444 !important;
}
.map-container.uncert-mode .overlay-svg polygon:hover {
    stroke: #444444 !important;
    fill: rgba(0, 0, 0, 0.15) !important;
}
.overlay-svg polygon:hover {
    fill: rgba(14, 42, 71, 0.4) !important;
    stroke: var(--cpom-dark) !important;
    stroke-width: 5 !important; /* Thicker on hover */
    cursor: pointer;
}
.overlay-svg polygon.selected {
    fill: rgba(255, 0, 0, 0.15) !important;
    stroke: red !important; /* Red for currently selected */
    stroke-width: 5 !important;
}
/* Custom Toggle Switch for Hill Shade */
.map-controls-overlay {
    position: absolute;
    top: 15px;
    z-index: 10;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 6px 10px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.map-controls-left {
    left: 15px;
    transform-origin: top left;
}
.map-controls-right {
    right: 15px;
    transform-origin: top right;
}
.map-controls-bottom-right {
    right: 15px;
    bottom: 15px;
    top: auto;
    transform-origin: bottom right;
}

/* Responsive Scaling for the Map Controls */
@media (max-width: 575.98px) {
    .map-controls-overlay {
        transform: scale(0.6);
    }
}
@media (min-width: 992px) and (max-width: 1199.98px) {
    .map-controls-overlay {
        transform: scale(0.55);
    }
}
@media (min-width: 1200px) and (max-width: 1399.98px) {
    .map-controls-overlay {
        transform: scale(0.75);
    }
}
@media (min-width: 1400px) {
    .map-controls-overlay {
        transform: scale(0.9);
    }
}
.toggle-title {
    font-weight: 700;
    font-size: 0.8rem;
    margin-bottom: 3px;
    color: #333;
}
.toggle-container {
    display: flex;
    align-items: center;
    gap: 6px;
}
.toggle-label {
    font-size: 0.75rem;
    color: #555;
}
.custom-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 18px;
}
.custom-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.custom-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 18px;
}
.custom-switch .slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
.custom-switch input:checked + .slider {
    background-color: var(--cpom-dark);
}
.custom-switch input:checked + .slider:before {
    transform: translateX(18px);
}

/* Download Button Styles */
.btn-download {
    background-color: #3b4578;
    color: white;
    font-weight: 500;
    border-radius: 6px;
    padding: 8px 16px;
    transition: background-color 0.2s ease, transform 0.1s ease;
}
.btn-download:hover, .btn-download:focus {
    background-color: #2b335a;
    color: white;
}
.btn-download:active {
    transform: scale(0.98);
}

/* ==========================================
   FULLSCREEN BASIN IMAGE PANE
   ========================================== */
.basin-image-fullscreen {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1060;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.98);
}
.basin-image-fullscreen .card-body {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: none !important;
    padding: 2rem !important;
}
.basin-image-fullscreen img {
    max-height: 90vh;
    max-width: 90vw;
    object-fit: contain;
    border: none !important;
    box-shadow: 0 1rem 3rem rgba(0,0,0,.175) !important;
}
.expand-icon {
    position: absolute;
    top: 10px;
    right: 15px;
    cursor: pointer;
    font-size: 0.96rem;
    color: #6c757d;
    transition: color 0.2s;
}
.expand-icon:hover {
    color: #343a40;
}

/* ==========================================
   FULLSCREEN TIMESERIES PANE
   ========================================== */
.timeseries-fullscreen {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1060;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.98);
}
.timeseries-fullscreen .card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}
.timeseries-fullscreen [id^="timeseries-plot"] {
    height: 100% !important;
    flex-grow: 1;
}

/* ==========================================
   CUMULATIVE dH/dM ANIMATION PLAYER
   ========================================== */
.cumv {
    --cumv-fill: 0%;
}
.cumv-player {
    border: 1px solid #dee2e6;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
.cumv-media {
    background: #000;
}
.cumv-media video,
.cumv-media img.cumv-static {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 900 / 750;
    background: #000;
}
.cumv-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px;
    background: #f7f9fc;
    border-top: 1px solid #e6ebf0;
}
.cumv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid #d9dee5;
    border-radius: 8px;
    background: #fff;
    color: var(--cpom-dark);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.cumv-btn:hover {
    background: #eef5ff;
    border-color: #c9d7ee;
}
.cumv-bound {
    font-size: 0.8rem;
    color: #333;
    white-space: nowrap;
}
.cumv-scrub-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    min-width: 140px;
}
.cumv-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 22px;
    background: transparent;
    cursor: pointer;
}
.cumv-range:focus {
    outline: none;
}
.cumv-range::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(to right,
        var(--cpom-blue) var(--cumv-fill), #d7dbe0 var(--cumv-fill));
}
.cumv-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    margin-top: -6px; /* vertically centre on the 6px track */
    width: 18px;
    height: 18px;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 50%;
}
.cumv-range::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: #d7dbe0;
}
.cumv-range::-moz-range-progress {
    height: 6px;
    border-radius: 999px;
    background: var(--cpom-blue);
}
.cumv-range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 50%;
}
