/* ==========================================================================
   Certigo – Ouverture de compte : feuille de style commune
   Couleurs de la marque : bleu marine #14243D, jaune #F8AB17
   ========================================================================== */

:root {
    --navy: #14243d;
    --navy-800: #1b3254;
    --navy-100: #dfe5ef;
    --navy-50: #eef1f6;
    --yellow: #f8ab17;
    --yellow-600: #dc950b;
    --yellow-100: #fff2d6;

    --bg: #f4f6fa;
    --surface: #ffffff;
    --text: #1d2733;
    --muted: #5d6b7e;
    --border: #dde3ec;

    --success: #19794a;
    --success-bg: #e4f4ec;
    --danger: #b3261e;
    --danger-bg: #fdeceb;
    --info: #1d5fa8;
    --info-bg: #e7f0fb;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(20, 36, 61, 0.06), 0 8px 24px rgba(20, 36, 61, 0.08);
    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: var(--navy-800);
}

:focus-visible {
    outline: 3px solid var(--yellow);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---- Boutons ------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: 44px;
    padding: 0.6rem 1.2rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn--primary {
    background: var(--yellow);
    color: var(--navy);
}

.btn--primary:hover {
    background: var(--yellow-600);
}

.btn--dark {
    background: var(--navy);
    color: #fff;
}

.btn--dark:hover {
    background: var(--navy-800);
}

.btn--ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--navy);
}

.btn--ghost:hover {
    background: var(--navy-50);
}

.btn--sm {
    min-height: 36px;
    padding: 0.3rem 0.8rem;
    font-size: 0.9rem;
}

.btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ---- Messages ----------------------------------------------------------- */
.alert {
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.95rem;
}

.alert--error {
    background: var(--danger-bg);
    border-color: #f2c4c1;
    color: var(--danger);
}

.alert--success {
    background: var(--success-bg);
    border-color: #b9e0cb;
    color: var(--success);
}

.alert--info {
    background: var(--info-bg);
    border-color: #bcd5f0;
    color: var(--info);
}

/* ---- Page de connexion -------------------------------------------------- */
.login {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}

.login__brand {
    background:
        radial-gradient(circle at 15% 20%, rgba(248, 171, 23, 0.18), transparent 45%),
        linear-gradient(160deg, var(--navy) 0%, var(--navy-800) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.5rem;
    padding: 3rem clamp(1.5rem, 6vw, 5rem);
}

.login__brand img {
    width: min(320px, 70%);
}

.login__brand h1 {
    margin: 0;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    line-height: 1.2;
}

.login__brand p {
    margin: 0;
    max-width: 34rem;
    color: #c9d3e3;
}

.login__panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem;
}

.login__card {
    width: 100%;
    max-width: 26rem;
    display: grid;
    gap: 1.1rem;
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login__card h2 {
    margin: 0;
    color: var(--navy);
}

.login__card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.btn--microsoft {
    background: #fff;
    border-color: #8c8c8c;
    color: #5e5e5e;
    min-height: 48px;
}

.btn--microsoft:hover {
    background: #f3f3f3;
}

.btn--microsoft svg {
    flex: none;
}

@media (max-width: 800px) {
    .login {
        grid-template-columns: 1fr;
    }

    .login__brand {
        padding: 2rem 1.5rem;
    }

    .login__brand p {
        display: none;
    }
}

/* ---- Structure de l'application ----------------------------------------- */
.app-header {
    background: var(--navy);
    color: #fff;
    border-bottom: 4px solid var(--yellow);
}

.app-header__inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.7rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.app-header__logo img {
    display: block;
    height: 30px;
    width: auto;
}

.app-header__user {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.92rem;
}

.app-header__name {
    text-align: right;
    line-height: 1.2;
}

.app-header__name small {
    display: block;
    color: #b8c4d8;
}

.badge-role {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: var(--yellow);
    color: var(--navy);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.app-main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 3rem;
}

.page-title {
    margin: 0 0 1.25rem;
    color: var(--navy);
    font-size: 1.6rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

@media (max-width: 560px) {
    .app-header__name small {
        display: none;
    }
}

.btn--header {
    background: transparent;
    border-color: #42567a;
    color: #fff;
}

.btn--header:hover {
    background: var(--navy-800);
}

@media (max-width: 800px) {
    .login__card {
        padding: 1.5rem 1.25rem;
    }

    .btn--microsoft {
        font-size: 0.95rem;
        padding-inline: 0.8rem;
    }
}

/* ---- En-têtes de page --------------------------------------------------- */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.page-head .page-title {
    margin-bottom: 0.2rem;
}

.page-subtitle {
    margin: 0;
    color: var(--muted);
}

.breadcrumb {
    margin: 0 0 0.75rem;
    font-size: 0.92rem;
}

.muted {
    color: var(--muted);
}

/* ---- Recherche et filtres ---------------------------------------------- */
.filters {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.search {
    position: relative;
    flex: 1;
}

.search input {
    width: 100%;
    min-height: 44px;
    padding: 0.5rem 0.9rem 0.5rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font: inherit;
    color: var(--text);
}

.search input:focus {
    border-color: var(--navy-800);
    outline: 3px solid rgba(248, 171, 23, 0.45);
    outline-offset: 0;
}

.search__icon {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.tabs {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--navy);
    font-weight: 600;
    font-size: 0.92rem;
    text-decoration: none;
}

.tab:hover {
    background: var(--navy-50);
}

.tab--active {
    background: var(--navy);
    border-color: var(--navy);
    color: #fff;
}

.tab__count {
    padding: 0 0.45rem;
    border-radius: 999px;
    background: var(--navy-100);
    color: var(--navy);
    font-size: 0.8rem;
}

.tab--active .tab__count {
    background: var(--yellow);
}

[aria-busy="true"] {
    opacity: 0.55;
    transition: opacity 0.15s;
}

/* ---- Badges -------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge--created {
    background: var(--navy-50);
    color: var(--muted);
    border: 1px solid var(--border);
}

.badge--in_progress {
    background: var(--yellow-100);
    color: #8a5a00;
}

.badge--validated,
.badge--mail-sent {
    background: var(--success-bg);
    color: var(--success);
}

.badge--mail-pending {
    background: var(--info-bg);
    color: var(--info);
}

.badge--mail-failed {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ---- Tableau ------------------------------------------------------------- */
.table-card {
    padding: 0;
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.8rem 1rem;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.table thead th {
    background: var(--navy-50);
    color: var(--navy);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table thead a {
    color: inherit;
    text-decoration: none;
}

.table thead a:hover {
    text-decoration: underline;
}

.table th[aria-sort="ascending"] a::after {
    content: " ▲";
    font-size: 0.7em;
}

.table th[aria-sort="descending"] a::after {
    content: " ▼";
    font-size: 0.7em;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table tbody tr:hover {
    background: #fafbfd;
}

.table td small {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
}

.cell-main a {
    font-weight: 600;
    color: var(--navy);
}

.cell-email {
    overflow-wrap: anywhere;
}

.cell-actions {
    text-align: right;
}

/* Tableau en cartes sur mobile */
@media (max-width: 860px) {
    .table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
    }

    .table tbody tr {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border);
    }

    .table tbody tr:last-child {
        border-bottom: 0;
    }

    .table td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.3rem 0;
        border: 0;
        text-align: right;
    }

    .table td::before {
        content: attr(data-label);
        flex: none;
        color: var(--muted);
        font-size: 0.8rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        text-align: left;
    }

    .table td.cell-actions {
        justify-content: flex-end;
        padding-top: 0.6rem;
    }

    .table td.cell-actions::before {
        content: none;
    }

    .table td small {
        display: inline;
        margin-left: 0.4rem;
    }
}

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.pager__info {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.pagination__current {
    color: var(--muted);
    font-size: 0.9rem;
}

[aria-disabled="true"] {
    opacity: 0.45;
    pointer-events: none;
}

.empty {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.empty__title {
    margin: 0 0 0.5rem;
    color: var(--navy);
    font-weight: 600;
}

@media (max-width: 560px) {
    .filters {
        flex-wrap: wrap;
    }

    .filters .btn {
        width: 100%;
    }
}

/* ---- Fiche détail -------------------------------------------------------- */
.detail {
    display: grid;
    grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 900px) {
    .detail {
        grid-template-columns: 1fr;
    }
}

.card__title {
    margin: 0 0 0.9rem;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.facts {
    margin: 0 0 1.5rem;
    display: grid;
    gap: 0.8rem;
}

.facts dt {
    color: var(--muted);
    font-size: 0.82rem;
}

.facts dd {
    margin: 0.1rem 0 0;
    font-weight: 600;
}

.facts dd small {
    display: block;
    font-weight: 400;
    color: var(--muted);
}

.copy {
    display: flex;
    gap: 0.5rem;
}

.copy input {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--navy-50);
    font: inherit;
    font-size: 0.85rem;
}

.recap + .recap {
    margin-top: 1.75rem;
}

.recap__title {
    margin: 0 0 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--yellow);
    color: var(--navy);
    font-size: 1.05rem;
}

.recap__rows {
    margin: 0;
}

.recap__row {
    display: grid;
    grid-template-columns: minmax(0, 14rem) minmax(0, 1fr);
    gap: 1rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--navy-50);
}

.recap__row dt {
    color: var(--muted);
}

.recap__row dd {
    margin: 0;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.recap__info {
    margin: 0.6rem 0 0.2rem;
    font-style: italic;
    color: var(--muted);
}

.signature-img {
    max-width: 260px;
    max-height: 140px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
}

@media (max-width: 560px) {
    .recap__row {
        grid-template-columns: 1fr;
        gap: 0.1rem;
    }
}

/* ---- Formulaires et fenêtre modale -------------------------------------- */
.stack {
    display: grid;
    gap: 1rem;
}

.narrow {
    max-width: 38rem;
}

.field {
    display: grid;
    gap: 0.35rem;
}

.field label {
    font-weight: 600;
    color: var(--navy);
}

.input {
    width: 100%;
    min-height: 44px;
    padding: 0.5rem 0.8rem;
    border: 1px solid #c3ccda;
    border-radius: var(--radius-sm);
    background: #fff;
    font: inherit;
    color: var(--text);
}

.input:focus {
    border-color: var(--navy-800);
    outline: 3px solid rgba(248, 171, 23, 0.45);
    outline-offset: 0;
}

.field__hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.field__error {
    margin: 0;
    color: var(--danger);
    font-size: 0.9rem;
    font-weight: 600;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.flash {
    margin-bottom: 1rem;
}

.dialog {
    width: min(34rem, calc(100vw - 2rem));
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(20, 36, 61, 0.35);
    color: var(--text);
}

.dialog::backdrop {
    background: rgba(20, 36, 61, 0.55);
}

.dialog__body {
    padding: 1.5rem;
}

.dialog__body[hidden] {
    display: none;
}

.dialog__title {
    margin: 0 0 0.8rem;
    color: var(--navy);
    font-size: 1.25rem;
}

/* ---- Formulaire client public ------------------------------------------- */
body.public {
    background: var(--bg);
}

.public-header {
    background: var(--navy);
    border-bottom: 4px solid var(--yellow);
}

.public-header__inner {
    max-width: 880px;
    margin: 0 auto;
    padding: 0.9rem 1.25rem;
}

.public-header img {
    display: block;
    height: 32px;
    width: auto;
}

.public-main {
    max-width: 880px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 2rem;
    display: grid;
    gap: 1.25rem;
}

.public-main form {
    display: grid;
    gap: 1.25rem;
}

.public-footer {
    max-width: 880px;
    margin: 0 auto;
    padding: 0 1.25rem 2rem;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: center;
}

.intro h1,
.message h1 {
    margin: 0 0 0.4rem;
    color: var(--navy);
    font-size: 1.7rem;
}

.intro__saved {
    margin: 0 0 0.4rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.intro p,
.message p {
    margin: 0;
}

.message {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.fieldgroup__title {
    margin: 0 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--yellow);
    color: var(--navy);
    font-size: 1.25rem;
}

.fieldgroup__description {
    margin: 0 0 1rem;
    color: var(--muted);
}

.fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 1rem 1.25rem;
}

.field--full {
    grid-column: 1 / -1;
}

.field--info {
    margin: 0.4rem 0 0;
    font-weight: 600;
    color: var(--navy);
}

.field__label {
    font-weight: 600;
    color: var(--navy);
    padding: 0;
}

.req {
    margin-left: 0.15rem;
    color: var(--danger);
}

.note {
    color: var(--muted);
    font-weight: 400;
}

textarea.input {
    min-height: 6.5rem;
    resize: vertical;
}

.input.is-invalid,
.signature.is-invalid {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.notes {
    margin-top: 1rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--navy-50);
    color: var(--muted);
    font-size: 0.88rem;
}

.notes p {
    margin: 0.15rem 0;
}

.warning {
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    border-left: 4px solid var(--yellow);
    border-radius: var(--radius-sm);
    background: var(--yellow-100);
    color: #5c3d00;
    font-size: 0.92rem;
}

fieldset.field {
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.choices__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.35rem;
}

.choice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    border: 1px solid #c3ccda;
    border-radius: var(--radius-sm);
    background: #fff;
}

.choice input[type="radio"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--navy);
}

.choice label {
    cursor: pointer;
}

.choice:has(input[type="radio"]:checked) {
    border-color: var(--navy);
    background: var(--navy-50);
}

.choice--other {
    flex: 1 1 100%;
    flex-wrap: wrap;
}

.choice--other .input {
    flex: 1 1 14rem;
    min-height: 36px;
}

.signature {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 26rem;
    min-height: 9rem;
    margin-top: 0.35rem;
    padding: 0.5rem;
    border: 2px dashed #9fb0c9;
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--muted);
    font: inherit;
    cursor: pointer;
}

.signature:hover {
    border-color: var(--navy);
    background: var(--navy-50);
}

.signature__hint[hidden],
.signature__preview[hidden] {
    display: none;
}

.signature__preview {
    max-width: 100%;
    max-height: 8rem;
}

.signature-pad {
    border: 2px dashed #9fb0c9;
    border-radius: var(--radius-sm);
    background: #fff;
}

.signature-pad canvas {
    display: block;
    width: 100%;
    height: 14rem;
    touch-action: none;
    cursor: crosshair;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
    position: sticky;
    bottom: 0.75rem;
}

.form-actions[hidden] {
    display: none;
}

@media (max-width: 560px) {
    .form-actions .btn {
        width: 100%;
    }

    .signature-pad canvas {
        height: 12rem;
    }
}

@media (max-width: 560px) {
    .form-actions {
        position: static;
    }
}

.page-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}
