/*
 * Ossature de l'application : barre superieure, navigation, gouttiere de page,
 * en-tete de page, pied de page et gabarit centre des ecrans d'authentification.
 */

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Barre superieure -------------------------------------------------------- */

.topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    border-bottom: 1px solid var(--rh-line);
    background: color-mix(in srgb, var(--rh-surface) 88%, transparent);
    backdrop-filter: blur(12px) saturate(140%);
}

.topbar-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--rh-space-2) var(--rh-space-4);
    width: min(var(--rh-page-width), 100%);
    min-height: 62px;
    margin: 0 auto;
    padding: var(--rh-space-2) var(--rh-space-5);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--rh-space-3);
    min-width: 0;
    color: var(--rh-ink);
    font-weight: 700;
    text-decoration: none;
}

.brand:hover {
    color: var(--rh-ink);
}

.brand-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    object-fit: contain;
}

.brand-copy {
    display: grid;
    min-width: 0;
    max-width: 20rem;
    line-height: 1.15;
}

.brand-name {
    overflow: hidden;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-org {
    overflow: hidden;
    color: var(--rh-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Navigation principale --------------------------------------------------- */

/*
 * La navigation occupe toujours sa propre ligne sous la marque et les
 * outils : les libelles ne se reductent pas, elle debordait donc et
 * chevauchait le titre et les onglets (retour MOA 07/09/2026). Elle reste
 * defilable si l'ecran est etroit.
 */

.main-nav {
    order: 4;
    display: flex;
    align-items: center;
    gap: var(--rh-space-1);
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: var(--rh-space-2);
    min-height: 36px;
    padding: 0 var(--rh-space-3);
    border-radius: var(--rh-radius-sm);
    color: var(--rh-ink-soft);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.nav-link:hover {
    background: var(--rh-surface-strong);
    color: var(--rh-ink);
}

.nav-link[aria-current="page"] {
    background: var(--rh-primary-soft);
    color: var(--rh-primary);
    box-shadow: inset 0 0 0 1px var(--rh-primary-line);
}

.nav-icon {
    flex: 0 0 auto;
    opacity: 0.75;
}

.nav-link[aria-current="page"] .nav-icon {
    opacity: 1;
}

/* Zone de droite : identite, theme, deconnexion. */

.topbar-tools {
    display: flex;
    align-items: center;
    gap: var(--rh-space-2);
    margin-left: auto;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--rh-space-2);
    max-width: 15rem;
    padding: var(--rh-space-1) var(--rh-space-3) var(--rh-space-1) var(--rh-space-1);
    border: 1px solid var(--rh-line);
    border-radius: var(--rh-radius-pill);
    background: var(--rh-surface-muted);
}

.user-avatar {
    display: grid;
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: linear-gradient(140deg, var(--rh-brand-600), var(--rh-brand-500));
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    place-items: center;
}

.user-name {
    overflow: hidden;
    color: var(--rh-ink-soft);
    font-size: 0.8rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Gouttiere de page ------------------------------------------------------- */

.page {
    width: min(var(--rh-page-width), 100%);
    flex: 1 0 auto;
    margin: 0 auto;
    padding: var(--rh-space-6) var(--rh-space-5) var(--rh-space-7);
}

.page > * + * {
    margin-top: var(--rh-space-5);
}

/* En-tete de page --------------------------------------------------------- */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--rh-space-5);
    flex-wrap: wrap;
}

.page-header-copy {
    min-width: min(100%, 24rem);
    flex: 1 1 32rem;
}

.page-eyebrow {
    display: flex;
    align-items: center;
    gap: var(--rh-space-2);
    margin-bottom: var(--rh-space-2);
    color: var(--rh-accent);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-eyebrow a {
    color: inherit;
    font: inherit;
    text-decoration: none;
}

.page-eyebrow a:hover {
    color: var(--rh-primary-hover);
    text-decoration: underline;
}

.page-lead {
    max-width: 62ch;
    margin: var(--rh-space-2) 0 0;
    color: var(--rh-muted);
    font-size: 0.92rem;
}

.page-header-aside {
    display: flex;
    align-items: center;
    gap: var(--rh-space-2);
    flex-wrap: wrap;
}

/* Ligne de titre interne a un panneau. */

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--rh-space-4);
    flex-wrap: wrap;
    margin-bottom: var(--rh-space-4);
}

.section-head > :first-child {
    min-width: 0;
}

.section-head h2,
.section-head h3 {
    margin-bottom: 0;
}

.section-hint {
    margin: var(--rh-space-1) 0 0;
    color: var(--rh-muted);
    font-size: 0.85rem;
}

/* Grilles generiques ------------------------------------------------------ */

.grid {
    display: grid;
    gap: var(--rh-space-4);
}

.grid-cards {
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
}

.grid-halves {
    grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr));
    align-items: start;
}

/* Pied de page ------------------------------------------------------------ */

.app-footer {
    border-top: 1px solid var(--rh-line);
    background: color-mix(in srgb, var(--rh-surface) 60%, transparent);
}

.app-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--rh-space-4);
    flex-wrap: wrap;
    width: min(var(--rh-page-width), 100%);
    margin: 0 auto;
    padding: var(--rh-space-4) var(--rh-space-5);
    color: var(--rh-muted);
    font-size: 0.8rem;
}

/* Version livrée : discrète, en chiffres tabulaires pour ne pas danser d'une
   livraison à l'autre. Le SHA complet est dans l'attribut « title ». */
.app-footer-version {
    font-family: var(--rh-font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.75rem;
    opacity: 0.75;
}

/* Ecrans d'authentification ---------------------------------------------- */

body.auth-page {
    background-image:
        radial-gradient(760px 420px at 15% -10%, color-mix(in srgb, var(--rh-brand-600) 26%, transparent) 0%, transparent 70%),
        radial-gradient(700px 420px at 88% 8%, color-mix(in srgb, var(--rh-brand-300) 24%, transparent) 0%, transparent 68%);
}

.auth-shell {
    display: grid;
    min-height: 100vh;
    padding: var(--rh-space-6) var(--rh-space-4);
    place-items: center;
}

.auth-card {
    width: min(30rem, 100%);
    padding: var(--rh-space-6);
    border: 1px solid var(--rh-line);
    border-radius: var(--rh-radius-lg);
    background: var(--rh-surface);
    box-shadow: var(--rh-shadow-lg);
}

.auth-brand {
    display: grid;
    margin-bottom: var(--rh-space-5);
    gap: var(--rh-space-3);
    justify-items: center;
    text-align: center;
}

.auth-mark {
    width: 74px;
    height: 74px;
}

.auth-brand h1 {
    margin-bottom: 0;
    font-size: 1.35rem;
}

.auth-brand p {
    margin: 0;
    color: var(--rh-muted);
    font-size: 0.85rem;
}

.auth-footer {
    margin-top: var(--rh-space-5);
    padding-top: var(--rh-space-4);
    border-top: 1px solid var(--rh-line);
    color: var(--rh-muted);
    font-size: 0.78rem;
    text-align: center;
}

/* Adaptations ------------------------------------------------------------- */

@media (max-width: 1080px) {
    .brand-org {
        display: none;
    }

    .user-name {
        display: none;
    }

    .user-chip {
        padding: var(--rh-space-1);
    }
}

@media (max-width: 900px) {
    .topbar-inner {
        padding-inline: var(--rh-space-4);
    }

    .page {
        padding: var(--rh-space-5) var(--rh-space-4) var(--rh-space-6);
    }
}
