/* ================================================================
   CEZER STAFF — Pages d'authentification (login, 2FA, 404)
   Design premium aligné avec le site principal Cezer
   ================================================================ */

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes subtlePulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50%      { opacity: 1; transform: scale(1.1); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

@keyframes gridPulse {
    0%, 100% { opacity: 0.15; }
    50%      { opacity: 0.3; }
}

/* ── Corps ───────────────────────────────────────────────── */
.login-body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: stretch;
    background: var(--beige);
    font-family: var(--font);
    color: var(--text-primary);
    /* Empêche le scroll bounce iOS qui peut donner l'impression de zoom */
    overscroll-behavior-y: contain;
}

.login-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ════════════════════════════════════════════════════════════════
   PANNEAU VISUEL (gauche) — thème sombre premium
   ════════════════════════════════════════════════════════════════ */
.login-visual {
    position: relative;
    flex: 0 0 58%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    overflow: hidden;
    background: #181818;
}

.visual-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.38;
    animation: fadeIn 1.2s ease both;
    filter: saturate(0.9) contrast(1.05);
}

.visual-overlay {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg,
            rgba(24, 24, 24, 0.2) 0%,
            rgba(24, 24, 24, 0.55) 45%,
            rgba(24, 24, 24, 0.95) 100%),
        radial-gradient(ellipse at 30% 40%, rgba(228, 226, 221, 0.05) 0%, transparent 60%);
    z-index: 1;
}

/* Maillage décoratif */
.visual-grid {
    position: absolute;
    top: 2.5rem;
    right: 3rem;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(5, 5px);
    gap: 14px;
    animation: gridPulse 4s ease-in-out infinite;
}

.visual-grid span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--beige);
}

/* Badge "Tous systèmes opérationnels" */
.visual-badge {
    position: absolute;
    top: 2.5rem;
    left: 3.25rem;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.05rem;
    background: rgba(228, 226, 221, 0.08);
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
    border: 1px solid rgba(228, 226, 221, 0.12);
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--beige);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    animation: fadeInUp 0.8s ease 0.5s both;
}

.visual-badge .badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    animation: subtlePulse 2s ease-in-out infinite;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}

/* Contenu du panneau visuel */
.visual-content {
    position: relative;
    z-index: 2;
    padding: 3.5rem 4rem 3.75rem;
    max-width: 620px;
    animation: fadeInUp 0.8s ease 0.3s both;
}

.visual-brand {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.visual-logo {
    height: 54px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.5));
    animation: float 6s ease-in-out infinite;
}

.visual-tagline {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--beige);
    margin-bottom: 0.65rem;
    letter-spacing: -0.015em;
    line-height: 1.35;
}

.visual-desc {
    font-size: 0.94rem;
    color: rgba(228, 226, 221, 0.58);
    line-height: 1.75;
    max-width: 460px;
    font-weight: 400;
}

/* Pilules de fonctionnalités */
.visual-features {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.75rem;
}

.visual-features .feature-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.9rem;
    background: rgba(228, 226, 221, 0.06);
    border: 1px solid rgba(228, 226, 221, 0.1);
    border-radius: 100px;
    font-size: 0.72rem;
    color: rgba(228, 226, 221, 0.72);
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: all 0.25s ease;
}

.visual-features .feature-pill:hover {
    background: rgba(228, 226, 221, 0.1);
    border-color: rgba(228, 226, 221, 0.2);
    color: var(--beige);
    transform: translateY(-1px);
}

.visual-features .feature-pill svg,
.visual-features .feature-pill i {
    width: 13px;
    height: 13px;
    opacity: 0.85;
}

/* ════════════════════════════════════════════════════════════════
   PANNEAU FORMULAIRE (droite) — thème clair beige
   ════════════════════════════════════════════════════════════════ */
.login-form-side {
    flex: 0 0 42%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--beige);
    padding: 3rem 2.5rem;
    position: relative;
    overflow: hidden;
}

/* Liséré d'accent en haut */
.login-form-side::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--dark), var(--dark-light), var(--dark));
    background-size: 200% 100%;
    animation: shimmer 5s ease infinite;
    z-index: 1;
}

/* Ornement subtil en arrière-plan */
.login-form-side::after {
    content: '';
    position: absolute;
    bottom: -30%;
    right: -25%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle at 50% 50%, rgba(41, 41, 41, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.login-form-container {
    width: 100%;
    max-width: 420px;
    animation: fadeInUp 0.6s ease 0.2s both;
    position: relative;
    z-index: 2;
}

/* Marque (mobile / en haut) */
.login-form-brand {
    display: none;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.25rem;
    justify-content: center;
}

.login-form-brand img {
    height: 32px;
    width: auto;
    object-fit: contain;
}

/* En-tête */
.login-heading {
    margin-bottom: 2.25rem;
}

.login-heading h2 {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.login-heading p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.55;
}

/* Formulaire (surcharge spécifique login) */
.login-form-container .form-group {
    margin-bottom: 1.1rem;
}

.login-form-container .form-group label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.45rem;
}

.login-form-container .input-icon {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
}

.login-form-container .input-wrapper input {
    padding-left: 2.7rem;
    height: 48px;
    font-size: 0.95rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.login-form-container .input-wrapper input:focus {
    border-color: var(--dark);
    box-shadow: 0 0 0 3px rgba(41, 41, 41, 0.08);
}

/* Afficher / masquer mot de passe */
.toggle-password {
    position: absolute;
    right: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.3rem;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
    z-index: 2;
}

.toggle-password:hover {
    color: var(--text-primary);
}

.toggle-password svg,
.toggle-password i {
    width: 16px;
    height: 16px;
}

/* Bouton principal */
.login-form-container .btn-primary {
    height: 48px;
    font-size: 0.92rem;
    font-weight: 600;
    background: var(--dark);
    color: var(--beige);
    border: 1px solid var(--dark);
    border-radius: var(--radius);
    transition: all 0.22s ease;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.005em;
}

.login-form-container .btn-primary:hover {
    background: var(--dark-soft);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(41, 41, 41, 0.18);
}

.login-form-container .btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(41, 41, 41, 0.12);
}

.login-form-container .btn-primary svg,
.login-form-container .btn-primary i {
    width: 16px;
    height: 16px;
    transition: transform 0.22s ease;
}

.login-form-container .btn-primary:hover svg,
.login-form-container .btn-primary:hover i {
    transform: translateX(3px);
}

/* hCaptcha */
.captcha-wrapper {
    margin-bottom: 1.2rem;
    display: flex;
    justify-content: center;
}

.captcha-wrapper iframe {
    border-radius: var(--radius) !important;
}

/* Alertes (surcharge pour page login) */
.login-form-container .alert {
    margin-bottom: 1.5rem;
    border-radius: var(--radius);
    font-size: 0.86rem;
    padding: 0.75rem 0.95rem;
    animation: fadeInUp 0.3s ease both;
    box-shadow: var(--shadow-xs);
}

/* Pied */
.login-footer {
    margin-top: 2.5rem;
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.login-footer p {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
}

/* Astuce session longue */
.login-session-hint {
    margin-top: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    background: rgba(41, 41, 41, 0.04);
    border: 1px dashed var(--border-dark);
    border-radius: 100px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.login-session-hint i,
.login-session-hint svg {
    width: 12px;
    height: 12px;
}

/* Diviseur */
.login-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.login-divider span {
    font-size: 0.68rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-weight: 600;
}

/* ════════════════════════════════════════════════════════════════
   PAGES 2FA (setup + verify)
   ════════════════════════════════════════════════════════════════ */
.twofa-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1.5rem;
}

.twofa-card {
    width: 100%;
    max-width: 460px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.75rem 2.5rem;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.5s ease both;
    position: relative;
    overflow: hidden;
}

/* Accent en haut de la carte */
.twofa-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--dark) 0%, #555 50%, var(--dark) 100%);
    background-size: 200% 100%;
    animation: shimmer 5s ease infinite;
}

.twofa-form-container {
    max-width: 440px;
    margin: 0 auto;
}

.twofa-header {
    margin-bottom: 1.75rem;
    text-align: center;
}

.twofa-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
    margin: 0 auto 1.25rem;
    display: block;
}

.twofa-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.55rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.twofa-header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.twofa-visual .visual-content {
    padding: 3rem;
}

/* Icône circulaire en-tête 2FA */
.twofa-icon-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--dark) 0%, #404040 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    box-shadow: 0 8px 24px rgba(41, 41, 41, 0.22);
    position: relative;
}

.twofa-icon-circle::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 1px dashed var(--border-dark);
    opacity: 0.5;
}

.twofa-icon-circle i,
.twofa-icon-circle svg {
    width: 28px;
    height: 28px;
    color: var(--beige);
}

/* QR Code */
.qr-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.qr-code {
    width: 220px;
    height: 220px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 10px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

/* Clé secrète manuelle */
.secret-display {
    text-align: center;
    margin-bottom: 1.75rem;
}

.secret-label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.secret-code {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.86rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    color: var(--text-primary);
    letter-spacing: 0.08em;
    word-break: break-all;
    user-select: all;
    font-weight: 500;
}

/* Lien retour */
.twofa-back {
    text-align: center;
    margin-top: 1.5rem;
}

.twofa-back a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    transition: color 0.15s ease;
    font-weight: 500;
}

.twofa-back a:hover {
    color: var(--text-primary);
}

.twofa-back a i,
.twofa-back a svg {
    width: 14px;
    height: 14px;
}

/* Champ code OTP — style premium */
.otp-input {
    text-align: center;
    letter-spacing: 0.5em !important;
    font-family: var(--font-mono) !important;
    font-size: 1.3rem !important;
    font-weight: 600;
    height: 54px !important;
    padding: 0 0.85rem !important;
}

.twofa-form-container .btn-primary {
    height: 50px;
    font-size: 0.92rem;
    font-weight: 600;
    background: var(--dark);
    color: var(--beige);
    border: 1px solid var(--dark);
    border-radius: var(--radius);
    transition: all 0.22s ease;
}

.twofa-form-container .btn-primary:hover {
    background: var(--dark-soft);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(41, 41, 41, 0.18);
}

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
    .login-visual {
        flex: 0 0 52%;
    }
    .login-form-side {
        flex: 0 0 48%;
    }
    .visual-content {
        padding: 2.75rem 3rem;
    }
    .visual-tagline {
        font-size: 1.2rem;
    }
}

@media (max-width: 900px) {
    .login-visual {
        display: none;
    }
    .login-form-side {
        flex: 1;
        padding: 2.5rem 1.5rem;
        /* Safe-area : éloigne le formulaire de l'encoche / barre Home */
        padding-top: max(2.5rem, env(safe-area-inset-top));
        padding-bottom: max(2.5rem, env(safe-area-inset-bottom));
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }
    .login-form-brand {
        display: flex;
    }
    .login-form-container {
        max-width: 440px;
    }
}

/* ── Mobile (≤ 768px) — anti-zoom iOS rigoureux ────────── */
@media (max-width: 768px) {
    /* iOS ne déclenche le zoom automatique que si font-size < 16px sur l'input focusé */
    .login-form-container .input-wrapper input {
        font-size: 16px;
    }
    .login-form-container .form-group label {
        font-size: 0.74rem;
    }
}

@media (max-width: 600px) {
    .login-form-side {
        padding: 1.75rem 1.15rem;
        padding-top: max(1.75rem, env(safe-area-inset-top));
        padding-bottom: max(1.75rem, env(safe-area-inset-bottom));
    }
    .login-form-brand {
        margin-bottom: 1.65rem;
    }
    .login-form-brand img {
        height: 28px;
    }
    .login-form-container {
        max-width: 100%;
    }
    .login-heading {
        margin-bottom: 1.65rem;
    }
    .login-heading h2 {
        font-size: 1.55rem;
    }
    .login-heading p {
        font-size: 0.88rem;
    }
    .login-form-container .input-wrapper input {
        height: 50px;
        font-size: 16px;
    }
    .login-form-container .btn-primary {
        height: 50px;
        font-size: 0.95rem;
    }
    .login-footer {
        margin-top: 2rem;
        padding-top: 1.25rem;
    }
    /* hCaptcha : forcer le wrapper à se redimensionner sans dépasser */
    .captcha-wrapper {
        margin-bottom: 1rem;
        transform: scale(0.92);
        transform-origin: center;
    }
}

@media (max-width: 400px) {
    .login-form-side {
        padding: 1.4rem 0.95rem;
        padding-top: max(1.4rem, env(safe-area-inset-top));
        padding-bottom: max(1.4rem, env(safe-area-inset-bottom));
    }
    .login-heading h2 {
        font-size: 1.4rem;
    }
    .captcha-wrapper {
        transform: scale(0.85);
    }
    .twofa-card {
        padding: 2rem 1.4rem;
    }
    .twofa-header h2 {
        font-size: 1.3rem;
    }
    .qr-code {
        width: 180px;
        height: 180px;
    }
    .otp-input {
        font-size: 16px !important;
        letter-spacing: 0.4em !important;
        height: 48px !important;
    }
}

/* ── Mode paysage mobile : compacte les marges ─────────── */
@media (max-height: 640px) and (orientation: landscape) {
    .login-form-side {
        padding-top: 1rem;
        padding-bottom: 1rem;
        align-items: flex-start;
        overflow-y: auto;
    }
    .login-form-brand {
        margin-bottom: 1rem;
    }
    .login-heading {
        margin-bottom: 1rem;
    }
}
