/*
 * SESAM espaces connectés — « Aurora Glass » (2026-10-08)
 * Même langage que le site public : fond presque blanc, vitres givrées, grands arrondis,
 * dégradé bleu pour l'action principale, une teinte par rubrique (--tone).
 * Chargé après sesam.css : les règles de ce fichier gagnent à spécificité égale.
 * Périmètre : socle commun (coque, barre, cartes, tableaux, formulaires, boutons, modale) et page de connexion.
 */

:root {
    --ag-fill: rgba(255, 255, 255, 0.72);
    --ag-fill-strong: rgba(255, 255, 255, 0.88);
    --ag-line: rgba(255, 255, 255, 0.92);
    --ag-edge: rgba(7, 26, 61, 0.08);
    --ag-blur: blur(22px) saturate(1.7);
    --ag-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        0 26px 52px -30px rgba(3, 50, 140, 0.34),
        0 8px 20px -14px rgba(7, 26, 61, 0.18);
    --ag-shadow-soft:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        0 16px 34px -24px rgba(3, 50, 140, 0.3),
        0 4px 12px -8px rgba(7, 26, 61, 0.12);
    --ag-grad: #0349b8;
    --ag-hero: #0a2d78;
    --ag-radius: 1.5rem;
    --ag-radius-sm: 0.85rem;
}

/* ---------- Fond ---------- */

body.is-app,
body.auth-body {
    background-color: #fdfeff;
    background-image:
        none;
    background-attachment: fixed;
}

body.is-app::before {
    top: -12rem;
    right: -8rem;
    width: 30rem;
    height: 30rem;
    background: rgba(8, 124, 255, 0.2);
    box-shadow: none;
    filter: blur(46px);
}

body.is-app::after {
    bottom: -10rem;
    left: 36%;
    width: 26rem;
    height: 26rem;
    background: rgba(124, 92, 255, 0.12);
    box-shadow: none;
    filter: blur(52px);
}

/* ---------- Rail : vitre claire, icônes teintées ---------- */

.is-app .tenant-rail {
    border: 1px solid var(--ag-line);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--ag-shadow);
    backdrop-filter: var(--ag-blur);
    -webkit-backdrop-filter: var(--ag-blur);
    color: var(--sesam-navy);
}

.is-app .tenant-rail-logo,
.is-app .tenant-rail-commerce,
.is-app .tenant-rail-brand .tenant-rail-text {
    color: var(--sesam-navy);
}

.is-app .tenant-rail-commerce {
    color: var(--sesam-muted);
}

.is-app .tenant-rail-logo img {
    box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px rgba(8, 124, 255, 0.5), 0 8px 18px -8px rgba(3, 73, 184, 0.6);
}

.is-app .tenant-rail-close {
    background: rgba(7, 26, 61, 0.06);
    color: var(--sesam-navy);
}

.is-app .tenant-rail-nav a {
    color: var(--sesam-navy);
    font-weight: 600;
    border-radius: 1rem;
}

.is-app .tenant-rail-nav a .ui-icon {
    box-sizing: content-box;
    width: 1.15rem;
    height: 1.15rem;
    padding: 0.4rem;
    border-radius: 0.8rem;
    background: var(--tone-soft, rgba(8, 124, 255, 0.13));
    color: var(--tone, var(--sesam-electric));
    transition: transform 0.2s var(--sesam-ease), background 0.2s var(--sesam-ease), color 0.2s var(--sesam-ease);
}

.is-app .tenant-rail-nav a:hover {
    background: rgba(255, 255, 255, 0.85);
    color: var(--sesam-navy);
}

.is-app .tenant-rail-nav a:hover .ui-icon {
    transform: translateY(-1px) scale(1.06);
}

.is-app .tenant-rail-nav a[aria-current="page"],
.is-app .tenant-rail-nav a[aria-current="page"]:hover {
    background: #fff;
    color: var(--sesam-navy);
    box-shadow: 0 10px 22px -12px rgba(3, 50, 140, 0.45), inset 0 0 0 1.5px var(--tone-soft, rgba(8, 124, 255, 0.2));
}

.is-app .tenant-rail-nav a[aria-current="page"] .ui-icon {
    background: var(--tone, var(--sesam-electric));
    color: #fff;
    box-shadow: 0 8px 16px -8px var(--tone, var(--sesam-electric));
}

.is-app .tenant-rail-logout-btn {
    border-radius: 1rem;
    color: var(--sesam-muted);
}

.is-app .tenant-rail-logout-btn:hover {
    background: rgba(229, 72, 77, 0.1);
    color: var(--sesam-danger);
}

.is-app .tenant-rail-scrim {
    background: rgba(7, 26, 61, 0.32);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* ---------- Barre du haut ---------- */

.is-app .tenant-chrome {
    border: 1px solid var(--ag-line);
    background: var(--ag-fill-strong);
    box-shadow: var(--ag-shadow-soft);
    backdrop-filter: var(--ag-blur);
    -webkit-backdrop-filter: var(--ag-blur);
}

.is-app .tenant-menu-toggle {
    border-color: transparent;
    background: var(--ag-grad);
    color: #fff;
    box-shadow: 0 10px 20px -10px rgba(3, 73, 184, 0.7);
}

.is-app .tenant-search {
    border-color: rgba(12, 23, 48, 0.1);
    background: rgba(246, 249, 255, 0.9);
    box-shadow: inset 0 1px 2px rgba(7, 26, 61, 0.05);
}

.is-app .tenant-search-submit {
    color: var(--sesam-blue);
}

.is-app .tenant-avatar {
    background: var(--ag-grad);
    box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px rgba(8, 124, 255, 0.45);
}

/* ---------- Titre de page ---------- */

.is-app .tenant-content h1 {
    color: var(--sesam-navy);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.is-app .tenant-content .dash-hero h1 {
    color: #fff;
}

.is-app .tenant-content h1::before {
    width: 0.38rem;
    background: var(--sesam-electric);
    box-shadow: 0 6px 12px -6px var(--tone, var(--sesam-electric));
}

.is-app .dash-hero :is(.console-eyebrow, .eyebrow) {
    color: rgba(255, 255, 255, 0.82);
}

/* ---------- Surfaces ---------- */

.is-app .card,
.is-app .panel,
.is-app .empty,
.is-app .stat,
.is-app .dash-card,
.is-app .dash-kpi,
.is-app .stats-kpi,
.is-app .table-wrap,
.is-app .notification-list > li,
.is-app .console-rows,
.is-app .portal-card {
    border: 1px solid var(--ag-line);
    border-radius: var(--ag-radius);
    background: var(--ag-fill);
    box-shadow: var(--ag-shadow-soft);
    backdrop-filter: var(--ag-blur);
    -webkit-backdrop-filter: var(--ag-blur);
}

.is-app .dash-card,
.is-app .card,
.is-app .panel {
    padding: 1.15rem 1.35rem;
}

.is-app .dash-card .table-wrap,
.is-app .dash-card .empty,
.is-app .card .table-wrap,
.is-app .card .empty {
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.is-app .dash-card h2,
.is-app .card h2,
.is-app .panel h2 {
    color: var(--sesam-navy);
    font-weight: 800;
    letter-spacing: -0.01em;
}

.is-app .empty {
    border-style: dashed;
    border-color: rgba(12, 23, 48, 0.1);
    background: rgba(255, 255, 255, 0.55);
    color: var(--sesam-muted);
    text-align: center;
}

.is-app .dash-kpi:hover,
.is-app .stats-kpi:hover {
    transform: translateY(-3px);
    box-shadow: var(--ag-shadow);
}

/* Formulaire de page entière : une vitre centrée, pas un champ étiré sur tout l'écran. */
.is-app .tenant-content > section > form.stack {
    width: min(100%, 46rem);
    padding: clamp(1.1rem, 2.4vw, 1.9rem);
    border: 1px solid var(--ag-line);
    border-radius: 1.75rem;
    background: var(--ag-fill-strong);
    box-shadow: var(--ag-shadow);
    backdrop-filter: var(--ag-blur);
    -webkit-backdrop-filter: var(--ag-blur);
}

.is-app .tenant-content > section > form.stack .row {
    gap: 0.6rem;
}

/* ---------- Bandeaux de tête ---------- */

.is-app .dash-hero {
    padding: clamp(1.2rem, 2.4vw, 1.9rem);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 1.9rem;
    background: var(--ag-hero);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        0 34px 60px -30px rgba(3, 73, 184, 0.7);
}

.is-app .dash-hero::before {
    top: -7rem;
    right: -3rem;
    width: 20rem;
    height: 20rem;
    background: transparent;
    box-shadow: none;
}

.is-app .dash-hero::after {
    content: "";
    position: absolute;
    z-index: -1;
    right: 14%;
    bottom: -4rem;
    width: 11rem;
    height: 11rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.28);
    pointer-events: none;
}

.is-app .console-hero::after {
    z-index: -1;
}

.is-app .dash-hero .btn-primary,
.is-app .dash-cta-solid {
    background: #fff;
    color: var(--sesam-blue);
    box-shadow: 0 14px 26px -14px rgba(0, 0, 0, 0.5);
}

.is-app .dash-hero .btn-primary:hover,
.is-app .dash-cta-solid:hover {
    background: #fff;
    color: var(--sesam-navy);
    transform: translateY(-2px);
}

.is-app .dash-cta-ghost {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.14);
}

/* ---------- Indicateurs ---------- */

.is-app .dash-kpi {
    padding: 1rem 1.15rem;
}

.is-app .dash-kpi strong,
.is-app .stats-kpi strong {
    color: var(--sesam-navy);
    font-weight: 800;
}

.is-app .dash-kpi-icon {
    width: 2.7rem;
    height: 2.7rem;
    border-radius: 1rem;
    background: var(--sesam-electric);
    box-shadow: 0 12px 22px -12px var(--kpi, var(--sesam-electric));
}

.is-app .dash-kpi-icon::after {
    inset: 0.8rem;
}

.is-app .stats-kpi-lead {
    border-color: transparent;
    background: var(--ag-hero);
}

.is-app .stats-kpi-lead,
.is-app .stats-kpi-lead strong,
.is-app .stats-kpi-lead p,
.is-app .stats-kpi-lead small,
.is-app .stats-kpi-lead span {
    color: #fff;
}

.is-app .stats-chart-bar {
    border-radius: 1rem;
    background: rgba(8, 124, 255, 0.07);
}

.is-app .stats-chart-bar span,
.is-app .stats-chart li:last-child .stats-chart-bar span {
    border-radius: 0.8rem 0.8rem 0 0;
    background: #4aa8ff;
}

.is-app .stats-chart li:last-child .stats-chart-bar span {
    background: var(--ag-grad);
    box-shadow: 0 -6px 18px -6px rgba(8, 124, 255, 0.6);
}

/* ---------- Boutons ---------- */

.is-app .btn {
    border-radius: 0.85rem;
    font-weight: 700;
}

.is-app .btn-primary {
    border: 0;
    background: var(--ag-grad);
    color: #fff;
    box-shadow: 0 14px 26px -14px rgba(3, 73, 184, 0.85);
}

.is-app .btn-primary:hover {
    background: var(--ag-grad);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 18px 30px -14px rgba(3, 73, 184, 0.9);
}

.is-app .btn-secondary {
    border-color: rgba(12, 23, 48, 0.1);
    background: rgba(255, 255, 255, 0.85);
    color: var(--sesam-blue);
}

.is-app .btn-secondary:hover {
    border-color: rgba(12, 23, 48, 0.1);
    background: #fff;
    transform: translateY(-1px);
}

.is-app .tenant-content .btn-ghost {
    border-color: rgba(12, 23, 48, 0.1);
    background: rgba(255, 255, 255, 0.6);
}

.is-app .btn-danger {
    border: 0;
    background: #c62f34;
}

/* ---------- Champs ---------- */

.is-app .input,
.is-app .select {
    border-color: rgba(12, 23, 48, 0.1);
    border-radius: var(--ag-radius-sm);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: inset 0 1px 2px rgba(7, 26, 61, 0.04);
}

.is-app .input:hover,
.is-app .select:hover {
    border-color: rgba(12, 23, 48, 0.1);
}

.is-app .input:focus,
.is-app .select:focus {
    /* Focus identique partout (le corail d'une rubrique passerait pour une erreur) : bordure neutre, halo bleu. */
    border-color: rgba(12, 23, 48, 0.28);
    box-shadow: 0 0 0 4px rgba(10, 108, 240, 0.16);
}

.is-app fieldset {
    border-color: rgba(12, 23, 48, 0.1);
    border-radius: var(--ag-radius);
    background: rgba(255, 255, 255, 0.5);
}

/* ---------- Tableaux ---------- */

.is-app .table-wrap {
    overflow: hidden;
    overflow-x: auto;
}

.is-app th {
    background: rgba(8, 124, 255, 0.09);
    color: var(--sesam-slate);
}

.is-app td {
    border-bottom: 1px solid rgba(12, 23, 48, 0.1);
}

.is-app tbody tr:hover {
    background: rgba(8, 124, 255, 0.05);
}

.is-app td a:not(.btn) {
    color: var(--sesam-blue);
    font-weight: 700;
    text-decoration: none;
    text-underline-offset: 0.2em;
}

.is-app td a:not(.btn):hover,
.is-app td a:not(.btn):focus-visible {
    text-decoration: underline;
}

/* ---------- Lignes-cartes de la console ---------- */

.is-app .console-rows {
    padding: 0.5rem;
    border-radius: 1.6rem;
}

.is-app .console-row {
    border: 1px solid transparent;
    border-radius: 1.15rem;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 6px 14px -10px rgba(7, 26, 61, 0.2);
}

.is-app .console-row:hover {
    border-color: rgba(12, 23, 48, 0.1);
    background: #fff;
    box-shadow: 0 18px 30px -18px rgba(3, 73, 184, 0.45);
    transform: translateY(-2px);
}

/* ---------- Pastilles, alertes ---------- */

.is-app .badge,
.is-app .chip-ok,
.is-app .chip-warn,
.is-app .chip-off,
.is-app .chip-muted {
    border-radius: 999px;
    font-weight: 700;
}

.is-app .alert {
    border: 1px solid var(--ag-line);
    border-left: 0;
    border-radius: var(--ag-radius-sm);
    background: rgba(240, 253, 248, 0.9);
}

.is-app .alert-danger {
    background: rgba(255, 244, 244, 0.92);
}

.is-app .alert-strong {
    background: rgba(255, 249, 235, 0.92);
}

/* ---------- Modale ---------- */

.form-modal::backdrop {
    background: rgba(7, 26, 61, 0.3);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
}

.form-modal-panel {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(30px) saturate(1.8);
    -webkit-backdrop-filter: blur(30px) saturate(1.8);
}

@media (min-width: 720px) {
    .form-modal-panel {
        border: 1px solid var(--ag-line);
        border-radius: 2rem;
        box-shadow: 0 50px 90px -40px rgba(3, 50, 140, 0.55);
    }
}

.form-modal-close {
    background: rgba(246, 249, 255, 0.95);
}

.form-modal-close:hover {
    background: var(--ag-grad);
}

/* ---------- Connexion et pages d'authentification ---------- */

.auth-body {
    position: relative;
    overflow-x: clip;
}

.auth-body::before,
.auth-body::after {
    content: "";
    position: fixed;
    z-index: -1;
    border-radius: 50%;
    filter: blur(48px);
    pointer-events: none;
}

.auth-body::before {
    top: -10rem;
    right: -6rem;
    width: 28rem;
    height: 28rem;
    background: rgba(8, 124, 255, 0.28);
}

.auth-body::after {
    bottom: -10rem;
    left: -8rem;
    width: 26rem;
    height: 26rem;
    background: rgba(124, 92, 255, 0.18);
}

.auth-sheet {
    max-width: 28rem;
    padding-block: clamp(1.5rem, 6vh, 3.5rem);
}

.auth-brand img {
    width: 4.25rem;
    height: 4.25rem;
    border-radius: 1.3rem;
    box-shadow: var(--ag-shadow);
}

.auth-card {
    padding: clamp(1.4rem, 4vw, 2.1rem);
    border: 1px solid var(--ag-line);
    border-radius: 2rem;
    background: var(--ag-fill-strong);
    box-shadow: var(--ag-shadow);
    backdrop-filter: var(--ag-blur);
    -webkit-backdrop-filter: var(--ag-blur);
}

.auth-card h1 {
    color: var(--sesam-navy);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.auth-card .input {
    border-color: rgba(12, 23, 48, 0.1);
    border-radius: var(--ag-radius-sm);
    background: rgba(255, 255, 255, 0.94);
}

.auth-card .input:focus {
    border-color: rgba(12, 23, 48, 0.1);
    box-shadow: 0 0 0 4px rgba(8, 124, 255, 0.16);
}

.auth-card .btn {
    border-radius: 0.95rem;
    font-weight: 700;
}

.auth-card .btn-primary {
    border: 0;
    background: var(--ag-grad);
    box-shadow: 0 16px 28px -14px rgba(3, 73, 184, 0.85);
}

.auth-card .btn-primary:hover {
    background: var(--ag-grad);
    transform: translateY(-2px);
}

.auth-back a,
.auth-help a {
    color: var(--sesam-blue);
    font-weight: 600;
}

/* ---------- Repli sans flou ---------- */

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .is-app .tenant-rail,
    .is-app .tenant-chrome,
    .is-app .card,
    .is-app .panel,
    .is-app .dash-card,
    .is-app .dash-kpi,
    .is-app .stats-kpi,
    .is-app .table-wrap,
    .is-app .console-rows,
    .auth-card,
    .form-modal-panel {
        background: #fff;
    }
}

@media (max-width: 719px) {
    .is-app .card,
    .is-app .panel,
    .is-app .empty,
    .is-app .dash-card,
    .is-app .dash-kpi,
    .is-app .stats-kpi,
    .is-app .table-wrap,
    .is-app .console-rows,
    .is-app .tenant-chrome {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(255, 255, 255, 0.92);
    }

    .is-app .stats-kpi.stats-kpi-lead {
        background: var(--ag-hero);
    }

    .is-app .dash-hero {
        border-radius: 1.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .is-app .dash-kpi:hover,
    .is-app .stats-kpi:hover,
    .is-app .console-row:hover,
    .is-app .btn-primary:hover,
    .auth-card .btn-primary:hover {
        transform: none;
    }
}

/* ---------- Menu des espaces : libellés visibles sur tablette et ordinateur ----------
   À partir de 768px, le menu reste ouvert à gauche avec l'icône et le nom de chaque lien.
   En dessous, il reste le volet ouvert par le bouton menu. */
@media (min-width: 768px) {
    .is-app .tenant-shell {
        padding: var(--sesam-space-3);
    }

    .is-app .tenant-board {
        display: grid;
        grid-template-columns: 14.5rem minmax(0, 1fr);
        gap: var(--sesam-space-3);
        border-radius: 0;
    }

    .is-app .tenant-rail {
        position: sticky;
        top: var(--sesam-space-3);
        inset: auto;
        width: auto;
        height: calc(100vh - 2 * var(--sesam-space-3));
        min-height: 0;
        padding: var(--sesam-space-3) var(--sesam-space-2);
        transform: none;
        border-radius: var(--sesam-radius-lg);
    }

    .is-app .tenant-rail-scrim,
    .is-app .tenant-rail-close,
    .is-app .tenant-menu-toggle {
        display: none;
    }

    .is-app .tenant-rail-head {
        justify-content: flex-start;
        margin-bottom: var(--sesam-space-3);
        padding-inline: 0.35rem;
    }

    .is-app .tenant-rail-logo {
        justify-content: flex-start;
        gap: 0.6rem;
        min-width: 0;
    }

    .is-app .tenant-rail-text {
        position: static;
        width: auto;
        height: auto;
        overflow: hidden;
        clip: auto;
        white-space: nowrap;
        text-overflow: ellipsis;
        letter-spacing: 0;
    }

    .is-app .tenant-rail-brand {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .is-app .tenant-rail-nav a,
    .is-app .tenant-rail-logout-btn {
        justify-content: flex-start;
        gap: 0.65rem;
        width: 100%;
        min-height: 2.6rem;
        padding: 0.3rem 0.6rem;
        font-size: 0.94rem;
        text-align: left;
    }

    .is-app .tenant-rail-nav a .tenant-rail-text,
    .is-app .tenant-rail-logout-btn .tenant-rail-text {
        flex: 1 1 auto;
        min-width: 0;
    }

    .is-app .tenant-rail-badge {
        position: static;
        margin-left: auto;
        min-height: 1.2rem;
        padding: 0 0.4rem;
        font-size: 0.72rem;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .is-app .tenant-board {
        grid-template-columns: 12.5rem minmax(0, 1fr);
    }

    .is-app .tenant-rail-nav a,
    .is-app .tenant-rail-logout-btn {
        font-size: 0.9rem;
    }
}
