/* ================================================================
   LoRaWAN Coverage Mapper — Feuille de style
   ================================================================ */

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    background: #1a1a2e;
    color: #e0e0e0;
}

/* ---- Layout principal ---- */

#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ---- Carte ---- */

#map {
    flex: 1;
    min-width: 0;
    background: #242424;
}

/* ---- Panneau latéral ---- */

#sidebar {
    width: 300px;
    min-width: 260px;
    background: #16213e;
    border-left: 1px solid #0f3460;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#sidebar-header {
    padding: 16px;
    background: #0f3460;
    border-bottom: 1px solid #1a4a8a;
    flex-shrink: 0;
}

#sidebar-header h1 {
    font-size: 15px;
    font-weight: 700;
    color: #e94560;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

#sidebar-header p {
    font-size: 11px;
    color: #8899aa;
}

#sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

#sidebar-body::-webkit-scrollbar {
    width: 4px;
}
#sidebar-body::-webkit-scrollbar-track { background: transparent; }
#sidebar-body::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 2px; }

/* ---- Sections ---- */

.section {
    margin-bottom: 14px;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #e94560;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #0f3460;
}

/* ---- Stats ---- */

#stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.stat-card {
    background: #0f3460;
    border-radius: 6px;
    padding: 8px 10px;
    text-align: center;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #e94560;
    line-height: 1;
}

.stat-label {
    font-size: 10px;
    color: #8899aa;
    margin-top: 2px;
}

/* ---- Contrôles des couches ---- */

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    cursor: pointer;
    user-select: none;
}

.layer-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #e94560;
    cursor: pointer;
}

.layer-toggle span {
    font-size: 13px;
    color: #cdd6e0;
}

.layer-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ---- Légende RSSI ---- */

#rssi-legend {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #bcc8d4;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.2);
}

.legend-line {
    width: 24px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ---- Boutons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 12px;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    width: 100%;
    margin-bottom: 6px;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: #e94560;
    color: #fff;
}
.btn-primary:hover { background: #c73652; }

.btn-secondary {
    background: #0f3460;
    color: #cdd6e0;
}
.btn-secondary:hover { background: #1a4a8a; }

/* ---- Status connexion ---- */

#status-bar {
    padding: 8px 12px;
    background: #0a0a1a;
    border-top: 1px solid #0f3460;
    flex-shrink: 0;
    font-size: 11px;
    color: #667788;
    display: flex;
    align-items: center;
    gap: 6px;
}

#status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4caf50;
    flex-shrink: 0;
}

#status-dot.error { background: #f44336; }
#status-dot.loading { background: #ff9800; animation: pulse 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ---- Popup Leaflet personnalisé ---- */

.custom-popup .leaflet-popup-content-wrapper {
    background: #16213e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.custom-popup .leaflet-popup-tip {
    background: #16213e;
}

.popup-title {
    font-weight: 700;
    font-size: 13px;
    color: #e94560;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #0f3460;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 2px 0;
    font-size: 12px;
}

.popup-key {
    color: #8899aa;
    margin-right: 10px;
}

.popup-val {
    color: #e0e0e0;
    font-weight: 600;
}

.popup-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
}

.badge-online  { background: #1b5e20; color: #69f0ae; }
.badge-offline { background: #b71c1c; color: #ff8a80; }
.badge-good    { background: #1b5e20; color: #69f0ae; }
.badge-fair    { background: #e65100; color: #ffcc02; }
.badge-poor    { background: #4a148c; color: #ea80fc; }

/* ---- Marqueur gateway personnalisé ---- */

.gw-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.7);
    box-shadow: 0 0 6px rgba(0,0,0,0.6);
}

/* ---- Responsive : masquer sidebar sur petits écrans ---- */

@media (max-width: 600px) {
    #sidebar {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 260px;
        z-index: 1000;
        transform: translateX(100%);
        transition: transform 0.3s;
    }
    #sidebar.open {
        transform: translateX(0);
    }
    #toggle-sidebar {
        display: block;
    }
}
