:root {
    --primary-color: #044c95;
    --primary-hover: #033a73;
    --accent-cyan: #06abe2;
    --accent-green: #00a851;
    --accent-gold: #f9c000;
    --text-muted: #64748b;
    --text-dark: #1e293b;
    --border-color: #e2e8f0;
    --input-bg: #f8fafc;
    --shadow-lg: 0 25px 50px -12px rgba(4, 76, 149, 0.25);
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body.recovery-body {
    font-family: 'Poppins', sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(0.5rem, 2vw, 1rem);
    margin: 0;
    background:
        radial-gradient(ellipse 80% 60% at 10% 20%, rgba(6, 171, 226, 0.16), transparent 50%),
        radial-gradient(ellipse 70% 50% at 90% 80%, rgba(0, 168, 81, 0.1), transparent 45%),
        linear-gradient(160deg, #eef4fb 0%, #f5f8fc 40%, #eef7f2 100%);
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.auth-ambient {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.auth-ambient .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.4;
    animation: orbFloat 14s ease-in-out infinite;
}

.orb-a {
    width: 200px;
    height: 200px;
    background: rgba(6, 171, 226, 0.35);
    top: 10%;
    left: 8%;
}

.orb-b {
    width: 160px;
    height: 160px;
    background: rgba(4, 76, 149, 0.28);
    bottom: 14%;
    right: 12%;
    animation-delay: -5s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(14px, -18px); }
}

.recovery-container {
    position: relative;
    z-index: 1;
    background: white;
    border-radius: clamp(12px, 2vw, 20px);
    box-shadow: var(--shadow-lg);
    width: min(100%, 460px);
    overflow-x: hidden;
    overflow-y: visible;
    border: 1px solid rgba(255, 255, 255, 0.8);
    animation: recoveryFadeIn 0.5s ease-out;
}

@keyframes recoveryFadeIn {
    from { opacity: 0; transform: translateY(14px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-anim {
    animation: authRise 0.5s ease both;
    animation-delay: var(--d, 0s);
}

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

.recovery-header {
    background:
        linear-gradient(145deg, rgba(6, 171, 226, 0.18) 0%, transparent 40%),
        linear-gradient(160deg, #044c95 0%, #033a73 55%, #022a54 100%);
    padding: clamp(1rem, 3vw, 1.35rem) clamp(1rem, 3vw, 1.5rem) clamp(0.9rem, 2.5vw, 1.15rem);
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.recovery-header::before {
    content: '';
    position: absolute;
    width: clamp(100px, 25vw, 160px);
    height: clamp(100px, 25vw, 160px);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    top: -50px;
    right: -40px;
    animation: softPulse 6s ease-in-out infinite;
}

@keyframes softPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.recovery-header > * {
    position: relative;
    z-index: 1;
}

.brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.logo-text {
    font-weight: 700;
    font-size: clamp(1.15rem, 3vw, 1.375rem);
    letter-spacing: -0.02em;
    color: #ffffff;
}

.logo-fne {
    font-weight: 700;
    font-size: clamp(0.95rem, 2.5vw, 1.125rem);
    color: var(--accent-gold);
    letter-spacing: 0.04em;
}

.recovery-header .header-sub {
    margin: 0.45rem 0 0;
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    opacity: 0.9;
}

.recovery-progress {
    height: 3px;
    background: #e2e8f0;
}

.recovery-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--primary-color));
    transition: width 0.45s ease;
}

.recovery-steps {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin: 1rem 0 0.25rem;
    padding: 0 1rem;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 0 0.75rem;
    flex: 1 1 auto;
    min-width: 70px;
}

.step-number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #E5E7EB;
    color: #6B7280;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
    z-index: 2;
    transition: background 0.25s, box-shadow 0.25s, transform 0.25s;
}

.step.active .step-number {
    background: var(--accent-cyan);
    color: white;
    box-shadow: 0 0 0 4px rgba(6, 171, 226, 0.18);
    transform: scale(1.08);
}

.step.completed .step-number {
    background: var(--accent-green);
    color: white;
}

.step-text {
    font-size: clamp(0.55rem, 1.8vw, 0.7rem);
    color: var(--text-muted);
    text-align: center;
}

.step.active .step-text {
    color: var(--primary-color);
    font-weight: 500;
}

.step.completed .step-text {
    color: var(--accent-green);
}

.step-connector {
    position: absolute;
    top: 15px;
    left: -50%;
    width: 100%;
    height: 2px;
    background: #E5E7EB;
    z-index: 1;
}

.step:first-child .step-connector {
    display: none;
}

.step.completed .step-connector,
.step.active .step-connector {
    background: color-mix(in srgb, var(--accent-cyan) 55%, #E5E7EB);
}

.recovery-form {
    padding: clamp(1rem, 3vw, 1.25rem) clamp(1rem, 3.5vw, 1.5rem) clamp(1.15rem, 3vw, 1.5rem);
}

.form-intro {
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    color: var(--text-muted);
    margin: 0 0 1rem;
    line-height: 1.5;
}

.form-group {
    margin-bottom: 0.9rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 0.8125rem;
}

.input-wrapper {
    position: relative;
}

.input-wrapper .input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1rem;
    pointer-events: none;
    z-index: 1;
    transition: color 0.2s;
}

.form-input:focus + .password-toggle,
.input-wrapper:focus-within .input-icon {
    color: var(--accent-cyan);
}

.form-input {
    width: 100%;
    max-width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text-dark);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.input-wrapper .form-input {
    padding-left: 2.5rem;
}

.password-container .form-input {
    padding-right: 2.75rem;
}

.form-input::placeholder {
    color: #94a3b8;
}

.form-input:hover {
    border-color: #cbd5e1;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(6, 171, 226, 0.18);
}

.pwd-meter {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-top: 0.45rem;
}

.pwd-meter span {
    height: 4px;
    border-radius: 999px;
    background: #e2e8f0;
    transition: background 0.25s;
}

.pwd-meter span.on {
    background: #f59e0b;
}

.pwd-meter[data-score="1"] span.on { background: #ef4444; }
.pwd-meter[data-score="2"] span.on { background: #f59e0b; }
.pwd-meter[data-score="3"] span.on { background: #06abe2; }
.pwd-meter[data-score="4"] span.on { background: #00a851; }

.match-hint {
    font-size: 0.75rem;
    margin: 0.35rem 0 0;
    min-height: 1.1em;
}

.match-hint.is-ok { color: #059669; }
.match-hint.is-bad { color: #e11d48; }

.btn-recovery {
    width: 100%;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--primary-color) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
    box-shadow: 0 4px 14px rgba(6, 171, 226, 0.3);
    margin-top: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 46px;
    position: relative;
}

.btn-recovery:hover {
    filter: brightness(1.05);
    box-shadow: 0 6px 20px rgba(4, 76, 149, 0.4);
    transform: translateY(-1px);
}

.btn-recovery.is-loading {
    pointer-events: none;
    opacity: 0.85;
}

.btn-recovery .btn-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn-recovery.is-loading .btn-spinner {
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.additional-links {
    text-align: center;
    margin-top: 1.1rem;
    font-size: 0.8125rem;
}

.additional-links a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 12px;
}

.additional-links a:hover {
    color: var(--accent-cyan);
    text-decoration: underline;
}

.step-content {
    display: none;
}

.step-content.active {
    display: block;
    animation: stepIn 0.35s ease;
}

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

.code-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(4px, 1.5vw, 8px);
    justify-content: center;
    margin-bottom: 1rem;
}

.code-input {
    width: clamp(34px, 9vw, 42px);
    height: clamp(40px, 10vw, 46px);
    text-align: center;
    font-size: clamp(0.95rem, 2.5vw, 1.05rem);
    font-weight: 600;
    font-family: inherit;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text-dark);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.code-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(6, 171, 226, 0.18);
    transform: translateY(-1px);
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--accent-cyan);
}

.password-container {
    position: relative;
}

.hint-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0.35rem 0 0;
}

@media (max-width: 480px) {
    body.recovery-body {
        align-items: flex-start;
        justify-content: center;
        padding: 0.75rem;
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
        overflow-y: auto;
    }
    .recovery-container {
        width: 100%;
        margin: auto;
        overflow-y: auto;
        max-height: none;
    }
    .form-input,
    .code-input {
        font-size: 16px;
    }
}

@media (max-height: 560px) {
    body.recovery-body {
        align-items: flex-start;
        overflow-y: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .recovery-container,
    .step-content.active,
    .btn-recovery,
    .auth-anim,
    .auth-ambient .orb,
    .recovery-header::before {
        animation: none;
        transition: none;
    }
}

/* SweetAlert : clics OK (Annuler / fermer / OK) */
.swal2-container {
    z-index: 20000 !important;
    pointer-events: auto !important;
}
.swal2-container .swal2-popup,
.swal2-container .swal2-actions,
.swal2-container .swal2-styled,
.swal2-container .swal2-close {
    pointer-events: auto !important;
    cursor: pointer;
}
