:root {
    --bg-dark: rgba(20, 25, 30, 0.9);
    --bg-light: rgba(255, 255, 255, 0.95);
    --primary: #3498db;
    --danger: #e74c3c;
    --success: #2ecc71;
    --text-dark: #2c3e50;
    --text-light: #ecf0f1;
    --glass-blur: blur(10px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body, html {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #111;
    width: 100%; height: 100%; height: 100dvh; 
    margin: 0; padding: 0; overflow: hidden; overscroll-behavior: none;
}

.hidden {
    display: none !important;
}

#map { width: 100%; height: 100%; z-index: 1; }

.glass-panel {
    background: var(--bg-light); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15); border: 1px solid rgba(255,255,255,0.2); border-radius: 12px;
}

.top-bar {
    position: absolute; top: env(safe-area-inset-top, 15px); left: 10px; right: 10px;
    z-index: 1000; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; 
}
.status-badge {
    background: var(--bg-light); color: var(--text-dark); pointer-events: auto;
    padding: 8px 12px; border-radius: 20px; font-weight: bold; font-size: 12px;
    backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); max-width: 65%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn-radar-toggle {
    background: var(--bg-dark); color: white; pointer-events: auto;
    border: none; padding: 8px 12px; border-radius: 20px; font-weight: bold; font-size: 12px;
    cursor: pointer; display: flex; align-items: center; gap: 5px; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.radar-panel {
    position: absolute; top: calc(env(safe-area-inset-top, 15px) + 45px); right: 10px;
    z-index: 999; background: var(--bg-light); padding: 15px; border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    display: flex; flex-direction: column; gap: 8px; font-size: 13px;
    transition: transform 0.3s, opacity 0.3s; transform-origin: top right;
}
.radar-panel.hidden { transform: scale(0.9); opacity: 0; pointer-events: none; }
.filter-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500;}

.side-tools {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 10px;
}
.tool-btn {
    width: 45px; height: 45px; border-radius: 12px; font-size: 20px;
    background: var(--bg-light); border: 2px solid transparent; color: var(--text-dark);
    cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.15); transition: 0.2s; display: flex; justify-content: center; align-items: center; 
    backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
}
.tool-btn:hover { background: #e0e0e0; }
.tool-btn.active-add { background: #e8f8f5; border-color: #1abc9c; }
.tool-btn.active-edit { background: #ebf5fb; border-color: #3498db; }
.tool-btn.active-del { background: #fdedec; border-color: #e74c3c; }
.tool-btn.active-measure { background: #f4f6f7; border-color: #95a5a6; }
.panic-btn { border: 2px solid #34495e; } .panic-btn:hover { background: #c0392b; color: white; border-color: #e74c3c; }

.bottom-dock {
    position: absolute; bottom: 0; left: 0; width: 100%; z-index: 1500; background: var(--bg-dark); 
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    display: flex; justify-content: space-around; align-items: center; padding: 10px 5px calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -5px 20px rgba(0,0,0,0.4); border-top: 1px solid rgba(255,255,255,0.1);
}
.dock-btn { background: transparent; border: none; color: #a4b0be; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; flex: 1; transition: 0.2s; }
.dock-btn:hover, .dock-btn:active { color: white; transform: scale(1.05); }
.dock-icon { font-size: 22px; } .dock-text { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.sos-btn { color: #ff4757; } .sos-btn .dock-icon { background: rgba(255, 71, 87, 0.2); border-radius: 50%; padding: 5px; animation: pulseSOS 2s infinite; }
@keyframes pulseSOS { 0% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.6); } 70% { box-shadow: 0 0 0 10px rgba(255, 71, 87, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0); } }
.stealth-btn { color: #57606f; }

.action-panel {
    position: absolute; bottom: calc(80px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: 92%; max-width: 400px;
    background: var(--bg-dark); color: white; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); z-index: 1400;
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); border: 1px solid rgba(255,255,255,0.1); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
}
.action-panel.hidden { transform: translate(-50%, 20px); opacity: 0; pointer-events: none; }
#layers-menu { padding: 15px; text-align: center; } #layers-menu h4 { margin-bottom: 15px; font-size: 14px; opacity: 0.8; }
.layer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.layer-grid button { background: rgba(255,255,255,0.1); border: none; color: white; padding: 12px; border-radius: 10px; font-weight: bold; font-size: 13px; cursor: pointer; }
.layer-grid button:active { background: var(--primary); }

.radio-header { background: rgba(0,0,0,0.3); padding: 12px; text-align: center; cursor: pointer; border-radius: 15px 15px 0 0; font-weight: bold; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.radio-messages { height: 180px; overflow-y: auto; padding: 10px; font-size: 13px; display: flex; flex-direction: column; gap: 8px; font-family: monospace; }
.radio-input-container { display: flex; border-top: 1px solid rgba(255,255,255,0.1); }
.radio-input-container input { flex: 1; background: transparent; border: none; color: white; padding: 12px; outline: none; font-size: 14px; }
.radio-input-container button { background: var(--primary); border: none; color: white; padding: 0 20px; cursor: pointer; border-radius: 0 0 15px 0; font-weight: bold; }
.msg-line { background: rgba(255,255,255,0.1); padding: 8px; border-radius: 8px; word-break: break-word; } .msg-time { color: #f39c12; margin-right: 5px; font-weight: bold; }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); z-index: 3000; justify-content: center; align-items: center; padding: 20px; }
.modal-content { background: white; padding: 20px; border-radius: 15px; width: 100%; max-width: 400px; max-height: 85vh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.input-group label { font-size: 13px; font-weight: bold; color: #7f8c8d; margin-bottom: 2px;} .input-group input, select { padding: 10px; border: 1px solid #bdc3c7; border-radius: 8px; font-size: 14px; width: 100%; background: #f9f9f9; outline: none;}
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 5px; } .btn-cancel, .btn-confirm { flex: 1; padding: 12px; border-radius: 8px; font-weight: bold; border: none; cursor: pointer;} .btn-cancel { background: #ecf0f1; color: #7f8c8d; } .btn-confirm { background: var(--success); color: white; }

.custom-popup .leaflet-popup-content-wrapper { background: var(--bg-dark); color: #ecf0f1; border-radius: 12px; padding: 5px; border: 1px solid rgba(255,255,255,0.1);} .custom-popup .leaflet-popup-tip { background: var(--bg-dark); }
.urbex-pin-container { display: flex; justify-content: center; align-items: flex-end; width: 100%; height: 100%; }
.urbex-pin { width: 24px; height: 24px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid white; box-shadow: -3px 3px 10px rgba(0,0,0,0.4); }
.bg-accessible { background: linear-gradient(135deg, #2ecc71, #27ae60); } .bg-garde { background: linear-gradient(135deg, #f1c40f, #f39c12); } .bg-dangereux { background: linear-gradient(135deg, #e74c3c, #c0392b); } .bg-detruit { background: linear-gradient(135deg, #34495e, #2c3e50); }

.gps-pulse-container { display: flex; justify-content: center; align-items: center; width: 100%; height: 100%; }
.gps-pulse-dot { width: 14px; height: 14px; background-color: #3498db; border-radius: 50%; border: 2px solid white; z-index: 2; }
.gps-pulse-ring { position: absolute; width: 40px; height: 40px; background-color: rgba(52, 152, 219, 0.4); border-radius: 50%; animation: pulse 1.5s infinite ease-out; z-index: 1; }

.sos-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh; background: rgba(231, 76, 60, 0.3); z-index: 9999; pointer-events: none; display: none; animation: flashSOS 0.4s infinite alternate; } @keyframes flashSOS { from { opacity: 0.1; } to { opacity: 0.6; } }
#stealth-screen { position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh; background: #000; z-index: 99999; }

.offline-banner { position: absolute; top: calc(env(safe-area-inset-top, 15px) + 50px); left: 50%; transform: translateX(-50%); background: rgba(231, 76, 60, 0.95); color: white; padding: 10px 20px; border-radius: 20px; font-weight: bold; font-size: 12px; z-index: 9999; box-shadow: 0 4px 15px rgba(231, 76, 60, 0.5); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); display: flex; align-items: center; gap: 8px; white-space: nowrap; animation: pulseOffline 2s infinite; } .offline-banner.hidden { display: none; } @keyframes pulseOffline { 0% { opacity: 0.8; } 50% { opacity: 1; box-shadow: 0 0 20px rgba(231,76,60,0.8); } 100% { opacity: 0.8; } }
.dock-btn.locked { color: #2ecc71; } .dock-btn.locked .dock-icon { animation: glowGPS 1.5s infinite alternate; } @keyframes glowGPS { from { text-shadow: 0 0 5px #2ecc71; } to { text-shadow: 0 0 15px #2ecc71; transform: scale(1.1); } }
.ping-pulse-wrapper { display: flex; justify-content: center; align-items: center; } .ping-tactique-ring { width: 60px; height: 60px; background-color: rgba(52, 152, 219, 0.4); border-radius: 50%; border: 2px solid #3498db; animation: pingTactiqueAnim 1.5s infinite ease-out; } @keyframes pingTactiqueAnim { 0% { transform: scale(0.1); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }

body.dark-mode .status-badge, body.dark-mode .radar-panel, body.dark-mode .tool-btn { background: rgba(20, 0, 0, 0.9); color: #e74c3c; border-color: #e74c3c; }
body.dark-mode .tool-btn.active-add, body.dark-mode .tool-btn.active-edit, body.dark-mode .tool-btn.active-del, body.dark-mode .tool-btn.active-measure { background: rgba(231, 76, 60, 0.3); }
body.dark-mode .bottom-dock { border-top-color: #e74c3c; } body.dark-mode .dock-btn { color: #c0392b; } body.dark-mode .dock-btn:hover { color: #e74c3c; }
body.dark-mode .modal-content { background: #111; color: #e74c3c; border: 1px solid #e74c3c; } body.dark-mode input, body.dark-mode select { background: #222; color: #e74c3c; border-color: #e74c3c; }

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

/* 🚨 NOUVEAU : STYLE DE L'INTERFACE PANIC "RandoCartes" */
#fake-ui {
    position: absolute; top: 0; left: 0; width: 100%; z-index: 5000;
}
.fake-header {
    background: #27ae60; color: white; padding: env(safe-area-inset-top, 20px) 15px 15px 15px;
    font-size: 18px; font-weight: bold; text-align: center; box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    user-select: none;
}

/* TOUT TON CSS PRECEDENT ICI... et ajoute ceci tout en bas : */

/* =========================================
   NOUVEAU : FILTRE INFRAROUGE (RED MODE)
   ========================================= */
body.red-mode {
    /* Magie CSS : Transforme toutes les couleurs du site en nuances de rouge sombre */
    filter: sepia(100%) hue-rotate(315deg) saturate(600%) brightness(0.7) contrast(1.3) !important;
    background-color: #000 !important;
}

/* =========================================
   NOUVEAU : GHOST RADIO (MESSAGES EPHEMERES)
   ========================================= */
.msg-line {
    transition: all 0.5s ease;
}

.msg-line.ghost-out {
    animation: fadeOutGhost 1s forwards;
}

@keyframes fadeOutGhost {
    0% { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(50px); height: 0; padding: 0; margin: 0; overflow: hidden; }
}

/* Ajustement pour que le chrono et le badge rentrent bien en haut */
.status-badge {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* =========================================
   NOUVEAUTÉS MARQUEURS (NOTES, STREETVIEW, PATROUILLE)
   ========================================= */

/* Champ Notes Tactiques */
textarea { 
    padding: 10px; border: 1px solid #bdc3c7; border-radius: 8px; 
    font-size: 14px; width: 100%; background: #f9f9f9; outline: none; 
    resize: vertical; font-family: inherit; 
}
body.dark-mode textarea { background: #222; color: #e74c3c; border-color: #e74c3c; }

/* Bouton Patrouille Actif */
.tool-btn.active-patrol { background: #fdedec; border-color: #9b59b6; color: #8e44ad; }

/* Marqueur Gyrophare (Patrouille) */
.bg-patrol { 
    background: linear-gradient(135deg, #2980b9, #8e44ad); 
    animation: flashPolice 1s infinite alternate; 
    border-color: #fff !important;
}
@keyframes flashPolice { 
    0% { box-shadow: 0 0 15px #2980b9, inset 0 0 10px #2980b9; } 
    100% { box-shadow: 0 0 25px #e74c3c, inset 0 0 10px #e74c3c; background: linear-gradient(135deg, #e74c3c, #c0392b); } 
}

/* Bouton Street View dans la popup */
.btn-streetview { 
    background: #34495e; color: white; border: none; padding: 8px 10px; 
    border-radius: 6px; font-size: 12px; cursor: pointer; width: 100%; 
    margin-top: 10px; font-weight: bold; transition: 0.2s; display: flex; justify-content: center; gap: 5px;
}
.btn-streetview:hover { background: #1abc9c; }
body.dark-mode .btn-streetview { background: rgba(231, 76, 60, 0.2); color: #e74c3c; border: 1px solid #e74c3c;}
body.dark-mode .btn-streetview:hover { background: #e74c3c; color: #111; }

/* =========================================
   NOUVEAU : V4 SURVIE GLOBALE
   ========================================= */

/* HUD Tactique GPS */
.tactical-hud {
    position: absolute; top: calc(env(safe-area-inset-top, 15px) + 50px);
    left: 50%; transform: translateX(-50%); width: 90%; max-width: 350px;
    background: rgba(10, 15, 20, 0.85); border: 1px solid #3498db;
    border-radius: 12px; padding: 10px 15px; color: #ecf0f1;
    font-family: monospace; font-size: 13px; z-index: 998;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.3);
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
    pointer-events: none;
}
.tactical-hud.hidden { display: none; }
.hud-row { display: flex; justify-content: space-between; margin-bottom: 5px; border-bottom: 1px dashed rgba(255,255,255,0.2); padding-bottom: 3px; }
.hud-row:last-child { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
.hud-row strong { color: #3498db; }
body.red-mode .tactical-hud { border-color: #e74c3c; box-shadow: 0 0 15px rgba(231, 76, 60, 0.3); }
body.red-mode .hud-row strong { color: #e74c3c; }

/* Couleur spécifique pour le point d'extraction */
.bg-extraction { background: linear-gradient(135deg, #3498db, #2980b9); border: 2px solid #fff; }
.badge-extraction { background-color: #3498db; }

/* =========================================
   NOUVEAU : STYLES DES PHOTOS DANS LES POPUPS
   ========================================= */
.popup-photo {
    width: 100%;
    max-height: 140px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* On agrandit un poil la popup si y a une photo */
.custom-popup .leaflet-popup-content {
    width: 220px !important;
}

#photo-preview {
    border: 2px solid #3498db;
}

/* =========================================
   NOUVEAUTÉS V5 : TARGET LOCK & INTEL
   ========================================= */

/* Bouton Verrouillage Cible (Target Lock) */
.btn-target-lock {
    background: rgba(231, 76, 60, 0.1); 
    color: #e74c3c; 
    border: 1px solid #e74c3c; 
    padding: 8px 10px; 
    border-radius: 6px; 
    font-size: 12px; 
    cursor: pointer; 
    width: 100%; 
    margin-top: 5px; 
    font-weight: bold; 
    transition: 0.2s; 
    display: flex; 
    justify-content: center; 
    gap: 5px;
}
.btn-target-lock:hover, .btn-target-lock.locked-active {
    background: #e74c3c; 
    color: white;
}
body.dark-mode .btn-target-lock { background: rgba(231, 76, 60, 0.2); }

/* Animation du Laser Target */
.target-laser {
    animation: dashLaser 20s linear infinite;
}
@keyframes dashLaser {
    to { stroke-dashoffset: -1000; }
}

/* Modale Intel Sombre */
body.dark-mode #intel-modal .modal-content {
    background: #111;
    border: 1px solid #3498db;
}
body.dark-mode #moon-tactical-advice {
    background: #222;
    color: #3498db;
}


/* =========================================
   NOUVEAUTÉS V6 : SQUAD RADAR, COMPASS & MICRO
   ========================================= */

/* Radar Multijoueur : Les potes sont en violet */
.teammate-pulse-dot { 
    width: 14px; height: 14px; background-color: #9b59b6; border-radius: 50%; border: 2px solid white; z-index: 2; box-shadow: 0 0 10px rgba(155, 89, 182, 0.8); 
}
.teammate-pulse-ring { 
    position: absolute; width: 40px; height: 40px; background-color: rgba(155, 89, 182, 0.4); border-radius: 50%; animation: pulse 1.5s infinite ease-out; z-index: 1; 
}
.teammate-label {
    position: absolute; top: -25px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.7); color: white; padding: 2px 6px; border-radius: 4px;
    font-size: 10px; font-weight: bold; white-space: nowrap; pointer-events: none;
}

/* Cône de vision (Boussole) attaché au marqueur GPS */
.gps-direction-cone {
    position: absolute; width: 0; height: 0;
    border-left: 25px solid transparent; border-right: 25px solid transparent;
    border-top: 50px solid rgba(52, 152, 219, 0.3); /* Cône vers le haut */
    top: -45px; left: -25px; 
    transform-origin: 25px 50px; /* Centre de rotation sur le point GPS */
    transition: transform 0.1s linear; pointer-events: none; z-index: 0;
    border-radius: 50%;
}
.teammate-cone { border-top-color: rgba(155, 89, 182, 0.3); }

/* Bouton Micro actif */
.mic-active {
    background: #e74c3c !important;
    animation: pulseMic 1s infinite alternate;
}
@keyframes pulseMic {
    from { box-shadow: inset 0 0 10px rgba(0,0,0,0.5); }
    to { box-shadow: inset 0 0 0 rgba(0,0,0,0); }
}


/* =========================================
   NOUVEAUTÉS V7 : GALERIE & TRACES MULTI
   ========================================= */

/* Grille de la Galerie Intel */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 5px;
}
.gallery-item {
    background: #ecf0f1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}
body.dark-mode .gallery-item { background: #222; box-shadow: 0 2px 8px rgba(231,76,60,0.2); }
.gallery-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
}
.gallery-item div {
    padding: 8px;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
body.dark-mode .gallery-item div { color: #e74c3c; }

/* Traces des alliés */
.teammate-trace {
    opacity: 0.6;
    stroke-dasharray: 6 6;
    animation: crawl 1s linear infinite;
}
@keyframes crawl {
    to { stroke-dashoffset: -12; }
}

/* =========================================
   NOUVEAUTÉS V10 : ARCHIVES & ETATS
   ========================================= */

/* Radar Headers */
#radar-content h5 {
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 5px;
    margin-bottom: 8px;
    font-size: 14px;
}

/* Couleurs des nouveaux Types de points */
.bg-entry { background: linear-gradient(135deg, #9b59b6, #8e44ad); border: 2px solid #fff; }

/* Badges d'État de conservation */
.badge-intact { background-color: #1abc9c; color: white; }
.badge-vandalise { background-color: #f39c12; color: white; }
.badge-renovation { background-color: #e67e22; color: white; }
.badge-demoli { background-color: #34495e; color: white; }

/* Style du conteneur d'histoire dans la popup */
.popup-history-box {
    background: rgba(0,0,0,0.1); 
    padding: 8px; 
    border-radius: 6px; 
    font-size: 11px; 
    margin-top: 8px; 
    border-left: 3px solid #8e44ad;
}
body.dark-mode .popup-history-box { background: #222; color: #ecf0f1; }