/* ===== LEAFLET EXTENSIONS FOR MODERN UI ===== */

/* Custom layers control styling */
.leaflet-control-layers {
    position: relative !important;
}

.leaflet-control-layers-toggle {
    display: none;
}

/* Map panes adjustments */
.leaflet-pane {
    z-index: inherit;
}

/* Measurement control styling */
.leaflet-control-measure {
    margin: 0 !important;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%) !important;
    border: none !important;
    border-radius: 4px !important;
}

.leaflet-control-measure-toggle {
    background: transparent !important;
    color: white !important;
}

/* Locate control styling */
.leaflet-control-locate {
    margin: 0 !important;
}

.leaflet-control-locate a {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%) !important;
    color: white !important;
    border-radius: 4px !important;
}

/* Zoom control styling */
.leaflet-control-zoom {
    border: none !important;
    border-radius: 4px !important;
    background: transparent !important;
    margin: 0 !important;
}

.leaflet-control-zoom a {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%) !important;
    border: none !important;
    color: white !important;
    border-radius: 2px !important;
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    text-align: center !important;
    margin-bottom: 5px !important;
}

.leaflet-control-zoom a:hover {
    background: #1a2d5c !important;
}

/* Attribution control */
.leaflet-control-attribution {
    font-size: 11px !important;
    background: rgba(255, 255, 255, 0.8) !important;
    border-radius: 4px !important;
}

/* Popup styling */
.leaflet-popup-content-wrapper {
    border-radius: 6px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.leaflet-popup-content {
    font-size: 13px !important;
    margin: 0 !important;
}

.leaflet-popup-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.leaflet-popup-content table tr {
    border-bottom: 1px solid #e0e0e0;
}

.leaflet-popup-content table tr:last-child {
    border-bottom: none;
}

.leaflet-popup-content table th,
.leaflet-popup-content table td {
    padding: 6px;
    text-align: left;
    color: #333;
}

.leaflet-popup-content table th {
    font-weight: 600;
    color: #1e3c72;
    background: #f5f5f5;
}

/* Tooltip styling */
.leaflet-tooltip {
    background: rgba(0, 0, 0, 0.8) !important;
    color: white !important;
    border: none !important;
    border-radius: 4px !important;
    padding: 4px 8px !important;
    font-size: 12px !important;
}

/* Search control styling */
.leaflet-control-search {
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

/* Marker cluster styling */
.marker-cluster {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%) !important;
}

.marker-cluster div {
    background: rgba(255, 255, 255, 0.9) !important;
    color: #1e3c72 !important;
}

/* ===== CUSTOM TOOLBAR ===== */
.map-toolbar {
    position: absolute;
    bottom: 40px;
    left: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 98;
}

.map-toolbar-btn {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border: none;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    tooltip: attr(data-tooltip);
}

.map-toolbar-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #2a5298 0%, #1e3c72 100%);
}

/* ===== LEGEND STYLING ===== */
.legend-container {
    padding: 15px 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 8px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.legend-item:hover {
    background-color: #f5f5f5;
}

.legend-icon {
    width: 30px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid #999;
}

.legend-label {
    font-size: 12px;
    color: #333;
    flex: 1;
}

/* ===== LOADING SPINNER ===== */
.spinner {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3000;
}

.spinner.show {
    display: block;
}

.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 2999;
    display: none;
}

.spinner-overlay.show {
    display: block;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    bottom: 50px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 4px solid #28a745;
}

.toast.error {
    border-left: 4px solid #dc3545;
}

.toast.info {
    border-left: 4px solid #17a2b8;
}

.toast.warning {
    border-left: 4px solid #ffc107;
}

.toast-icon {
    font-size: 18px;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.toast-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #999;
    transition: all 0.2s ease;
}

.toast-close:hover {
    color: #333;
}

/* ===== CUSTOM TOOLTIPS FOR LAYERS ===== */

/* Tooltips générales */
.leaflet-tooltip {
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    z-index: 500;
}

.leaflet-tooltip-top:before {
    border-top-color: rgba(0, 0, 0, 0.8);
}

.leaflet-tooltip-bottom:before {
    border-bottom-color: rgba(0, 0, 0, 0.8);
}

/* Tooltip pour les régions */
.leaflet-tooltip-region {
    background-color: rgba(90, 240, 21, 0.9);
    color: #000;
    font-weight: bold;
    border: 2px solid rgba(90, 240, 21, 1);
}

.leaflet-tooltip-region:before {
    border-top-color: rgba(90, 240, 21, 0.9);
}

/* Tooltip pour les départements */
.leaflet-tooltip-departement {
    background-color: rgba(228, 26, 28, 0.9);
    color: white;
    font-weight: bold;
    border: 2px solid rgba(228, 26, 28, 1);
}

.leaflet-tooltip-departement:before {
    border-top-color: rgba(228, 26, 28, 0.9);
}

/* Tooltip pour les arrondissements */
.leaflet-tooltip-arrondissement {
    background-color: rgba(74, 153, 175, 0.9);
    color: white;
    font-weight: bold;
    border: 2px solid rgba(74, 153, 175, 1);
}

.leaflet-tooltip-arrondissement:before {
    border-top-color: rgba(74, 153, 175, 0.9);
}

/* Tooltip pour les localités */
.leaflet-tooltip-localites {
    background-color: rgba(141, 90, 153, 0.9);
    color: white;
    font-weight: bold;
    border: 2px solid rgba(141, 90, 153, 1);
}

.leaflet-tooltip-localites:before {
    border-top-color: rgba(141, 90, 153, 0.9);
}

/* ===== RESPONSIVE: mobile / small screens ===== */
@media (max-width: 768px) {
    /* Hide side panels by default to maximize map area */
    .left-panel,
    .right-panel {
        display: none !important;
        position: fixed;
        top: 0;
        bottom: 0;
        width: 320px;
        background: #ffffff;
        z-index: 2200;
        box-shadow: 0 6px 18px rgba(0,0,0,0.25);
        overflow: auto;
    }

    /* Allow panels to be shown when a JS toggle adds an "open" class */
    .left-panel.open,
    .right-panel.open {
        display: block !important;
    }

    /* Make main container and map take full width */
    .container {
        display: block;
    }

    .map-container {
        margin: 0;
        width: 100%;
        height: calc(100vh - 56px); /* leave space for nav */
    }

    /* Show small toggle buttons on top of the map */
    .toggle-left-btn,
    .toggle-right-btn {
        display: inline-flex !important;
        position: fixed;
        top: 12px;
        z-index: 2300;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
        background: rgba(255,255,255,0.95);
        box-shadow: 0 4px 12px rgba(0,0,0,0.18);
        border: none;
        cursor: pointer;
    }

    .toggle-left-btn { left: 10px; }
    .toggle-right-btn { right: 10px; }

    .toggle-left-btn i, .toggle-right-btn i {
        color: #2b5d6f;
        font-size: 18px;
    }

    /* Reduce nav items on mobile to avoid overflow */
    nav .nav-menu { display: none; }
    nav .nav-right .search-bar { display: none; }

    /* Ensure toolbars and floating controls remain accessible */
    .map-toolbar { left: 10px; bottom: 80px; }
}

/* Pulsating GPS marker */
.gps-marker {
  width: 18px;
  height: 18px;
  background-color: #1a73e8;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.9);
    box-shadow: 0 0 0 0 rgba(26, 115, 232, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 15px rgba(26, 115, 232, 0);
  }
  100% {
    transform: scale(0.9);
    box-shadow: 0 0 0 0 rgba(26, 115, 232, 0);
  }
}
