﻿/* Global Reset & Typography */
* {
    font-family: 'Play', sans-serif !important;
    box-sizing: border-box;
}

body {
    background-color: #020617;
    background-image: radial-gradient(#1e293b 1px, transparent 1px);
    background-size: 40px 40px;
    margin: 0;
    padding: 0;
}

#map {
    background: #020617 !important;
    width: 100%;
    height: 100%;
}

/* Glassmorphism & Panel Styling */
.glass-panel {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-logo-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
    filter: grayscale(1) brightness(1.8);
}

.brand-title {
    font-size: 22px;
    font-weight: 700;
    font-style: normal;
    color: white;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Tactical Map Markers */
.threat-marker-wrapper {
    position: relative;
    width: 0;
    height: 0;
}

.diamond {
    width: 32px;
    height: 32px;
    transform: translate(-50%, -50%) rotate(45deg);
    position: absolute;
    left: 0;
    top: 0;
    border: 2px solid white;
    z-index: 10;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
    transition: transform 0.15s ease, filter 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.diamond:hover {
    transform: translate(-50%, -50%) rotate(45deg) scale(1.15);
    filter: brightness(1.2);
}

.threat-marker-icon {
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 75%;
    height: 75%;
    pointer-events: none;
    user-select: none;
}

.sev-катастрофічно {
    background: #b91c1c;
    border-color: #fecaca;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
}

.sev-критично {
    background: #7f1d1d;
    border-color: #fca5a5;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

.sev-помірно {
    background: #713f12;
    border-color: #fde68a;
    box-shadow: 0 0 12px rgba(234, 179, 8, 0.4);
}

.sev-незначні {
    background: #1e3a8a;
    border-color: #93c5fd;
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.4);
}

.sec-diamond {
    background: #f97316;
    border-color: #fed7aa;
    width: 24px;
    height: 24px;
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.4);
}

.risk-НВ {
    background: #dc2626 !important;
    border-color: #fca5a5 !important;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.6) !important;
}
.risk-В {
    background: #ea580c !important;
    border-color: #fdba74 !important;
    box-shadow: 0 0 12px rgba(249, 115, 22, 0.6) !important;
}
.risk-С {
    background: #ca8a04 !important;
    border-color: #fde047 !important;
    box-shadow: 0 0 12px rgba(234, 179, 8, 0.6) !important;
}
.risk-Н {
    background: #0284c7 !important;
    border-color: #7dd3fc !important;
    box-shadow: 0 0 12px rgba(14, 165, 233, 0.6) !important;
}
@keyframes border-pulse-nd {
    0% {
        border-color: #ff0000;
        box-shadow: 0 0 12px 3px rgba(255, 0, 0, 1);
    }
    50% {
        border-color: rgba(255, 0, 0, 0.2);
        box-shadow: 0 0 4px 1px rgba(255, 0, 0, 0.2);
    }
    100% {
        border-color: #ff0000;
        box-shadow: 0 0 12px 3px rgba(255, 0, 0, 1);
    }
}
.risk-ND {
    background: #64748b !important;
    box-shadow: 0 0 12px 3px rgba(255, 0, 0, 1);
    border-color: #ff0000;
    animation: border-pulse-nd 1.5s infinite ease-in-out;
}

@keyframes badge-pulse-nd {
    0% {
        border-color: rgba(255, 0, 0, 0.8);
        box-shadow: 0 0 8px 1px rgba(255, 0, 0, 0.8);
    }
    50% {
        border-color: rgba(255, 0, 0, 0.2);
        box-shadow: 0 0 2px rgba(255, 0, 0, 0.2);
    }
    100% {
        border-color: rgba(255, 0, 0, 0.8);
        box-shadow: 0 0 8px 1px rgba(255, 0, 0, 0.8);
    }
}
.badge-residual.badge-nd-glow {
    border-color: rgba(255, 0, 0, 0.8);
    box-shadow: 0 0 8px 1px rgba(255, 0, 0, 0.8);
    animation: badge-pulse-nd 1.5s infinite ease-in-out;
}

@keyframes border-pulse {
    0% {
        border-color: #ef4444;
        box-shadow: 0 0 12px rgba(239, 68, 68, 0.9);
    }
    50% {
        border-color: rgba(239, 68, 68, 0.2);
        box-shadow: 0 0 4px rgba(239, 68, 68, 0.2);
    }
    100% {
        border-color: #ef4444;
        box-shadow: 0 0 12px rgba(239, 68, 68, 0.9);
    }
}
.pulse-border-red {
    animation: border-pulse 1.5s infinite ease-in-out;
}

.secured {
    background: #16a34a !important;
    box-shadow: 0 0 12px rgba(22, 163, 74, 0.6) !important;
}

.threat-icon-img {
    display: inline-block;
    vertical-align: middle;
    width: 14px;
    height: 14px;
    margin-right: 4px;
    filter: invert(1);
}

.threat-marker-icon .threat-icon-img {
    width: 100%;
    height: 100%;
    margin-right: 0;
    display: block;
}


/* UI Tactical Buttons on Markers */
.btn-ui {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: 1px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    color: white;
    font-size: 12px;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    transition: transform 0.15s ease, filter 0.15s ease, background-color 0.15s ease;
}

.btn-ui:hover {
    transform: scale(1.25);
    filter: brightness(1.2);
}

.btn-s-sec {
    background: #6d28d9;
    transform: rotate(45deg);
    width: 16px;
    height: 16px;
}

.btn-s-sec span {
    transform: rotate(-45deg);
    display: inline-block;
}

.btn-s-sec:hover {
    transform: rotate(45deg) scale(1.25);
}

.btn-ctrl {
    background: #059669;
    border-color: #6ee7b7;
}

.btn-info {
    background: #0ea5e9;
    border-color: #7dd3fc;
}

.btn-close {
    background: #7f1d1d;
    border-color: #fca5a5;
    width: 14px;
    height: 14px;
    font-size: 10px;
    z-index: 110;
    opacity: 0.6;
    transition: opacity 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
}

.btn-close:hover {
    opacity: 1;
    background: #dc2626;
}

.label-threat {
    position: absolute;
    left: 22px;
    top: -14px;
    white-space: nowrap;
    font-weight: bold;
    font-size: 10px;
    text-shadow: 1px 1px 2px black;
    pointer-events: none;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.label-threat-left {
    position: absolute;
    right: 22px;
    top: -14px;
    white-space: nowrap;
    font-weight: bold;
    font-size: 10px;
    text-shadow: 1px 1px 2px black;
    pointer-events: none;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.badge-residual {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 2px 5px;
    pointer-events: none;
    z-index: 15;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.badge-res-level {
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.badge-res-details {
    display: flex;
    flex-direction: column;
    font-size: 8px;
    line-height: 1.1;
    font-weight: bold;
    gap: 1px;
    text-transform: uppercase;
}

.diamond.sec-diamond ~ .badge-residual {
    right: 17px;
}

/* Sidebar Item List Styling */
.sidebar-item {
    border-left: 3px solid #10b981;
    background: rgba(30, 41, 59, 0.8);
    padding: 8px 12px;
    margin-bottom: 5px;
    font-size: 11px;
    line-height: 1.35;
    border-radius: 0 6px 6px 0;
    transition: transform 0.15s ease, background-color 0.15s ease, border-left-color 0.15s ease;
}

.sidebar-item:hover {
    transform: translateX(3px);
    background: rgba(30, 41, 59, 1);
    border-left-color: #34d399;
}

/* Custom Input / Combo-box select */
.custom-select {
    background: #1e293b;
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px;
    border-radius: 6px;
    width: 100%;
    outline: none;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.custom-select:focus,
.custom-select:hover {
    border-color: rgba(16, 185, 129, 0.5);
    background-color: #0f172a;
}

.btn-disabled {
    opacity: 0.2;
    cursor: not-allowed !important;
    pointer-events: none !important;
    filter: grayscale(1);
    transition: opacity 0.2s ease, filter 0.2s ease;
}

/* Premium Animations for Modals */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.fixed:not(.hidden) > div {
    animation: modalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.fixed {
    transition: opacity 0.25s ease;
}

/* Geoman Vertex Handle Styling - Smaller & Interactive */
.leaflet-marker-icon.leaflet-pm-draggable {
    width: 5px !important;
    height: 5px !important;
    margin-left: -2.5px !important;
    margin-top: -2.5px !important;
    background-color: #3b82f6 !important;
    border: 1px solid #ffffff !important;
    border-radius: 50% !important;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5) !important;
    transition: transform 0.1s ease !important;
}

.leaflet-marker-icon.leaflet-pm-draggable:hover {
    transform: scale(1.6) !important;
}

/* Make ghost (intermediate) vertex markers even smaller and less prominent */
.leaflet-marker-icon.leaflet-pm-draggable.leaflet-pm-ghost-marker {
    width: 4px !important;
    height: 4px !important;
    margin-left: -2px !important;
    margin-top: -2px !important;
    background-color: #cbd5e1 !important;
    opacity: 0.6 !important;
}

/* Custom Route Length Tooltip */
.route-length-tooltip {
    background: rgba(15, 23, 42, 0.9) !important;
    border: 1px solid rgba(34, 197, 94, 0.3) !important;
    color: #4ade80 !important;
    font-size: 10px !important;
    font-weight: bold !important;
    font-family: 'Play', sans-serif !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6) !important;
    pointer-events: auto !important;
}
.route-length-tooltip::before {
    display: none !important;
}

/* DeepState Frontline Tooltip */
.frontline-feature-tooltip {
    background: rgba(15, 23, 42, 0.95) !important;
    border: 1px solid rgba(220, 38, 38, 0.4) !important;
    color: #fca5a5 !important;
    font-size: 10px !important;
    font-family: 'Play', sans-serif !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6) !important;
}
.frontline-feature-tooltip::before {
    display: none !important;
}

/* Base Routes Tooltip */
.base-route-tooltip {
    background: rgba(15, 23, 42, 0.95) !important;
    border: 1px solid rgba(168, 85, 247, 0.4) !important;
    color: #d8b4fe !important;
    font-size: 10px !important;
    font-family: 'Play', sans-serif !important;
    padding: 3px 8px !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6) !important;
}
.base-route-tooltip::before {
    display: none !important;
}

/* Probability dropdown menu selector */
.probability-select {
    background-color: #374151 !important; /* gray-700 background */
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 4px !important;
    outline: none !important;
    font-size: 11px !important;
    font-weight: bold !important;
    cursor: pointer !important;
}

.probability-select option {
    background-color: #374151 !important; /* gray-700 background */
}

/* Yellow Ruler Tooltip styling */
.ruler-length-tooltip {
    background: rgba(15, 23, 42, 0.9) !important;
    border: 1px solid rgba(234, 179, 8, 0.4) !important; /* Yellow border (#eab308) */
    color: #facc15 !important; /* Yellow text (#facc15) */
    font-size: 10px !important;
    font-weight: bold !important;
    font-family: 'Play', sans-serif !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6) !important;
    pointer-events: auto !important;
}
.ruler-length-tooltip::before {
    display: none !important;
}

/* Hide native details arrow marker */
summary::-webkit-details-marker {
    display: none !important;
}
summary {
    list-style: none !important;
}

/* Custom Layer Control Spacing & styling */
.leaflet-control-layers-overlays label {
    margin: 4px 0 !important;
}
.leaflet-control-layers-separator {
    margin: 4px -10px 4px -6px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* RISK CARD MODAL AND PRINT STYLES */
@media screen {
    /* Set borders for the table and its sub-borders to glass-style border */
    .risk-card-table, 
    .risk-card-table th, 
    .risk-card-table td,
    .risk-card-table div {
        border-color: rgba(255, 255, 255, 0.1) !important;
    }
    
    /* Section Headings (.bg-gray-100) -> emerald highlight */
    #modal-risk-card .bg-gray-100 {
        background-color: rgba(16, 185, 129, 0.15) !important;
        color: #34d399 !important;
    }
    
    /* Label Headers/cells (.bg-gray-50) -> dark slate highlight */
    #modal-risk-card .bg-gray-50 {
        background-color: rgba(15, 23, 42, 0.6) !important;
        color: #94a3b8 !important;
    }
    
    /* Text color inside table cell values */
    .risk-card-table td {
        color: #cbd5e1 !important;
    }
    
    /* Inputs inside tables (text, date, datetime-local) */
    .risk-card-table input[type="text"], 
    .risk-card-table input[type="date"], 
    .risk-card-table input[type="datetime-local"] {
        color: #ffffff !important;
        background-color: transparent !important;
        outline: none !important;
    }
    
    /* Hover/Focus inline bottom borders for text inputs */
    .risk-card-table input[type="text"]:focus {
        border-bottom-color: rgba(16, 185, 129, 0.5) !important;
    }
    
    /* Checkboxes and radio buttons -> emerald accent color */
    .risk-card-table input[type="checkbox"],
    .risk-card-table input[type="radio"] {
        accent-color: #10b981 !important;
        cursor: pointer;
    }
    
    /* Textareas -> dark panel background with subtle border */
    .risk-card-table textarea {
        color: #f8fafc !important;
        background-color: rgba(15, 23, 42, 0.4) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-radius: 4px;
        padding: 6px 10px !important;
        outline: none !important;
        width: 100% !important;
    }
    
    .risk-card-table textarea:focus {
        border-color: rgba(16, 185, 129, 0.5) !important;
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2) !important;
    }
    
    /* Select element defaults just in case */
    .risk-card-table select {
        color: #ffffff !important;
        background-color: rgba(15, 23, 42, 0.6) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-radius: 4px;
        outline: none !important;
    }
    .risk-card-table select option {
        color: #ffffff !important;
        background-color: #0f172a !important;
    }

    /* Overall risk radio list labels styling */
    #rc-overall-risk label {
        color: #cbd5e1 !important;
        transition: color 0.15s;
    }
    #rc-overall-risk label:hover {
        color: #ffffff !important;
    }

    /* Specific text color overrides for screen contrast */
    #modal-risk-card .text-orange-700 {
        color: #f97316 !important; /* orange-500 */
    }
    #modal-risk-card .text-orange-800 {
        color: #fdba74 !important; /* orange-300 */
    }
    #modal-risk-card .text-gray-700 {
        color: #cbd5e1 !important; /* slate-300 */
    }
    #modal-risk-card .text-gray-500 {
        color: #94a3b8 !important; /* slate-400 */
    }
}

@media print {
    body * {
        visibility: hidden !important;
    }
    #modal-risk-card, #modal-risk-card * {
        visibility: visible !important;
        color: #000000 !important;
    }
    #modal-risk-card {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        background: #ffffff !important;
        display: block !important;
    }
    .risk-card-panel {
        border: none !important;
        box-shadow: none !important;
        background: #ffffff !important;
        color: #000000 !important;
        max-width: none !important;
    }
    .risk-card-content {
        padding: 0 !important;
        overflow: visible !important;
        background: #ffffff !important;
        color: #000000 !important;
    }
    .risk-card-table {
        color: #000000 !important;
        background: #ffffff !important;
    }
    .risk-card-table th, 
    .risk-card-table td,
    .risk-card-table div {
        border-color: #9ca3af !important; /* clear gray borders for printing */
        color: #000000 !important;
        background: transparent !important;
    }
    #modal-risk-card .bg-gray-100 {
        background-color: #f3f4f6 !important;
        color: #000000 !important;
    }
    #modal-risk-card .bg-gray-50 {
        background-color: #f9fafb !important;
        color: #000000 !important;
    }
    .risk-card-table input[type="text"],
    .risk-card-table input[type="date"],
    .risk-card-table input[type="datetime-local"] {
        color: #000000 !important;
        background-color: transparent !important;
    }
    .risk-card-table textarea {
        color: #000000 !important;
        background-color: transparent !important;
        border: 1px solid #9ca3af !important;
        resize: none !important;
        overflow: visible !important;
        width: 100% !important;
    }
}

.badge-res-level-top {
    position: absolute;
    left: 0px;
    bottom: 22px;
    transform: translateX(-50%);
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 2px 5px;
    pointer-events: none;
    z-index: 15;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}



.badge-res-level-top.pulse-border-red { animation: border-pulse 1.5s infinite ease-in-out; }

.badge-residual.pulse-border-red { animation: badge-pulse-nd 1.5s infinite ease-in-out; }

.diamond.pulse-border-red { animation: border-pulse 1.5s infinite ease-in-out; }

