/* ========== 1. VARIABLES & CONFIGURATION ========== */
:root {
    --cfl-green: #386918;
    --cfl-green-hover: #2a5012;
    --admin-bg: #1e293b;        
    --sidebar-bg: #0f172a;      /* Sombre pour le look Admin */
    --card-bg: #ffffff;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --sidebar-width: 260px;
}

/* ========== 2. STYLES GLOBAUX ========== */
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background-color: #A9A9A9; 
    color: var(--text-main);
    margin: 0;
    padding: 0;
    transition: background 0.3s;
}

body.admin-logged {
    background-color: var(--admin-bg) !important;
    text-align: left;
}

.is-pc:not(.admin-logged), .app-hero-header {
    text-align: center;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/*============Carte Leaflet==========*/
.leaflet-tile-container {
    opacity: 1 !important;
}
.leaflet-container {
    background: #ddd !important; /* Pour voir si le conteneur est au moins là */
}

/* ========== 3. SIDEBAR (LOOK ADMIN) ========== */
.admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #0b1220 0%, #111827 48%, #0f172a 100%);
    z-index: 9999;
    display: none;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

body.admin-logged .admin-sidebar {
    display: flex;
}

.sidebar-header {
    flex-shrink: 0;
    padding: 18px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
}

.sidebar-brand img {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.sidebar-brand-title {
    color: #f8fafc !important;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.sidebar-brand-sub {
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 2px;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 10px 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
}

.menu-group {
    margin-bottom: 6px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.menu-group-external {
    background: rgba(56, 105, 24, 0.08);
    border-color: rgba(56, 105, 24, 0.22);
}

.menu-group-title {
    list-style: none;
    cursor: pointer;
    padding: 11px 12px;
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 700;
    color: #cbd5e1;
    letter-spacing: 0.08em;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: background 0.2s ease, color 0.2s ease;
}

.menu-group-title::-webkit-details-marker,
.menu-group-title::marker {
    display: none;
    content: '';
}

.menu-group-title:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #f1f5f9;
}

.menu-group[open] > .menu-group-title {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.menu-group-chevron {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    position: relative;
    flex-shrink: 0;
    transition: transform 0.22s ease, background 0.2s ease;
}

.menu-group-chevron::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    border-right: 2px solid #cbd5e1;
    border-bottom: 2px solid #cbd5e1;
    transform: translate(-60%, -65%) rotate(-45deg);
    transition: border-color 0.2s ease;
}

.menu-group[open] > .menu-group-title .menu-group-chevron {
    transform: rotate(90deg);
    background: rgba(56, 105, 24, 0.35);
}

.menu-group[open] > .menu-group-title .menu-group-chevron::before {
    border-color: #ecfccb;
}

.menu-subitems {
    padding: 4px 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link,
.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    color: #94a3b8;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.84rem;
    line-height: 1.25;
    transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
    border: 1px solid transparent;
}

.sidebar-link-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar-link-text {
    flex: 1;
    min-width: 0;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #f8fafc;
    border-color: rgba(255, 255, 255, 0.06);
}

.sidebar-link.is-active {
    background: linear-gradient(90deg, rgba(56, 105, 24, 0.45) 0%, rgba(56, 105, 24, 0.18) 100%);
    color: #ffffff;
    border-color: rgba(134, 239, 172, 0.25);
    box-shadow: inset 3px 0 0 #86efac;
}

.sidebar-link.is-active .sidebar-link-icon {
    background: rgba(255, 255, 255, 0.14);
}

.sidebar-link-external .sidebar-ext-badge {
    font-size: 0.65rem;
    font-weight: 700;
    color: #86efac;
    background: rgba(56, 105, 24, 0.25);
    border-radius: 6px;
    padding: 2px 6px;
    line-height: 1.2;
}

.sidebar-footer {
    flex-shrink: 0;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-logout {
    width: 100%;
    box-sizing: border-box;
    color: #fca5a5;
    background: rgba(127, 29, 29, 0.18);
    border-color: rgba(248, 113, 113, 0.2);
}

.sidebar-logout .sidebar-link-icon {
    background: rgba(248, 113, 113, 0.15);
    font-size: 0.85rem;
    font-weight: 800;
}

.sidebar-logout:hover {
    color: #ffffff;
    background: rgba(185, 28, 28, 0.35);
    border-color: rgba(248, 113, 113, 0.45);
}

/* Legacy selectors (pages avec anciennes classes) */
.sidebar-menu {
    padding: 12px 0 16px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    gap: 12px;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    border-right: 4px solid var(--cfl-green);
}

.menu-category {
    padding: 20px 25px 10px;
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 800;
    color: #475569;
    letter-spacing: 1px;
}

.sidebar-header h3 {
    color: #f8fafc !important;
    margin: 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 800;
}

.sidebar-header img {
    max-width: 44px;
    height: auto;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    color: #fca5a5;
    text-decoration: none;
    font-weight: 600;
}

/* ========== 4. MISE EN PAGE & CONTENU ========== */
.main-container {
    margin-left: var(--sidebar-width); /* Laisse la place à la sidebar fixe */
    width: calc(100% - var(--sidebar-width));
    padding: 40px;
    box-sizing: border-box;
}

.main-container h1, .main-container h2, .user-management-header h2 {
    color: #198754 !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.user-management-header p {
    color: #cbd5e1 !important;
}

.user-management-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(255,255,255,0.1);
}

.user-table-card {
    background: var(--card-bg);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    color: #333;
}

/* ========== 5. TABLEAUX & FORMULAIRES ========== */
.table-users {
    width: 100%;
    border-collapse: collapse;
}

.table-users th {
    background-color: #f1f5f9;
    color: #475569;
    padding: 15px;
    text-align: center;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.table-users td {
    padding: 15px;
    border-bottom: 1px solid #f1f5f9;
}

input, select {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    padding: 10px;
    border-radius: 8px;
    color: #1e293b;
}

button, .btn-primary {
    padding: 12px 20px;
    background-color: var(--cfl-green);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

button:hover { background-color: var(--cfl-green-hover); }

/* ========== 6. CARTES DE CONNEXION ========== */
.wrapper-connexion {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.carte-blanche {
    background: white;
    color: #1e293b;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

/* ========== 7. RESPONSIVE ========== */
@media (max-width: 992px) {
    .admin-sidebar { display: none !important; }
    .main-container { margin-left: 0; width: 100%; padding: 20px; }
}

/* ========== 8. VUE MOBILE & ANIMATIONS ========= */
.card, .carte-course {
    background-color: #f8f9fa !important;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
}

@keyframes borderPulseMobile {
    0% { border-color: #386918; box-shadow: 0 0 5px rgba(56, 105, 24, 0.2); }
    50% { border-color: #84cc16; box-shadow: 0 0 15px rgba(132, 204, 22, 0.6); }
    100% { border-color: #386918; box-shadow: 0 0 5px rgba(56, 105, 24, 0.2); }
}

.course-actuelle, .active-course, .clignotant-mobile {
    border: 3px solid #386918 !important;
    animation: borderPulseMobile 2s infinite;
    background-color: #ffffff !important;
}

.comptage-annule {
    color: #dc3545;
    font-weight: 900;
    background: #ffebeb;
    padding: 2px 10px;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
}

.ligne-annulee {
    background-color: #f1f1f1 !important;
    color: #adb5bd !important;
    text-decoration: line-through;
}

.bg-danger { animation: pulse-red 2s infinite; }

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

/* Conteneur pour positionner la pastille */
.avis-badge-container {
    position: relative;
    display: inline-block;
}

/* La pastille rouge (le chiffre) */
.notification-bubble {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #ef4444; /* Rouge vif */
    color: white;
    font-size: 11px;
    font-weight: 900;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 10;
}

/* Animation pour attirer l'oeil si plusieurs avis */
.pulse-multi {
    animation: shadow-pulse 2s infinite;
}

@keyframes shadow-pulse {
    0% { box-shadow: 0 0 0 0px rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0px rgba(239, 68, 68, 0); }
}