:root {
    --bg-color: var(--tg-theme-bg-color, #ffffff);
    --text-color: var(--tg-theme-text-color, #000000);
    --hint-color: var(--tg-theme-hint-color, #999999);
    --link-color: var(--tg-theme-link-color, #2481cc);
    --button-color: var(--tg-theme-button-color, #2481cc);
    --button-text-color: var(--tg-theme-button-text-color, #ffffff);
}

* { box-sizing: border-box; }

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color, #0F172A);
    overflow: hidden;
    position: relative;
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Glassmorphism Dark UI Filter Panel */
#filter-panel {
    position: fixed;
    top: 10px;
    left: 10px;
    right: 10px;
    max-width: 480px;
    margin: 0 auto;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 8px 12px;
    z-index: 1000;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 2px 4px 6px 4px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: #E2E8F0;
}

.toggle-icon {
    font-size: 11px;
    transition: transform 0.25s ease;
    opacity: 0.75;
}

#filter-panel.collapsed {
    padding-bottom: 2px;
}

#filter-panel.collapsed .panel-body {
    display: none;
}

#filter-panel.collapsed .toggle-icon {
    transform: rotate(180deg);
}

.panel-body {
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.filter-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.filter-row select {
    flex: 1;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(30, 41, 59, 0.85);
    color: #F8FAFC;
    outline: none;
    font-size: 12px;
    font-weight: 500;
}

.filter-row select option {
    background: #0F172A;
    color: #F8FAFC;
}

.event-types {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-chip {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 5px 10px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: all 0.18s ease;
    color: #94A3B8;
}

.filter-chip input {
    display: none;
}

.filter-chip:has(input:checked) {
    background: rgba(33, 150, 243, 0.25);
    border-color: #2196F3;
    color: #FFFFFF;
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.35);
}

.filter-chip.danger-zone-chip:has(input:checked) {
    background: rgba(244, 67, 54, 0.22);
    border-color: #F44336;
    color: #FFCDD2;
    box-shadow: 0 0 8px rgba(244, 67, 54, 0.35);
}

/* Modern Eye-Pleasing Teardrop Map Pins */
.dozor-pin-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    user-select: none;
    pointer-events: auto;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
}

.dozor-pin-wrapper:hover {
    transform: scale(1.22);
    z-index: 1000 !important;
}

.dozor-modern-pin {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(145deg, #1E293B 0%, #0F172A 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #F59E0B;
    position: relative;
    pointer-events: auto;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.pin-icon {
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}

.pin-tail {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #0F172A;
    margin-top: -1px;
}

/* Subtle Threat Accents & Ambient Glow */
.dozor-modern-pin.threat-red {
    border-color: #EF4444;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.2);
    animation: gentleRedPulse 2.5s infinite ease-in-out;
}

.dozor-modern-pin.threat-yellow {
    border-color: #F59E0B;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.45), inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.dozor-modern-pin.threat-green {
    border-color: #10B981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.45), inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

@keyframes gentleRedPulse {
    0%, 100% {
        box-shadow: 0 0 8px rgba(239, 68, 68, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.2);
    }
    50% {
        box-shadow: 0 0 16px rgba(239, 68, 68, 0.75), inset 0 1px 2px rgba(255, 255, 255, 0.2);
    }
}

.dozor-modern-pin.unverified { opacity: 0.95; }
.dozor-modern-pin.denied { opacity: 0.35; filter: grayscale(100%); }

.status-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 10px;
    background: #0F172A;
    border: 1.5px solid #10B981;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

/* Legend Panel */
#legend-panel {
    position: fixed;
    bottom: 24px;
    right: 20px;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 8px 12px;
    border-radius: 12px;
    z-index: 1000;
    color: #F8FAFC;
    font-size: 11px;
    font-weight: 500;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}
.legend-item:last-child { margin-bottom: 0; }

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 7px;
    display: inline-block;
}

.legend-color.threat-red { background: #EF4444; box-shadow: 0 0 6px rgba(239, 68, 68, 0.6); }
.legend-color.threat-yellow { background: #F59E0B; box-shadow: 0 0 6px rgba(245, 158, 11, 0.6); }
.legend-color.threat-green { background: #10B981; box-shadow: 0 0 6px rgba(16, 185, 129, 0.6); }

/* Yandex Info Window / Balloon Content (Dark Theme) */
.info-window-content {
    color: #1E293B;
    padding: 4px;
    min-width: 200px;
    font-family: inherit;
}
.info-window-content h3 {
    margin: 0 0 6px 0;
    font-size: 15px;
    font-weight: 700;
    color: #0F172A;
}
.info-window-content p {
    margin: 4px 0;
    font-size: 13px;
    color: #334155;
    line-height: 1.4;
}
.info-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    border-top: 1px solid #E2E8F0;
    padding-top: 6px;
}

/* Floating Action Buttons (GPS & Sound) */
#map-controls-panel {
    position: fixed;
    bottom: 24px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.map-action-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(30, 30, 30, 0.90);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s;
    user-select: none;
}

.map-action-btn:hover {
    transform: scale(1.1);
    background: rgba(45, 45, 45, 0.95);
}

.map-action-btn:active {
    transform: scale(0.95);
}

/* Live User GPS Dot Animation */
.user-live-marker {
    position: relative;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-live-core {
    width: 14px;
    height: 14px;
    background: #2196F3;
    border: 2.5px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(33, 150, 243, 0.8);
    z-index: 2;
}

.user-live-pulse {
    position: absolute;
    width: 30px;
    height: 30px;
    background: rgba(33, 150, 243, 0.4);
    border-radius: 50%;
    animation: userPulse 2s infinite ease-out;
    z-index: 1;
}

@keyframes userPulse {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* Offline Status Bar */
.offline-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #DC2626;
    color: #FFFFFF;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    padding: 4px;
    z-index: 2000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
