/* ============================================================
   MASI-ID — Système d'Identité Numérique (CSS Refondu v2)
   ============================================================ */

:root {
    /* Palette Institutionnelle */
    --blue-dark:    #0f2d5a;
    --blue-primary: #1a4b8c;
    --blue-mid:     #2a62b0;
    --blue-light:   #eef3fb;
    --blue-lighter: #f5f8fd;
    --accent:       #d4a017;
    --accent-light: #fdf6e3;

    /* États */
    --success:      #1e6e42;
    --success-bg:   #eaf4ee;
    --danger:       #b91c1c;
    --danger-bg:    #fef2f2;
    --warn:         #92400e;

    /* Neutres */
    --text:         #12243d;
    --text-muted:   #5a6a85;
    --text-subtle:  #8898aa;
    --border:       #d5dce8;
    --border-light: #e8edf5;
    --bg:           #f3f6fb;
    --white:        #ffffff;

    /* Effets */
    --card-shadow:  0 2px 8px rgba(15, 45, 90, 0.06), 0 8px 24px rgba(15, 45, 90, 0.08);
    --card-shadow-hover: 0 4px 16px rgba(15, 45, 90, 0.10), 0 16px 40px rgba(15, 45, 90, 0.12);
    --radius:       10px;
    --radius-sm:    6px;
    --transition:   all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Source Sans 3', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ── Focus visible (accessibilité) ──────────────────────────  */
:focus-visible {
    outline: 2.5px solid var(--blue-primary);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

/* ── Header ──────────────────────────────────────────────── */
.header {
    background: var(--blue-dark);
    border-bottom: 3px solid var(--accent);
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}

.header-inner {
    max-width: 1160px;
    margin: 0 auto;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 13px;
    text-decoration: none;
}

.logo-emblem {
    width: 40px;
    height: 40px;
    background: var(--accent);
    color: var(--blue-dark);
    font-family: 'Source Serif 4', serif;
    font-size: 22px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.logo-name {
    font-family: 'Source Serif 4', serif;
    font-size: 20px;
    color: #fff;
    line-height: 1.1;
}

.logo-tagline {
    font-size: 10.5px;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.header-nav {
    display: flex;
    gap: 6px;
}

.header-nav a {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.header-nav a:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

/* ── Layout ──────────────────────────────────────────────── */
.main {
    flex: 1;
    padding: 36px 20px 48px;
}

.page-layout {
    max-width: 1080px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 32px;
    align-items: start;
}

/* ── Cartes communes ─────────────────────────────────────── */
.info-panel, .form-panel {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.info-panel:hover, .form-panel:hover {
    box-shadow: var(--card-shadow-hover);
}

/* ── Panneau Info (gauche) ───────────────────────────────── */
.info-block {
    display: none;
    padding: 36px;
    animation: fadeSlideUp 0.35s ease forwards;
}

.info-block.active {
    display: block;
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.info-block-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 14px;
}

.info-icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    background: var(--blue-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--blue-primary);
    margin-top: 2px;
}

.info-title {
    font-family: 'Source Serif 4', serif;
    font-size: 22px;
    color: var(--blue-dark);
    line-height: 1.25;
}

.info-intro {
    color: var(--text-muted);
    font-size: 14.5px;
    margin-bottom: 28px;
    line-height: 1.65;
}

/* Security badge */
.security-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(46, 125, 79, 0.2);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 12.5px;
    font-weight: 500;
    margin-top: 8px;
}

/* Requirements List */
.req-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 28px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    overflow: hidden;
}

.req-item {
    display: flex;
    gap: 14px;
    padding: 18px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.18s ease;
}

.req-item:last-child { border-bottom: none; }
.req-item:hover { background: var(--blue-lighter); }

.req-icon-wrap {
    font-size: 22px;
    flex-shrink: 0;
    width: 36px;
    text-align: center;
    padding-top: 2px;
}

.req-content { flex: 1; min-width: 0; }

.req-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--blue-dark);
    margin-bottom: 3px;
}

.req-desc {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.5;
}

.req-hint {
    display: block;
    font-size: 11.5px;
    color: var(--text-subtle);
    margin-top: 5px;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--blue-light);
    color: var(--blue-primary);
    border: 1px solid rgba(26, 75, 140, 0.2);
    border-radius: var(--radius-sm);
    padding: 6px 11px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-download:hover {
    background: var(--blue-primary);
    color: #fff;
    border-color: var(--blue-primary);
}

/* Steps */
.steps-block {
    border-top: 1px solid var(--border-light);
    padding-top: 24px;
}

.steps-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-subtle);
    margin-bottom: 18px;
}

.steps-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.step {
    display: flex;
    gap: 16px;
    position: relative;
    padding-bottom: 20px;
}

.step:last-child { padding-bottom: 0; }

/* Connecting line between steps */
.step:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 14px;
    top: 30px;
    bottom: 0;
    width: 2px;
    background: var(--border-light);
}

.step-num {
    width: 30px;
    height: 30px;
    background: var(--blue-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    box-shadow: 0 0 0 3px rgba(26, 75, 140, 0.12);
}

.step-body { padding-top: 4px; }

.step-label {
    font-weight: 600;
    color: var(--blue-dark);
    font-size: 14px;
    margin-bottom: 2px;
}

.step-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Store badges */
.store-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.store-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--blue-dark);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

.store-badge:hover {
    background: var(--blue-mid);
    transform: translateY(-1px);
}

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
    display: flex;
    background: var(--blue-lighter);
    border-bottom: 1px solid var(--border-light);
}

.tab {
    flex: 1;
    padding: 15px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-muted);
    font-family: inherit;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab:hover:not(.active) {
    color: var(--blue-primary);
    background: rgba(26, 75, 140, 0.05);
}

.tab.active {
    background: var(--white);
    color: var(--blue-primary);
    box-shadow: inset 0 -3px 0 var(--blue-primary);
}

/* ── Form sections ───────────────────────────────────────── */
.form-section {
    display: none;
    padding: 36px;
    animation: fadeSlideUp 0.35s ease forwards;
}

.form-section.active {
    display: block;
}

.panel-header {
    margin-bottom: 28px;
}

.panel-header h1 {
    font-family: 'Source Serif 4', serif;
    font-size: 24px;
    color: var(--blue-dark);
    margin-bottom: 6px;
}

.panel-sub {
    color: var(--text-muted);
    font-size: 14.5px;
    line-height: 1.6;
}

/* ── Champs ──────────────────────────────────────────────── */
.field {
    margin-bottom: 22px;
}

.field label {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 7px;
}

.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 7px;
}

.label-row label {
    margin-bottom: 0;
}

.label-optional {
    font-size: 11.5px;
    color: var(--text-subtle);
    font-weight: 400;
    background: var(--border-light);
    padding: 2px 7px;
    border-radius: 20px;
}

.forgot-link {
    font-size: 13px;
    color: var(--blue-mid);
    text-decoration: none;
    font-weight: 500;
}

.forgot-link:hover { text-decoration: underline; }

/* Input wrapper with icon */
.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 13px;
    color: var(--text-subtle);
    pointer-events: none;
    transition: color 0.2s ease;
    z-index: 1;
}

.field input {
    width: 100%;
    padding: 11px 42px 11px 40px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    transition: var(--transition);
    appearance: none;
}

/* Input sans icône (checkbox) */
.checkbox-field .field input {
    padding: 0;
}

.field input::placeholder {
    color: var(--text-subtle);
}

.field input:hover {
    border-color: #a0aec0;
}

.field input:focus {
    outline: none;
    border-color: var(--blue-primary);
    box-shadow: 0 0 0 3px rgba(26, 75, 140, 0.12);
    background: #fff;
}

.field input:focus ~ .input-icon,
.input-wrap:focus-within .input-icon {
    color: var(--blue-primary);
}

/* Input validé */
.field input:valid:not(:placeholder-shown):not([type="password"]):not([type="checkbox"]) {
    border-color: var(--success);
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%231e6e42'%3E%3Cpath fill-rule='evenodd' d='M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

/* Bouton show/hide password */
.toggle-pwd {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-subtle);
    padding: 4px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
    z-index: 2;
}

.toggle-pwd:hover { color: var(--blue-primary); }

/* Hints & errors */
.field-hint {
    display: block;
    font-size: 12.5px;
    color: var(--text-subtle);
    margin-top: 6px;
    line-height: 1.4;
}

.field-error {
    display: block;
    font-size: 12.5px;
    color: var(--danger);
    margin-top: 5px;
    min-height: 18px;
    font-weight: 500;
}

/* ── Indicateur de force mot de passe ────────────────────── */
.strength-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 9px;
}

.strength-bars {
    display: flex;
    gap: 4px;
    flex: 1;
}

.sbar {
    height: 4px;
    flex: 1;
    background: var(--border-light);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.strength-label {
    font-size: 12px;
    font-weight: 600;
    min-width: 60px;
    text-align: right;
}

/* ── Checkbox personnalisée ──────────────────────────────── */
.checkbox-field {
    margin-bottom: 24px;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 13.5px;
    color: var(--text-muted);
    line-height: 1.5;
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
    transition: var(--transition);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--blue-primary);
    border-color: var(--blue-primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '';
    display: block;
    width: 9px;
    height: 5px;
    border-left: 2px solid white;
    border-bottom: 2px solid white;
    transform: rotate(-45deg) translateY(-1px);
}

.checkbox-label input[type="checkbox"]:focus-visible + .checkbox-custom {
    outline: 2.5px solid var(--blue-primary);
    outline-offset: 2px;
}

.checkbox-label a {
    color: var(--blue-mid);
    font-weight: 500;
}

/* ── Info box ────────────────────────────────────────────── */
.info-box {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: var(--blue-light);
    border: 1px solid rgba(26, 75, 140, 0.15);
    border-left: 3px solid var(--blue-primary);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 26px;
    font-size: 13.5px;
    color: var(--blue-dark);
    line-height: 1.55;
}

.info-box svg {
    flex-shrink: 0;
    color: var(--blue-primary);
    margin-top: 1px;
}

/* ── Bouton principal ────────────────────────────────────── */
.btn-primary {
    width: 100%;
    padding: 13px 20px;
    background: var(--blue-primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 15.5px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 4px;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, transparent 60%);
    pointer-events: none;
}

.btn-primary:hover {
    background: var(--blue-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(15, 45, 90, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-arrow {
    transition: transform 0.22s ease;
    flex-shrink: 0;
}

.btn-primary:hover .btn-arrow {
    transform: translateX(3px);
}

/* ── Alertes de formulaire (générées par ui.js) ──────────── */
.form-alert {
    padding: 12px 15px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 18px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: fadeSlideUp 0.25s ease forwards;
}

.form-alert--error {
    background: var(--danger-bg);
    border: 1px solid rgba(185, 28, 28, 0.2);
    border-left: 3px solid var(--danger);
    color: var(--danger);
}

.form-alert--success {
    background: var(--success-bg);
    border: 1px solid rgba(46, 125, 79, 0.2);
    border-left: 3px solid var(--success);
    color: var(--success);
}

/* ── Footer ──────────────────────────────────────────────── */
.footer {
    background: var(--blue-dark);
    padding: 20px 24px;
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.footer-inner {
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-copy {
    color: rgba(255,255,255,0.4);
    font-size: 12.5px;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.footer-links a {
    color: rgba(255,255,255,0.45);
    text-decoration: none;
    font-size: 12.5px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.footer-links a:hover {
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.08);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 920px) {
    .page-layout {
        grid-template-columns: 1fr;
        max-width: 600px;
    }

    .info-panel {
        order: 2;
    }

    .form-panel {
        order: 1;
    }
}

@media (max-width: 600px) {
    .main { padding: 20px 14px 36px; }

    .info-block, .form-section { padding: 24px 20px; }

    .tabs { }
    .tab { padding: 13px 10px; font-size: 13px; gap: 6px; }

    .panel-header h1 { font-size: 21px; }

    .footer-inner { flex-direction: column; text-align: center; }
    .footer-links { justify-content: center; }

    .req-list { border: none; gap: 0; }
    .req-item { padding: 14px 0; }

    .header-nav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Toast / Popup notifications ────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    width: calc(100vw - 48px);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    box-shadow: 0 8px 30px rgba(15, 45, 90, 0.16), 0 2px 8px rgba(15, 45, 90, 0.08);
    padding: 14px 14px 18px;
    pointer-events: all;
    position: relative;
    overflow: hidden;
    animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.toast--out {
    animation: toastOut 0.25s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(30px) scale(0.95); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0) scale(1); max-height: 200px; margin-bottom: 0; }
    to   { opacity: 0; transform: translateX(30px) scale(0.95); max-height: 0; margin-bottom: -10px; }
}

.toast-icon {
    flex-shrink: 0;
    margin-top: 1px;
}

.toast--success .toast-icon { color: var(--success); }
.toast--error   .toast-icon { color: var(--danger); }
.toast--info    .toast-icon { color: var(--blue-primary); }

.toast--success { border-left: 3px solid var(--success); }
.toast--error   { border-left: 3px solid var(--danger); }
.toast--info    { border-left: 3px solid var(--blue-primary); }

.toast-message {
    flex: 1;
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
    padding-right: 4px;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-subtle);
    padding: 2px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: color 0.15s ease;
    margin-top: -1px;
}

.toast-close:hover { color: var(--text); }

/* Barre de progression */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border-light);
}

.toast-bar {
    height: 100%;
    width: 100%;
    transform-origin: left;
}

.toast--success .toast-bar { background: var(--success); }
.toast--error   .toast-bar { background: var(--danger); }
.toast--info    .toast-bar { background: var(--blue-primary); }

.toast-bar--running {
    animation: toastProgress linear forwards;
}

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

@media (max-width: 480px) {
    #toast-container {
        bottom: 16px;
        right: 12px;
        left: 12px;
        width: auto;
        max-width: none;
    }
}