/*
 * Dashboard JRDR-Transaction.
 * Feuille externe : la CSP interdit les styles en ligne.
 */

:root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --border: #dde3ec;
    --text: #1b2330;
    --muted: #6b7688;
    --primary: #1f4fd8;
    --primary-dark: #1840b0;
    --success: #12855a;
    --success-bg: #e3f6ed;
    --pending: #b06a00;
    --pending-bg: #fdf0dc;
    --danger: #c2273d;
    --danger-bg: #fdeaed;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(20, 30, 50, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

h1, h2, h3 { margin: 0 0 .4rem; line-height: 1.25; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
code { font-family: "Cascadia Mono", Consolas, monospace; font-size: .87em; }
.muted { color: var(--muted); font-size: .88rem; }
.strong { font-weight: 600; }

/* ---------------------------------- Navigation --------------------------------- */
.topbar {
    display: flex; align-items: center; gap: 2rem;
    padding: 0 1.5rem; height: 58px;
    background: #12203a; color: #fff;
}
.topbar-brand { display: flex; align-items: baseline; gap: .4rem; font-weight: 700; }
.brand-mark { color: #5b8cff; letter-spacing: .5px; }
.brand-name { font-weight: 400; opacity: .85; }
.topbar-links { display: flex; gap: .35rem; list-style: none; margin: 0; padding: 0; flex: 1; }
.topbar-links a {
    color: #c9d4e8; text-decoration: none; padding: .45rem .8rem;
    border-radius: 6px; font-size: .93rem;
}
.topbar-links a:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.topbar-links a.active { background: rgba(91, 140, 255, .22); color: #fff; }
.topbar-user { display: flex; align-items: center; gap: .8rem; font-size: .9rem; }
.username { color: #c9d4e8; }

/* ------------------------------------ Mise en page ------------------------------ */
.container { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1.5rem 3rem; }
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.25rem; margin-bottom: 1.25rem;
}
.card-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 1rem; margin-bottom: 1rem; padding-bottom: .8rem;
    border-bottom: 1px solid var(--border);
}
.subsection { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 1.5rem 0 2.5rem; }

/* ----------------------------------- Indicateurs -------------------------------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.15rem;
    display: flex; flex-direction: column; gap: .15rem;
}
.kpi-label { font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.6rem; font-weight: 600; }
.kpi-hint { font-size: .8rem; color: var(--muted); }

/* ------------------------------------ Formulaires ------------------------------- */
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 150px; }
.field.grow { flex: 1; }
.field-checkbox { flex-direction: row; align-items: center; gap: .45rem; }
.field label { font-size: .84rem; font-weight: 600; color: #46536b; }
.field-hint { font-size: .78rem; color: var(--muted); }
.field-error { font-size: .8rem; color: var(--danger); }

input[type="text"], input[type="url"], input[type="password"], input[type="number"],
input[type="date"], select {
    padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 7px;
    font-size: .92rem; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid rgba(31, 79, 216, .35); outline-offset: 1px; border-color: var(--primary); }

.filter-form, .inline-fields {
    display: flex; flex-wrap: wrap; gap: .9rem; align-items: flex-end;
}

/*
 * Le formulaire d'un operateur est une grille, pas une rangee flexible.
 * En flex-wrap avec align-items: flex-end, les deux champs de secret et leurs textes
 * d'aide — nettement plus hauts que les autres champs — se chevauchaient avec les
 * boutons « Afficher » et « Sauvegarder ». Une grille attribue une cellule par champ :
 * des hauteurs inegales ne peuvent plus provoquer de collision.
 */
.provider-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.1rem;
    align-items: start;
}
.provider-form .field-checkbox { align-self: center; padding-top: 1.1rem; }
.provider-form .button-row { grid-column: 1 / -1; margin-top: 0; }

/* « Tester la connexion » vit dans son propre formulaire, hors de la grille : sans cette
   regle il se colle au bouton de sauvegarde qui le precede. */
.provider-form + .inline-form { display: block; margin-top: .7rem; }
.stacked-form { display: flex; flex-direction: column; gap: .9rem; max-width: 560px; }
.stacked-form .btn { align-self: flex-start; }
.inline-form { display: inline; margin: 0; }
.field-actions { flex-direction: row; gap: .5rem; }
.toolbar { display: flex; align-items: center; gap: .7rem; margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.button-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .9rem; }
.secret-input { display: flex; gap: .4rem; }
.inline-select { padding: .25rem .4rem; font-size: .82rem; border: 1px solid var(--border); border-radius: 6px; }
.data-table .button-row { margin-top: 0; gap: .35rem; }
.data-table .btn:disabled { opacity: .45; cursor: not-allowed; }
.secret-input input { flex: 1; }

/* -------------------------------------- Boutons --------------------------------- */
.btn {
    display: inline-block; padding: .5rem .9rem; border-radius: 7px;
    border: 1px solid transparent; font-size: .88rem; font-weight: 600;
    font-family: inherit; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: #35415a; border-color: var(--border); }
.btn-ghost:hover { background: #eef1f7; }
.btn-warning { background: var(--pending-bg); color: #8a5200; border-color: #f0d5a8; }
.btn-warning:hover { background: #fbe4c4; }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #f3c3ca; }
.btn-danger:hover { background: #fbd8dd; }
.btn-small { padding: .3rem .6rem; font-size: .8rem; }
.btn-block { width: 100%; }

/* -------------------------------------- Tableau --------------------------------- */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th, .data-table td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8fafc; }
.data-table tbody tr:hover { background: #f7f9fd; }
.data-table .numeric { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 2rem 0; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; }

/* -------------------------------------- Badges ---------------------------------- */
.badge { display: inline-block; padding: .18rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-pending { background: var(--pending-bg); color: var(--pending); }
.badge-failed { background: var(--danger-bg); color: var(--danger); }
.badge-neutral { background: #eceff4; color: #5b6678; }
.tag { display: inline-block; padding: .1rem .45rem; border-radius: 4px; background: #eceff4; color: #5b6678; font-size: .74rem; font-weight: 600; }
.tag-ok { background: var(--success-bg); color: var(--success); }
.tag-warn { background: var(--danger-bg); color: var(--danger); }

/* ------------------------------- Temoin de sante -------------------------------- */
.health { display: flex; align-items: center; gap: .45rem; font-size: .88rem; }
.health-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.health-up { background: #1aa06a; box-shadow: 0 0 0 3px rgba(26, 160, 106, .18); }
.health-down { background: #d33a4f; box-shadow: 0 0 0 3px rgba(211, 58, 79, .18); }

/* -------------------------------------- Messages -------------------------------- */
.alerts { display: flex; flex-direction: column; gap: .7rem; margin-bottom: 1.25rem; }
.alerts:empty { display: none; }
.alert { padding: .75rem 1rem; border-radius: 8px; border: 1px solid transparent; font-size: .9rem; }
.alert-success { background: var(--success-bg); border-color: #b6e4cd; color: #0d6b48; }
.alert-error { background: var(--danger-bg); border-color: #f3c3ca; color: #9c1f31; }
.alert-info { background: #e8f0ff; border-color: #c2d6fb; color: #1b3f9e; }
.alert-secret { background: #fffaf0; border-color: #f0d5a8; color: #6d4a06; }
.secret-title { margin: 0 0 .5rem; font-weight: 700; }
.secret-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.secret-value { background: #fff; border: 1px solid #e6d3ab; border-radius: 6px; padding: .35rem .55rem; word-break: break-all; }

/* --------------------------------- Domaines ------------------------------------- */
.domain-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.domain-list li {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .45rem .7rem; background: #f8fafc; border: 1px solid var(--border); border-radius: 7px;
}

/* --------------------------------- Connexion ------------------------------------ */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #12203a; }
.login-card {
    width: 100%; max-width: 380px; background: var(--surface);
    border-radius: 14px; padding: 2rem; box-shadow: 0 18px 45px rgba(0, 0, 0, .3);
}
.login-brand { display: flex; align-items: baseline; gap: .4rem; font-size: 1.3rem; font-weight: 700; }
.login-brand .brand-mark { color: var(--primary); }
.login-brand .brand-name { color: var(--muted); font-weight: 400; }
.login-subtitle { color: var(--muted); font-size: .87rem; margin: .2rem 0 1.4rem; }
.login-form { display: flex; flex-direction: column; gap: .35rem; }
.login-form label { font-size: .84rem; font-weight: 600; color: #46536b; margin-top: .6rem; }
.login-form .btn { margin-top: 1.2rem; }

/* -------------------------- Double authentification ------------------------------ */
.login-card-wide { max-width: 460px; }
.login-footnote { margin: .9rem 0 0; text-align: center; font-size: .84rem; }
.login-footnote a { color: var(--primary); }
.btn-link {
    background: none; border: none; padding: 0; font: inherit; font-size: .84rem;
    color: var(--muted); text-decoration: underline; cursor: pointer;
}
.btn-link:hover { color: var(--text); }
.code-input {
    font-size: 1.35rem; letter-spacing: .22em; text-align: center;
    font-family: "Cascadia Mono", Consolas, monospace;
}
.steps { margin: 0 0 1rem; padding-left: 1.2rem; color: #46536b; font-size: .89rem; }
.steps li { margin-bottom: .3rem; }
.qr-frame {
    display: flex; justify-content: center; padding: 1rem;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: 1rem;
}
.manual-entry { margin-bottom: 1rem; font-size: .86rem; }
.manual-entry summary { cursor: pointer; color: var(--primary); }
.manual-entry .secret-value { display: block; margin-top: .4rem; letter-spacing: .08em; }
.recovery-codes {
    list-style: none; margin: 1rem 0; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .5rem;
}
.recovery-codes code {
    display: block; padding: .5rem .6rem; background: #fff;
    border: 1px solid #e6d3ab; border-radius: 6px;
    font-size: 1rem; letter-spacing: .06em; text-align: center;
}

/* ----------------------------------- Erreur ------------------------------------- */
.error-card { max-width: 620px; margin: 3rem auto; text-align: center; }
.error-card .btn { margin-top: 1.2rem; }
.intro { background: #fbfcfe; }
