: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);
    --auth-pad: clamp(1rem, 2.5vw, 2rem);
    --auth-gap: clamp(0.5rem, 1.5vw, 1rem);
}

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

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

body.auth-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.45;
    animation: orbFloat 14s ease-in-out infinite;
}

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

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

.orb-c {
    width: 140px;
    height: 140px;
    background: rgba(0, 168, 81, 0.22);
    top: 55%;
    left: 45%;
    animation-delay: -8s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(18px, -22px) scale(1.08); }
}

.auth-container {
    position: relative;
    z-index: 1;
    background: white;
    border-radius: clamp(12px, 2vw, 20px);
    box-shadow: var(--shadow-lg);
    width: min(100%, 920px);
    overflow: hidden;
    display: flex;
    flex-wrap: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.8);
    animation: authFadeIn 0.55s ease-out;
}

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

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

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

.auth-left {
    flex: 1 1 48%;
    min-width: 0;
    background:
        linear-gradient(145deg, rgba(6, 171, 226, 0.18) 0%, transparent 42%),
        linear-gradient(160deg, #044c95 0%, #033a73 55%, #022a54 100%);
    color: white;
    padding: var(--auth-pad);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.auth-left::before {
    content: '';
    position: absolute;
    width: clamp(140px, 30vw, 280px);
    height: clamp(140px, 30vw, 280px);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    top: -80px;
    right: -60px;
    animation: softPulse 6s ease-in-out infinite;
}

.auth-left::after {
    content: '';
    position: absolute;
    width: clamp(100px, 20vw, 180px);
    height: clamp(100px, 20vw, 180px);
    border-radius: 50%;
    background: rgba(6, 171, 226, 0.18);
    bottom: -40px;
    left: -30px;
}

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

.auth-left > * {
    position: relative;
    z-index: 1;
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: var(--auth-gap);
    flex-wrap: wrap;
}

.logo-text {
    font-weight: 700;
    font-size: clamp(1.25rem, 2.5vw, 1.625rem);
    letter-spacing: -0.02em;
    line-height: 1;
    color: #ffffff;
}

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

.auth-left-title,
.auth-left h2 {
    font-size: clamp(1rem, 2vw, 1.2rem);
    font-weight: 600;
    margin: 0 0 0.4rem;
    line-height: 1.35;
}

.tagline,
.auth-left .tagline {
    font-size: clamp(0.75rem, 1.5vw, 0.875rem);
    opacity: 0.88;
    margin: 0 0 clamp(0.75rem, 2vw, 1.15rem);
    line-height: 1.5;
    max-width: 100%;
}

.feature-list {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
}

.feature-list li {
    display: flex;
    align-items: center;
    margin-bottom: 0.55rem;
    font-size: clamp(0.75rem, 1.4vw, 0.875rem);
    opacity: 0.95;
}

.feature-list li:last-child {
    margin-bottom: 0;
}

.feature-list i {
    margin-right: 0.65rem;
    color: white;
    background: rgba(255, 255, 255, 0.15);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.auth-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 1rem;
}

.auth-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.6rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    font-size: 0.7rem;
    font-weight: 500;
}

.auth-right {
    flex: 1 1 52%;
    min-width: 0;
    padding: var(--auth-pad);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-header {
    text-align: left;
    margin-bottom: clamp(0.85rem, 2vw, 1.15rem);
}

.auth-header .welcome {
    font-size: clamp(1.1rem, 2.2vw, 1.25rem);
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 0.3rem;
}

.auth-header .welcome-sub {
    font-size: clamp(0.75rem, 1.5vw, 0.875rem);
    color: var(--text-muted);
    margin: 0;
}

.auth-tabs {
    display: flex;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-color);
}

.auth-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.auth-tab.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

.form-group {
    margin-bottom: clamp(0.7rem, 1.5vw, 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;
    transition: transform 0.2s ease;
}

.input-wrapper.is-focused {
    transform: translateY(-1px);
}

.input-wrapper.is-focused .input-icon {
    color: var(--accent-cyan);
}

.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 {
    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);
}

.btn-auth {
    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.35rem;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 46px;
}

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

.btn-auth:active {
    transform: translateY(0);
}

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

.btn-auth .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-auth.is-loading .btn-label {
    opacity: 0.85;
}

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

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

.additional-links {
    text-align: center;
    margin-top: clamp(0.85rem, 2vw, 1.1rem);
    font-size: 0.8125rem;
}

.additional-links a,
.forgot-link {
    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;
}

.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;
    justify-content: center;
    transition: color 0.2s;
}

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

.password-container {
    position: relative;
}

.auth-content {
    display: none;
}

.auth-content.active {
    display: block;
    animation: contentIn 0.35s ease;
}

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

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.form-row .form-group {
    flex: 1 1 140px;
    min-width: 0;
}

@media (max-width: 900px) {
    .auth-container { width: min(100%, 720px); }
    .auth-left { flex: 1 1 42%; }
    .auth-right { flex: 1 1 58%; }
}

@media (max-width: 768px) {
    body.auth-body {
        align-items: flex-start;
        justify-content: center;
        padding: 0.75rem;
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
        overflow-y: auto;
    }
    .auth-container {
        flex-direction: column;
        width: min(100%, 440px);
        margin: auto;
        overflow: visible;
    }
    .auth-left,
    .auth-right {
        flex: 1 1 auto;
        width: 100%;
    }
    .auth-left {
        padding: 1.1rem 1.25rem;
        align-items: center;
        text-align: center;
    }
    .auth-left::before,
    .auth-left::after {
        display: none;
    }
    .brand-mark {
        justify-content: center;
        margin-bottom: 0.35rem;
    }
    .auth-left-title,
    .auth-left h2 {
        display: block;
        font-size: 0.85rem;
        margin-bottom: 0;
        opacity: 0.95;
    }
    .tagline,
    .auth-left .tagline,
    .feature-list,
    .auth-chips {
        display: none;
    }
    .auth-right {
        padding: 1.25rem 1.25rem 1.4rem;
    }
    .auth-header {
        text-align: center;
    }
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .form-row .form-group {
        flex: 1 1 100%;
    }
}

@media (max-width: 380px) {
    body.auth-body { padding: 0.5rem; }
    .auth-left,
    .auth-right { padding: 1rem; }
    .logo-text { font-size: 1.15rem; }
    .logo-fne { font-size: 0.95rem; }
    .form-input { font-size: 16px; }
}

@media (max-height: 640px) and (min-width: 769px) {
    body.auth-body {
        align-items: flex-start;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
        overflow-y: auto;
    }
    .auth-left,
    .auth-right { padding: 1.15rem 1.5rem; }
    .feature-list li { margin-bottom: 0.35rem; }
    .auth-header { margin-bottom: 0.75rem; }
    .form-group { margin-bottom: 0.65rem; }
}

@media (max-height: 520px) {
    .feature-list,
    .auth-chips { display: none; }
    .tagline,
    .auth-left .tagline { margin-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-container,
    .auth-content.active,
    .btn-auth,
    .auth-anim,
    .auth-ambient .orb,
    .auth-left::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;
}
