/**
 * Cargo — pages d'authentification (connexion, mot de passe).
 * Utilise les variables de thème (--primary, --premium-navy-gradient, etc.).
 */

html[data-theme="blue_corporate"],
html[data-theme="blue_premium"],
html[data-theme="light_minimal"],
html[data-theme="emerald_business"] {
    --primary: var(--blue-500, #2563eb);
    --primary-dark: var(--blue-600, #1d4ed8);
    --primary-light: var(--blue-soft, #e8f2ff);
}

body.cargo-auth-page.login-page {
    min-height: 100vh;
    margin: 0;
    padding: 0;
    background: var(--premium-navy-gradient, linear-gradient(165deg, #071b3b 0%, #06142f 55%, #0f172a 100%));
    overflow-x: hidden;
}

body.cargo-auth-page .login-box,
body.cargo-auth-page .register-box {
    width: 100%;
    max-width: none;
    margin: 0;
}

body.cargo-auth-page .guest-preferences-bar {
    top: 1rem;
    right: 1rem;
}

body.cargo-auth-page .guest-preferences-bar .btn-outline-primary {
    color: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    font-weight: 600;
}

body.cargo-auth-page .guest-preferences-bar .btn-outline-primary:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.55);
    color: #fff;
}

html[dir="rtl"] body.cargo-auth-page .guest-preferences-bar {
    right: auto;
    left: 1rem;
}

.cargo-auth {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100vh;
    width: 100%;
}

@media (min-width: 992px) {
    .cargo-auth {
        grid-template-columns: minmax(320px, 1.05fr) minmax(360px, 0.95fr);
    }

    html[dir="rtl"] .cargo-auth {
        direction: rtl;
    }
}

/* ------------------------------------------------------------------ Brand panel */
.cargo-auth__brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2.5rem clamp(1.5rem, 4vw, 3.5rem);
    color: #111827;
    background: linear-gradient(165deg, #ffffff 0%, var(--surface-soft, #f4f8fc) 55%, #eef4fb 100%);
    border-right: 1px solid var(--border-soft, #e2e8f0);
    overflow: hidden;
}

.cargo-auth__brand::before,
.cargo-auth__brand::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.cargo-auth__brand::before {
    width: 420px;
    height: 420px;
    top: -120px;
    right: -80px;
    background: radial-gradient(circle, color-mix(in srgb, var(--primary, #2563eb) 12%, transparent) 0%, transparent 68%);
}

.cargo-auth__brand::after {
    width: 280px;
    height: 280px;
    bottom: -60px;
    left: -40px;
    background: radial-gradient(circle, color-mix(in srgb, var(--primary, #2563eb) 8%, transparent) 0%, transparent 70%);
}

.cargo-auth__brand-inner {
    position: relative;
    z-index: 1;
    max-width: 28rem;
}

.cargo-auth__logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.cargo-auth__logo-mark {
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--surface, #fff);
    border: 1px solid var(--border-soft, #d4e3f4);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.cargo-auth__logo-img {
    width: 36px;
    height: 36px;
    display: block;
}

.cargo-auth__logo-mark i {
    font-size: 1.5rem;
    color: #fff;
}

.cargo-auth__brand-name {
    font-size: clamp(1.35rem, 2.5vw, 1.65rem);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0;
    color: #111827;
}

.cargo-auth__brand-tagline {
    margin: 0.35rem 0 0;
    font-size: 0.95rem;
    font-weight: 800;
    color: #111827;
    letter-spacing: 0.02em;
    text-transform: none;
}

.cargo-auth__brand-lead {
    margin: 0 0 1.5rem;
    font-size: 1.05rem;
    line-height: 1.55;
    color: #111827;
    font-weight: 700;
}

.cargo-auth__features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cargo-auth__features li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.92rem;
    color: #111827;
    font-weight: 700;
}

.cargo-auth__features li span {
    color: #111827;
    font-weight: 700;
}

.cargo-auth__features i {
    flex: 0 0 2rem;
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    background: var(--primary-light, #e8f2ff);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary, #2563eb);
    font-size: 0.85rem;
}

.cargo-auth__company {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(17, 24, 39, 0.12);
    font-size: 0.8rem;
    color: #111827;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ------------------------------------------------------------------ Form panel */
.cargo-auth__main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem clamp(1.25rem, 3vw, 2.5rem);
    background: var(--surface-soft, #f4f8fc);
}

@media (min-width: 992px) {
    .cargo-auth__main {
        box-shadow: -12px 0 40px rgba(0, 0, 0, 0.08);
    }

    html[dir="rtl"] .cargo-auth__main {
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.08);
    }

    body.cargo-auth-page .guest-preferences-bar .btn-outline-primary {
        color: #111827;
        border-color: var(--border-soft, #d4e3f4);
        background: #fff;
    }

    body.cargo-auth-page .guest-preferences-bar .btn-outline-primary:hover {
        background: var(--primary-light, #e8f2ff);
        border-color: var(--primary, #2563eb);
        color: var(--primary-dark, #1e40af);
    }
}

.cargo-auth__card {
    width: 100%;
    max-width: 420px;
    background: var(--surface, #fff);
    border: 1px solid var(--border-soft, #d4e3f4);
    border-radius: 16px;
    box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(15, 23, 42, 0.12));
    padding: clamp(1.5rem, 3vw, 2rem);
}

.cargo-auth__card-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.cargo-auth__card-header h1 {
    margin: 0 0 0.35rem;
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text-main, #102033);
    letter-spacing: -0.02em;
}

.cargo-auth__card-header p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted, #64748b);
    line-height: 1.45;
}

.cargo-auth__mobile-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
}

@media (min-width: 992px) {
    .cargo-auth__mobile-brand {
        display: none;
    }
}

.cargo-auth__mobile-brand img {
    width: 32px;
    height: 32px;
}

.cargo-auth__mobile-brand span {
    font-weight: 800;
    font-size: 1rem;
    color: var(--text-main, #102033);
}

.cargo-auth-field {
    margin-bottom: 1.1rem;
}

.cargo-auth-field label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted, #64748b);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.cargo-auth-input {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0 0.85rem;
    min-height: 46px;
    border: 1px solid var(--border-soft, #d4e3f4);
    border-radius: 10px;
    background: var(--surface-soft, #f8fafc);
    transition: border-color var(--transition-fast, 150ms ease), box-shadow var(--transition-fast, 150ms ease);
}

.cargo-auth-input:focus-within {
    border-color: var(--primary, #2563eb);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary, #2563eb) 18%, transparent);
    background: var(--surface, #fff);
}

.cargo-auth-input i {
    color: var(--text-muted, #94a3b8);
    font-size: 0.9rem;
    width: 1rem;
    text-align: center;
}

.cargo-auth-input .form-control {
    border: 0;
    background: transparent;
    padding: 0.65rem 0;
    height: auto;
    font-size: 0.95rem;
    color: var(--text-main, #102033);
    box-shadow: none !important;
}

.cargo-auth-input .form-control::placeholder {
    color: var(--text-muted, #94a3b8);
    opacity: 0.85;
}

.cargo-auth-input .form-control.is-invalid {
    color: var(--danger, #ef4444);
}

.cargo-auth-field .invalid-feedback {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.82rem;
}

.cargo-auth-remember {
    margin-bottom: 1.25rem;
}

.cargo-auth-remember .custom-control-label {
    font-size: 0.88rem;
    color: var(--text-muted, #64748b);
    cursor: pointer;
}

.cargo-auth-submit {
    width: 100%;
    min-height: 46px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    background: var(--premium-gradient, linear-gradient(135deg, var(--primary, #2563eb), #0ea5e9));
    border: none;
    color: #fff;
    box-shadow: 0 4px 14px color-mix(in srgb, var(--primary, #2563eb) 35%, transparent);
    transition: transform var(--transition-fast, 150ms ease), box-shadow var(--transition-fast, 150ms ease);
}

.cargo-auth-submit:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px color-mix(in srgb, var(--primary, #2563eb) 42%, transparent);
}

.cargo-auth-submit:focus {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary, #2563eb) 25%, transparent);
}

.cargo-auth-links {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.88rem;
}

.cargo-auth-links a {
    color: var(--primary, #2563eb);
    font-weight: 600;
    text-decoration: none;
}

.cargo-auth-links a:hover {
    text-decoration: underline;
    color: var(--primary-dark, #1e40af);
}

.cargo-auth__footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted, #94a3b8);
}

.cargo-auth-flash {
    position: fixed;
    top: 4.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1060;
    width: min(420px, calc(100vw - 2rem));
    pointer-events: none;
}

.cargo-auth-flash .alert {
    pointer-events: auto;
}

body.cargo-auth-page .alert {
    border-radius: 10px;
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

@media (max-width: 991.98px) {
    .cargo-auth__brand {
        display: none;
    }

    body.cargo-auth-page.login-page {
        background: var(--surface-soft, #f4f8fc);
    }

    body.cargo-auth-page .guest-preferences-bar .btn-outline-primary {
        color: var(--primary, #2563eb);
        border-color: var(--border-soft, #d4e3f4);
        background: var(--surface, #fff);
    }
}

/* ------------------------------------------------------------------ RTL (arabe) */
html[dir="rtl"] body.cargo-auth-page .guest-preferences-bar {
    right: auto;
    left: 1rem;
}

html[dir="rtl"] .cargo-auth__logo {
    flex-direction: row-reverse;
}

html[dir="rtl"] .cargo-auth__features li {
    flex-direction: row-reverse;
    text-align: right;
}

html[dir="rtl"] .cargo-auth-input {
    flex-direction: row-reverse;
}

html[dir="rtl"] .cargo-auth__card-header,
html[dir="rtl"] .cargo-auth-links {
    text-align: right;
}

html[dir="rtl"] .cargo-auth-remember .custom-control {
    padding-right: 1.75rem;
    padding-left: 0;
}

html[dir="rtl"] .cargo-auth-remember .custom-control-label::before,
html[dir="rtl"] .cargo-auth-remember .custom-control-label::after {
    right: 0;
    left: auto;
}

@media (min-width: 992px) {
    html[dir="rtl"] .cargo-auth {
        direction: rtl;
    }

    html[dir="rtl"] .cargo-auth__main {
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.08);
    }

    html[dir="rtl"] .cargo-auth__brand {
        border-right: 0;
        border-left: 1px solid var(--border-soft, #e2e8f0);
    }
}

html[dir="rtl"] .guest-preferences-bar .dropdown-menu-right {
    right: auto;
    left: 0;
}

@media print {
    .cargo-auth__brand,
    .guest-preferences-bar {
        display: none !important;
    }
}
