/* =========================================================
   AIROBI — wizard.css (onboarding 11 étapes)
   Thème bleu unifié · CSS mort supprimé · styles manquants
   ajoutés (email/password/tel, listes dynamiques, vérif. email)
   Responsive : 600 / 520 / 420 / 360 · paysage · safe-areas
   ========================================================= */

:root {
    --bg-start: #eef2f7; --bg-middle: #dce3ed; --bg-end: #e8ecf3;
    --surface: #ffffff;
    --primary: #1976d2; --primary-dark: #0d47a1;
    --text: #0d1b3e; --muted: #78909c;
    --border: #eceff1; --input-bg: #fafbfc;
    --shadow: rgba(15, 50, 100, 0.08);
    --danger: #ef5350; --danger-dark: #d32f2f;
    --ok: #43a047;
}

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

html { min-height: 100%; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: linear-gradient(160deg, var(--bg-start) 0%, var(--bg-middle) 50%, var(--bg-end) 100%);
    background-attachment: fixed;
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh;
    min-height: 100dvh;                 /* vraie hauteur mobile */
    padding: clamp(12px, 3vw, 18px);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* =========================================================
   CONTAINER
   ========================================================= */
.wizard-container {
    width: min(100%, 550px);
    border-radius: 28px;
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 25px 60px var(--shadow), 0 4px 20px rgba(15, 50, 100, 0.04);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    max-height: 92dvh;
}

/* =========================================================
   HEADER + PROGRESSION
   ========================================================= */
.wizard-header {
    padding: 24px 28px 16px;
    text-align: center;
    background: radial-gradient(circle at top left, rgba(255,255,255,0.72), transparent 38%),
                linear-gradient(180deg, #e8f4fd 0%, #c5e3f9 45%, #9ecff2 100%);
    flex-shrink: 0;
}
.logo-small { width: 80px; height: auto; margin-bottom: 8px; }
.progress-text {
    font-size: 13px; font-weight: 700; color: #1565c0;
    margin-bottom: 10px; letter-spacing: 0.3px;
}
.progress-bar-bg {
    width: 100%; height: 8px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px; overflow: hidden;
}
.progress-bar-fill {
    height: 100%; width: 9.09%;            /* 1/11 — mis à jour par le JS */
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 10px;
    transition: width 0.35s ease;
}

/* =========================================================
   BODY / ÉTAPES
   ========================================================= */
.wizard-body {
    flex: 1;
    overflow-y: auto;
    padding: 28px 30px 20px;
    background: var(--surface);
    -webkit-overflow-scrolling: touch;      /* scroll fluide iOS */
}

.step-section { display: none; }
.step-section.active { display: block; animation: stepIn .3s ease; }
@keyframes stepIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.step-section h2 {
    font-size: clamp(20px, 5vw, 24px);
    font-weight: 800; margin-bottom: 8px; letter-spacing: -0.5px;
}
.step-subtitle { color: #90a4ae; font-size: 14px; margin-bottom: 24px; font-weight: 500; }
.step-hint { color: #90a4ae; font-size: 13px; margin-bottom: 15px; }

/* =========================================================
   FORMULAIRES
   ⭐ TOUS les types d'input stylés (text/email/password/tel/number)
   + select + inputs des listes dynamiques
   ========================================================= */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 600;
    color: #546e7a; margin-bottom: 8px;
}
.req { color: var(--danger); }

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group select,
.dynamic-list-item input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: var(--input-bg);
    font: inherit;
    font-size: 16px;                     /* ⭐ 16px : anti-zoom auto iOS */
    color: #37474f;
    outline: none;
    min-height: 52px;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.form-group select { cursor: pointer; }

.form-group input::placeholder,
.dynamic-list-item input::placeholder { color: #b0bec5; }

.form-group input:focus,
.form-group select:focus,
.dynamic-list-item input:focus {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(25, 118, 210, 0.08);
}

/* Autofill Chrome : évite le fond bleu/jaune qui casse le design */
.form-group input:-webkit-autofill,
.dynamic-list-item input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 60px var(--input-bg) inset;
    -webkit-text-fill-color: #37474f;
    transition: background-color 9999s ease-in-out 0s;
}

/* Champs côte à côte */
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

/* Erreurs de validation */
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; display: none; }
.form-group.has-error input,
.form-group.has-error select { border-color: var(--danger); }
.form-group.has-error .field-error { display: block; }

/* =========================================================
   GRILLE D'OPTIONS (cartes)
   ========================================================= */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 12px;
    margin-top: 4px;
}
/* Variante pleine largeur (étapes 4, 8, 9) — remplace le style inline */
.options-grid.single { grid-template-columns: 1fr; }

.option-card {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 14px 10px;
    border: 2px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    gap: 8px;
    min-height: 90px;
    -webkit-tap-highlight-color: transparent;
}
.option-card i { font-size: 22px; color: #78909c; transition: color 0.25s; }
.option-card span { font-size: 13px; font-weight: 600; color: #37474f; line-height: 1.3; }

.option-card:hover {
    border-color: var(--primary);
    background: #f8fbff;
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.1);
}
.option-card:hover i { color: var(--primary); }

.option-card.selected {
    border-color: var(--primary);
    background: rgba(25, 118, 210, 0.06);
    box-shadow: 0 4px 16px rgba(13, 71, 161, 0.12);
}
.option-card.selected i { color: var(--primary-dark); }
.option-card.selected span { font-weight: 700; color: var(--primary-dark); }

/* =========================================================
   CHECKBOXES PERSONNALISÉES (gardées pour compat)
   ========================================================= */
.checkbox-list { display: flex; flex-direction: column; gap: 12px; }
.checkbox-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 18px;
    border: 2px solid var(--border); border-radius: 16px;
    background: var(--surface); cursor: pointer;
    transition: all 0.25s ease; position: relative;
}
.checkbox-item input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.check-icon {
    display: flex; align-items: center; justify-content: center;
    width: 24px; height: 24px;
    border: 2px solid #b0bec5; border-radius: 8px;
    background: #fff; transition: all 0.25s ease; flex-shrink: 0;
}
.check-icon i { font-size: 13px; color: #fff; opacity: 0; transition: opacity 0.2s ease; }
.checkbox-item.selected {
    border-color: var(--primary);
    background: rgba(25, 118, 210, 0.04);
    box-shadow: 0 4px 12px rgba(13, 71, 161, 0.06);
}
.checkbox-item.selected .check-icon {
    background: var(--primary); border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.2);
}
.checkbox-item.selected .check-icon i { opacity: 1; color: #fff; }
.check-label { font-size: 14px; font-weight: 500; color: #37474f; line-height: 1.4; }
.checkbox-item:hover { border-color: var(--primary); background: #f8fbff; }

/* =========================================================
   LISTES DYNAMIQUES (magasins, entrepôts, catégories)
   ========================================================= */
.dynamic-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.dynamic-list-item { display: flex; gap: 10px; align-items: center; }
.dynamic-list-item input { flex: 1; min-width: 0; }   /* hérite des styles inputs ci-dessus */

.btn-remove {
    background: transparent;
    color: var(--danger);
    border: 2px solid rgba(239, 83, 80, 0.35);
    width: 48px; height: 48px;
    border-radius: 12px;
    cursor: pointer; font-size: 15px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.btn-remove:hover { background: #fdecea; border-color: var(--danger); color: var(--danger-dark); }

.btn-add-item {
    background: transparent;
    border: 2px dashed #c5cdd6;
    color: var(--muted);
    padding: 13px;
    border-radius: 12px;
    cursor: pointer;
    font: 600 14px 'Plus Jakarta Sans', sans-serif;
    margin-top: 10px;
    width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: all 0.2s;
}
.btn-add-item:hover { border-color: var(--primary); color: var(--primary); background: #f6faff; }

/* =========================================================
   SOUS-ÉTAPES CONDITIONNELLES (thème bleu unifié)
   ========================================================= */
.sub-single { margin-top: 15px; }

.sub-step {
    margin-top: 20px;
    padding: 20px;
    background: #f5f9ff;
    border-radius: 14px;
    border-left: 4px solid var(--primary);
    display: none;
}
.sub-step.visible { display: block; }
.sub-step-label { font-weight: 600; margin-bottom: 10px; display: block; font-size: 14px; color: #37474f; }

/* =========================================================
   ⭐ VÉRIFICATION EMAIL (code à 6 chiffres) — avant tout en inline
   ========================================================= */
.verify-box {
    background: #f5f9ff;
    border: 1px solid #dbe7f5;
    border-radius: 14px;
    padding: 14px;
}
.verify-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.verify-state { font-size: 12.5px; color: var(--muted); flex: 1; min-width: 180px; }

.btn-verify {
    flex-shrink: 0;
    padding: 11px 18px;
    border-radius: 11px;
    border: none;
    background: var(--primary);
    color: #fff;
    font: 700 13px 'Plus Jakarta Sans', sans-serif;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 44px;                      /* zone tactile confortable */
    transition: background 0.2s, transform 0.15s, opacity 0.2s;
}
.btn-verify:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }
.btn-verify:disabled { opacity: 0.6; cursor: wait; }

.code-zone { margin-top: 12px; }
.code-label { font-size: 12px; font-weight: 700; color: #37474f; display: block; margin-bottom: 6px; }
.code-row { display: flex; gap: 10px; }
.code-input {
    flex: 1; min-width: 0;
    letter-spacing: 8px;
    font-size: 18px;
    text-align: center;
    padding: 12px 10px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--input-bg);
    font: 700 18px 'Plus Jakarta Sans', sans-serif;
    color: #37474f;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
}
.code-input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(25, 118, 210, 0.08); }

/* =========================================================
   RÔLES & PERMISSIONS (thème bleu unifié)
   ========================================================= */
.role-config-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}
.role-config-card.active { border-color: var(--primary); }

.role-config-header {
    display: flex; align-items: center; gap: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.role-config-header .role-name { font-weight: 700; flex: 1; font-size: 14.5px; }
.role-hint { font-size: 12px; color: #90a4ae; }
.role-config-header i.toggle-icon { transition: transform 0.2s; color: #b0bec5; font-size: 13px; }
.role-config-card.active .role-config-header i.toggle-icon { transform: rotate(180deg); color: var(--primary); }

.role-permissions-grid {
    display: none;
    margin-top: 14px; padding-top: 14px;
    border-top: 1px solid var(--border);
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.role-config-card.active .role-permissions-grid { display: grid; }

.perm-chip {
    font-size: 12.5px;
    padding: 9px 10px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    text-align: center;
    font-weight: 600;
    color: #546e7a;
    -webkit-tap-highlight-color: transparent;
}
.perm-chip:hover { background: #eef4fb; border-color: #c5d9f0; }
.perm-chip.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.perm-chip.selected:hover { background: var(--primary-dark); }

/* =========================================================
   FOOTER (boutons)
   ========================================================= */
.wizard-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 30px calc(20px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--border);
    gap: 12px;
    flex-shrink: 0;
}

.btn-prev {
    min-height: 52px;
    padding: 0 22px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    font: 700 14px/1 'Plus Jakarta Sans', sans-serif;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    transition: all 0.25s ease;
}
.btn-prev i { font-size: 14px; }
.btn-prev:hover { border-color: var(--primary); background: #f0f7ff; color: var(--primary-dark); }
.btn-prev.hidden { display: none; }

.btn-next {
    min-height: 52px;
    padding: 0 24px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    font: 700 14px/1 'Plus Jakarta Sans', sans-serif;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    position: relative; overflow: hidden;
    box-shadow: 0 4px 18px rgba(13, 71, 161, 0.26);
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.2s;
}
.btn-next::after {
    content: '';
    position: absolute; top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.16), transparent);
    transition: left 0.55s ease;
}
.btn-next:hover:not(.loading) { transform: translateY(-1px); box-shadow: 0 8px 25px rgba(13, 71, 161, 0.32); }
.btn-next:hover:not(.loading)::after { left: 100%; }
.btn-next:active:not(.loading) { transform: translateY(0); }
.btn-next i { font-size: 14px; }

/* État chargement (pendant la création de l'espace) */
.btn-next.loading { pointer-events: none; opacity: 0.7; }
.btn-next.loading i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   OVERLAY FINAL
   ========================================================= */
.wizard-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(13, 27, 62, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center; justify-content: center;
    padding: 18px;
}
.wizard-overlay.visible { display: flex; }

.wizard-overlay-content {
    background: var(--surface);
    border-radius: 20px;
    padding: 40px 32px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 25px 70px rgba(13, 27, 62, 0.35);
}
.wizard-overlay-content h3 { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.overlay-text { color: var(--muted); font-size: 14px; line-height: 1.6; }

.wizard-overlay-content .spinner {
    width: 50px; height: 50px;
    border: 4px solid #e3ecf5;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}
.wizard-overlay-content.success .spinner { display: none; }
.wizard-overlay-content.success i.success-icon {
    font-size: 50px;
    color: var(--ok);
    margin-bottom: 20px;
    display: block;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

/* ---------- Tablettes / grands mobiles (≤ 600px) ---------- */
@media (max-width: 600px) {
    .wizard-container { width: 100%; border-radius: 22px; max-height: 94dvh; }
    .wizard-header { padding: 16px 20px 12px; }
    .logo-small { width: 64px; }
    .wizard-body { padding: 20px 20px 16px; }
    .wizard-footer { padding: 14px 20px calc(16px + env(safe-area-inset-bottom, 0px)); }
    .step-subtitle { margin-bottom: 18px; }
    .form-group { margin-bottom: 16px; }
}

/* ---------- Smartphones (≤ 520px) : les champs passent en colonne ---------- */
@media (max-width: 520px) {
    .inline-fields { grid-template-columns: 1fr; gap: 0; }
    .options-grid { grid-template-columns: repeat(2, 1fr); }
    .option-card { min-height: 84px; padding: 12px 8px; }
    .option-card i { font-size: 20px; }
    .option-card span { font-size: 12.5px; }
    .options-grid.single { grid-template-columns: 1fr; }
    .code-row { flex-direction: column; }
    .code-row .btn-verify { width: 100%; }
    .verify-row { flex-direction: column; align-items: stretch; }
    .verify-state { min-width: 0; }
}

/* ---------- Petits smartphones (≤ 420px) : options en ligne ---------- */
@media (max-width: 420px) {
    .options-grid { grid-template-columns: 1fr; }
    .option-card {
        flex-direction: row;
        justify-content: flex-start;
        text-align: left;
        gap: 14px;
        padding: 13px 16px;
        min-height: unset;
    }
    .option-card i { font-size: 20px; }
    .role-permissions-grid { grid-template-columns: 1fr; }
    .wizard-overlay-content { padding: 30px 22px; }
    .sub-step { padding: 16px; }
}

/* ---------- Footer : boutons pleine largeur (≤ 480px) ---------- */
@media (max-width: 480px) {
    .wizard-footer { flex-wrap: wrap; }
    .wizard-footer .btn-prev,
    .wizard-footer .btn-next { flex: 1; min-height: 50px; font-size: 13.5px; padding: 0 14px; }
}

/* ---------- Très petits smartphones (≤ 360px) ---------- */
@media (max-width: 360px) {
    body { padding: 10px; }
    .wizard-container { border-radius: 18px; }
    .wizard-body { padding: 16px 14px 14px; }
    .step-section h2 { font-size: 19px; }
    .btn-remove { width: 44px; height: 44px; }
}

/* ---------- Téléphone en paysage (peu de hauteur) ---------- */
@media (max-height: 620px) and (orientation: landscape) {
    body { align-items: flex-start; }
    .wizard-container { max-height: 96dvh; }
    .wizard-header { padding: 10px 20px 8px; }
    .logo-small { width: 44px; margin-bottom: 4px; }
    .progress-text { margin-bottom: 6px; }
    .wizard-body { padding: 14px 22px 12px; }
    .form-group { margin-bottom: 12px; }
    .form-group input, .dynamic-list-item input { min-height: 46px; padding-top: 10px; padding-bottom: 10px; }
    .wizard-footer { padding: 10px 22px 12px; }
    .btn-prev, .btn-next { min-height: 46px; }
}

/* ---------- Écrans tactiles ---------- */
@media (hover: none) {
    .option-card, .perm-chip, .checkbox-item { min-height: 48px; }
}

/* ---------- Accessibilité : mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}