/* ========================================
   SDIS 66 - Cartographie Opérationnelle
   Design iOS/iPhone - Liquid Glass Effect
   ======================================== */

:root {
    /* Couleurs SDIS 66 */
    --sdis-red: #AB0209;
    --sdis-red-dark: #8A0107;
    --sdis-red-light: #D4030B;
    --sdis-gold: #F7C419;
    --sdis-gold-dark: #D4A614;
    --sdis-gold-light: #FFD84D;
    
    /* Colors */
    --red-600: #AB0209;
    --red-500: #D4030B;
    --red-400: #F87171;
    --gold-400: #F7C419;
    --blue-500: #3B82F6;
    --cyan-500: #06B6D4;
    --emerald-500: #10B981;
    --purple-500: #8B5CF6;
    --orange-500: #F97316;
    
    /* Neutrals */
    --white: #FFFFFF;
    --black: #000000;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    
    /* Glass Effect */
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-bg-dark: rgba(30, 30, 30, 0.65);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    --glass-blur: 20px;
    
    /* Spacing */
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --nav-height: 85px;
    
    /* Animation */
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ========================================
   Reset & Base
   ======================================== */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
    font-size: 15px;
    line-height: 1.4;
    color: var(--gray-900);
    background: var(--gray-900);
    -webkit-font-smoothing: antialiased;
}

/* ========================================
   Map - Full Screen
   ======================================== */

#map {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.leaflet-control-attribution {
    font-size: 10px !important;
    background: var(--glass-bg) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 3px 8px !important;
    border-radius: 8px 0 0 0;
}

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

/* ========================================
   Top Bar - Search
   ======================================== */

.top-bar {
    position: fixed;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 1000;
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-container {
    flex: 1;
    position: relative;
}

.search-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
}

.search-loading {
    display: none;
    width: 20px;
    height: 20px;
}

.search-loading.visible {
    display: block;
}

.search-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--sdis-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ========================================
   Search Suggestions Dropdown
   ======================================== */

.search-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 16px;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    max-height: 400px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.25s var(--spring);
    z-index: 1001;
}

.search-suggestions.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.search-suggestions:empty {
    display: none;
}

.suggestion-group {
    padding: 8px 0;
}

.suggestion-group:not(:last-child) {
    border-bottom: 1px solid var(--gray-100);
}

.suggestion-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
}

.suggestion-group-title.dfci {
    color: var(--sdis-gold-dark);
}

.suggestion-group-title.address {
    color: var(--gray-500);
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background: var(--gray-50);
}

.suggestion-item:active {
    background: var(--gray-100);
}

.suggestion-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

/* DFCI 1km - Vert (plus précis, prioritaire) */
.suggestion-icon.dfci-1km {
    background: linear-gradient(135deg, #D1FAE5, #6EE7B7);
    color: #047857;
}

.suggestion-item.dfci-1km {
    border-left: 3px solid #10B981;
}

/* DFCI 2km - Orange (moins précis) */
.suggestion-icon.dfci-2km {
    background: linear-gradient(135deg, #FEF3C7, #FCD34D);
    color: #B45309;
}

.suggestion-item.dfci-2km {
    border-left: 3px solid #F59E0B;
}

/* Ancien style dfci pour rétrocompatibilité */
.suggestion-icon.dfci {
    background: linear-gradient(135deg, var(--sdis-gold-light), var(--sdis-gold));
    color: var(--sdis-red-dark);
}

.suggestion-icon.address {
    background: var(--gray-100);
    color: var(--gray-600);
}

.suggestion-icon.commune {
    background: linear-gradient(135deg, #E0F2FE, #BAE6FD);
    color: #0369A1;
}

.suggestion-content {
    flex: 1;
    min-width: 0;
}

.suggestion-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-subtitle {
    font-size: 12px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.suggestion-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

/* Badge 1km - Vert (prioritaire) */
.suggestion-badge.badge-1km {
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
}

/* Badge 2km - Orange */
.suggestion-badge.badge-2km {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
}

.no-suggestions {
    padding: 20px 16px;
    text-align: center;
    color: var(--gray-400);
    font-size: 13px;
}

.search-icon {
    color: var(--gray-400);
    flex-shrink: 0;
}

.search-pill input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    font-family: inherit;
    color: var(--gray-900);
    outline: none;
}

.search-pill input::placeholder {
    color: var(--gray-400);
}

.top-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    color: var(--gray-700);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s var(--spring), background 0.2s;
}

.top-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.9);
}

/* ========================================
   Map Toggle - Satellite/OSM
   ======================================== */

.map-toggle {
    position: fixed;
    top: 72px;
    right: 12px;
    z-index: 1000;
    display: flex;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    box-shadow: var(--glass-shadow);
    padding: 4px;
    gap: 4px;
}

.map-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--gray-600);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s var(--ease-out);
}

.map-toggle-btn.active {
    background: var(--white);
    color: var(--gray-900);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.map-toggle-btn:active {
    transform: scale(0.96);
}

/* ========================================
   Zoom Controls
   ======================================== */

.zoom-controls {
    position: fixed;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    padding: 4px;
}

.zoom-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--gray-700);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s var(--spring);
}

.zoom-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.zoom-btn:active {
    transform: scale(0.9);
    background: rgba(0, 0, 0, 0.1);
}

/* ========================================
   Bottom Navigation - Liquid Glass
   ======================================== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 0 8px calc(var(--safe-bottom) + 8px);
}

.nav-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 70px;
    padding: 0 8px;
    background: var(--glass-bg);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 
        0 -4px 30px rgba(0, 0, 0, 0.08),
        0 4px 20px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--gray-400);
    font-size: 11px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s var(--spring);
    border-radius: 16px;
    position: relative;
}

.nav-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: transparent;
    transition: background 0.3s;
}

.nav-item.active {
    color: var(--sdis-red);
}

.nav-item.active::before {
    background: rgba(171, 2, 9, 0.1);
}

/* Couleurs spécifiques par onglet */
.nav-item[data-panel="water"].active {
    color: #0EA5E9;
}

.nav-item[data-panel="water"].active::before {
    background: rgba(14, 165, 233, 0.1);
}

.nav-item[data-panel="fire"].active {
    color: var(--sdis-red);
}

.nav-item[data-panel="fire"].active::before {
    background: rgba(171, 2, 9, 0.1);
}

.nav-item[data-panel="dfci"].active {
    color: var(--sdis-gold-dark);
}

.nav-item[data-panel="dfci"].active::before {
    background: rgba(247, 196, 25, 0.15);
}

.nav-item[data-panel="admin"].active {
    color: #374151;
}

.nav-item[data-panel="admin"].active::before {
    background: rgba(55, 65, 81, 0.1);
}

.nav-item[data-panel="layers"].active {
    color: var(--sdis-gold-dark);
}

.nav-item[data-panel="layers"].active::before {
    background: rgba(247, 196, 25, 0.15);
}

.nav-item:active {
    transform: scale(0.92);
}

.nav-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.nav-icon svg {
    transition: transform 0.3s var(--spring);
}

.nav-item.active .nav-icon svg {
    transform: scale(1.1);
}

.nav-item span {
    position: relative;
    z-index: 1;
}

/* Fire icon animation */
.nav-item.active .fire-icon svg {
    animation: fireGlow 1.5s ease-in-out infinite;
}

@keyframes fireGlow {
    0%, 100% { filter: drop-shadow(0 0 0 transparent); }
    50% { filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.6)); }
}

/* ========================================
   Panel Overlay
   ======================================== */

.panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.35s var(--ease-out);
}

.panel-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   Sliding Panels
   ======================================== */

.sliding-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70vh;
    background: var(--white);
    border-radius: 24px 24px 0 0;
    z-index: 2000;
    transform: translateY(100%);
    transition: transform 0.4s var(--ease-out);
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.15);
}

.sliding-panel.visible {
    transform: translateY(0);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px 16px;
    border-bottom: 1px solid var(--gray-100);
    position: relative;
}

.panel-drag-indicator {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 5px;
    background: var(--gray-300);
    border-radius: 3px;
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    padding-top: 8px;
}

/* Couleurs des titres de panneaux */
#panel-water .panel-header h2 {
    color: #0EA5E9;
}

#panel-fire .panel-header h2 {
    color: var(--sdis-red);
}

#panel-dfci .panel-header h2 {
    color: var(--sdis-gold-dark);
}

#panel-admin .panel-header h2 {
    color: #374151;
}

.panel-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--gray-100);
    color: var(--gray-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.panel-close:active {
    transform: scale(0.9);
    background: var(--gray-200);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px calc(var(--safe-bottom) + 20px);
    overscroll-behavior: contain;
}

/* ========================================
   Layer Items in Panels
   ======================================== */

.layer-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--gray-50);
    border-radius: 16px;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.layer-card:active {
    transform: scale(0.98);
    background: var(--gray-100);
}

.layer-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.layer-card-icon img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.layer-card-icon.color-icon {
    background: var(--blue-500);
}

.layer-card-info {
    flex: 1;
    min-width: 0;
}

.layer-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-card-count {
    font-size: 13px;
    color: var(--gray-500);
}

/* iOS Toggle Switch */
.toggle-switch {
    position: relative;
    width: 51px;
    height: 31px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--gray-200);
    border-radius: 31px;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 27px;
    height: 27px;
    left: 2px;
    bottom: 2px;
    background: var(--white);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s var(--spring);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--sdis-red);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Toggle couleurs par catégorie */
/* EAU - Bleu */
#panel-water .toggle-switch input:checked + .toggle-slider,
[data-group="water"] .toggle-switch input:checked + .toggle-slider {
    background: #0EA5E9 !important;
}

/* FEU - Rouge SDIS */
#panel-fire .toggle-switch input:checked + .toggle-slider,
[data-group="fires"] .toggle-switch input:checked + .toggle-slider {
    background: var(--sdis-red) !important;
}

/* DFCI - Or SDIS */
#panel-dfci .toggle-switch input:checked + .toggle-slider,
[data-group="dfci"] .toggle-switch input:checked + .toggle-slider {
    background: var(--sdis-gold-dark) !important;
}

/* Admin - Gris foncé */
#panel-admin .toggle-switch input:checked + .toggle-slider,
[data-group="admin"] .toggle-switch input:checked + .toggle-slider {
    background: #374151 !important;
}

/* ========================================
   Info Sheet
   ======================================== */

.info-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 60vh;
    background: var(--white);
    border-radius: 24px 24px 0 0;
    z-index: 2500;
    transform: translateY(100%);
    transition: transform 0.4s var(--ease-out);
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.2);
}

.info-sheet.visible {
    transform: translateY(0);
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px 16px;
    border-bottom: 1px solid var(--gray-100);
    position: relative;
}

.sheet-drag-indicator {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 5px;
    background: var(--gray-300);
    border-radius: 3px;
}

.sheet-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    padding-top: 8px;
}

.sheet-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--gray-100);
    color: var(--gray-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sheet-close:active {
    transform: scale(0.9);
}

.sheet-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px calc(var(--safe-bottom) + 20px);
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 14px;
    color: var(--gray-500);
}

.info-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-900);
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}

/* ========================================
   Loading Overlay
   ======================================== */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s, visibility 0.5s;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    color: var(--white);
}

.loading-logo {
    margin-bottom: 30px;
    animation: logoPulse 2s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--sdis-gold);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

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

.loading-content p {
    font-size: 16px;
    font-weight: 500;
    opacity: 0.8;
}

/* ========================================
   Marker Clusters
   ======================================== */

.marker-cluster {
    background: transparent !important;
}

.marker-cluster div {
    background: linear-gradient(135deg, var(--sdis-red), var(--sdis-red-dark));
    color: white;
    font-weight: 700;
    font-size: 13px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 12px rgba(171, 2, 9, 0.4);
    border: 3px solid var(--sdis-gold);
}

.marker-cluster-small div {
    width: 32px;
    height: 32px;
    font-size: 12px;
}

.marker-cluster-medium div {
    width: 40px;
    height: 40px;
    font-size: 14px;
}

.marker-cluster-large div {
    width: 48px;
    height: 48px;
    font-size: 15px;
}

/* ========================================
   Toast Notifications
   ======================================== */

.toast-notification {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s var(--ease-out);
    max-width: calc(100vw - 40px);
}

.toast-notification.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    background: #10B981;
    color: white;
}

.toast-error .toast-icon {
    background: var(--sdis-red);
    color: white;
}

.toast-info .toast-icon {
    background: var(--sdis-gold);
    color: var(--sdis-red-dark);
}

.toast-message {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-800);
}

/* ========================================
   Location Marker & Animation
   ======================================== */

.location-dot {
    width: 20px;
    height: 20px;
    background: #3B82F6;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.5);
    animation: locationPulse 2s ease-in-out infinite;
}

@keyframes locationPulse {
    0% { 
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 0 15px rgba(59, 130, 246, 0);
        transform: scale(1.05);
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
        transform: scale(1);
    }
}

/* Animation du bouton de géolocalisation */
.top-btn.locating {
    animation: locatingBtn 1.5s ease-in-out infinite;
}

.top-btn.locating svg {
    animation: locatingSpin 1.5s linear infinite;
}

@keyframes locatingBtn {
    0%, 100% { 
        background: var(--glass-bg);
        box-shadow: var(--glass-shadow);
    }
    50% { 
        background: rgba(59, 130, 246, 0.2);
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3);
    }
}

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

/* ========================================
   Leaflet Popup Styling
   ======================================== */

.leaflet-popup-content-wrapper {
    border-radius: 16px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
    padding: 0 !important;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0 !important;
    font-family: inherit !important;
}

.leaflet-popup-tip {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1) !important;
}

.popup-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--gray-100);
}

.popup-content {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--gray-600);
    max-height: 200px;
    overflow-y: auto;
}

.popup-content p {
    margin: 6px 0;
}

.popup-content strong {
    color: var(--gray-900);
}

/* Liste des communes dans les popups DFCI */
.communes-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
}

.commune-tag {
    display: inline-block;
    padding: 4px 10px;
    background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
    color: #1E40AF;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #BFDBFE;
    white-space: nowrap;
}

/* Style pour plusieurs communes (chevauchement) */
.communes-list .commune-tag:nth-child(n+2) {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    color: #92400E;
    border-color: #FCD34D;
}

.popup-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: var(--red-500);
    color: white;
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s;
}

.popup-btn:hover {
    background: var(--red-600);
}

/* ========================================
   iOS Style Location Popup
   ======================================== */

.ios-popup .leaflet-popup-content-wrapper {
    padding: 0 !important;
    border-radius: 20px !important;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25) !important;
}

.ios-popup .leaflet-popup-content {
    margin: 0 !important;
    width: 100% !important;
}

.ios-popup .leaflet-popup-tip {
    background: white;
}

.location-popup {
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
}

.location-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, var(--sdis-red) 0%, var(--sdis-red-dark) 100%);
    color: white;
}

.location-icon {
    width: 44px;
    height: 44px;
    background: var(--sdis-gold);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.location-icon svg {
    filter: none;
}

.location-icon svg circle,
.location-icon svg path {
    stroke: var(--sdis-red-dark);
    fill: none;
}

.location-icon svg circle:first-child {
    fill: var(--sdis-red-dark);
}

.location-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.location-label {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.location-accuracy {
    font-size: 13px;
    opacity: 0.85;
    font-weight: 500;
}

.location-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
    position: relative;
}

.location-card:last-of-type {
    border-bottom: none;
}

.card-icon {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.card-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.card-label {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.card-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
}

.card-value.dfci-code {
    color: var(--sdis-red);
    font-family: 'SF Mono', 'Menlo', monospace;
    letter-spacing: 0.5px;
}

.card-badge {
    background: linear-gradient(135deg, var(--sdis-red), var(--sdis-red-dark));
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.location-card-commune .card-icon {
    background: linear-gradient(135deg, var(--sdis-gold-light), var(--sdis-gold));
}

.location-card-dfci .card-icon {
    background: linear-gradient(135deg, #FFEEBA, var(--sdis-gold));
}

.location-coords {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    background: white;
    border-top: 1px solid var(--gray-100);
}

.coord-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.coord-label {
    font-size: 11px;
    color: var(--gray-400);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.coord-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    font-family: 'SF Mono', 'Menlo', monospace;
}

.coord-divider {
    width: 1px;
    height: 36px;
    background: var(--gray-200);
    margin: 0 8px;
}

.location-copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 18px;
    border: none;
    background: linear-gradient(135deg, var(--sdis-red), var(--sdis-red-dark));
    color: white;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.location-copy-btn:hover {
    background: linear-gradient(135deg, var(--sdis-red-light), var(--sdis-red));
}

.location-copy-btn:active {
    background: var(--sdis-red-dark);
    transform: scale(0.98);
}

.location-copy-btn svg {
    opacity: 0.9;
}

/* ========================================
   Category Headers
   ======================================== */

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    margin-bottom: 8px;
}

.category-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.category-toggle {
    font-size: 12px;
    color: var(--red-500);
    background: none;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

/* ========================================
   Empty State
   ======================================== */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-400);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
}

/* ========================================
   Scrollbar
   ======================================== */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ========================================
   Media Queries
   ======================================== */

@media (min-width: 768px) {
    .bottom-nav {
        left: 50%;
        transform: translateX(-50%);
        max-width: 500px;
        padding: 0 0 12px;
    }
    
    .sliding-panel {
        left: 50%;
        transform: translateX(-50%) translateY(100%);
        max-width: 500px;
        border-radius: 24px 24px 0 0;
    }
    
    .sliding-panel.visible {
        transform: translateX(-50%) translateY(0);
    }
    
    .info-sheet {
        left: 50%;
        transform: translateX(-50%) translateY(100%);
        max-width: 400px;
    }
    
    .info-sheet.visible {
        transform: translateX(-50%) translateY(0);
    }
}

/* ========================================
   Mobile Styles (max-width: 767px)
   ======================================== */

@media (max-width: 767px) {
    /* Top bar - repositionner pour mobile */
    .top-bar {
        top: 10px;
        left: 10px;
        right: 10px;
        gap: 8px;
    }
    
    /* Search pill plus petit sur mobile */
    .search-pill {
        height: 44px;
        padding: 0 12px;
    }
    
    .search-pill input {
        font-size: 16px; /* Empêche le zoom iOS */
    }
    
    /* Bouton localisation sur mobile */
    .top-btn {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
    }
    
    /* Search suggestions - STYLE COMPLET pour mobile */
    .search-suggestions {
        position: fixed !important;
        top: 64px !important;
        left: 10px !important;
        right: 10px !important;
        max-height: calc(100vh - 200px);
        background: white !important;
        border-radius: 16px;
        box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3) !important;
        z-index: 3000 !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .suggestion-group {
        padding: 10px 0;
        background: white;
    }
    
    .suggestion-group-title {
        padding: 10px 16px 8px;
        font-size: 12px;
        font-weight: 700;
        background: white;
    }
    
    .suggestion-item {
        padding: 14px 16px;
        background: white;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .suggestion-item:last-child {
        border-bottom: none;
    }
    
    .suggestion-item:active {
        background: #f5f5f5;
    }
    
    .suggestion-icon {
        width: 40px;
        height: 40px;
        border-radius: 12px;
        font-size: 18px;
    }
    
    .suggestion-title {
        font-size: 15px;
        font-weight: 600;
        color: #1a1a1a;
    }
    
    .suggestion-subtitle {
        font-size: 13px;
        color: #666;
        margin-top: 3px;
    }
    
    .suggestion-badge {
        font-size: 11px;
        padding: 4px 10px;
        border-radius: 12px;
    }
    
    /* Map toggle position for mobile - plus bas */
    .map-toggle {
        top: auto !important;
        bottom: 170px !important;
        right: 10px !important;
        z-index: 900 !important;
    }
    
    /* Zoom controls position for mobile */
    .zoom-controls {
        right: 10px;
        top: auto;
        bottom: 260px;
        transform: none;
        z-index: 900;
    }
    
}

/* ========================================
   Safe Area (iPhone X+) - Mobile only
   ======================================== */

@supports (padding-top: env(safe-area-inset-top)) {
    @media (max-width: 767px) {
        .top-bar {
            top: calc(env(safe-area-inset-top) + 10px);
        }
        
        .search-suggestions {
            top: calc(env(safe-area-inset-top) + 64px) !important;
        }
        
        /* Sur mobile avec notch, garder le map-toggle en bas */
        .map-toggle {
            top: auto !important;
            bottom: 170px;
        }
    }
}

/* ========================================
   Styles pour classe .is-mobile
   (détection JS pour iframe/PWA)
   ======================================== */

body.is-mobile .top-bar {
    top: 10px;
    left: 10px;
    right: 10px;
    gap: 8px;
}

body.is-mobile .search-pill {
    height: 44px;
    padding: 0 12px;
}

body.is-mobile .search-pill input {
    font-size: 16px;
}

body.is-mobile .top-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

body.is-mobile .search-suggestions {
    position: fixed !important;
    top: 64px !important;
    left: 10px !important;
    right: 10px !important;
    max-height: calc(100vh - 200px);
    max-height: calc(100dvh - 200px); /* Dynamic viewport height */
    background: white !important;
    border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3) !important;
    z-index: 3000 !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

body.is-mobile .suggestion-group {
    padding: 10px 0;
    background: white;
}

body.is-mobile .suggestion-group-title {
    padding: 10px 16px 8px;
    font-size: 12px;
    font-weight: 700;
    background: white;
}

body.is-mobile .suggestion-item {
    padding: 14px 16px;
    background: white;
    border-bottom: 1px solid #f0f0f0;
}

body.is-mobile .suggestion-item:last-child {
    border-bottom: none;
}

body.is-mobile .suggestion-item:active {
    background: #f5f5f5;
}

body.is-mobile .suggestion-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 18px;
}

body.is-mobile .suggestion-title {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
}

body.is-mobile .suggestion-subtitle {
    font-size: 13px;
    color: #666;
    margin-top: 3px;
}

body.is-mobile .suggestion-badge {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
}

body.is-mobile .map-toggle {
    top: auto !important;
    bottom: 170px !important;
    right: 10px !important;
    z-index: 900 !important;
}

body.is-mobile .zoom-controls {
    right: 10px;
    top: auto !important;
    bottom: 260px !important;
    transform: none;
    z-index: 900;
}

/* Safe area pour .is-mobile avec notch */
@supports (padding-top: env(safe-area-inset-top)) {
    body.is-mobile .top-bar {
        top: calc(env(safe-area-inset-top) + 10px);
    }
    
    body.is-mobile .search-suggestions {
        top: calc(env(safe-area-inset-top) + 64px) !important;
    }
}

/* ========================================
   Styles spécifiques pour iframe
   ======================================== */

body.is-iframe {
    /* Assure que tout est bien visible dans l'iframe */
    overflow: hidden;
}

body.is-iframe .search-suggestions {
    /* Utilise 100% de la hauteur disponible dans l'iframe */
    max-height: calc(100% - 200px);
}

/* Support écran tactile */
body.is-touch .suggestion-item {
    /* Zone de tap plus grande sur tactile */
    min-height: 56px;
}

body.is-touch .nav-item {
    /* Zone de tap plus grande */
    min-width: 60px;
}

/* ========================================
   Landscape adjustments
   ======================================== */

/* Landscape adjustments */
@media (max-height: 500px) {
    .sliding-panel {
        max-height: 85vh;
    }
    
    .nav-container {
        height: 60px;
    }
    
    .nav-item {
        padding: 6px 12px;
    }
    
    .nav-icon {
        width: 24px;
        height: 24px;
    }
    
    .nav-item span {
        font-size: 10px;
    }
    
    .zoom-controls {
        bottom: 100px;
    }
}
