/* UX-R3 — coque applicative professionnelle et navigation conventionnelle. */

.app-shell--authenticated {
    --content-width: min(1440px, calc(100% - 32px));
    padding-top: 16px;
}

/* La coque rend la navigation À L'INTÉRIEUR de <header> : le contrat
   structurel historique exige que </header> soit adjacent à <main>. La colonne
   de navigation devient donc une barre supérieure, positionnée en CSS. */
.app-shell--authenticated .app-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 24px;
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.app-shell--authenticated .app-header__identity {
    flex: 1 1 auto;
    min-width: 0;
}

.app-shell--authenticated .app-header__locale {
    flex: 0 0 auto;
}

/* Navigation et fil d'Ariane occupent chacun leur propre ligne du header. */
.app-shell--authenticated .app-navigation-r3,
.app-shell--authenticated .breadcrumb {
    flex: 1 0 100%;
}

.app-shell--authenticated .app-header h1 {
    margin: 0;
    color: var(--ink);
    font-family: var(--font-family-body);
    font-size: 1.25rem;
    font-weight: 700;
}

/* ---- Menu de compte ---- */

.app-identity {
    position: relative;
    flex: 0 0 auto;
}

/* <summary> : on retire le marqueur natif, la pastille et le nom suffisent. */
.app-identity__button {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: var(--tap-min);
    padding: 4px 12px 4px 4px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: #fff;
    color: var(--ink);
    font: inherit;
    cursor: pointer;
    max-width: 100%;
    list-style: none;
}

.app-identity__button::-webkit-details-marker {
    display: none;
}

.app-identity__button:hover {
    background: var(--sea-soft);
}

.app-identity__avatar {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    overflow: hidden;
    border-radius: 50%;
    background: var(--sea);
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
}

.app-identity__avatar-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.app-identity__text {
    min-width: 0;
    text-align: left;
    line-height: 1.2;
}

.app-identity__name {
    display: block;
    font-weight: 700;
    font-size: .88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-identity__context {
    display: block;
    color: var(--muted);
    font-size: .76rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-identity__menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 40;
    min-width: 232px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.app-identity__item {
    display: flex;
    align-items: center;
    min-height: var(--tap-min);
    padding: 9px 10px;
    border-radius: 7px;
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
}

.app-identity__item:hover {
    background: var(--sea-soft);
    color: var(--sea-text);
    text-decoration: none;
}

.app-identity__logout {
    margin: 6px 0 0;
    padding-top: 6px;
    border-top: 1px solid var(--line);
}

.app-identity__logout .btn {
    width: 100%;
    min-height: var(--tap-min);
    border-radius: 7px;
}

.app-header__locale {
    display: grid;
    grid-template-columns: auto minmax(110px, 160px) auto;
    gap: 8px;
    align-items: end;
    margin: 0;
}

.app-header__locale label {
    margin: 0;
    align-self: center;
    font-size: .9rem;
}

.app-header__locale select,
.app-header__locale button {
    min-height: 40px;
}

.app-navigation-r3 {
    border-top: 1px solid var(--line);
    padding-top: 8px;
    background: #fff;
}

.app-navigation-r3__toggle {
    width: 100%;
    min-height: var(--tap-min);
    padding: 10px 12px;
    border: 0;
    border-radius: 0;
    background: var(--sea);
    color: #fff;
    font: inherit;
    font-weight: 700;
    text-align: left;
}

/* Barre horizontale : chaque groupe garde sa propre boîte, un groupe déplié
   pousse le contenu vers le bas plutôt que de le recouvrir. */
.app-navigation-r3__links {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 4px;
    padding: 0;
}

/* `display` explicite ne doit jamais annuler l'attribut [hidden] posé par
   navigation.js — sinon le menu replié resterait visible. */
.app-navigation-r3__links[hidden],
.app-navigation-r3__toggle[hidden] {
    display: none;
}

.app-navigation-r3__group {
    flex: 0 0 auto;
    min-width: 190px;
}

.app-navigation-r3__link,
.app-navigation-r3__submenu a {
    display: flex;
    align-items: center;
    min-height: var(--tap-min);
    padding: 9px 10px;
    border-radius: 7px;
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
}

.app-navigation-r3__link:hover,
.app-navigation-r3__submenu a:hover,
.app-navigation-r3 [aria-current="page"] {
    background: var(--sea-soft);
    color: var(--sea-text);
    text-decoration: none;
}

.app-navigation-r3 [aria-current="page"] {
    box-shadow: inset 0 -3px 0 var(--sea);
}

.app-navigation-r3__group > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--tap-min);
    padding: 9px 10px;
    border-radius: 7px;
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.app-navigation-r3__group > summary::-webkit-details-marker {
    display: none;
}

.app-navigation-r3__group > summary::after {
    content: "⌄";
    color: var(--muted);
    font-weight: 400;
}

.app-navigation-r3__group[open] > summary::after {
    content: "⌃";
}

.app-navigation-r3__group > summary:hover {
    background: var(--sand);
}

.app-navigation-r3__submenu {
    display: flex;
    flex-direction: column;
    margin: 0 0 4px 10px;
    padding-left: 7px;
    border-left: 1px solid var(--line);
}

.app-navigation-r3__submenu a {
    min-height: 40px;
    font-size: .92rem;
    font-weight: 600;
}

/* Profil et déconnexion sont poussés en fin de barre, séparés du reste. */
.app-navigation-r3__profile {
    margin-left: auto;
}

.app-navigation-r3__logout {
    margin: 0;
    padding-left: 8px;
    border-left: 1px solid var(--line);
}

.app-navigation-r3__logout .btn {
    min-height: var(--tap-min);
    border-radius: 7px;
}

.app-shell--authenticated .breadcrumb {
    margin: 0 0 12px;
}

.app-shell--authenticated .card {
    border-radius: 10px;
    box-shadow: none;
}

.app-shell--authenticated .btn,
.app-shell--authenticated button[type="submit"],
.app-shell--authenticated .messenger button {
    border-radius: 8px;
}

.dashboard-r3 {
    min-width: 0;
}

.dashboard-r3__intro,
.messages-r3__intro {
    margin-bottom: 24px;
}

.dashboard-r3__intro h2,
.messages-r3__intro h2 {
    margin-bottom: 6px;
}

.dashboard-r3__section + .dashboard-r3__section {
    margin-top: 28px;
}

.dashboard-summary__grid--r3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-r3-shortcuts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.dashboard-r3-shortcut {
    display: flex;
    align-items: center;
    min-height: 50px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-weight: 700;
}

.dashboard-r3-shortcut:hover {
    border-color: var(--sea);
    background: var(--sea-soft);
    text-decoration: none;
}

.messages-r3 .messenger {
    margin-top: 16px;
}

.messages-r3__communication {
    margin-top: 24px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--sand);
}

/* ---- Profil professionnel et création de salarié ---- */

.error-banner,
.warning-banner {
    margin: 12px 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--sand);
}

.error-banner {
    border-left: 4px solid currentColor;
}

.warning-banner {
    border-left: 4px solid var(--sea);
}

.profile-page,
.employee-create-page {
    min-width: 0;
}

.profile-card {
    display: grid;
    grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    margin: 16px 0 24px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.profile-card__photo {
    display: grid;
    gap: 12px;
    justify-items: start;
    min-width: 0;
}

.profile-photo {
    display: block;
    width: 128px;
    height: 128px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--sea-soft);
}

.profile-photo--initials {
    display: grid;
    place-items: center;
    background: var(--sea);
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
}

.profile-photo-form {
    display: grid;
    gap: 8px;
    width: min(100%, 320px);
    margin: 0;
}

.profile-card__details {
    min-width: 0;
}

.profile-details {
    display: grid;
    grid-template-columns: minmax(150px, 200px) minmax(0, 1fr);
    gap: 8px 18px;
    margin: 12px 0 16px;
}

.profile-details dt {
    font-weight: 700;
}

.profile-details dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.employee-create-form {
    display: grid;
    gap: 18px;
    max-width: 760px;
}

.employee-create-form fieldset {
    margin: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.employee-create-form legend {
    padding: 0 6px;
    font-weight: 700;
}

@media (max-width: 960px) {
    .app-navigation-r3__group {
        min-width: 160px;
    }

    .dashboard-summary__grid--r3,
    .dashboard-r3-shortcuts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .app-shell--authenticated {
        --content-width: min(100% - 20px, 100%);
        padding-top: 10px;
    }

    .app-shell--authenticated .app-header {
        display: block;
        margin-bottom: 10px;
        padding: 10px;
    }

    .app-header__locale {
        grid-template-columns: 1fr auto;
        margin-top: 10px;
    }

    .app-header__locale label {
        grid-column: 1 / -1;
    }

    /* Sous 720 px la barre redevient une liste verticale repliable. */
    .app-navigation-r3 {
        margin: 10px 0 0;
    }

    .app-navigation-r3__links {
        display: block;
    }

    .app-navigation-r3__group {
        min-width: 0;
    }

    .app-navigation-r3__profile {
        margin-left: 0;
    }

    .app-navigation-r3__logout {
        margin-top: 8px;
        padding: 8px 0 0;
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .app-navigation-r3__logout .btn {
        width: 100%;
    }

    .app-navigation-r3__toggle {
        display: block;
    }

    .app-navigation-r3__toggle[hidden],
    .app-navigation-r3__links[hidden] {
        display: none;
    }

    .app-navigation-r3__links {
        max-height: min(70vh, 620px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .dashboard-summary__grid--r3,
    .dashboard-r3-shortcuts {
        grid-template-columns: 1fr;
    }

    .profile-card {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 16px;
    }

    .profile-details {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .profile-details dd + dt {
        margin-top: 8px;
    }
}
