/* =========================================================================
   e-Hadj Al Qiblatayn — thème "rail sombre / canvas clair" (cyan pétrole)
   Surcouche de Bootstrap 5.3
   ========================================================================= */
:root {
    --side-w: 250px;
    --top-h: 60px;

    --bg: #f5f7f8;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --ink: #0f1826;
    --muted: #6b7682;
    --faint: #98a2ad;
    --line: #e8ecef;
    --line-strong: #dde3e7;

    --primary: #0e7c8a;
    --primary-600: #0b6672;
    --primary-050: #e3f1f3;
    --primary-100: #cbe7ea;

    --good: #0f9d63;
    --warn: #b7791f;
    --crit: #c23b34;

    --side-bg: #0f1f29;
    --side-bg-2: #0c1a22;
    --side-ink: #9fb0ba;
    --side-ink-strong: #eef4f6;
    --side-line: rgba(255,255,255,.07);
    --side-active-ink: #3ecad6;
    --side-active-bg: rgba(62,202,214,.12);

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(15,24,38,.04), 0 8px 22px rgba(15,24,38,.05);
    --shadow-sm: 0 1px 2px rgba(15,24,38,.05);

    /* Overrides Bootstrap */
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--ink);
    --bs-primary: var(--primary);
    --bs-primary-rgb: 14,124,138;
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--primary-600);
    --bs-border-color: var(--line);
    --bs-border-radius: var(--radius-sm);
    --bs-emphasis-color: var(--ink);
    --bs-secondary-color: var(--muted);
    --bs-font-sans-serif: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg);
    color: var(--ink);
    font-family: var(--bs-font-sans-serif);
    -webkit-font-smoothing: antialiased;
}

/* Décalage du contenu (sauf page de login) pour laisser place au rail + topbar */
body:not(.login-page) {
    padding-left: var(--side-w);
    padding-top: var(--top-h);
}

h1, h2, h3, h4, h5, h6 { color: var(--ink); font-weight: 700; letter-spacing: -.01em; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }
.text-muted { color: var(--muted) !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.container-fluid { max-width: 1500px; }

/* ============ RAIL LATÉRAL ============ */
.app-side {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--side-w); z-index: 1040;
    background: var(--side-bg);
    border-right: 1px solid rgba(0,0,0,.2);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.side-brand {
    height: var(--top-h); flex: none; display: flex; align-items: center;
    padding: 0 18px; border-bottom: 1px solid var(--side-line);
}
.side-brand a { display: flex; align-items: center; gap: 11px; color: var(--side-ink-strong); }
.brand-mark {
    width: 34px; height: 34px; border-radius: 9px; flex: none;
    display: grid; place-items: center; font-size: 18px; color: #04222a;
    background: linear-gradient(135deg, var(--side-active-ink), var(--primary));
    box-shadow: 0 2px 8px rgba(14,124,138,.4);
}
/* Logo agence dans le rail : image a la place de la pastille degradee. */
.brand-mark:has(.brand-logo) { width: auto; height: 34px; background: none; box-shadow: none; border-radius: 0; }
.brand-logo { height: 34px; width: auto; max-width: 150px; object-fit: contain; display: block; }
.brand-txt { font-size: 15px; font-weight: 600; letter-spacing: .01em; line-height: 1.1; }
.brand-txt b { font-weight: 400; opacity: .68; display: block; font-size: 12px; }

.side-nav { flex: 1; overflow-y: auto; padding: 12px 12px 26px; }
.side-nav::-webkit-scrollbar { width: 8px; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 8px; }

.side-group {
    font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
    color: #5c6f7a; padding: 16px 12px 6px;
}
.side-link {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; margin-bottom: 2px; border-radius: 9px;
    color: var(--side-ink); font-size: 13.5px; font-weight: 500; line-height: 1.2;
    transition: background .12s, color .12s;
}
.side-link i { font-size: 15px; width: 18px; text-align: center; opacity: .85; flex: none; }
.side-link:hover { background: rgba(255,255,255,.05); color: var(--side-ink-strong); }
.side-link.is-active {
    background: var(--side-active-bg); color: var(--side-active-ink); font-weight: 600;
    box-shadow: inset 2px 0 0 var(--side-active-ink);
}
.side-link.is-active i { opacity: 1; }

/* Sections repliables du menu (grands points + sous-options) */
.side-top { margin: 2px 0 6px; }
.side-section { margin-bottom: 2px; }
.side-parent {
    width: 100%; display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; border: 0; background: none; cursor: pointer; border-radius: 9px;
    color: var(--side-ink-strong); font-size: 13px; font-weight: 600; line-height: 1.2;
}
.side-parent > i:first-child { font-size: 15px; width: 18px; text-align: center; opacity: .9; flex: none; }
.side-parent:hover { background: rgba(255,255,255,.06); }
.side-caret { margin-left: auto; font-size: 10px; opacity: .55; transition: transform .2s; }
.side-parent[aria-expanded="true"] .side-caret { transform: rotate(180deg); opacity: .8; }
.side-sub { padding: 2px 0 4px; }
.side-sub .side-link { padding-left: 41px; }

/* ============ BARRE HAUTE ============ */
.app-top {
    position: fixed; top: 0; left: var(--side-w); right: 0; height: var(--top-h); z-index: 1030;
    background: rgba(255,255,255,.9); backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 12px; padding: 0 22px;
}
.top-spacer { flex: 1 1 auto; min-width: 0; }
/* Rien dans la barre ne doit pouvoir en pousser le contenu hors de l'ecran : c'est ainsi que le
   profil et la deconnexion disparaissaient sur telephone des que le libelle d'edition etait long. */
.app-top > * { flex: none; }
.edition-btn { max-width: 42vw; }
.edition-btn > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-toggle {
    display: none; border: 1px solid var(--line); background: var(--surface);
    color: var(--ink); width: 38px; height: 38px; border-radius: 10px; font-size: 18px;
}
.edition-btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--surface); border: 1px solid var(--line); color: var(--ink);
    font-size: 13px; font-weight: 500; padding: 7px 13px; border-radius: 999px;
}
.edition-btn:hover { border-color: var(--primary-100); color: var(--primary-600); }
.edition-btn i { color: var(--primary); }
.top-user { display: flex; align-items: center; gap: 9px; text-decoration: none; }
a.top-user:hover .top-name { color: var(--primary); }
.top-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex: none;
    display: grid; place-items: center; background: var(--primary-050); color: var(--primary-600); font-size: 15px;
}
.top-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.btn-logout {
    width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
    background: var(--surface); color: var(--muted); font-size: 16px;
}
.btn-logout:hover { color: var(--crit); border-color: #f3d4d1; background: #fdf3f2; }
.theme-toggle {
    width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
    background: var(--surface); color: var(--muted); font-size: 16px; flex: none;
    display: inline-grid; place-items: center; transition: color .12s, border-color .12s;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary-100); }
.side-backdrop {
    position: fixed; inset: 0; z-index: 1035; background: rgba(6,12,18,.5); display: none;
}
.side-backdrop.is-on { display: block; }

/* ============ CARTES ============ */
.card {
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius);
    background: var(--surface);
}
.card-header {
    background-color: var(--surface);
    font-weight: 700; color: var(--ink); font-size: 14.5px;
    border-bottom: 1px solid var(--line);
    padding: 13px 18px;
}
.card-body { padding: 18px; }
.card-header .btn-sm { font-weight: 600; }

/* Cartes statistiques (tuiles) */
.stat-card { border: 1px solid var(--line) !important; border-radius: var(--radius); }
.stat-card .card-body { padding: 16px 18px; }
.stat-label {
    font-size: .72rem; color: var(--muted); text-transform: uppercase;
    letter-spacing: .06em; font-weight: 600; margin-bottom: 6px;
}
.stat-value {
    font-size: 1.85rem; font-weight: 800; color: var(--ink);
    letter-spacing: -.02em; line-height: 1.05; font-variant-numeric: tabular-nums;
}
.stat-value-sm {
    font-size: 1.25rem; font-weight: 800; color: var(--ink);
    letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.stat-icon { font-size: 1.4rem; opacity: .32; }

/* ============ BOUTONS ============ */
.btn { font-weight: 600; border-radius: var(--radius-sm); }
.btn-sm { border-radius: 8px; }
.btn-lg { border-radius: var(--radius); }
.btn-primary { background-color: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover, .btn-primary:focus { background-color: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.btn-outline-primary { color: var(--primary); border-color: var(--line-strong); }
.btn-outline-primary:hover { background-color: var(--primary); border-color: var(--primary); color: #fff; }
.btn-outline-secondary { color: var(--muted); border-color: var(--line-strong); }
.btn-outline-secondary:hover { background-color: var(--ink); border-color: var(--ink); color: #fff; }
.btn-outline-danger { color: var(--crit); border-color: #f0d2cf; }
.btn-outline-danger:hover { background-color: var(--crit); border-color: var(--crit); }
.btn-outline-success { color: var(--good); border-color: #cbe9d8; }
.btn-outline-success:hover { background-color: var(--good); border-color: var(--good); }
.btn-success { background-color: var(--good); border-color: var(--good); }
.btn-link { color: var(--primary); font-weight: 600; }

/* ============ TABLES ============ */
.table { --bs-table-bg: transparent; color: var(--ink); margin-bottom: 0; }
.table > thead th, .table-light > th, .table-light td {
    background-color: var(--surface-2) !important;
    color: var(--muted); font-size: .72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
    border-bottom: 1px solid var(--line) !important; border-top: none;
    padding: 11px 16px; white-space: nowrap;
}
.table > tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink); }
.table > tbody tr:last-child td { border-bottom: none; }
.table-hover > tbody > tr:hover > * { background-color: var(--primary-050); }
.table-sm > thead th { padding: 9px 14px; }
.table-sm > tbody td { padding: 9px 14px; }
.table-responsive { border-radius: var(--radius); }

/* ============ BADGES (pastilles) ============ */
.badge {
    font-weight: 600; border-radius: 999px; padding: .4em .75em; font-size: .72rem;
    letter-spacing: .01em;
}
.badge.bg-primary   { background-color: var(--primary-050) !important; color: var(--primary-600) !important; }
.badge.bg-success   { background-color: #dcf3e7 !important; color: #0c7a4b !important; }
.badge.bg-warning   { background-color: #fbeecd !important; color: #93650f !important; }
.badge.bg-danger    { background-color: #fbe3e1 !important; color: #b0322b !important; }
.badge.bg-secondary { background-color: #eef1f4 !important; color: #5b6570 !important; }
.badge.bg-info      { background-color: #dff0f2 !important; color: #0e6773 !important; }
.badge.bg-light     { background-color: #eef1f4 !important; color: #5b6570 !important; }
.badge.text-dark    { color: inherit !important; }

/* ============ FORMULAIRES ============ */
.form-label { font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: .35rem; }
.form-control, .form-select {
    border-color: var(--line-strong); border-radius: var(--radius-sm);
    color: var(--ink); padding: .5rem .8rem; font-size: .92rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,124,138,.14);
}
.form-control-sm, .form-select-sm { border-radius: 8px; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,124,138,.14); }
.form-text { color: var(--faint); }
.input-group-text { background: var(--surface-2); border-color: var(--line-strong); color: var(--muted); }

/* ============ DROPDOWNS ============ */
.dropdown-menu {
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    box-shadow: var(--shadow); padding: 6px; font-size: .9rem;
}
.dropdown-item { border-radius: 8px; padding: 7px 12px; color: var(--ink); }
.dropdown-item:hover { background: var(--primary-050); color: var(--primary-600); }
.dropdown-item.active { background: var(--primary); color: #fff; }
.dropdown-header { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }

/* ============ ALERTES / DIVERS ============ */
.alert { border: 1px solid transparent; border-radius: var(--radius-sm); font-size: .92rem; }
.alert-success { background: #e8f6ee; border-color: #cbe9d8; color: #0c6a44; }
.alert-danger { background: #fdeeec; border-color: #f4d4d0; color: #a5302a; }
.alert-info { background: var(--primary-050); border-color: var(--primary-100); color: var(--primary-600); }
.progress { background: var(--line); border-radius: 999px; }
.progress-bar { background-color: var(--primary); }
.progress-bar.bg-primary { background-color: var(--primary) !important; }
hr { color: var(--line-strong); opacity: 1; }
code { color: var(--primary-600); background: var(--primary-050); padding: 1px 6px; border-radius: 6px; font-size: .85em; }
.text-success { color: var(--good) !important; }
.text-danger { color: var(--crit) !important; }
.border-primary { border-color: var(--line) !important; }
.border-success, .border-danger, .border-warning, .border-info, .border-secondary { border-color: var(--line) !important; }

/* ============ PAGE DE CONNEXION (split-screen) ============ */
body.auth { margin: 0; min-height: 100vh; background: var(--bg); }
.auth-wrap { display: flex; min-height: 100vh; }

/* Panneau marque (gauche) */
.auth-brand {
    flex: 1 1 46%; position: relative; overflow: hidden; color: #eaf6f7;
    display: flex; flex-direction: column; justify-content: center; padding: 3.4rem 3.4rem;
    background:
        radial-gradient(1100px 620px at 18% -12%, rgba(62,202,214,.20) 0, transparent 62%),
        linear-gradient(155deg, #08151c 0%, #0e2530 48%, #103944 78%, var(--primary) 200%);
}
.auth-brand::before, .auth-brand::after { content: ''; position: absolute; }
.auth-brand::after {
    /* Halo diffus plutot qu'un disque a bord franc, qui se decoupait au couteau sur le degrade.
       Le filigrane de la Kaaba des impressions n'a pas ete repris ici : cette image est calibree
       pour le papier (fondue vers le blanc, luminosite 210-255) et ne donne sur fond sombre
       qu'un voile laiteux. Une photo dediee au fond sombre serait a fournir pour l'y mettre. */
    width: 620px; height: 620px; right: -170px; bottom: -190px; border-radius: 50%;
    background: radial-gradient(closest-side, rgba(69,211,223,.15), rgba(69,211,223,.04) 62%, transparent 100%);
}
/* Motif geometrique en claire-voie, inspire des moucharabiehs : deux trames de losanges qui se
   croisent. Dessine en CSS plutot qu'en image — il suit la couleur de l'agence, ne pese rien et
   reste net a toutes les resolutions. */
.auth-brand::before {
    inset: 0; opacity: .07;
    background-image:
        repeating-linear-gradient(45deg, rgba(255,255,255,.9) 0 1px, transparent 1px 22px),
        repeating-linear-gradient(-45deg, rgba(255,255,255,.9) 0 1px, transparent 1px 22px);
    -webkit-mask-image: radial-gradient(120% 90% at 15% 0%, #000 0, transparent 72%);
    mask-image: radial-gradient(120% 90% at 15% 0%, #000 0, transparent 72%);
}
.auth-brand-inner { position: relative; z-index: 2; max-width: 460px; }
.auth-mark {
    width: 62px; height: 62px; border-radius: 16px; display: grid; place-items: center;
    font-size: 2rem; color: #04222a; margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--side-active-ink, #45d3df), var(--primary));
    box-shadow: 0 12px 30px rgba(0,0,0,.35);
}
.auth-mark:has(.auth-logo-img) { width: auto; height: auto; background: none; box-shadow: none; }
.auth-logo-img { max-height: 60px; max-width: 200px; object-fit: contain; display: block; }
.auth-title { font-size: 2.6rem; font-weight: 800; letter-spacing: .03em; margin: 0 0 .55rem; color: #ffffff; }
.auth-tag { font-size: 1.04rem; opacity: .78; margin-bottom: 2.1rem; line-height: 1.55; max-width: 30ch; }
/* ---- Verset du jour ----
   Le bloc porte le regard : c'est la seule respiration de la page. Le filet lateral remplace des
   guillemets, que la composition arabe n'emploie pas. */
.auth-verset {
    margin: 0 0 2rem; padding: .1rem 0;
    /* Proprietes logiques : en arabe, le filet doit passer a droite du texte. Avec border-left
       il restait a gauche, detache de la colonne, et l'oeil ne le rattachait plus au verset. */
    padding-inline-start: 1.15rem;
    border-inline-start: 2px solid var(--side-active-ink, #45d3df);
}
.auth-verset-ar {
    font-family: 'Amiri', 'Scheherazade New', 'Traditional Arabic', serif;
    font-size: 1.8rem; line-height: 2.2; color: #ffffff; margin: 0 0 .6rem;
    /* line-height genereux : les diacritiques arabes se superposent sinon aux lignes voisines. */
}
.auth-verset-tr { font-size: .95rem; line-height: 1.6; opacity: .76; margin: 0 0 .5rem; font-style: italic; }
.auth-verset-ref {
    font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; opacity: .62;
    color: var(--side-active-ink, #45d3df);
}

/* Repli sur telephone, sous le formulaire : discret, il ne doit pas concurrencer la saisie. */
.auth-verset-mobile { display: none; margin: 1.8rem 0 0; padding-top: 1.2rem; border-top: 1px solid var(--line); text-align: center; }
.auth-verset-mobile .auth-verset-ar { font-size: 1.3rem; line-height: 2; color: var(--ink); }
.auth-verset-mobile .auth-verset-ref { color: var(--faint); }

.auth-features { list-style: none; padding: 0; margin: 0; }
.auth-features li { display: flex; align-items: center; gap: .7rem; padding: .5rem 0; opacity: .86; font-size: .96rem; }
.auth-features i { color: var(--side-active-ink, #45d3df); font-size: 1.05rem; flex: none; }
.auth-brand-foot { position: absolute; bottom: 1.6rem; left: 3.2rem; z-index: 1; font-size: .8rem; opacity: .5; }

/* Panneau formulaire (droite) */
.auth-panel {
    flex: 1 1 54%; position: relative; display: flex; align-items: center; justify-content: center; padding: 2rem;
    /* Degrade a peine perceptible : sans lui, le demi-ecran de droite est un aplat de gris qui
       fait paraitre le formulaire pose sur rien. */
    background: radial-gradient(760px 520px at 72% 18%, var(--primary-050) 0, transparent 68%);
}
.auth-lang { position: absolute; top: 1.3rem; right: 1.6rem; display: flex; gap: .35rem; }
.auth-lang a {
    text-decoration: none; font-size: .8rem; font-weight: 600; color: var(--muted);
    padding: .18rem .55rem; border-radius: 999px; border: 1px solid var(--line);
}
.auth-lang a.active { color: #fff; background: var(--primary); border-color: var(--primary); }
.auth-card { width: 100%; max-width: 400px; }
/* La carte n'apparait qu'a partir de la tablette : sur telephone elle occuperait toute la largeur
   et n'ajouterait qu'une bordure inutile autour du formulaire. */
@media (min-width: 861px) {
    .auth-card {
        max-width: 420px; background: var(--surface); border: 1px solid var(--line);
        border-radius: 18px; padding: 2.6rem 2.4rem;
        box-shadow: 0 24px 60px rgba(15,24,38,.09), 0 2px 6px rgba(15,24,38,.04);
    }
}
.auth-welcome { font-weight: 700; font-size: 1.75rem; margin-bottom: .25rem; letter-spacing: -.01em; }
.auth-card .form-label { font-weight: 600; font-size: .82rem; color: var(--muted); letter-spacing: .01em; }
/* Les bordures interieures du groupe sont retirees des deux cotes : en arabe, c'est la bordure
   droite de l'icone qui doit disparaitre, pas la gauche. Les traiter separement laissait un
   double filet au milieu du champ en RTL. */
.auth-card .input-group-text { background: var(--surface); color: var(--muted); border-inline-end: 0; }
.auth-card .form-control { border-inline-start: 0; }
.auth-card .input-group { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.auth-card .input-group:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-050); }
.auth-card .input-group > * { border: 0 !important; box-shadow: none !important; }
.auth-card .btn-primary {
    background: var(--primary); border-color: var(--primary); border-radius: 12px;
    padding: .8rem 1rem; font-weight: 600; letter-spacing: .01em;
    box-shadow: 0 8px 20px rgba(14,124,138,.22);
}
.auth-card .btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.auth-card .btn-primary:active { transform: translateY(1px); }
.auth-demo { text-align: center; color: var(--faint); font-size: .82rem; margin-top: 1.6rem; margin-bottom: 0; }
.auth-logo-mobile { display: none; text-align: center; margin-bottom: 1.2rem; font-size: 2rem; color: var(--primary); }
.auth-logo-mobile img { max-height: 56px; max-width: 180px; object-fit: contain; }

@media (max-width: 860px) {
    .auth-brand { display: none; }
    .auth-panel { flex: 1; }
    .auth-logo-mobile { display: block; }
    .auth-verset-mobile { display: block; }
}

/* ============ TOUCHE DE COULEUR & POLISH ============ */
:root { --info: #4b63d6; --amber: #c98a12; }

/* Icônes de tuiles → pastilles colorées */
.stat-card .card-body { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stat-icon {
    width: 46px; height: 46px; border-radius: 13px; flex: none;
    display: inline-grid; place-items: center; font-size: 1.3rem; opacity: 1;
}
.stat-icon.text-primary   { background: var(--primary-050); color: var(--primary) !important; }
.stat-icon.text-success   { background: #dcf3e7; color: var(--good) !important; }
.stat-icon.text-info      { background: #e7ebfb; color: var(--info) !important; }
.stat-icon.text-warning   { background: #fbeed0; color: var(--amber) !important; }
.stat-icon.text-danger    { background: #fbe3e1; color: var(--crit) !important; }
.stat-icon.text-secondary { background: #eef1f4; color: #6b7682 !important; }

/* Cartes stat sans icône (détails finances) → liseré coloré à gauche */
.stat-card:not(:has(.stat-icon)).border-primary   { border-left: 3px solid var(--primary) !important; }
.stat-card:not(:has(.stat-icon)).border-success   { border-left: 3px solid var(--good) !important; }
.stat-card:not(:has(.stat-icon)).border-danger    { border-left: 3px solid var(--crit) !important; }
.stat-card:not(:has(.stat-icon)).border-warning   { border-left: 3px solid var(--amber) !important; }
.stat-card:not(:has(.stat-icon)).border-info      { border-left: 3px solid var(--info) !important; }
.stat-card:not(:has(.stat-icon)).border-secondary { border-left: 3px solid #9aa4ad !important; }
.stat-card:not(:has(.stat-icon)).border-primary .card-body,
.stat-card:not(:has(.stat-icon)).border-success .card-body,
.stat-card:not(:has(.stat-icon)).border-danger .card-body,
.stat-card:not(:has(.stat-icon)).border-warning .card-body,
.stat-card:not(:has(.stat-icon)).border-info .card-body,
.stat-card:not(:has(.stat-icon)).border-secondary .card-body { display: block; }

/* Info → indigo (variété) */
.text-info { color: var(--info) !important; }
.text-warning { color: var(--amber) !important; }
.badge.bg-info { background-color: #e7ebfb !important; color: #3a4fc4 !important; }

/* Icônes de titres de page et d'en-têtes de cartes en couleur d'accent */
h4 > i:first-child, h5 > i:first-child { color: var(--primary); }
.card-header > i:first-child, .card-header > span:first-child > i { color: var(--primary); }

/* Meilleure lisibilité des icônes en pastille */
.stat-icon.text-success { background: #d7f1e2; color: #0b7a4c !important; }
.stat-icon.text-info    { background: #e6eafc; color: #3f56d6 !important; }

/* ---- Polish fin transverse ---- */
/* Titre de page + espace sous l'en-tête */
h4 { font-size: 1.4rem; }
.card-header .btn-sm { padding: .32rem .72rem; }
.card-body > .row.g-3:only-child { margin: 0; }

/* Fiches détail : colonne de gauche = libellés discrets (fiche technique) */
.table tbody th {
    color: var(--muted); font-weight: 600; font-size: .82rem;
    white-space: nowrap; width: 36%; vertical-align: middle;
}

/* États vides plus doux et centrés */
.table td.text-muted.text-center,
.table td.text-center.text-muted { color: var(--faint) !important; padding-top: 26px; padding-bottom: 26px; }

/* Liens en tableau plus affirmés */
.table tbody a { font-weight: 600; }

/* Barres de progression plus fines */
.progress { height: 7px; }

/* Boutons icône compacts en fin de ligne de tableau */
.table .btn-sm { padding: .28rem .55rem; }
.table td .d-inline + .btn-sm, .table td .btn-sm + .d-inline { margin-left: 2px; }

/* Séparateurs de fiches détail moins marqués */
.card .table-sm > tbody > tr > td, .card .table-sm > tbody > tr > th { border-color: #eef1f3; }

/* Champs de recherche / input-group : coins cohérents */
.input-group .form-control:focus { z-index: 3; }

/* ============ RTL (arabe) ============ */
[dir="rtl"] body:not(.login-page) { padding-left: 0; padding-right: var(--side-w); }
[dir="rtl"] .app-side { left: auto; right: 0; border-right: none; border-left: 1px solid rgba(0,0,0,.2); }
[dir="rtl"] .app-top { left: 0; right: var(--side-w); padding: 0 22px; }
[dir="rtl"] .side-link.is-active { box-shadow: inset -2px 0 0 var(--side-active-ink); }
[dir="rtl"] .side-link i { text-align: center; }
[dir="rtl"] .stat-card:not(:has(.stat-icon))[class*="border-"] { border-left: 1px solid var(--line) !important; border-right: 3px solid var(--primary); }
[dir="rtl"] .table > thead th, [dir="rtl"] .table > tbody td, [dir="rtl"] .table > tbody th { text-align: right; }
[dir="rtl"] .table .num, [dir="rtl"] .text-end { text-align: left !important; }
[dir="rtl"] .me-1, [dir="rtl"] .me-2, [dir="rtl"] .me-3 { margin-right: 0 !important; }
[dir="rtl"] .ms-2 { margin-left: 0 !important; margin-right: .5rem; }
[dir="rtl"] .dropdown-menu-end { --bs-position: start; }

@media (max-width: 991.98px) {
    [dir="rtl"] body:not(.login-page) { padding-right: 0; }
    [dir="rtl"] .app-side { transform: translateX(100%); }
    [dir="rtl"] .app-side.is-open { transform: translateX(0); }
    [dir="rtl"] .app-top { right: 0; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 991.98px) {
    body:not(.login-page) { padding-left: 0; }
    .app-side { transform: translateX(-100%); transition: transform .22s ease; }
    .app-side.is-open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.4); }
    .app-top { left: 0; }
    .side-toggle { display: inline-grid; place-items: center; }
    .top-name { display: none; }
}

/* Telephone : la barre doit loger huit commandes sur 360 px. Les libelles cedent la place aux
   icones — le profil et la deconnexion, eux, ne se negocient pas : ce sont les deux seules sorties
   de l'application. */
@media (max-width: 575.98px) {
    .app-top { gap: 6px; padding: 0 10px; }
    .edition-btn { padding: 7px 10px; max-width: none; }
    .edition-btn > span, .edition-btn.dropdown-toggle::after { display: none; }
    .theme-toggle, .btn-logout, .side-toggle { width: 34px; height: 34px; }
}

/* =========================================================================
   MODE SOMBRE (canvas) — active via data-bs-theme="dark" sur <html>.
   Le rail est deja sombre : seul le canvas passe en ardoise profond.
   Palette re-derivee via les tokens ; overrides ponctuels pour les teintes
   pales codees en dur (badges, alertes, pastilles, champs).
   ========================================================================= */
[data-bs-theme="dark"] {
    color-scheme: dark;
    --bg: #0a1216;
    --surface: #101d24;
    --surface-2: #16262f;
    --ink: #e7eef2;
    --muted: #93a1ac;
    --faint: #6f7d88;
    --line: #223038;
    --line-strong: #2c3d46;

    --primary: #22b2c4;
    --primary-600: #3ccadb;      /* survol plus clair sur fond sombre */
    --primary-050: rgba(56,199,214,.12);
    --primary-100: rgba(56,199,214,.24);

    --good: #2fb877;
    --warn: #d59a2a;
    --crit: #e56a62;
    --info: #7d90f0;
    --amber: #dca63a;

    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 26px rgba(0,0,0,.45);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.45);

    --bs-body-bg: var(--bg);
    --bs-body-color: var(--ink);
    --bs-border-color: var(--line);
    --bs-emphasis-color: var(--ink);
    --bs-secondary-color: var(--muted);
}

/* Legere separation rail / canvas */
[data-bs-theme="dark"] .app-side { border-right-color: var(--line); }
[data-bs-theme="dark"] .app-top { background: rgba(16,29,36,.85); border-bottom-color: var(--line); }

/* Utilitaires de fond clair codes en dur -> surfaces sombres.
   (en-tetes de cartes .bg-white, panneaux repliables .bg-light) */
[data-bs-theme="dark"] .bg-white { background-color: var(--surface) !important; }
[data-bs-theme="dark"] .bg-light { background-color: var(--surface-2) !important; color: var(--ink); }

/* Champs : fond assombri, texte clair */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--surface-2); border-color: var(--line-strong); color: var(--ink);
}
[data-bs-theme="dark"] .form-control::placeholder { color: var(--faint); }
[data-bs-theme="dark"] .input-group-text,
[data-bs-theme="dark"] .auth-card .input-group-text { background: var(--surface-2); border-color: var(--line-strong); color: var(--muted); }

/* Badges : tons translucides sur fond sombre */
[data-bs-theme="dark"] .badge.bg-primary   { background-color: var(--primary-050) !important; color: var(--primary-600) !important; }
[data-bs-theme="dark"] .badge.bg-success   { background-color: rgba(47,184,119,.16) !important; color: #57d69d !important; }
[data-bs-theme="dark"] .badge.bg-warning   { background-color: rgba(220,166,58,.18) !important; color: #e6b862 !important; }
[data-bs-theme="dark"] .badge.bg-danger    { background-color: rgba(229,106,98,.16) !important; color: #f2938c !important; }
[data-bs-theme="dark"] .badge.bg-secondary,
[data-bs-theme="dark"] .badge.bg-light     { background-color: rgba(255,255,255,.08) !important; color: #bcc7d0 !important; }
[data-bs-theme="dark"] .badge.bg-info      { background-color: rgba(125,144,240,.20) !important; color: #a6b4f7 !important; }

/* Alertes */
[data-bs-theme="dark"] .alert-success { background: rgba(47,184,119,.12); border-color: rgba(47,184,119,.30); color: #78dcae; }
[data-bs-theme="dark"] .alert-danger  { background: rgba(229,106,98,.12); border-color: rgba(229,106,98,.32); color: #f29a93; }
[data-bs-theme="dark"] .alert-warning { background: rgba(220,166,58,.12); border-color: rgba(220,166,58,.32); color: #e8c274; }
[data-bs-theme="dark"] .alert-info    { background: var(--primary-050); border-color: var(--primary-100); color: var(--primary-600); }

/* Pastilles d'icones des tuiles */
[data-bs-theme="dark"] .stat-icon.text-primary   { background: rgba(56,199,214,.15); color: var(--primary) !important; }
[data-bs-theme="dark"] .stat-icon.text-success   { background: rgba(47,184,119,.15); color: #57d69d !important; }
[data-bs-theme="dark"] .stat-icon.text-info      { background: rgba(125,144,240,.18); color: #a6b4f7 !important; }
[data-bs-theme="dark"] .stat-icon.text-warning   { background: rgba(220,166,58,.16); color: var(--amber) !important; }
[data-bs-theme="dark"] .stat-icon.text-danger    { background: rgba(229,106,98,.15); color: var(--crit) !important; }
[data-bs-theme="dark"] .stat-icon.text-secondary { background: rgba(255,255,255,.07); color: #9aa6b0 !important; }

/* Boutons : bordures d'outline adoucies + survol logout */
[data-bs-theme="dark"] .btn-outline-danger  { border-color: rgba(229,106,98,.42); }
[data-bs-theme="dark"] .btn-outline-success { border-color: rgba(47,184,119,.42); }
[data-bs-theme="dark"] .btn-outline-secondary { border-color: var(--line-strong); }
[data-bs-theme="dark"] .btn-logout:hover { color: var(--crit); border-color: rgba(229,106,98,.42); background: rgba(229,106,98,.14); }

/* Tableaux : survol translucide (les fonds viennent deja des tokens) */
[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * { background-color: rgba(56,199,214,.08); }
/* .table-light (thead ET tfoot totaux) : passer par les variables Bootstrap
   pour couvrir toutes les cellules descendantes (th/td, meme en petit-enfant). */
[data-bs-theme="dark"] .table-light {
    --bs-table-bg: var(--surface-2);
    --bs-table-color: var(--muted);
    --bs-table-border-color: var(--line);
}

/* Code, separateurs */
[data-bs-theme="dark"] code { background: var(--primary-050); color: var(--primary-600); }

/* Etats desactive / lecture seule */
[data-bs-theme="dark"] .btn.disabled, [data-bs-theme="dark"] .btn:disabled { opacity: .5; }

/* ==========================================================================
   PLAN DES CHAMBRES
   Une vignette par chambre : le numero, le public admis, les lits un a un
   (occupes / libres), et l'etat d'occupation porte par la couleur du liseré.
   ========================================================================== */
.chambres-grille {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.chambre-vignette {
    display: block;
    text-decoration: none;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-left: 4px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 10px 12px;
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.chambre-vignette:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(15, 24, 38, .12);
    border-color: var(--primary);
}
.chambre-vignette:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* L'etat se lit d'abord a la couleur, mais jamais seulement : le pied de vignette
   ecrit toujours le nombre de places libres. */
.chambre-vignette.etat-vide      { border-left-color: var(--good); }
.chambre-vignette.etat-partielle { border-left-color: var(--warn); }
.chambre-vignette.etat-pleine    { border-left-color: var(--crit); background: var(--surface-2); }

.vignette-tete {
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
    margin-bottom: 6px;
}
.vignette-tete .numero { font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.vignette-tete .genre {
    font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
    padding: 1px 6px; border-radius: 999px; white-space: nowrap;
    background: var(--primary-050); color: var(--primary-600);
}
.vignette-tete .genre.genre-HOMMES { background: #e5eefb; color: #1c4f96; }
.vignette-tete .genre.genre-FEMMES { background: #fbe9f1; color: #9b2c62; }

.chambre-vignette .lits {
    display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 6px; min-height: 18px;
}
.chambre-vignette .lits i { font-size: 13px; line-height: 1; }
.chambre-vignette .lits .lit-occupe { color: var(--primary); }
.chambre-vignette .lits .lit-libre  { color: var(--line-strong); }

.vignette-pied {
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
    font-size: 11.5px; color: var(--muted);
}

[data-bs-theme="dark"] .chambre-vignette { background: var(--surface); }
[data-bs-theme="dark"] .chambre-vignette:hover { box-shadow: 0 6px 16px rgba(0, 0, 0, .45); }
[data-bs-theme="dark"] .vignette-tete .genre.genre-HOMMES { background: #16283f; color: #8fb6e8; }
[data-bs-theme="dark"] .vignette-tete .genre.genre-FEMMES { background: #34172a; color: #e29bc0; }

/* ============ PAGES D'ERREUR ============
   Autonomes : ni rail ni barre superieure. L'utilisateur y arrive parfois deconnecte, et une page
   d'erreur qui dependrait du contexte de session echouerait au pire moment. */
.err-body { margin: 0; min-height: 100vh; background: var(--bg); }
.err-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1.25rem; }
.err-card {
    width: 100%; max-width: 480px; text-align: center;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 3rem 2rem 2.4rem; position: relative; overflow: hidden;
}
.err-icone {
    width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 1.4rem;
    display: grid; place-items: center; font-size: 1.9rem;
    background: var(--primary-050); color: var(--primary-600);
}
/* Le code en tres gros et tres pale : reperable d'un coup d'oeil pour decrire l'incident au
   support, sans voler la vedette au message en clair. */
.err-code {
    position: absolute; top: -.9rem; right: .9rem;
    font-size: 4.6rem; font-weight: 800; line-height: 1;
    color: var(--ink); opacity: .055; letter-spacing: -.04em; pointer-events: none;
}
.err-titre { font-size: 1.45rem; font-weight: 700; margin-bottom: .6rem; }
.err-texte { color: var(--muted); line-height: 1.6; margin-bottom: 1.8rem; }
.err-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
