:root {
    /* PALETTE PREMIUM */
    --primary: #2563eb;
    /* Bleu vibrant */
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;

    --success: #10b981;
    /* Vert émeraude */
    --success-light: #d1fae5;

    --warning: #f59e0b;
    /* Ambre */
    --warning-light: #fef3c7;

    --danger: #ef4444;
    /* Rouge vif */
    --danger-light: #fee2e2;

    --bg-body: #f8fafc;
    /* Gris très clair (Ardoise) */
    --bg-white: #ffffff;
    --bg-sidebar: #ffffff;

    --text-main: #1e293b;
    /* Gris très foncé */
    --text-muted: #64748b;
    /* Gris moyen */
    --text-light: #94a3b8;
    /* Gris clair */

    --border-color: #e2e8f0;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --sidebar-width: 380px;
    --header-height: 60px;

    /* COULEURS STATUTS */
    --color-afaire: #f59e0b;
    --color-encours: #2563eb;
    --color-urgent: #ef4444;
    --color-termine: #10b981;
}

/* RESET & BASE */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    background: var(--bg-body);
    height: 100vh;
    overflow: hidden;
    display: flex;
    font-size: 14px;
}

/* --- SIDEBAR --- */
#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    z-index: 3000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md);
    position: relative;
}

#sidebar.closed {
    transform: translateX(-100%);
    position: absolute;
    height: 100%;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 1.5rem;
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

.sidebar-header small {
    background: var(--primary-light);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.75rem;
}

/* --- CONTROLS --- */
.sidebar-controls {
    padding: 1rem;
    background: var(--bg-body);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-group {
    position: relative;
}

.input-group i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    pointer-events: none;
}

.filter-input,
.filter-select {
    width: 100%;
    padding: 10px 12px 10px 38px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: white;
    color: var(--text-main);
    font-size: 0.9rem;
    transition: all 0.2s;
    outline: none;
}

.filter-select {
    padding-left: 12px;
}

.filter-input:focus,
.filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-input::placeholder {
    color: var(--text-light);
}

.filter-row {
    display: flex;
    gap: 10px;
}

.filter-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
}

.btn-tool {
    padding: 8px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.85rem;
}

.btn-tool:hover {
    background: var(--bg-body);
    color: var(--text-main);
    border-color: #cbd5e1;
}

.btn-tool:active {
    transform: translateY(1px);
}

.btn-tool.active-filter {
    background: var(--success-light);
    border-color: var(--success);
    color: #047857;
}

/* --- LISTE DOSSIERS --- */
#folder-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f1f5f9;
}

.folder-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    border: 1px solid transparent;
    /* Pour la bordure de sélection */
    border-left: 8px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.folder-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.folder-card strong {
    display: block;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 4px;
}

.folder-card small {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.folder-info-row {
    display: flex;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid var(--bg-body);
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 500;
}

/* Indication Statut (Bordure Gauche) */
.card-afaire {
    border-left-color: var(--color-afaire);
}

.card-encours {
    border-left-color: var(--color-encours);
}

.card-urgent {
    border-left-color: var(--color-urgent);
}

.card-termine {
    border-left-color: var(--color-termine);
    opacity: 0.8;
}

/* Selection state */
.folder-card.selected-card {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* --- FOOTER --- */
.sidebar-footer {
    padding: 1rem;
    background: white;
    border-top: 1px solid var(--border-color);
}

summary {
    cursor: pointer;
    padding: 10px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-body);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

summary:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-top: 12px;
}

.btn-data {
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    transition: filter 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn-data:hover {
    filter: brightness(110%);
}

.btn-exp-json {
    background: #475569;
}

.btn-imp-json {
    background: #334155;
}

.btn-exp-csv {
    background: #059669;
}

.btn-imp-csv {
    background: #047857;
}

.btn-sig {
    background: #7c3aed;
    grid-column: span 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* --- MAP AREA --- */
#map-container {
    flex: 1;
    position: relative;
    z-index: 1;
}

#map {
    width: 100%;
    height: 100%;
}

/* Toggle Button */
.btn-toggle-sidebar {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    background: white;
    border-radius: 12px;
    border: none;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-main);
    cursor: pointer;
    z-index: 4000;
    transition: all 0.2s;
}

.btn-toggle-sidebar:hover {
    transform: scale(1.05);
    color: var(--primary);
}

/* Search Bar on Map */
.address-search-wrapper {
    position: absolute;
    top: 20px;
    left: 80px;
    width: 360px;
    z-index: 1000;
}

.search-box {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 4px;
    display: flex;
    align-items: center;
}

.search-box i {
    padding: 0 16px;
    color: var(--text-muted);
}

.search-box input {
    border: none;
    background: transparent;
    flex: 1;
    padding: 10px 0;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    color: var(--text-main);
}

.search-results {
    margin-top: 8px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item:hover {
    background: var(--bg-body);
}

.result-item strong {
    display: block;
    color: var(--text-main);
}

.result-item span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- MODALE --- */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    /* Backdrop blur compatible color */
    backdrop-filter: blur(4px);
    z-index: 5000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-box {
    background: white;
    width: 500px;
    max-width: 100%;
    padding: 30px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-box h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-box label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    margin-bottom: 16px;
    transition: all 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.btn-cancel {
    background: var(--bg-body);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.btn-save {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
}

/* --- MAPLIBRE CUSTOMIZATIONS --- */
.maplibregl-ctrl-group {
    border: none !important;
    box-shadow: var(--shadow-md) !important;
    border-radius: 8px !important;
}

.maplibregl-ctrl-group button {
    width: 36px !important;
    height: 36px !important;
    color: var(--text-main) !important;
}

.maplibregl-ctrl-group button:hover {
    background: #f8fafc !important;
}

/* Custom Toolbar */
.maplibregl-ctrl-top-right {
    top: 10px;
    right: 10px;
}

.mapboxgl-ctrl-group {
    display: none !important;
}

/* On masque la toolbar par défaut du Draw pour utiliser notre bouton custom */

/* Popup Styling — conteneur MapLibre */
.maplibregl-popup-content {
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 0;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    min-width: 210px;
}

.maplibregl-popup-close-button {
    font-size: 1.1rem;
    color: var(--text-muted);
    padding: 4px 8px;
    z-index: 1;
    top: 4px;
    right: 4px;
}

/* --- Carte Popup redesignée --- */
.popup-card {
    border-radius: 10px;
    overflow: hidden;
    background: white;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--border-color);
}

.popup-client {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.3;
}

.popup-ref {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.popup-badge {
    font-size: 0.68rem;
    font-weight: 700;
    color: white;
    padding: 3px 8px;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.popup-actions {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
}

.popup-btn {
    flex: 1;
    padding: 7px 6px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: filter 0.15s, transform 0.1s;
}

.popup-btn:hover {
    filter: brightness(110%);
}

.popup-btn:active {
    transform: scale(0.97);
}

.popup-btn-edit {
    background: var(--primary-light);
    color: var(--primary);
}

.popup-btn-move {
    background: #fef3c7;
    color: #92400e;
}

.popup-nav {
    display: flex;
    gap: 0;
    padding: 8px 10px;
    justify-content: space-between;
}

.popup-nav-link {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    padding: 5px 8px;
    border-radius: 8px;
    transition: background 0.15s;
}

.popup-nav-link:hover {
    background: var(--primary-light);
    text-decoration: none;
}

.popup-sv {
    display: flex;
    justify-content: center;
    width: calc(100% - 20px);
    margin: 0 10px 10px;
    background: #f1f5f9;
    color: var(--text-muted);
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
}

.popup-sv:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

/* --- TOAST --- */
#toast-container {
    position: fixed;
    top: 24px;
    right: 80px;
    /* Decalé pour ne pas masquer les boutons map */
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    background: white;
    color: var(--text-main);
    padding: 14px 20px;
    border-radius: 10px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    border-left: 5px solid #ccc;
    transform: translateX(50px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.success i {
    color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.error i {
    color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast.warning i {
    color: var(--warning);
}

.toast.info {
    border-left-color: var(--primary);
}

.toast.info i {
    color: var(--primary);
}


/* --- BOTTOM ACTION BAR --- */
#multi-action-bar {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: white;
    padding: 8px 12px 8px 20px;
    border-radius: 100px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    display: none;
    align-items: center;
    gap: 16px;
    animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.btn-multi-route {
    background: var(--success);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 100px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
}

.btn-clear-sel {
    background: rgba(255, 255, 255, 0.2);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

body.dark-mode #multi-action-bar {
    background: var(--bg-body) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
}

#multi-action-bar {
    box-shadow: 0 0 12px 2px rgba(255, 255, 255, 0.8), var(--shadow-lg) !important;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.btn-active-tool {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5) !important;
    border-color: #3b82f6 !important;
    background-color: var(--primary-light) !important;
}

/* Override Mapbox Draw colors to make them visible in satellite mode */
.mapboxgl-canvas-container.mapboxgl-interactive,
.mapboxgl-ctrl-group {
    /* Forcer le curseur de base partout où draw pourrait l'écraser */
    cursor: default !important;
}

/* On mapbox-gl-draw specific SVG elements if generated outside Canvas */
path.mapboxgl-draw-polygon,
.mapboxgl-draw-polygon {
    stroke: #3b82f6 !important;
    stroke-width: 4px !important;
    fill: rgba(59, 130, 246, 0.4) !important;
}

circle.mapbox-gl-draw-vertex {
    fill: #3b82f6 !important;
    stroke: #ffffff !important;
}

.btn-clear-sel:hover {
    background: rgba(255, 255, 255, 0.3);
}

.badge-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
}

#multi-action-bar .btn-data.btn-sig,
#multi-action-bar .btn-multi-route {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    font-size: 1.1rem;
}

#multi-action-bar .btn-multi-route {
    background: var(--success);
}

#multi-action-bar .btn-data.btn-sig {
    margin-left: 0 !important;
    background: var(--primary);
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    #sidebar {
        position: absolute;
        height: 100%;
        width: 100%;
        max-width: none;
        z-index: 5000;
        /* Au-dessus de tout sur mobile */
    }

    .btn-close-sidebar {
        display: flex !important;
    }

    .address-search-wrapper {
        top: 80px;
        left: 16px;
        width: calc(100% - 70px);
    }

    .search-results {
        max-height: 200px;
    }

    .btn-toggle-sidebar {
        top: 16px;
        left: 16px;
    }

    #multi-action-bar {
        bottom: 90px;
        width: 90%;
        justify-content: space-between;
    }

    .sidebar-footer {
        display: none !important;
    }
}

/* --- IMPORT PREVIEW MODAL --- */
#import-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 6000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.import-preview-box {
    background: white;
    width: 720px;
    max-width: 100%;
    max-height: 85vh;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: modalSlide 0.3s ease-out;
}

.import-preview-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-color);
}

.import-preview-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-main);
}

.import-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.import-stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.stat-new {
    background: #d1fae5;
    color: #065f46;
}

.stat-update {
    background: #fef3c7;
    color: #92400e;
}

.stat-skip {
    background: #fee2e2;
    color: #991b1b;
}

.import-table-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.import-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: transparent;
}

.import-table th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    padding: 10px 15px;
    text-align: left;
    font-weight: 600;
    color: #334155;
    border-bottom: 2px solid #cbd5e1;
    white-space: nowrap;
    z-index: 10;
}

.import-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #e2e8f0;
    color: var(--text-main);
}

.import-table tr:last-child td {
    border-bottom: none;
}

.import-table .row-new {
    background-color: rgba(16, 185, 129, 0.1);
}

.import-table .row-update {
    background-color: rgba(245, 158, 11, 0.1);
}

.import-table .row-identical {
    background-color: rgba(148, 163, 184, 0.1);
}

.import-table .row-skip {
    background-color: rgba(239, 68, 68, 0.1);
    opacity: 0.8;
}

body.dark-mode .import-table th {
    background: var(--bg-sidebar);
    color: var(--text-muted);
    border-bottom-color: var(--border-color);
}

body.dark-mode .import-table td {
    border-bottom-color: var(--border-color);
}

body.dark-mode .import-table .row-new {
    background-color: rgba(16, 185, 129, 0.15);
}

body.dark-mode .import-table .row-update {
    background-color: rgba(245, 158, 11, 0.15);
}

body.dark-mode .import-table .row-identical {
    background-color: rgba(148, 163, 184, 0.15);
}

body.dark-mode .import-table .row-skip {
    background-color: rgba(239, 68, 68, 0.15);
}

.import-table .badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-new {
    background: #10b981;
    color: white;
}

.badge-update {
    background: #f59e0b;
    color: white;
}

.badge-identical {
    background: #94a3b8;
    color: white;
}

.badge-skip {
    background: #ef4444;
    color: white;
}

.import-actions {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.import-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: filter 0.2s;
}

.import-actions button:hover {
    filter: brightness(110%);
}

.btn-import-all {
    background: var(--primary);
    color: white;
}

.btn-import-new {
    background: var(--success);
    color: white;
}

.btn-import-cancel {
    background: var(--bg-body);
    color: var(--text-main);
    border: 1px solid var(--border-color) !important;
}

/* Close Sidebar Button (Mobile Only by default) */
.btn-close-sidebar {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-close-sidebar:hover {
    background: #f1f5f9;
    color: var(--danger);
}

/* Markers Custom (Legacy - kept for reference if needed) */
/* .custom-pin i { font-size: 32px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); transition: transform 0.2s; } */
/* .custom-pin.selected-pin i { color: var(--warning) !important; transform: scale(1.2) translateY(-5px); } */

/* =========================================
   DATA DRAWER (TABLEUR)
   ========================================= */

#data-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60vh;
    /* Prend 60% de l'écran par défaut */
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transform: translateY(100%);
    /* Caché par défaut */
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

#data-drawer:not(.data-drawer-closed) {
    transform: translateY(0);
}

.data-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid #e2e8f0;
}

.btn-close-drawer {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #64748b;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
}

.btn-close-drawer:hover {
    color: var(--color-urgent);
}

.data-drawer-content {
    flex: 1;
    overflow: hidden;
    padding: 0;
    position: relative;
}

.table-container {
    height: 100%;
    overflow-y: auto;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: white;
}

.data-table thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    color: #334155;
    font-weight: 600;
    padding: 10px 15px;
    text-align: left;
    border-bottom: 2px solid #cbd5e1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 10;
    cursor: pointer;
    white-space: nowrap;
}

.data-table thead th.sortable:hover {
    background: #f1f5f9;
}

.data-table thead th i {
    margin-left: 5px;
    color: #94a3b8;
    font-size: 0.8rem;
}

.table-filter {
    width: 100%;
    margin-top: 8px;
    padding: 4px 8px;
    font-size: 0.8rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-family: inherit;
    font-weight: normal;
}

.table-filter:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.data-table tbody tr {
    border-bottom: 1px solid #e2e8f0;
    transition: background-color 0.15s ease;
    cursor: pointer;
}

.data-table tbody tr:hover {
    background-color: #f1f5f9;
}

.data-table tbody td {
    padding: 10px 15px;
    color: #475569;
}

.table-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Modificateurs de taille de colonne */
.col-client {
    min-width: 150px;
    font-weight: 500;
    color: #1e293b !important;
}

.col-ref {
    min-width: 100px;
}

.col-ville {
    min-width: 120px;
}

.col-cp {
    min-width: 80px;
}

.col-statut {
    min-width: 110px;
}

.col-charge {
    min-width: 130px;
}

/* Responsive mobile */
@media (max-width: 768px) {
    #data-drawer {
        height: 85vh;
        /* Plus grand sur mobile */
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table thead th,
    .data-table tbody td {
        padding: 8px 10px;
    }
}

/* =========================================
   DASHBOARD OVERLAY
   ========================================= */

#dashboard-overlay {
    position: fixed;
    top: 50px;
    /* Se positionne à droite de la sidebar ouverte */
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    height: calc(100vh - 50px);
    background: #f8fafc;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center; /* Centre le contenu horizontalement */
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

/* Quand la sidebar est fermée, le dashboard prend tout l'écran */
body.sidebar-closed #dashboard-overlay {
    left: 0;
    width: 100%;
}

#dashboard-overlay.dashboard-open {
    transform: translateY(0);
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.dashboard-header h2 {
    margin: 0;
    color: var(--primary);
    font-size: 1.5rem;
}

.dashboard-content {
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.dashboard-kpi-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    text-align: center;
    border-top: 4px solid var(--color-primary);
}

.kpi-title {
    font-size: 0.9rem;
    color: #64748b;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 10px;
}

.kpi-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1e293b;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}

.chart-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.chart-container h3 {
    margin-top: 0;
    color: #334155;
    font-size: 1.1rem;
    margin-bottom: 20px;
    text-align: center;
}

/* Rendre le canvas responsive dans son conteneur */
.chart-container canvas {
    width: 100% !important;
    max-height: 400px;
}

@media (max-width: 768px) {
    #dashboard-overlay {
        display: none !important;
        /* Pas de dashboard sur petit écran */
    }
}

/* --- DARK MODE --- */
body.dark-mode {
    --bg-body: #0f172a;
    --bg-white: #1e293b;
    --bg-sidebar: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
    --text-light: #94a3b8;
    --border-color: #334155;
    --primary-light: #1e3a8a;
    --success-light: #064e3b;
    --warning-light: #78350f;
    --danger-light: #7f1d1d;
}

body.dark-mode .sidebar-header,
body.dark-mode .filter-input,
body.dark-mode .filter-select,
body.dark-mode .btn-tool,
body.dark-mode .folder-card,
body.dark-mode .sidebar-footer,
body.dark-mode .btn-toggle-sidebar,
body.dark-mode .search-box,
body.dark-mode .search-results,
body.dark-mode .modal-box,
body.dark-mode .toast,
body.dark-mode .maplibregl-ctrl-group,
body.dark-mode .import-preview-box,
body.dark-mode .data-drawer-content,
body.dark-mode .data-drawer-header,
body.dark-mode .dashboard-content,
body.dark-mode .dashboard-header {
    background: var(--bg-white);
    color: var(--text-main);
}

body.dark-mode .maplibregl-ctrl-group button span.maplibregl-ctrl-icon {
    filter: invert(100%) hue-rotate(180deg) brightness(150%);
}

body.dark-mode .maplibregl-popup-content {
    background: var(--bg-white);
    color: var(--text-main);
}

body.dark-mode .maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
    border-top-color: var(--bg-white);
}

body.dark-mode .folder-card {
    border: 1px solid var(--border-color);
    border-left-width: 8px;
}

body.dark-mode .folder-card.selected-card {
    border-color: var(--primary);
    background: var(--primary-light);
}

body.dark-mode .folder-card.card-afaire {
    border-left-color: var(--color-afaire);
}

body.dark-mode .folder-card.card-encours {
    border-left-color: var(--color-encours);
}

body.dark-mode .folder-card.card-urgent {
    border-left-color: var(--color-urgent);
}

body.dark-mode .folder-card.card-termine {
    border-left-color: var(--color-termine);
}

body.dark-mode #folder-list {
    /* Fond de la liste un peu moins foncé (ou légèrement différent) pour contraster avec les dossiers */
    background: #0f172a;
}

/* =============================================
   AUTHENTIFICATION — OVERLAY DE CONNEXION
   ============================================= */

#auth-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: authFadeIn 0.4s ease-out;
}

@keyframes authFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.auth-overlay-fadeout {
    animation: authFadeOut 0.5s ease-in forwards !important;
}

@keyframes authFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

#login-card {
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    padding: 48px 40px;
    width: 420px;
    max-width: 92vw;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    animation: loginCardIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes loginCardIn {
    from {
        transform: translateY(30px) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes loginShake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-10px);
    }

    40% {
        transform: translateX(10px);
    }

    60% {
        transform: translateX(-6px);
    }

    80% {
        transform: translateX(6px);
    }
}

.login-shake {
    animation: loginShake 0.5s ease-in-out !important;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: white;
    margin: 0 auto 20px;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4);
}

.login-title {
    text-align: center;
    color: #f1f5f9;
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
}

.login-subtitle {
    text-align: center;
    color: #94a3b8;
    font-size: 0.9rem;
    margin-bottom: 32px;
}

.login-field {
    position: relative;
    margin-bottom: 16px;
}

.login-field i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 0.95rem;
    pointer-events: none;
    transition: color 0.2s;
}

.login-field input {
    width: 100%;
    padding: 14px 14px 14px 44px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    color: #f1f5f9;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.login-field input::placeholder {
    color: #475569;
}

.login-field input:focus {
    border-color: rgba(59, 130, 246, 0.6);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.login-field input:focus+i,
.login-field:focus-within i {
    color: #3b82f6;
}

.login-error {
    color: #f87171;
    font-size: 0.85rem;
    text-align: center;
    min-height: 20px;
    margin-bottom: 12px;
    font-weight: 500;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
    letter-spacing: 0.01em;
}

.login-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.login-btn:active:not(:disabled) {
    transform: translateY(0);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Infos utilisateur & Déconnexion dans la sidebar --- */
.auth-user-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
    max-width: 120px;
    overflow: hidden;
}

.auth-user-info i {
    color: var(--primary);
    font-size: 1rem;
    flex-shrink: 0;
}

.auth-user-info span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    width: 32px;
    height: 32px;
    background: var(--danger-light);
    border: 1px solid #fca5a5;
    border-radius: 8px;
    color: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.btn-logout:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    transform: scale(1.05);
}

@media (max-width: 768px) {
    #login-card {
        padding: 36px 24px;
    }

    .auth-user-info span {
        display: none;
    }
}