/* ====== PALETTES ====== */
:root{
    /* MAHA */
    --maha-red:#e00019;
    --maha-red-700:#b50015;
    --maha-blue:#0b54a6;

    /* AUTOMOTEC */
    --auto-orange:#f28c00;
    --auto-ink:#5f777f;

    /* UI commune */
    --text:#0a0e22;
    --muted:#6b7280;
    --white:#ffffff;
    --border:#e8edf3;
    --shadow:0 14px 44px rgba(0,0,0,.16);

    /* Fond uni */
    --bg-cream:#fbfaf7;

    /* Hauteur fixe du header */
    --header-h: 64px;
}

/* ====== RESET ====== */
*{box-sizing:border-box}
html,body{height:100%}
body{
    margin:0;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--text);
    position: relative;
    background: var(--bg-cream);
}

/* Calque MOTIF (Fond.png) — commence sous le header */
body::before{
    content:"";
    position: fixed; left:0; right:0; bottom:0;
    top: var(--header-h);
    z-index: 0;
    pointer-events: none;
    background-image: url("Fond.png");
    background-repeat: repeat;
    background-size: 420px 420px;
    opacity: .35;
    mix-blend-mode: multiply;
}

/* Grain fin */
body::after{
    content:"";
    position: fixed; left:0; right:0; bottom:0;
    top: var(--header-h);
    z-index: 0;
    pointer-events: none;
    opacity:.06;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 180px 180px;
}

/* ====== HEADER ====== */
header{
    position: relative;
    z-index: 5;
    height: var(--header-h);
    display:flex; justify-content:flex-end; align-items:center;
    padding:0 16px;
    background:#fff;
    border-bottom:1px solid var(--border);
}
header img{height:40px}

/* ====== LAYOUT ====== */
.wrap{
    position:relative;
    display:grid;
    grid-template-columns:1fr;
    min-height:calc(100vh - var(--header-h));
}

.wrap::before{ display:none; }

.panel{
    position:relative;
    z-index:2;
    display:grid;
    place-items:center;
    min-height:inherit;
    padding:40px 24px;
}

/* ====== Cartes (verre dépoli) ====== */
.card{
    width:min(520px, 88vw);
    background: rgba(245,247,250,.95);
    border: 1px solid #dde5ef;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius:18px;
    box-shadow: 0 14px 34px rgba(17,24,39,.14), 0 2px 6px rgba(17,24,39,.08);
    padding:22px;
}
.panel.maha .card{
    background: rgba(252,235,238,.95);
    border-color:#f0cfd5;
}
.panel.automotec .card,
.panel.auto .card{
    background: rgba(245,249,253,.95);
    border-color:#dfe9f5;
}

.panel h2{
    margin:0 0 14px; font-size:22px; letter-spacing:.4px; font-weight:800; color:#0f172a;
}

/* Titres brandés */
.panel.maha h2{ color: var(--maha-blue); }
.panel.automotec h2,
.panel.auto h2{ color: var(--auto-ink); }

/* ====== Form ====== */
form{display:grid; gap:12px}
.field{display:grid}
input[type="text"], input[type="password"], input[type="email"]{
    width:100%; padding:12px 12px; font-size:15px;
    background:#fff; border:1px solid var(--border); border-radius:12px; outline:none;
    transition:border-color .15s ease, box-shadow .15s ease;
}

/* Focus brandé */
.panel.maha input[type="text"]:focus,
.panel.maha input[type="password"]:focus,
.panel.maha input[type="email"]:focus{
    border-color: var(--maha-red);
    box-shadow: 0 0 0 4px rgba(224,0,25,.22);
}
.panel.automotec input[type="text"]:focus,
.panel.automotec input[type="password"]:focus,
.panel.automotec input[type="email"]:focus,
.panel.auto input[type="text"]:focus,
.panel.auto input[type="password"]:focus,
.panel.auto input[type="email"]:focus{
    border-color: var(--auto-orange);
    box-shadow: 0 0 0 4px rgba(242,140,0,.22);
}

/* ====== Boutons ====== */
.btn, button{
    appearance:none; border:0; cursor:pointer;
    border-radius:12px; padding:12px; font-weight:700; font-size:15px;
    transition:transform .06s ease, filter .15s ease, box-shadow .15s ease;
}
.panel.maha .btn.primary{
    background: var(--maha-red); color:#fff;
    box-shadow: 0 8px 18px rgba(224,0,25,.28);
}
.panel.maha .btn.primary:hover{ transform:translateY(-1px); filter:saturate(1.05); }

.panel.automotec .btn.primary,
.panel.auto .btn.primary{
    background: var(--auto-orange); color:#fff;
    box-shadow: 0 8px 18px rgba(242,140,0,.26);
}
.panel.automotec .btn.primary:hover,
.panel.auto .btn.primary:hover{ transform:translateY(-1px); filter:saturate(1.05); }

/* Messages */
.msg{min-height:18px; font-weight:600; color:#b91c1c}

/* ====== Liens sous le formulaire ====== */
.links-row{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    margin-top:2px;
}
.link-sep{
    color:var(--muted);
    font-size:.85rem;
    user-select:none;
}
.link-btn{
    background:none !important;
    border:0 !important;
    padding:0 !important;
    margin:0 !important;
    cursor:pointer;
    font-size:.9rem;
    font-weight:600;
    text-decoration:underline;
    text-underline-offset:2px;
    transition:opacity .15s ease, color .15s ease;
    border-radius:0 !important;
    box-shadow:none !important;
}
.link-btn:hover{
    opacity:.8;
}

/* Couleurs des liens par panel */
.panel.maha .link-btn{
    color: var(--maha-blue);
}
.panel.automotec .link-btn,
.panel.auto .link-btn{
    color: var(--auto-ink);
}

/* ====== Modal ====== */
.modal{
    position:fixed; inset:0;
    display:none; align-items:center; justify-content:center;
    z-index:1000;
}
.modal[aria-hidden="false"]{display:flex}
.modal-backdrop{
    position:absolute; inset:0;
    background:rgba(0,0,0,.55);
    backdrop-filter: blur(2px);
}
.modal-panel{
    position:relative;
    width:min(440px, 92vw);
    background:#0f1117;
    color:#e6eef8;
    border:1px solid #242938;
    border-radius:14px;
    padding:20px 22px;
    box-shadow:0 20px 70px rgba(0,0,0,.5);
    z-index:1;
    animation: modalIn .2s ease-out;
}

@keyframes modalIn{
    from{ opacity:0; transform:translateY(12px) scale(.97); }
    to{ opacity:1; transform:translateY(0) scale(1); }
}

.modal-hd{
    display:flex; align-items:center; justify-content:space-between;
    margin-bottom:12px;
    border-bottom:1px solid #242938;
    padding-bottom:10px;
}
.modal-hd h3{margin:0; font-size:1.05rem; font-weight:700}
.modal-close{
    background:none; border:0; color:#9aa4af;
    font-size:1.2rem; cursor:pointer;
    transition:color .15s;
}
.modal-close:hover{color:#fff}

.modal-bd p{
    margin:.2rem 0 .8rem;
    color:#c8d0da;
    font-size:.93rem;
    line-height:1.45;
}

/* Champs dans les modals */
.modal-field{
    display:grid;
    gap:4px;
    margin-bottom:10px;
}
.modal-field label{
    font-size:.85rem;
    font-weight:600;
    color:#a0aab6;
    letter-spacing:.02em;
}
.modal-field input[type="text"],
.modal-field input[type="password"],
.modal-field input[type="email"]{
    width:100%;
    padding:.65rem .75rem;
    border-radius:10px;
    border:1px solid #2a3042;
    background:#0a1220;
    color:#e6eef8;
    font-size:.95rem;
    outline:none;
    transition:border-color .15s ease, box-shadow .15s ease;
}
.modal-field input:focus{
    border-color:#4a8fe7;
    box-shadow:0 0 0 3px rgba(74,143,231,.2);
}

.form-row{display:flex; gap:.5rem; justify-content:flex-end; margin-top:.65rem}
.modal-actions{margin-top:14px}
.btn.secondary{background:#2a3042; color:#fff; border-radius:10px}
.btn.secondary:hover{background:#343d52}

.modal-primary{
    background:#4a8fe7 !important;
    color:#fff !important;
    box-shadow: 0 4px 14px rgba(74,143,231,.3) !important;
    border-radius:10px !important;
}
.modal-primary:hover{
    background:#3a7fd7 !important;
    transform:translateY(-1px);
}

/* Message dans les modals */
.modal-msg{
    margin-top:.6rem;
    font-size:.9rem;
    font-weight:600;
    min-height:20px;
}
.modal-msg.error{color:#f87171}
.modal-msg.success{color:#4ade80}
.modal-msg.info{color:#93c5fd}

/* ====== Modal "Mot de passe oublié" — étapes MFA ====== */
.forgot-panel{
    width: min(500px, 92vw);
}

.step-block{
    border: 1px solid #242938;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
    transition: opacity .2s ease, border-color .2s ease;
}
.step-block.active{
    border-color: #4a8fe7;
    background: rgba(74,143,231,.06);
}
.step-block.done{
    border-color: #4ade80;
    background: rgba(74,222,128,.05);
    opacity: .85;
}
.step-block.locked{
    opacity: .55;
    border-color: #1e2535;
}
.step-block.unlocked{
    border-color: #4a8fe7;
    background: rgba(74,143,231,.06);
    opacity: 1;
}

.step-label{
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: .9rem;
    margin-bottom: 8px;
    color: #c8d0da;
}
.step-num{
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #2a3042;
    color: #93c5fd;
    font-size: .78rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.step-block.done .step-num{
    background: #166534;
    color: #4ade80;
}

.step-lock-msg{
    font-size: .85rem;
    color: #6b7280;
    margin: 6px 0 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Bouton Microsoft */
.ms-btn{
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #d0d5dd;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, box-shadow .15s ease;
    margin-bottom: 8px;
}
.ms-btn:hover{
    background: #f5f5f5;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.ms-btn:disabled{
    opacity: .5;
    cursor: not-allowed;
}

/* Utilisateur vérifié */
.verified-info{
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .88rem;
    color: #4ade80;
    background: rgba(74,222,128,.08);
    border: 1px solid rgba(74,222,128,.2);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
}
.verified-icon{
    font-style: normal;
    font-weight: 700;
    color: #4ade80;
}

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

/* ====== Responsive ====== */
/* .wrap est déjà en 1 colonne — pas de breakpoint nécessaire */

@media (max-width:480px){
    .card{padding:22px 16px;}
    .panel h2{font-size:1.5rem;}
    .step-block{padding:14px 12px;}
}
