/* Portail : charte, formulaires, tableaux et pictogrammes accessibles ; aucun style lecteur. */
/*
 * Rôle du fichier : mise en page du portail sécurisé idcloudCB.
 * Structure : base visuelle, connexion, navigation, cartes, formulaires, tableaux et responsive mobile.
 */

:root {
    --ink: #172234;
    --muted: #617083;
    --line: #dfe5ec;
    --surface: #ffffff;
    --soft: #f4f7fa;
    --accent: #ed1b2f;
    --accent-dark: #be0e20;
    --success: #157347;
    --danger: #b42318;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--soft);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--soft); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, .primary-button, .secondary-button {
    border: 0; border-radius: 10px; padding: 11px 16px; cursor: pointer; font-weight: 700;
}
button, .primary-button { color: #fff; background: var(--accent); }
button:hover, .primary-button:hover { background: var(--accent-dark); }
button:disabled { opacity: .45; cursor: not-allowed; }
.secondary-button, button.secondary { color: var(--ink); background: #e9eef4; text-decoration: none; }
.danger-button { background: var(--danger); }
.link-button { padding: 0; color: var(--accent); background: transparent; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.kicker { margin: 0 0 6px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

.login-page { display: grid; place-items: center; padding: 28px; background: linear-gradient(135deg, #162234 0 42%, #f4f7fa 42%); }
.login-shell { display: grid; grid-template-columns: minmax(280px, 420px) minmax(320px, 480px); width: min(920px, 100%); min-height: 560px; overflow: hidden; border-radius: 24px; background: #fff; box-shadow: 0 24px 70px #07101f33; }
.login-brand { padding: 60px 48px; color: #fff; background: #172234; }
.login-brand img { width: min(230px, 100%); margin-bottom: 74px; filter: brightness(0) invert(1); }
.login-brand h1 { margin: 8px 0; font-size: 52px; }
.login-brand p:last-child { color: #cbd5e1; line-height: 1.6; }
.login-card { align-self: center; padding: 48px; }
.login-card h2 { margin-top: 0; }
.login-tabs { display: flex; gap: 8px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.tab-button { border-radius: 0; padding: 12px 4px; color: var(--muted); background: transparent; }
.tab-button + .tab-button { margin-left: 18px; }
.tab-button.active { color: var(--accent); box-shadow: inset 0 -3px var(--accent); }
.passkey-login-box { padding: 4px 0 8px; text-align: center; }
.passkey-login-box h2 { margin-bottom: 8px; }
.passkey-login-box button { width: 100%; }
.login-separator { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--muted); font-size: .9rem; }
.login-separator::before, .login-separator::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.field-status { display: block; margin: 8px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.35; }

.form-stack { display: grid; gap: 16px; }
label, .field { display: grid; gap: 7px; color: #344054; font-size: 14px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 9px; padding: 11px 12px; color: var(--ink); background: #fff; }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid #ed1b2f22; border-color: var(--accent); }
.check-field { display: flex; align-items: center; gap: 8px; }
.check-field input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.portal-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 32px; min-height: 76px; padding: 12px max(24px, calc((100vw - 1240px) / 2)); color: #fff; background: #172234; }
.portal-brand { display: flex; align-items: center; gap: 13px; text-decoration: none; }
.portal-brand img { width: 86px; filter: brightness(0) invert(1); }
.portal-brand span { display: grid; }
.portal-brand small { color: #aebacd; }
.portal-top nav { display: flex; gap: 8px; }
.portal-top nav a { border-radius: 8px; padding: 9px 12px; color: #cbd5e1; text-decoration: none; }
.portal-top nav a.active, .portal-top nav a:hover { color: #fff; background: #ffffff17; }
.portal-user { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.portal-client-logo { width: 58px; height: 36px; border-radius: 6px; padding: 3px; object-fit: contain; background: #fff; }
.portal-client-switch { color: #fff; font-size: 12px; }
.portal-shell { width: min(1680px, calc(100% - 40px)); margin: 0 auto; padding: 36px 0 70px; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-title h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); }

.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }
.menu-card, .card { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 8px 28px #1220330a; }
.menu-card { position: relative; min-height: 180px; padding: 28px; text-decoration: none; transition: transform .18s, box-shadow .18s; }
.menu-card:hover { transform: translateY(-3px); box-shadow: 0 14px 34px #12203317; }
.menu-card h2 { margin: 34px 0 8px; font-size: 21px; }
.menu-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.permission-badge { position: absolute; top: 20px; right: 20px; border-radius: 999px; padding: 5px 9px; color: #9f1020; background: #ffe8eb; font-family: ui-monospace, monospace; font-size: 12px; font-weight: 800; }
.card { margin-bottom: 20px; padding: 24px; }
.card h2 { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.notice { margin-bottom: 20px; border: 1px solid; border-radius: 10px; padding: 12px 14px; line-height: 1.45; }
.notice.error { border-color: #f0b8b4; color: #7a271a; background: #fef3f2; }
.notice.success { border-color: #a6d8bd; color: #085d3a; background: #ecfdf3; }
.secret-state { display: inline-flex; border-radius: 999px; padding: 6px 10px; color: #344054; background: #e9eef4; font-family: ui-monospace, monospace; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 12px 10px; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
td form { display: inline-flex; gap: 6px; }
.inline-form { display: grid; grid-template-columns: repeat(6, minmax(100px, 1fr)); align-items: end; gap: 10px; }
.inline-form .actions { grid-column: auto; }
.filter-rules { display: grid; gap: 10px; }
.filter-rule { display: grid; grid-template-columns: 1.2fr .8fr 1.4fr auto; align-items: end; gap: 10px; }
.rule-meta { min-height: 20px; color: var(--muted); font-size: 12px; }
.logo-preview { display: block; max-width: 260px; max-height: 120px; margin: 12px 0; object-fit: contain; }
.mapping-editor { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: var(--soft); }
.mapping-editor summary { cursor: pointer; }
.mapping-editor label { margin-top: 14px; }
.mapping-editor textarea { min-height: 460px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; line-height: 1.5; tab-size: 2; }

@media (max-width: 760px) {
    .login-page { padding: 0; background: #fff; }
    .login-shell { display: block; min-height: 100vh; border-radius: 0; }
    .login-brand { padding: 30px; }
    .login-brand img { width: 150px; margin-bottom: 24px; }
    .login-brand h1 { font-size: 38px; }
    .login-card { padding: 30px; }
    .portal-top { grid-template-columns: 1fr auto; gap: 14px; }
    .portal-top nav { grid-column: 1 / -1; grid-row: 2; }
    .portal-user span { display: none; }
    .portal-shell { width: min(100% - 24px, 1240px); padding-top: 24px; }
    .page-title, .card-head { align-items: flex-start; flex-direction: column; }
    .form-grid, .inline-form, .filter-rule { grid-template-columns: 1fr; }
}

/* Journal iD Cloud : événements lisibles, détails repliables et valeurs longues contenues. */
.exchange-log-card { min-width: 0; }
.log-mode, .log-level, .log-channel { border-radius: 6px; padding: 4px 8px; font-size: 12px; font-weight: 700; }
.log-mode, .log-channel { background: #edf2f7; color: #475569; }
.log-mode { white-space: nowrap; }
.log-clear-form { margin-left: auto; }
.log-overview { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0; }
.log-overview > span, .log-overview > a { padding: 12px 18px; background: #f4f7fa; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); }
.log-overview > a[aria-current="page"] { border-color: var(--ink); color: var(--ink); }
.log-overview strong { color: #172234; font-size: 20px; margin-right: 6px; }
.exchange-log-list { display: grid; gap: 12px; }
.exchange-log-entry { border: 1px solid var(--line); border-left: 4px solid #94a3b8; border-radius: 10px; padding: 16px 18px; min-width: 0; }
.exchange-log-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 13px; }
.log-level { color: #175078; background: #edf6ff; }
.log-warning { border-left-color: #bd7708; }
.log-warning .log-level { background: #fff4d6; color: #805207; }
.log-error { border-left-color: #c93636; }
.log-error .log-level { background: #ffeded; color: #9c2424; }
.exchange-log-entry h3 { margin: 12px 0; font-size: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.exchange-log-entry summary { cursor: pointer; padding: 4px 0; font-size: 13px; color: #475569; }
.exchange-log-entry summary:focus-visible { outline: 2px solid #175078; outline-offset: 4px; }
.exchange-log-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 0; }
.exchange-log-details > div { background: #f8fafc; padding: 12px; min-width: 0; }
.exchange-log-details > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
.exchange-log-details dt { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.exchange-log-details dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.6 ui-monospace, monospace; }
.log-empty { padding: 30px 12px; text-align: center; color: var(--muted); }
@media (max-width: 640px) {
    .exchange-log-details { grid-template-columns: 1fr; }
    .log-clear-form { margin-left: 0; }
    .exchange-log-card .card-head { align-items: flex-start; }
    .exchange-log-entry { padding: 12px; }
}

/* Corps JSON du diagnostic privé : lecture sur mobile sans débordement horizontal. */
.exchange-log-api pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 32rem; overflow: auto; padding: 12px; background: #f8fafc; font: 12px/1.6 ui-monospace, monospace; }

/* Actions de ligne : cibles compactes, libellés accessibles et focus clavier visible. */
.icon-action, button.icon-action, a.icon-action {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 36px; width: 36px; height: 36px; padding: 8px;
    border: 1px solid transparent; border-radius: 9px;
    color: #475569; background: transparent; text-decoration: none;
}
.icon-action svg { width: 20px; height: 20px; flex: none; pointer-events: none; }
.icon-action:hover { color: #172234; background: #edf2f7; border-color: #dbe3ec; }
.icon-action.danger, .icon-action.danger-button { color: #b42318; background: transparent; }
.icon-action.danger:hover, .icon-action.danger-button:hover { background: #fef3f2; border-color: #fecdca; }
.icon-action:focus-visible { outline: 2px solid #475569; outline-offset: 2px; }
.action-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.table-scroll td .actions { gap: 4px; min-width: 120px; }
.table-scroll td form { align-items: end; }
.table-scroll td label { min-width: 0; }
.table-scroll td input:not([type="hidden"]):not([type="checkbox"]),
.table-scroll td select { min-width: 18ch; }
.table-scroll td select { width: auto; max-width: 44ch; }
.table-scroll td input[name="label"] { width: 28ch; }
.devices-table td:nth-child(3) { min-width: 160px; max-width: 240px; overflow-wrap: anywhere; }
.devices-table td:nth-child(4) { min-width: 150px; }
.devices-table td:last-child { min-width: 300px; }
.devices-table td:last-child form:has(select) { flex-basis: 100%; margin: 4px 0; }
.devices-table td:last-child select { flex: 1; min-width: 24ch; width: 100%; }
.devices-table select[name="reader_version"] { min-width: 9ch; width: 100%; }
.users-table .inline-form { display: grid; grid-template-columns: minmax(24ch, 1.3fr) minmax(20ch, 1fr) minmax(22ch, 1fr); min-width: 640px; }
.users-table .inline-form select { width: 100%; }
.users-table .secret-state { border-radius: 8px; font-size: 12px; line-height: 1.5; font-family: inherit; overflow-wrap: anywhere; }
.users-table td:last-child { min-width: 150px; }
@supports (field-sizing: content) {
    .table-scroll td input[name="label"], .table-scroll td input[name="display_name"] { field-sizing: content; width: auto; min-width: 24ch; max-width: 44ch; }
}
@media (pointer: coarse) { .icon-action, button.icon-action, a.icon-action { width: 44px; height: 44px; flex-basis: 44px; } }

/* Inventaires : deux colonnes explicites gardent Envoyer dans la cellule, y compris dans Safari. */
.table-scroll td .inventory-row-actions {
    display: grid; grid-template-columns: repeat(2, 36px);
    width: max-content; min-width: 0; gap: 4px;
}
.inventory-row-actions > form { margin: 0; min-width: 0; }
@media (pointer: coarse) {
    .table-scroll td .inventory-row-actions { grid-template-columns: repeat(2, 44px); }
}
