:root {
    --accent: #2c4a7c;
    --accent-dark: color-mix(in oklch, #2c4a7c 78%, black);
    --accent-alt: color-mix(in oklch, #2c4a7c 55%, oklch(72% 0.13 45));
    --accent-tint: color-mix(in oklch, #2c4a7c 8%, white);
    --ink: oklch(22% 0.015 255);
    --ink-muted: oklch(52% 0.02 255);
    --border: oklch(90% 0.006 255);
    --white: #fff;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: linear-gradient(165deg, oklch(16% 0.02 255), oklch(7% 0.015 255));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 20px;
    padding-bottom: 20px;
    gap: 30px;
    min-height: 100vh;
    color: var(--ink);
    position: relative;
    overflow: hidden;
}

/* Effets de fond */
.bg-halo {
    position: fixed;
    top: 0;
    left: 0;
    width: 200px;
    height: 200px;
    margin: -100px 0 0 -100px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent) 0%, transparent 90%);
    opacity: 0;
    z-index: 0;
    pointer-events: none;
    filter: blur(80px);
    transform: translate3d(50vw, 50vh, 0);
    transition: opacity 0.7s ease;
    will-change: transform;
}

.bg-halo.login-mode {
    opacity: 1
}

.bg-halo.signup-mode {
    opacity: 0.516;
}

.bg-lens {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    z-index: 0;
    opacity: 0.95;
    pointer-events: none;
    transform: translate(-50%, -50%);
    will-change: transform;
}

.bg-icons {
    position: fixed;
    z-index: 0;
    opacity: 0.11;
    pointer-events: none;
    width: 48px;
    height: 48px;
    color: #fff;
}

.bg-icons svg {
    width: 100%;
    height: 100%;
}

.bg-icon-1 { top: 5%; left: 5%; animation: floatIcon 8s ease-in-out infinite; }
.bg-icon-2 { top: 8%; right: 3%; animation: floatIcon 6s ease-in-out infinite -1s; }
.bg-icon-3 { bottom: 15%; left: 2%; animation: floatIcon 10s ease-in-out infinite -2s; }
.bg-icon-4 { bottom: 10%; right: 5%; animation: floatIcon 7s ease-in-out infinite -3s; }
.bg-icon-5 { top: 50%; left: 3%; animation: floatIcon 9s ease-in-out infinite -1.5s; }
.bg-icon-6 { top: 30%; right: 2%; animation: floatIcon 11s ease-in-out infinite -2.5s; }
.bg-icon-7 { bottom: 40%; right: 10%; animation: floatIcon 8s ease-in-out infinite -0.5s; }
.bg-icon-8 { top: 60%; left: 8%; animation: floatIcon 13s ease-in-out infinite -3.5s; }

@keyframes floatIcon {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(2deg); }
}

/* Conteneur principal */
.main-wrapper {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1180px;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

/* Ligne connexion : panneau de bienvenue + carte */
.auth-layout {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 56px;
}

/* Panneau de bienvenue (colonne gauche) */
.welcome-panel {
    flex: 1 1 380px;
    min-width: 0;
    color: var(--white);
}

.welcome-panel .brand {
    margin-bottom: 28px;
}

.welcome-panel .brand-name {
    color: var(--white);
}

.welcome-title {
    font-size: 34px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--white);
    margin-bottom: 16px;
    max-width: 460px;
}

.welcome-text {
    font-size: 14px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.55);
    max-width: 420px;
    margin-bottom: 28px;
}

.welcome-contact-label {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
}

.welcome-contact-link {
    display: block;
    width: fit-content;
    font-size: 15px;
    font-weight: 700;
    color: var(--white);
    text-decoration: underline;
    text-decoration-color: color-mix(in oklch, var(--accent) 55%, white);
    text-underline-offset: 3px;
    margin-bottom: 6px;
    transition: text-decoration-color 0.2s;
}

.welcome-contact-link:hover {
    text-decoration-color: var(--white);
}

/* Aligne la frise sous la carte, pas sous toute la largeur */
.steps-align {
    width: 100%;
    display: flex;
    justify-content: flex-end;
}

/* Carte et décoration */
.card-wrapper {
    position: relative;
    flex: 0 0 547px;
    width: 547px;
    max-width: 94vw;
    perspective: 1600px;
}

.card-bg-decoration {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--accent) 0%, black 100%);
    border-radius: 20px;
    transform: translate(14px, 14px) rotate(-3deg);
    z-index: -1;
    opacity: 0.6;
}

.card {
    position: relative;
    z-index: 1;
    height: min(596px, 88vh);
    transform-style: preserve-3d;
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.brand-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.brand-icon::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--white);
    border-radius: 50%;
}

.brand-icon::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border: 2px solid var(--accent);
    border-radius: 50%;
}

.brand-logo {
    height: 52px;
    width: auto;
    display: block;
    padding: 3px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.brand-name {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--ink);
}

h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 6px;
}

.subtitle {
    font-size: 12px;
    color: var(--ink-muted);
    margin-bottom: 14px;
}

/* Formulaires — pivot vertical (rotateX) */
.form-section {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 6% 4%, color-mix(in oklch, var(--accent) 20%, white) 0%, transparent 42%),
        radial-gradient(circle at 96% 10%, color-mix(in oklch, var(--accent-alt) 18%, white) 0%, transparent 38%),
        radial-gradient(circle at 10% 100%, color-mix(in oklch, var(--accent-alt) 16%, white) 0%, transparent 46%),
        radial-gradient(circle at 100% 96%, color-mix(in oklch, var(--accent) 18%, white) 0%, transparent 42%),
        var(--white);
    border-radius: 20px;
    box-shadow: 0 30px 70px -20px rgba(0,0,0,.55), 0 2px 10px rgba(0,0,0,.25);
    padding: 24px 36px;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.form-section.login {
    transform: rotateX(0deg);
    pointer-events: auto;
}

.form-section.signup {
    transform: rotateX(180deg);
    pointer-events: none;
}

.card.flipped .form-section.login {
    transform: rotateX(-180deg);
    pointer-events: none;
}

.card.flipped .form-section.signup {
    transform: rotateX(0deg);
    pointer-events: auto;
}

.form-group {
    margin-bottom: 14px;
    position: relative;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 13px;
    width: 16px;
    height: 16px;
    color: var(--ink-muted);
    pointer-events: none;
    z-index: 2;
    display: flex;
}

.input-icon svg {
    width: 100%;
    height: 100%;
}

input {
    width: 100%;
    padding: 14px 13px 4px 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-family: 'Inter', inherit;
    font-size: 13.5px;
    color: var(--ink);
    background: var(--white);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

input::placeholder {
    color: transparent;
}

input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-tint);
}

label {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13.5px;
    color: var(--ink-muted);
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: calc(100% - 80px);
}

input:has(+ label):focus + label,
input:not(:placeholder-shown) + label {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.02em;
    top: 6px;
    transform: translateY(0);
}

input:focus,
input:not(:placeholder-shown) {
    padding-top: 21px;
    padding-bottom: 7px;
}

/* Champs pre-remplis par le navigateur (identifiants enregistres) : Chrome
   n'expose pas la valeur avant une interaction, donc :placeholder-shown reste
   vrai et le label chevauchait le texte. Regles separees : un selecteur non
   supporte invaliderait toute la liste. */
input:-webkit-autofill + label {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.02em;
    top: 6px;
    transform: translateY(0);
}

input:autofill + label {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.02em;
    top: 6px;
    transform: translateY(0);
}

input:-webkit-autofill {
    padding-top: 21px;
    padding-bottom: 7px;
}

input:autofill {
    padding-top: 21px;
    padding-bottom: 7px;
}

.input-wrapper.with-icon input {
    padding-left: 40px;
}

.input-wrapper.with-icon label {
    left: 40px;
}

.input-wrapper.password-field input {
    padding-right: 70px;
}

.password-toggle {
    position: absolute;
    right: 13px;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
    z-index: 3;
}

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

/* Checkbox + mot de passe oublié */
.options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--ink-muted);
}

input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
    padding: 0;
    width: 18px;
    height: 18px;
}

.checkbox-group label {
    position: static;
    transform: none;
    top: auto;
    left: auto;
    font-size: 12px;
    color: var(--ink-muted);
}

/* Lien mot de passe oublié */
.forgot-password a {
    font-size: 11px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.forgot-password a:hover {
    color: var(--accent-dark);
}

/* Boutons */
.btn-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

button {
    padding: 12px 20px;
    border: none;
    border-radius: 9px;
    font-family: 'Inter', inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--accent-dark);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.015);
    box-shadow: 0 0 0 1px var(--accent), 0 0 22px 2px rgba(44, 74, 124, 0.3);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: skewX(-18deg);
}

.btn-primary:hover::before {
    animation: shimmer 0.8s ease-in-out;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Etat de chargement du bouton de connexion */
.btn-primary.is-loading,
.btn-primary.is-loading:hover {
    cursor: progress;
    transform: none;
    opacity: 0.85;
}

.btn-primary.is-loading:hover::before {
    animation: none;
}

.btn-primary.is-loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 10px;
    vertical-align: -2px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: btnSpin 0.7s linear infinite;
}

/* Fondu de sortie avant la redirection */
body.page-exit {
    opacity: 0;
    transition: opacity 0.35s ease;
}

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

.btn-secondary {
    background: transparent;
    color: var(--ink-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-weight: 600;
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 14px 1px rgba(44, 74, 124, 0.2);
}

/* Ripple effect */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    pointer-events: none;
    animation: rippleExpand 0.6s ease-out forwards;
}

.ripple.secondary {
    background: rgba(44, 74, 124, 0.4);
}

@keyframes rippleExpand {
    0% {
        width: 10px;
        height: 10px;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        width: 10px;
        height: 10px;
        opacity: 0;
        transform: translate(-50%, -50%) scale(4.2);
    }
}

/* Texte légal */
.legal {
    font-size: 11px;
    color: var(--ink-muted);
    text-align: center;
    margin-top: 8px;
}

/* Frise étapes */
.steps-container {
    width: 547px;
    max-width: 94vw;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    position: relative;
    z-index: 2;
}

.steps-line {
    position: absolute;
    top: 5px;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.16);
    z-index: 0;
}

.steps-progress {
    position: absolute;
    top: 5px;
    left: 0;
    height: 1px;
    width: 12.5%;
    background: linear-gradient(90deg, transparent, var(--accent));
    box-shadow: 0 0 8px 1px rgba(44, 74, 124, 0.45);
    z-index: 0;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1), background 0.4s ease;
}

.steps-progress.signup {
    background: linear-gradient(90deg, transparent, var(--accent-alt));
    box-shadow: 0 0 8px 1px rgba(44, 74, 124, 0.35);
}

.step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1;
    cursor: pointer;
    transition: all 0.5s;
}

.step:hover .step-dot {
    background: rgba(255, 255, 255, 0.5);
}

.step:hover .step-label {
    color: rgba(255, 255, 255, 0.7);
}

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.9s;
}

.step.active .step-dot {
    width: 16px;
    height: 16px;
    background: var(--accent);
    box-shadow: 0 0 12px 3px rgba(44, 74, 124, 0.4);
}

.step.active.signup .step-dot {
    background: var(--accent-alt);
    box-shadow: 0 0 12px 3px rgba(44, 74, 124, 0.3);
}

.step-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.7s;
}

.step.active .step-label {
    color: var(--white);
    font-weight: 700;
}

/* En dessous de cette largeur, plus assez de place pour les deux colonnes :
   on masque le panneau de bienvenue et on retrouve l'ecran de connexion
   centre tel qu'il etait avant son ajout. */
@media (max-width: 960px) {
    .welcome-panel {
        display: none;
    }

    .auth-layout {
        justify-content: center;
    }

    .steps-align {
        justify-content: center;
    }
}

@media (max-width: 600px) {
    body {
        gap: 30px;
    }

    .card-wrapper {
        width: calc(100% - 20px);
    }

    .card {
        height: min(596px, 86vh);
    }

    .form-section {
        padding: 32px 24px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 22px;
    }

    .steps-container {
        width: calc(100% - 20px);
    }

    .step-label {
        font-size: 10px;
    }

    .bg-icons {
        width: 36px;
        height: 36px;
    }
}

/* Toasts d'alerte (SweetAlert2 reskinné) */
.grace-toast-popup {
    border-radius: 16px !important;
    padding: 12px 18px 12px 14px !important;
    box-shadow: 0 20px 45px -15px rgba(0,0,0,.35), 0 4px 14px rgba(0,0,0,.12) !important;
    border: 1px solid var(--border) !important;
}

.grace-toast-html {
    margin: 0 !important;
    padding: 0 !important;
}

.grace-toast-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.grace-toast-msg {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
    text-align: left;
    line-height: 1.4;
}

.grace-toast-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.grace-toast-badge svg {
    width: 15px;
    height: 15px;
}

.grace-toast-badge-success {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    box-shadow: 0 4px 12px -2px rgba(44, 74, 124, .5);
}

.grace-toast-badge-error {
    background: linear-gradient(135deg, #e8574a, #c0392b);
    box-shadow: 0 4px 12px -2px rgba(192, 57, 43, .4);
}

.grace-toast-progress-success {
    background: var(--accent) !important;
}

.grace-toast-progress-error {
    background: #c0392b !important;
}

@keyframes graceToastIn {
    from { opacity: 0; transform: translateX(24px) scale(.96); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes graceToastOut {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to { opacity: 0; transform: translateX(24px) scale(.96); }
}

.grace-toast-show {
    animation: graceToastIn .35s cubic-bezier(.4, 0, .2, 1) both;
}

.grace-toast-hide {
    animation: graceToastOut .25s ease-in both;
}
