body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f6f9;
}

/* ─── STRUCTURE GLOBALE ────────────────────────────────────────────────────── */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── SIDEBAR ──────────────────────────────────────────────────────────────── */

.sidebar {
    width: 240px;
    background: #111827;
    color: white;
    padding-top: 20px;

    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;

    z-index: 200;
    transition: width 0.3s ease, left 0.3s ease;

    scrollbar-width: thin;
    scrollbar-color: #374151 transparent;
}

.sidebar::-webkit-scrollbar       { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #374151; border-radius: 4px; }

.sidebar-logo {
    padding: 16px 20px;
    font-weight: bold;
    font-size: 20px;
    white-space: nowrap;
    overflow: hidden;
    transition: padding 0.3s;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    /* Espace en bas pour que le dernier item (Paramètres) ne colle pas
       au bord et reste bien visible/cliquable en fin de défilement */
    padding-bottom: 40px;
}

/* ─── ITEMS DU MENU ────────────────────────────────────────────────────────── */

.nav-item {
    padding: 13px 20px;
    color: #cbd5e1;
    text-decoration: none;       /* pas de soulignement */
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s, color 0.2s, padding 0.3s;
    white-space: nowrap;
    overflow: hidden;
    border-left: 4px solid transparent;
}

.nav-item:hover,
.nav-item:focus,
.nav-item:active {
    text-decoration: none;       /* soulignement bloqué sur tous les états */
    background: #1f2937;
    color: white;
    border-left-color: #4b5563;
}

/* Menu actif */
.nav-item.active {
    background: #1e3a5f;
    color: #ffffff;
    border-left: 4px solid #3b82f6;
    font-weight: bold;
    text-decoration: none;
}

.nav-item.active:hover {
    background: #1e3a5f;
    text-decoration: none;
}

.nav-icon {
    flex-shrink: 0;
    font-size: 1.1em;
    width: 22px;
    text-align: center;
    transition: font-size 0.3s;
}

.nav-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s;
}

/* ─── MAIN ─────────────────────────────────────────────────────────────────── */

.main {
    flex: 1;
    /* min-width:0 : sans cela, un tableau large empêche .main de rétrécir
       et déborde le viewport (casse le hamburger/header fixes sur mobile).
       Le débordement est désormais contenu par .table-wrapper (overflow:auto). */
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: 240px;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* ─── HEADER ───────────────────────────────────────────────────────────────── */

.header {
    position: fixed;
    left: 240px;
    right: 0;
    top: 0;
    height: 60px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 150;
    transition: left 0.3s ease;
    box-sizing: border-box;
}

.header-left  { display: flex; align-items: center; gap: 15px; }
.header-right { display: flex; align-items: center; gap: 20px; }

/* ─── HAMBURGER ────────────────────────────────────────────────────────────── */

.hamburger {
    font-size: 22px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
    line-height: 1;
}

.hamburger:hover { background: #f3f4f6; }

/* ─── CONTENU DE PAGE ──────────────────────────────────────────────────────── */

.page-content {
    padding: 70px 15px 15px;   /* 60px header fixe + 15px = marge standard Bootstrap */
    flex: 1;
}

/* ─── SIDEBAR MINI (desktop) ───────────────────────────────────────────────── */
/* En mode réduit : icônes seulement, largeur 60px                             */

.app-layout.sidebar-collapsed .sidebar {
    width: 60px;
}

.app-layout.sidebar-collapsed .sidebar-logo {
    padding: 16px 0;
    text-align: center;
    font-size: 14px;
}

.app-layout.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 13px 0;
    gap: 0;
}

.app-layout.sidebar-collapsed .nav-text {
    display: none;
}

.app-layout.sidebar-collapsed .nav-icon {
    font-size: 1.3em;
    width: auto;
}

.app-layout.sidebar-collapsed .main {
    margin-left: 60px;
}

.app-layout.sidebar-collapsed .header {
    left: 60px;
}


/* ─── ICONS / BADGE ────────────────────────────────────────────────────────── */

.icon-btn {
    position: relative;
    font-size: 20px;
    cursor: pointer;
}

/* Pastille de notification (compteur) sur un bouton-icône : la cloche, etc.
   Scopée à .icon-btn — sinon elle capturait TOUTES les .badge de l'appli
   (statuts, priorités…) et les sortait de leur cellule (colonnes vides). */
.icon-btn .badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background: red;
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
}

/* Étiquette « pastille » en ligne (statut, priorité, marqueur dans un tableau).
   La couleur de fond/texte est fournie en inline sur chaque usage ; ce socle
   ne gère que la forme. Défaut neutre pour les pastilles sans couleur propre. */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 12px;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    background: #f1f5f9;
    color: #475569;
}

/* Compteurs de messages non lus (listes de conversations) : pastille rouge. */
.conversation-meta .badge,
.conv-right .badge {
    background: #ef4444;
    color: #fff;
    min-width: 20px;
    text-align: center;
    padding: 2px 7px;
}

/* ─── PROFILE DROPDOWN ─────────────────────────────────────────────────────── */

.profile {
    position: relative;
    cursor: pointer;
}

.profile img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.profile-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    min-width: 180px;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: 0.2s;
}

.profile.open .profile-dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    z-index: 100;
}

.profile-dropdown a {
    display: block;
    padding: 12px 15px;
    text-decoration: none;
    color: #333;
}

.profile-dropdown a:hover { background: #f3f4f6; text-decoration: none; }

/* ─── NOTIFICATIONS ────────────────────────────────────────────────────────── */

.notification { position: relative; }

.notif-dropdown {
    position: absolute;
    right: 0;
    top: 45px;
    width: 260px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: 0.2s;
}

.notif-dropdown.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    z-index: 100;
}

.notif-dropdown h4 { padding: 10px 15px; border-bottom: 1px solid #eee; margin: 0; }
.notif-list        { max-height: 250px; overflow: auto; }

.notif-item        { padding: 10px 15px; border-bottom: 1px solid #f3f4f6; }
.notif-item small  { display: block; color: gray; font-size: 12px; }

.notif-footer {
    display: block;
    text-align: center;
    padding: 10px;
    text-decoration: none;
    background: #f9fafb;
}

/* ─── OVERLAY MOBILE ───────────────────────────────────────────────────────── */

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 199;
}

.sidebar-overlay.active { display: block; }

/* ─── MOBILE ───────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {

    /* Empêche tout débordement horizontal de la page : garantit que le
       positionnement fixe (header, sidebar, hamburger) reste correct. */
    html, body { overflow-x: hidden; }
    .main, .page-content { max-width: 100vw; overflow-x: hidden; }

    .sidebar {
        left: -240px;
        width: 240px !important;   /* force la largeur complète sur mobile */
        z-index: 999;
    }

    /* !important : garantit l'ouverture même si .sidebar-collapsed est présent
       (sinon .app-layout.sidebar-collapsed .sidebar est plus spécifique) */
    .sidebar.active { left: 0 !important; overflow-y: auto; }

    .main    { margin-left: 0; }
    .header  { left: 0; }


    /* En mode "collapsed" sur mobile → sidebar toujours cachée */
    .app-layout.sidebar-collapsed .sidebar { left: -240px; }
    .app-layout.sidebar-collapsed .main    { margin-left: 0; }
    .app-layout.sidebar-collapsed .header  { left: 0; }

    /* items du menu restent complets sur mobile */
    .app-layout.sidebar-collapsed .nav-item  { justify-content: flex-start; padding: 13px 20px; gap: 12px; }
    .app-layout.sidebar-collapsed .nav-text  { display: block; }
    .app-layout.sidebar-collapsed .nav-icon  { font-size: 1.1em; }
    .app-layout.sidebar-collapsed .sidebar-logo { padding: 16px 20px; font-size: 20px; }
}
