:root {
    /* Couleurs principales sombres (Header / Footer) */
    --header-bg: #020617; /* Noir bleuté très profond */
    --footer-bg: #0f172a; /* Bleu marine foncé */
    --text-light: #f1f5f9; /* Blanc cassé pour lisibilité */
    
    /* Couleurs de contenu */
    --bg-main: #f8fafc; 
    --accent: #3b82f6; 
    --accent-light: #eff6ff; 
    --text-dark: #1e293b; 
    --text-muted: #64748b;
    --border-color: #e2e8f0; 
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, sans-serif; }

/* =========================================
   PAGE DE CONNEXION
========================================= */
body.login-mode { background-color: #0f172a; display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: white; border-radius: 16px; text-align: center; }
.login-subtitle { color: #64748b; margin-bottom: 25px; }
.login-input { width: 100%; border: 2px solid #e2e8f0; border-radius: 8px; box-sizing: border-box; padding: 18px; margin-bottom: 20px; outline:none; transition: 0.2s; font-size: 16px;}
.login-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.login-btn { width: 100%; background-color: #3b82f6; color: white; border: none; border-radius: 8px; padding: 18px; font-weight: bold; cursor: pointer; transition: 0.2s; font-size: 1.2rem;}
.login-btn:hover { background-color: #2563eb; }
.error-msg { color: #ef4444; font-size: 0.9rem; margin-bottom: 15px; font-weight: bold; }

@media (min-width: 751px) { .login-card { padding: 40px; box-shadow: 0 20px 40px rgba(0,0,0,0.3); width: 450px; } .login-card h2 { font-size: 1.4rem; margin-top:0;} }
@media (max-width: 750px) { .login-card { width: 85%; padding: 30px 20px; } .login-card h2 { font-size: 1.4rem; margin-top:0;} }

/* =========================================
   TABLEAU DE BORD (DASHBOARD)
========================================= */
body.dashboard-mode { 
    background-color: #f4f7f9;
    color: var(--text-dark); 
    min-height: 100dvh;
    margin: 0;
}
#sidebar { display: none !important; }

#main-content { width: 100%; }

/* --- HEADER SOMBRE ET ÉLÉGANT --- */
.top-navbar { 
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--header-bg); 
    color: var(--text-light);
    padding: 15px 30px; 
    border-bottom: 2px solid var(--accent); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-shrink: 0; 
    gap: 20px;
    flex-wrap: wrap;
}

.navbar-left { display: flex; align-items: center; gap: 30px; }
.navbar-left h1 { font-size: 1.5rem; font-weight: 700; color: var(--text-light); margin: 0; white-space: nowrap; }

/* Onglets adaptés au fond sombre */
.navbar-tabs { display: flex; background-color: #1e293b; border-radius: 12px; padding: 5px; border: 1px solid #334155; }
.tab-btn { padding: 8px 20px; background: transparent; border: none; color: #94a3b8; font-size: 0.95rem; font-weight: 600; cursor: pointer; border-radius: 8px; transition: all 0.3s ease; }
.tab-btn:hover { color: var(--text-light); }
.tab-btn.active { color: white; background-color: var(--accent); box-shadow: 0 2px 4px rgba(0,0,0,0.2); }

/* Barre de recherche mode nuit */
.navbar-center { flex-grow: 1; max-width: 600px; min-width: 250px; }
.search-input { width: 100%; padding: 10px 20px; background-color: #0f172a; border: 1px solid #334155; border-radius: 8px; color: var(--text-light); font-size: 0.95rem; outline: none; transition: 0.2s; }
.search-input::placeholder { color: #64748b; }
.search-input:focus { border-color: var(--accent); background-color: #1e293b; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }

/* Boutons d'action adaptés au header sombre */
.navbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nav-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 15px; border-radius: 8px; font-size: 0.85rem; font-weight: 600; cursor: pointer; text-decoration: none; transition: all 0.2s; border: 1px solid transparent; white-space: nowrap; color: var(--text-light); }

.btn-nouveautes { background: #1e293b; border-color: #334155; }
.btn-nouveautes:hover { background: #334155; }
.btn-contact { background: #9a3412; color: #fff7ed; border-color: #c2410c; }
.btn-contact:hover { background: #c2410c; }
.btn-admin { background: #1e3a8a; color: #eff6ff; border-color: #1e40af; }
.btn-admin:hover { background: #1e40af; }
.btn-neutral { background: #1e293b; border-color: #334155; }
.btn-neutral:hover { background: #334155; }
.btn-danger { background: #7f1d1d; color: #fef2f2; border-color: #991b1b; }
.btn-danger:hover { background: #991b1b; }

/* --- CORPS DE PAGE ET RÉSULTATS --- */
.content-body { 
    padding: 30px; 
    padding-bottom: 100px; 
    max-width: 1400px; 
    margin: 0 auto; 
    width: 100%; 
}
.card { background: white; border-radius: 12px; border: 1px solid var(--border-color); box-shadow: var(--card-shadow); overflow-x: auto; margin-bottom: 24px; }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 80px 40px; color: var(--text-muted); }

.list-card { background: white; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px; display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 12px; transition: border-color 0.2s, box-shadow 0.2s; }
.list-card:hover { border-color: #cbd5e1; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.card-main { flex: 2; }
.card-middle { flex: 1; text-align: center; }
.card-right { flex: 1; display: flex; justify-content: flex-end; }
.card-title { margin: 0; color: #0f172a; font-size: 1.15rem; font-weight: 400; display: flex; align-items: center; gap: 8px; }
.card-subtitle { color: #64748b; font-size: 0.95rem; display: flex; align-items: flex-start; gap: 8px; }
.card-badge { display: inline-block; background: #f1f5f9; color: #475569; padding: 4px 12px; border-radius: 20px; font-size: 0.85rem; font-weight: 400; border: 1px solid #e2e8f0; }

.gps-badge { display: inline-flex; align-items: center; gap: 6px; background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; padding: 8px 15px; border-radius: 8px; font-family: monospace; font-size: 0.95rem; font-weight: 400; text-decoration: none; white-space: nowrap; transition: 0.2s; }
.gps-badge:hover { background: #dbeafe; color: #1d4ed8; }

.pagination { display: flex; justify-content: center; align-items: center; padding: 20px; background: #f8fafc; border-top: 1px solid var(--border-color); gap: 15px; border-radius: 0 0 12px 12px;}
.pagination button { padding: 8px 16px; background-color: white; border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-dark); cursor: pointer; font-weight: 600; transition: 0.2s; }
.pagination button:hover:not(:disabled) { background-color: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; background-color: #f1f5f9; }
.pagination span { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; }

/* --- FOOTER FIXE --- */
.dashboard-footer { 
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background-color: var(--footer-bg); 
    color: #94a3b8; 
    padding: 20px 40px; 
    border-top: 1px solid #1e293b; 
    display: flex; 
    justify-content: space-between; 
    font-size: 0.85rem; 
}
.footer-restrict { background-color: #7f1d1d; color: #fef2f2; padding: 4px 10px; border-radius: 4px; font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 1080px) {
    .top-navbar { flex-direction: column; align-items: stretch; padding: 15px; gap: 15px; }
    .navbar-left { justify-content: space-between; width: 100%; flex-wrap: wrap; gap: 10px; }
    .navbar-center { max-width: 100%; }
    .navbar-right { justify-content: flex-start; width: 100%; overflow-x: auto; padding-bottom: 4px; padding-top: 4px; }
    .content-body {
        padding: 15px;
        padding-bottom: 130px; 
    }
    .dashboard-footer { 
        padding: 15px; 
        flex-direction: column; 
        align-items: center; 
        gap: 10px; 
        text-align: center; 
    }
    .pagination { flex-direction: column; gap: 10px; }
    .pagination button { width: 100%; }
    .list-card { flex-direction: column; align-items: flex-start; gap: 15px; padding: 20px 15px; }
    .card-main, .card-middle, .card-right { flex: none; width: 100%; text-align: left !important; justify-content: flex-start !important; }
    #map-container {
        position: sticky !important;
        top: 60px; 
        height: 48vh !important;
        z-index: 10;
        pointer-events: none; 
    }

    #table-container {
        margin-top: 10px;
        background: white;
        position: relative;
        z-index: 5;
    }
}

@media (max-width: 768px) {
    .admin-data-grid { grid-template-columns: 1fr !important; }
}

/* --- MODALES --- */
.modal { position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(15, 23, 42, 0.7); backdrop-filter: blur(4px); align-items: center; justify-content: center; display:none; }
.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 700px; 
    height: 70vh;    
    display: flex;
    flex-direction: column; 
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow-y: auto; 
    overflow-x: hidden;
}
.modal-content::-webkit-scrollbar { width: 8px; }
.modal-content::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 10px; }

.close-btn { position: absolute; right: 20px; top: 15px; font-size: 28px; cursor: pointer; color: #94a3b8; transition: 0.2s; }
.close-btn:hover { color: #ef4444; }
.success-msg { color: #16a34a; font-size: 0.9rem; margin-bottom: 15px; font-weight: bold; background: #dcfce3; padding: 10px; border-radius: 6px; }

.notif-dot { animation: pulse-notif 2s infinite; }
@keyframes pulse-notif { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); } 70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }

/* ONGLETS ADMINISTRATION & MESSAGERIE */
.admin-nav { display: flex; gap: 5px; margin-bottom: 25px; background: #f1f5f9; padding: 5px; border-radius: 12px; overflow-x: auto; }
.admin-tab-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 15px; font-size: 0.85rem; font-weight: 600; color: #64748b; background: none; border: none; border-radius: 8px; cursor: pointer; transition: all 0.3s ease; white-space: nowrap; }
.admin-tab-btn:hover { background: rgba(255,255,255,0.5); color: #2563eb; }
.admin-tab-btn.active { background: #fff; color: #2563eb; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
.tab-badge { background: #ef4444; color: white; font-size: 0.7rem; padding: 2px 6px; border-radius: 10px; min-width: 18px; text-align: center; }

.admin-tab-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    display: none;
}
.admin-tab-content.active { display: block !important; }

/* --- CLASSES POUR L'ONGLET DONNÉES --- */
.admin-data-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.admin-form-box { background: #f1f5f9; padding: 15px; border-radius: 10px; margin-bottom: 15px; }
.admin-list-box { max-height: 350px; overflow-y: auto; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px; }
.admin-list-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
.admin-btn-delete { background: #fee2e2; color: #ef4444; border: none; padding: 4px 8px; border-radius: 5px; cursor: pointer; font-size: 0.7rem; font-weight: bold; }
.admin-btn-delete:hover { background: #fca5a5; }

.msg-bubble { background: white; border: 1px solid #e2e8f0; border-radius: 12px; padding: 15px; margin-bottom: 12px; transition: border-color 0.2s; }
.msg-bubble:hover { border-color: #cbd5e1; }
.msg-header { display: flex; justify-content: space-between; margin-bottom: 10px; border-bottom: 1px solid #f1f5f9; padding-bottom: 5px; }

/* Alertes Toast */
.toast-msg {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #10b981;
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.2);
    z-index: 10000;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s ease-in-out;
}
.toast-msg.show {
    opacity: 1;
    visibility: visible;
}

/* Bannière de bienvenue */
.welcome-banner {
    background: #eff6ff; 
    border-left: 4px solid #3b82f6; 
    padding: 20px; 
    border-radius: 0 12px 12px 0; 
    margin-bottom: 30px; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.welcome-banner h3 {
    margin: 0 0 6px 0; 
    color: #1e3a8a; 
    font-size: 1.25rem; 
    display: flex; 
    align-items: center; 
    gap: 8px;
}
.welcome-banner p {
    margin: 0; 
    color: #1e40af; 
    font-size: 0.95rem; 
    line-height: 1.4;
}
.welcome-text {
    line-height: 1.6; 
    font-size: 1.05rem; 
    color: #334155; 
    white-space: pre-wrap;
}

/* --- BARRE DE RECHERCHE & BOUTON CLEAR --- */
.search-wrapper { position: relative; width: 100%; display: flex; align-items: center; }
.search-clear-btn { 
    position: absolute; right: 15px; 
    cursor: pointer; color: #64748b; 
    display: none; font-size: 1.2rem; 
    transition: 0.2s; 
}
.search-clear-btn:hover { color: #ef4444; }

/* La modale d'administration */
#admin-modal {
    z-index: 1000;
    position: fixed; 
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Les modales d'édition / notes au premier plan */
#edit-user-modal, #edit-contact-modal, #edit-poi-modal, #notes-modal {
    z-index: 2000; 
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); 
    display: flex;
    justify-content: center;
    align-items: center;
}

/* =========================================
   MODE IMPRESSION (FICHE TERRAIN PDF)
========================================= */
#print-area { display: none; }

@media print {
    /* On cache toute l'interface classique (boutons, barres, menus, etc) */
    body > * { display: none !important; }
    
    /* On n'affiche QUE notre zone d'impression */
    #print-area { 
        display: block !important; 
        position: absolute; 
        left: 0; top: 0; 
        width: 100%; 
        padding: 20px; 
    }
    
    #print-area * { 
        display: block; 
        visibility: visible; 
    }

    body { 
        background: white; 
        color: black; 
        margin: 0; 
    }

    /* Enlève les marges automatiques du navigateur pour le PDF */
    @page { 
        margin: 1.5cm; 
        size: A4 portrait;
    }
}