/**
 * AirWatch Styles v3.5
 * Apple-inspired design system
 */

/* ============================================================================
   CSS VARIABLES
   ============================================================================ */

:root {
    /* Colors - Dark theme */
    --bg-primary: #1c1c1e;
    --bg-secondary: #2c2c2e;
    --bg-tertiary: #3a3a3c;
    --bg-elevated: rgba(44, 44, 46, 0.95);

    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-tertiary: rgba(255, 255, 255, 0.5);

    --accent-blue: #0a84ff;
    --accent-red: #ff453a;
    --accent-orange: #ff9f0a;
    --accent-yellow: #ffd60a;
    --accent-green: #30d158;
    --accent-purple: #bf5af2;

    --border-color: rgba(255, 255, 255, 0.1);
    --border-radius: 12px;
    --border-radius-lg: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Sidebar */
    --sidebar-width: 380px;
    --sidebar-collapsed-width: 48px;

    /* Z-index layers */
    --z-map: 1;
    --z-sidebar: 100;
    --z-overlay: 200;
    --z-modal: 300;
}

/* ============================================================================
   BASE STYLES
   ============================================================================ */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* ============================================================================
   LAYOUT
   ============================================================================ */

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

#map {
    flex: 1;
    height: 100%;
    background: #000;
    z-index: var(--z-map);
}

/* ============================================================================
   SIDEBAR
   ============================================================================ */

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-elevated);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    transition: width var(--transition-normal), transform var(--transition-normal);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-content,
.sidebar.collapsed .tab-content {
    opacity: 0;
    pointer-events: none;
}

.sidebar-toggle svg {
    transition: transform var(--transition-fast);
}

.sidebar.collapsed .sidebar-title {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Sidebar Header */
.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
}

.sidebar-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.sidebar-toggle {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--accent-blue);
    color: white;
}

/* Tabs */
.tabs {
    display: flex;
    padding: 8px 16px;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.tab-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent-blue);
    color: white;
}

.tab-btn .badge {
    position: absolute;
    top: 4px;
    right: 8px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--accent-red);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tab Content */
.tab-content {
    flex: 1;
    overflow: hidden;
    display: none;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Scrollable List */
.scrollable-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.scrollable-list::-webkit-scrollbar {
    width: 6px;
}

.scrollable-list::-webkit-scrollbar-track {
    background: transparent;
}

.scrollable-list::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

/* ============================================================================
   MAP MARKERS (SVG Icons)
   ============================================================================ */

.svg-threat-icon {
    background: transparent !important;
    border: none !important;
}

.threat-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
    position: relative;
}

.threat-marker svg {
    width: 100%;
    height: 100%;
}

.threat-icon {
    position: relative;
    z-index: 2;
}

/* Статичний маркер (filled circle) */
.threat-marker--static {
    cursor: pointer;
}

.threat-marker--static .threat-marker-circle {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.threat-marker--static:hover .threat-marker-circle {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.threat-marker-ring {
    position: absolute;
    inset: -30%;
    border: 2px solid var(--accent-yellow);
    border-radius: 50%;
    opacity: 0.6;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
    z-index: 1;
}

/* Hover effects */
.threat-marker:hover {
    transform: scale(1.2);
}

.threat-marker--static:hover {
    transform: none;
}

/* Animated marker (new events) */
.threat-marker.pulse {
    animation: marker-pulse 2s ease-in-out infinite;
}

.threat-count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.35);
    pointer-events: none;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
    z-index: 10;
}

@keyframes marker-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 0 rgba(231, 76, 60, 0));
    }
    50% {
        filter: drop-shadow(0 0 12px rgba(231, 76, 60, 0.8));
    }
}

/* Highlighted marker */
.threat-marker.highlighted {
    filter: drop-shadow(0 0 8px rgba(255, 159, 10, 0.8));
}

/* ============================================================================
   TRAJECTORIES
   ============================================================================ */

.trajectory-line {
    stroke-dasharray: 8, 4;
    animation: dash-flow 1s linear infinite;
}

@keyframes dash-flow {
    to {
        stroke-dashoffset: -12;
    }
}

/* ============================================================================
   POPUPS
   ============================================================================ */

.leaflet-popup-content-wrapper {
    background: var(--bg-elevated);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
    margin: 12px;
    color: var(--text-primary);
}

.leaflet-popup-tip {
    background: var(--bg-elevated);
}

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

.popup-type {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.popup-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.popup-icon svg {
    width: 20px;
    height: 20px;
}

.popup-time {
    font-size: 12px;
    color: var(--text-tertiary);
}

.popup-info {
    font-size: 13px;
}

.popup-info-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0;
    color: var(--text-secondary);
}

.popup-info-row svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

/* ============================================================================
   STATUS BAR
   ============================================================================ */

.status-bar {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 8px 20px;
    z-index: var(--z-overlay);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-item.active {
    color: var(--accent-red);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
}

.status-dot.alert {
    background: var(--accent-red);
    animation: status-blink 1s ease-in-out infinite;
}

@keyframes status-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ============================================================================
   CUSTOM LAYER CONTROL
   ============================================================================ */

.custom-layer-control {
    position: fixed;
    bottom: 24px;
    left: 24px;
    background: var(--bg-elevated);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    z-index: var(--z-overlay);
    box-shadow: var(--shadow-md);
    min-width: 140px;
}

.layer-control-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.layer-control-toggle {
    margin-left: auto;
    border: none;
    background: transparent;
    padding: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 11px;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.layer-control-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.layer-control-list {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.layer-control-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 4px 0;
    transition: opacity var(--transition-fast);
}

.layer-control-item:hover {
    opacity: 0.8;
}

.layer-checkbox {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--text-tertiary);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.layer-checkbox:checked {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

.layer-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.layer-label {
    font-size: 13px;
    color: var(--text-secondary);
    user-select: none;
}

/* ============================================================================
   ALERT CARDS
   ============================================================================ */

.alert-card {
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--accent-red);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.alert-card:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.alert-card.inactive {
    border-left-color: var(--accent-green);
    opacity: 0.6;
}

.alert-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.alert-region {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.alert-time {
    font-size: 12px;
    color: var(--text-tertiary);
}

.alert-types {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.alert-type-badge {
    padding: 2px 8px;
    background: rgba(255, 69, 58, 0.2);
    color: var(--accent-red);
    font-size: 11px;
    font-weight: 500;
    border-radius: 4px;
}

/* ============================================================================
   MESSAGE CARDS
   ============================================================================ */

.message-card {
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--accent-blue);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.message-card:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.message-card.highlighted {
    border-left-color: var(--accent-orange);
    background: rgba(255, 159, 10, 0.1);
}

.message-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.message-channel {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-blue);
}

.message-time {
    font-size: 11px;
    color: var(--text-tertiary);
}

.message-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.message-events {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.event-chip {
    padding: 3px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ============================================================================
   LOADING / EMPTY STATES
   ============================================================================ */

.loading-state,
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
    text-align: center;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================================
   LEAFLET OVERRIDES
   ============================================================================ */

.leaflet-interactive:focus {
    outline: none !important;
}

.leaflet-container .leaflet-overlay-pane svg {
    outline: none !important;
}

.leaflet-control-layers {
    display: none !important;
}

.leaflet-control-attribution {
    display: none;
}

/* ============================================================================
   ALERT TOOLTIPS
   ============================================================================ */

.leaflet-tooltip-alert {
    background: var(--bg-elevated) !important;
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--shadow-md) !important;
    padding: 0 !important;
    color: var(--text-primary) !important;

}
.leaflet-tooltip-alert:before {

    border-top-color:var(--bg-elevated);
}

.alert-tooltip {
    padding: 10px 14px;
    min-width: 160px;
}

.alert-tooltip .tooltip-header {
    font-size: 14px;
    margin-bottom: 6px;
}

.alert-tooltip .tooltip-status {
    font-size: 13px;
    margin-bottom: 4px;
}

.alert-tooltip.alert-active .tooltip-status {
    color: var(--accent-red);
    font-weight: 500;
}

.alert-tooltip.alert-inactive .tooltip-status {
    color: var(--accent-green);
}

.alert-tooltip .tooltip-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.alert-tooltip .tooltip-types {
    font-size: 11px;
    color: var(--accent-orange);
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-color);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    :root {
        --sidebar-width: 100vw;
    }

    .sidebar {
        position: fixed;
        right: 0;
        transform: translateX(100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-toggle {
        display: block;
        position: fixed;
        bottom: 24px;
        right: 24px;
        width: 56px;
        height: 56px;
        background: var(--accent-blue);
        border: none;
        border-radius: 50%;
        color: white;
        box-shadow: var(--shadow-lg);
        z-index: var(--z-sidebar);
        cursor: pointer;
    }
}

@media (min-width: 769px) {
    .mobile-toggle {
        display: none;
    }
}

/* ============================================================================
   ALERTS ACCORDION STYLES
   Стилі для групування тривог по областях (акордеон)
   ============================================================================ */

/* Група (область) */
.alerts-group {
    margin-bottom: 8px;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--bg-secondary);
    transition: all var(--transition-fast);
}

.alerts-group:last-child {
    margin-bottom: 0;
}

/* Заголовок групи (плашка області) — стиль як message-card */
.alerts-group-header {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: none;
    border-left: 4px solid var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all var(--transition-fast);
    gap: 12px;
}

/* Активна тривога — червоний бордер */
.alerts-group-header.alert-active {
    border-left-color: var(--accent-red);
    background: rgba(255, 69, 58, 0.08);
}

/* Немає тривоги — сірий/зелений бордер */
.alerts-group-header.alert-inactive {
    border-left-color: var(--accent-green);
    opacity: 0.75;
}

.alerts-group-header:hover {
    background: var(--bg-tertiary);
}

.alerts-group.is-active .alerts-group-header:hover {
    background: rgba(255, 69, 58, 0.12);
}

/* Ліва частина заголовка */
.group-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

/* Індикатор статусу (кружечок) */
.group-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    flex-shrink: 0;
}

.alerts-group.is-active .group-status-indicator {
    background: var(--accent-red);
    animation: status-pulse 1.5s ease-in-out infinite;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.2); }
}

/* Інформація в заголовку */
.group-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.group-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    display: flex;
    gap: 8px;
}

.group-meta-active {
    color: var(--text-secondary);
}

.alerts-group.is-active .group-meta-active {
    color: var(--accent-red);
}

/* Права частина заголовка */
.group-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.group-time {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* Бейдж кількості районів */
.group-badge {
    min-width: 36px;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

.alerts-group.is-active .group-badge {
    background: rgba(255, 69, 58, 0.2);
    color: var(--accent-red);
}

/* Іконка стрілки */
.group-toggle-icon {
    font-size: 10px;
    color: var(--text-tertiary);
    transition: transform var(--transition-fast);
    width: 16px;
    text-align: center;
}

.alerts-group.is-open .group-toggle-icon {
    transform: rotate(180deg);
}

/* Область без районів — без стрілки і курсора */
.alerts-group.no-districts .alerts-group-header {
    cursor: default;
}

.alerts-group.no-districts .group-toggle-icon {
    display: none;
}

/* Тіло групи (список районів) */
.alerts-group-body {
    padding: 4px 8px 8px 8px;
    background: rgba(0, 0, 0, 0.15);
    display: none;
}

.alerts-group.is-open .alerts-group-body {
    display: block;
}

/* ============================================================================
   DISTRICT CARD (картка району всередині акордеону)
   ============================================================================ */

.district-card {
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 3px solid var(--accent-green);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.district-card:last-child {
    margin-bottom: 0;
}

.district-card:hover {
    background: var(--bg-tertiary);
    transform: translateX(2px);
}

.district-card.active {
    border-left-color: var(--accent-red);
    background: rgba(255, 69, 58, 0.06);
}

.district-card.active:hover {
    background: rgba(255, 69, 58, 0.1);
}

.district-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.district-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.district-type {
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.district-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.district-status {
    color: var(--accent-green);
}

.district-status.active {
    color: var(--accent-red);
    font-weight: 500;
}

.district-time {
    color: var(--text-tertiary);
}

.district-duration {
    font-size: 11px;
    color: var(--accent-orange);
    margin-top: 4px;
}

.district-types {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.district-type-badge {
    padding: 2px 6px;
    background: rgba(255, 69, 58, 0.15);
    color: var(--accent-red);
    font-size: 10px;
    font-weight: 500;
    border-radius: 4px;
}

/* ============================================================================
   ALERTS ACCORDION STYLES v3.4
   - Плавні анімації переміщення
   - Без "Відбій"
   - Артилерія окремим кольором
   ============================================================================ */

/* Група (область) */
.alerts-group {
    margin-bottom: 8px;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--bg-secondary);
    transition: transform 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease;
}

.alerts-group:last-child {
    margin-bottom: 0;
}

/* Заголовок групи (плашка області) */
.alerts-group-header {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: none;
    border-left: 4px solid var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 12px;
}

/* Активна тривога — червоний бордер */
.alerts-group-header.alert-active {
    border-left-color: var(--accent-red);
    background: rgba(255, 69, 58, 0.08);
}

/* Немає тривоги — сірий бордер (без зеленого, бо немає "Відбій") */
.alerts-group-header.alert-inactive {
    border-left-color: var(--bg-tertiary);
    opacity: 0.7;
}

.alerts-group-header:hover {
    background: var(--bg-tertiary);
}

.alerts-group.is-active .alerts-group-header:hover {
    background: rgba(255, 69, 58, 0.12);
}

/* Ліва частина заголовка */
.group-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

/* Індикатор статусу (кружечок) */
.group-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    flex-shrink: 0;
    transition: background 0.3s ease, transform 0.3s ease;
}

.alerts-group.is-active .group-status-indicator {
    background: var(--accent-red);
    animation: status-pulse 1.5s ease-in-out infinite;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.2); }
}

/* Інформація в заголовку */
.group-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.group-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
}

.group-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    display: flex;
    gap: 8px;
}

.group-meta-active {
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.alerts-group.is-active .group-meta-active {
    color: var(--accent-red);
}

/* Права частина заголовка */
.group-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.group-time {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* Бейдж кількості районів */
.group-badge {
    min-width: 36px;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    transition: background 0.2s ease, color 0.2s ease;
}

.alerts-group.is-active .group-badge {
    background: rgba(255, 69, 58, 0.2);
    color: var(--accent-red);
}

/* Іконка стрілки */
.group-toggle-icon {
    font-size: 10px;
    color: var(--text-tertiary);
    transition: transform 0.2s ease;
    width: 16px;
    text-align: center;
}

.alerts-group.is-open .group-toggle-icon {
    transform: rotate(180deg);
}

/* Область без районів — без стрілки і курсора */
.alerts-group.no-districts .alerts-group-header {
    cursor: default;
}

.alerts-group.no-districts .group-toggle-icon {
    display: none;
}

/* Тіло групи (список районів) */
.alerts-group-body {
    padding: 4px 8px 8px 8px;
    background: rgba(0, 0, 0, 0.15);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.alerts-group-body[style*="display: block"],
.alerts-group-body[style*="display:block"] {
    max-height: 2000px;
    padding: 4px 8px 8px 8px;
}

.alerts-group-body[style*="display: none"],
.alerts-group-body[style*="display:none"] {
    max-height: 0;
    padding: 0 8px;
}

/* ============================================================================
   DISTRICT CARD (картка району)
   ============================================================================ */

.district-card {
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.district-card:last-child {
    margin-bottom: 0;
}

.district-card:hover {
    background: var(--bg-tertiary);
    transform: translateX(2px);
}

/* Неактивний район — без бордера, просто сіруватий */
.district-card.inactive {
    border-left-color: transparent;
    opacity: 0.6;
}

/* Активний район — червоний бордер */
.district-card.active {
    border-left-color: var(--accent-red);
    background: rgba(255, 69, 58, 0.06);
    opacity: 1;
}

.district-card.active:hover {
    background: rgba(255, 69, 58, 0.1);
}

.district-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.district-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.district-type {
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.district-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

/* Статус тривоги */
.district-status {
    color: var(--text-tertiary);
    min-height: 16px;
}

.district-status.active {
    color: var(--accent-red);
    font-weight: 500;
}

.district-time {
    color: var(--text-tertiary);
}

.district-duration {
    font-size: 11px;
    color: var(--accent-orange);
    margin-top: 4px;
}

/* Типи тривог */
.district-types {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.district-type-badge {
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 500;
    border-radius: 4px;
    /* Кольори задаються inline через JS */
}

/* ============================================================================
   АНІМАЦІЇ
   ============================================================================ */

/* Плавна поява */
.alerts-group {
    animation: fadeInUp 0.25s ease-out;
}

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

/* Плавне переміщення районів */
.district-card {
    transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

/* ============================================================================
   SCROLLBAR STYLING
   ============================================================================ */

.scrollable-list {
    padding: 8px;
}

.scrollable-list::-webkit-scrollbar {
    width: 6px;
}

.scrollable-list::-webkit-scrollbar-track {
    background: transparent;
}

.scrollable-list::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.scrollable-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================================================
   СТАТУС ОБЛАСТІ БЕЗ РАЙОНІВ (Крим, Київ тощо)
   ============================================================================ */

.group-state-status {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    color: var(--accent-red);
    font-weight: 500;
}

.group-duration {
    font-size: 11px;
    color: var(--accent-orange);
    font-weight: 400;
}

/* Для неактивних областей без районів */
.alerts-group.no-districts:not(.is-active) .group-header-info {
    opacity: 0.7;
}


/**
 * AirWatch Sidebar Styles - Messages & Modal
 * v3.5 additions
 */

/* ============================================================================
   МОДАЛЬНЕ ВІКНО ПОВІДОМЛЕННЯ
   ============================================================================ */

.message-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.message-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.message-modal {
    background: #1c1c1e;
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.25s ease;
}

.message-modal-overlay.visible .message-modal {
    transform: scale(1) translateY(0);
}

.message-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

.message-modal-channel {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.message-modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}

.message-modal-close:hover {
    background: rgba(255, 69, 58, 0.2);
    color: #ff453a;
}

.message-modal-meta {
    padding: 12px 20px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    gap: 8px;
}

.message-modal-body {
    padding: 16px 20px;
    font-size: 15px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
    overflow-y: auto;
    flex: 1;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-modal-events {
    padding: 12px 20px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ============================================================================
   КАРТКА ПОВІДОМЛЕННЯ (ОНОВЛЕНО)
   ============================================================================ */

.message-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.message-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}

.message-card.has-event {
    border-left: 3px solid #3498db;
}

.message-card.has-event:hover {
    border-left-color: #e74c3c;
    background: rgba(52, 152, 219, 0.08);
}

.message-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.message-channel {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

/* Telegram посилання */
.message-channel-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #29b6f6;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 12px;
    font-weight: 600;
}

.message-channel-link:hover {
    color: #4fc3f7;
}

.message-channel-link .telegram-icon {
    flex-shrink: 0;
    opacity: 0.8;
}

.message-channel-link:hover .telegram-icon {
    opacity: 1;
}

/* Telegram іконка */
.telegram-icon {
    width: 14px;
    height: 14px;
    vertical-align: middle;
}

.message-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
}

.message-text {
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 8px;
}

.message-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.message-link-indicator {
    font-size: 12px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.message-card:hover .message-link-indicator {
    opacity: 1;
}

/* Event chip */
.event-chip {
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Modal Telegram link */
.modal-channel-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #29b6f6;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: color 0.2s ease;
}

.modal-channel-link:hover {
    color: #4fc3f7;
}

.modal-channel-link .telegram-icon {
    width: 16px;
    height: 16px;
}

/* ============================================================================
   АНІМАЦІЯ ЗВ'ЯЗКУ EVENT НА КАРТІ
   ============================================================================ */

/* Базовий стиль для маркерів */
.svg-threat-icon {
    position: relative;
}

/* Анімоване кільце при hover на повідомлення */
/* Колір береться з CSS custom property --highlight-color */
.svg-threat-icon.event-linked-highlight::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin-top: -25px;
    margin-left: -25px;
    border: 3px solid transparent;
    border-top-color: var(--highlight-color, #ff453a);
    border-right-color: var(--highlight-color, #ff453a);
    border-radius: 50%;
    animation: linkSpin 1s linear infinite;
    pointer-events: none;
    z-index: 1000;
}

/* Друге кільце (offset) */
.svg-threat-icon.event-linked-highlight::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    margin-top: -30px;
    margin-left: -30px;
    border: 2px solid transparent;
    border-bottom-color: var(--highlight-color-fade, rgba(255, 69, 58, 0.5));
    border-left-color: var(--highlight-color-fade, rgba(255, 69, 58, 0.5));
    border-radius: 50%;
    animation: linkSpin 1.5s linear infinite reverse;
    pointer-events: none;
    z-index: 999;
}

@keyframes linkSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Пульсація фону */
.svg-threat-icon.event-linked-highlight .threat-marker {
    animation: linkPulse 0.8s ease-in-out infinite;
}

@keyframes linkPulse {
    0%, 100% {
        filter: drop-shadow(0 0 8px var(--highlight-color-fade, rgba(255, 69, 58, 0.6)));
    }
    50% {
        filter: drop-shadow(0 0 16px var(--highlight-color, rgba(255, 69, 58, 0.9)));
    }
}

/* Highlighted маркер (при кліку) */
.svg-threat-icon.highlighted .threat-marker {
    filter: drop-shadow(0 0 12px var(--highlight-color, rgba(255, 69, 58, 0.8)));
}

.svg-threat-icon.highlighted::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    margin-top: -22px;
    margin-left: -22px;
    border: 2px solid var(--highlight-color, #ff453a);
    border-radius: 50%;
    animation: highlightPulse 1.5s ease-out infinite;
    pointer-events: none;
}

@keyframes highlightPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* ============================================================================
   АДАПТИВ
   ============================================================================ */

@media (max-width: 768px) {
    .message-modal-overlay {
        padding: 10px;
    }

    .message-modal {
        max-height: 90vh;
        border-radius: 12px;
    }

    .message-modal-header {
        padding: 14px 16px;
    }

    .message-modal-body {
        padding: 14px 16px;
        font-size: 14px;
    }
}

/* ============================================================================
   INFO MODAL (Про AirWatch)
   ============================================================================ */

.info-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.info-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.info-modal {
    background: linear-gradient(145deg, #1c1c1e, #2c2c2e);
    border-radius: 20px;
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
}

.info-modal-overlay.visible .info-modal {
    transform: scale(1) translateY(0);
}

.info-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

.info-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.info-modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 10px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}

.info-modal-close:hover {
    background: rgba(255, 69, 58, 0.2);
    color: #ff453a;
}

.info-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.info-section {
    margin-bottom: 20px;
}

.info-section:last-child {
    margin-bottom: 0;
}

.info-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin: 0 0 10px 0;
}

.info-section p {
    font-size: 14px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

.info-section ul {
    margin: 0;
    padding-left: 20px;
}

.info-section li {
    font-size: 13px;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.7);
}

.info-section strong {
    color: #ff453a;
}

/* Telegram Channels */
.telegram-channels {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.channel-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(41, 182, 246, 0.1);
    border: 1px solid rgba(41, 182, 246, 0.2);
    border-radius: 10px;
    color: #29b6f6;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.channel-link:hover {
    background: rgba(41, 182, 246, 0.2);
    border-color: rgba(41, 182, 246, 0.4);
    transform: translateX(4px);
}

.channel-link .telegram-icon {
    flex-shrink: 0;
}

/* Modal Footer */
.info-modal-footer {
    padding: 16px 24px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
}

.contact-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #29b6f6, #0288d1);
    border: none;
    border-radius: 12px;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(41, 182, 246, 0.3);
}

.contact-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(41, 182, 246, 0.4);
}

.contact-btn .telegram-icon {
    flex-shrink: 0;
}

/* ============================================================================
   STATUS BAR UPDATES
   ============================================================================ */

.status-info-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-info-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.status-logo {
    padding-right: 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    margin-right: 4px;
}

.status-time {
    opacity: 0.6;
    font-size: 12px;
}

/* ============================================================================
   ТЕМНА ТЕМА (ПІДТРИМКА)
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    .message-modal {
        background: #1c1c1e;
    }

    .info-modal {
        background: linear-gradient(145deg, #1c1c1e, #2c2c2e);
    }
}

/* ============================================================================
   MOBILE ADAPTATIONS FOR INFO MODAL
   ============================================================================ */

@media (max-width: 768px) {
    .info-modal-overlay {
        padding: 12px;
    }

    .info-modal {
        max-height: 90vh;
        border-radius: 16px;
    }

    .info-modal-header {
        padding: 16px 18px;
    }

    .info-modal-header h2 {
        font-size: 16px;
    }

    .info-modal-body {
        padding: 16px 18px;
    }

    .info-section h3 {
        font-size: 13px;
    }

    .info-section p,
    .info-section li {
        font-size: 13px;
    }

    .channel-link {
        padding: 8px 12px;
        font-size: 12px;
    }

    .contact-btn {
        width: 100%;
        justify-content: center;
    }
}



