/**
 * Alaola — Auth pages (login / verification / forgot-password)
 *
 * Brand identity inspired by the three-color logo:
 *   - Vibrant Green   #2E8B57  (growth, life)
 *   - Royal Blue      #3B7DD8  (trust, motion)
 *   - Deep Navy       #1E4976  (depth, stability)
 *
 * Layout: editorial split-screen on desktop with a hero brand panel and
 * a refined form card. Stacked on mobile. Inspired by world-class SaaS
 * onboarding (Stripe, Linear, Vercel) — calm, confident, premium.
 */

:root {
    /* Brand palette — extracted from the logo */
    --brand-green: #2E8B57;
    --brand-green-soft: #3FA56C;
    --brand-blue: #3B7DD8;
    --brand-blue-soft: #5B95E0;
    --brand-navy: #1E4976;
    --brand-navy-deep: #14304F;

    /* Auth tokens */
    --auth-accent: var(--brand-blue);
    --auth-accent-dark: var(--brand-navy);
    --auth-accent-soft: rgba(59, 125, 216, 0.10);
    --auth-accent-ring: rgba(59, 125, 216, 0.18);
    --auth-success: var(--brand-green);
    --auth-success-soft: rgba(46, 139, 87, 0.10);

    --auth-text: #0F1F35;
    --auth-text-muted: #5A6B82;
    --auth-text-faint: #92A1B6;
    --auth-border: #E4E9F0;
    --auth-border-strong: #D4DCE6;
    --auth-bg: #F4F6FA;
    --auth-card-bg: #ffffff;
    --auth-radius: 18px;
    --auth-radius-sm: 12px;
    --auth-shadow-sm: 0 1px 2px rgba(15, 31, 53, 0.04);
    --auth-shadow: 0 24px 60px -12px rgba(20, 48, 79, 0.18), 0 8px 24px -8px rgba(20, 48, 79, 0.10);
    --auth-shadow-soft: 0 1px 3px rgba(15, 31, 53, 0.06);
    --auth-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body.auth-page {
    margin: 0;
    background: var(--auth-bg);
    color: var(--auth-text);
    font-family: 'Cairo', 'Nunito', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* =============== Layout =============== */
.auth-shell {
    width: 100%;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    background: var(--auth-bg);
    position: relative;
}

@media (max-width: 991px) {
    .auth-shell { grid-template-columns: 1fr; }
}

/* =============== Brand panel — hero =============== */
.auth-brand {
    position: relative;
    overflow: hidden;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3.25rem 3rem;
    isolation: isolate;
    background:
        radial-gradient(120% 80% at 0% 0%, rgba(46, 139, 87, 0.55) 0%, rgba(46, 139, 87, 0) 55%),
        radial-gradient(110% 80% at 100% 100%, rgba(59, 125, 216, 0.55) 0%, rgba(59, 125, 216, 0) 60%),
        linear-gradient(140deg, var(--brand-navy-deep) 0%, var(--brand-navy) 50%, #0F2540 100%);
}

[dir="rtl"] .auth-brand {
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(46, 139, 87, 0.55) 0%, rgba(46, 139, 87, 0) 55%),
        radial-gradient(110% 80% at 0% 100%, rgba(59, 125, 216, 0.55) 0%, rgba(59, 125, 216, 0) 60%),
        linear-gradient(220deg, var(--brand-navy-deep) 0%, var(--brand-navy) 50%, #0F2540 100%);
}

@media (max-width: 991px) {
    .auth-brand {
        padding: 2.25rem 1.75rem;
        min-height: 220px;
    }
}

/* Subtle grid pattern overlay */
.auth-brand::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse 90% 60% at 50% 50%, #000 30%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 50%, #000 30%, transparent 80%);
    pointer-events: none;
    z-index: -1;
}

/* Floating accent orbs in brand colors */
.auth-brand::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background:
        radial-gradient(circle at 12% 88%, rgba(46, 139, 87, 0.35) 0%, transparent 22%),
        radial-gradient(circle at 88% 18%, rgba(91, 149, 224, 0.32) 0%, transparent 24%),
        radial-gradient(circle at 78% 72%, rgba(59, 125, 216, 0.22) 0%, transparent 28%);
    filter: blur(2px);
}

/* Brand logo cluster */
.auth-brand__logo {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.auth-brand__logo img {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    /* Glass tile — soft top-to-bottom gradient instead of flat white */
    background:
        linear-gradient(180deg, #FFFFFF 0%, #F0F4FA 100%);
    padding: 8px;
    object-fit: contain;
    /* Layered finish: top sheen, bottom depth, crisp ring,
       soft white halo, brand-tinted glow, and lift shadow */
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 1),
        inset 0 -1px 2px rgba(15, 31, 53, 0.08),
        0 0 0 1px rgba(255, 255, 255, 0.65),
        0 0 0 5px rgba(255, 255, 255, 0.06),
        0 6px 18px -4px rgba(46, 139, 87, 0.22),
        0 8px 20px -6px rgba(59, 125, 216, 0.28),
        0 14px 32px -8px rgba(0, 0, 0, 0.45),
        0 4px 10px -2px rgba(0, 0, 0, 0.25);
    transition: transform 320ms var(--auth-ease),
                box-shadow 320ms var(--auth-ease);
}

.auth-brand__logo:hover img {
    transform: translateY(-1px) scale(1.02);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 1),
        inset 0 -1px 2px rgba(15, 31, 53, 0.08),
        0 0 0 1px rgba(255, 255, 255, 0.75),
        0 0 0 7px rgba(255, 255, 255, 0.08),
        0 8px 22px -4px rgba(46, 139, 87, 0.30),
        0 10px 24px -6px rgba(59, 125, 216, 0.36),
        0 18px 38px -8px rgba(0, 0, 0, 0.50),
        0 6px 14px -2px rgba(0, 0, 0, 0.30);
}

.auth-brand__logo-text {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.015em;
    background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0.78) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Hero copy */
.auth-brand__hero {
    position: relative;
    z-index: 2;
    margin-block: auto;
    padding-block: 2rem;
    max-width: 480px;
}

.auth-brand__hero h2 {
    font-size: clamp(1.85rem, 2.4vw, 2.35rem);
    font-weight: 800;
    line-height: 1.2;
    margin: 0 0 1rem;
    letter-spacing: -0.025em;
    color: #ffffff;
}

.auth-brand__hero p {
    font-size: 1.02rem;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.78);
    margin: 0 0 1.85rem;
    font-weight: 400;
}

.auth-brand__features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.85rem;
}

.auth-brand__features li {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.92);
    font-weight: 500;
}

.auth-brand__features li i {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.92rem;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Each feature gets one of the three brand colors */
.auth-brand__features li:nth-child(1) i {
    color: #7BD9A6;
    background: rgba(46, 139, 87, 0.22);
    border-color: rgba(123, 217, 166, 0.28);
}
.auth-brand__features li:nth-child(2) i {
    color: #A8C8F0;
    background: rgba(59, 125, 216, 0.22);
    border-color: rgba(168, 200, 240, 0.28);
}
.auth-brand__features li:nth-child(3) i {
    color: #C8D9F0;
    background: rgba(30, 73, 118, 0.45);
    border-color: rgba(200, 217, 240, 0.22);
}

.auth-brand__footer {
    position: relative;
    z-index: 2;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.01em;
}

@media (max-width: 991px) {
    .auth-brand__hero,
    .auth-brand__footer { display: none; }
}

/* =============== Form panel =============== */
.auth-form-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    overflow-y: auto;
    background: var(--auth-bg);
    position: relative;
}

/* Soft brand wash on form side */
.auth-form-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(60% 40% at 100% 0%, rgba(59, 125, 216, 0.06) 0%, transparent 60%),
        radial-gradient(50% 35% at 0% 100%, rgba(46, 139, 87, 0.06) 0%, transparent 60%);
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 460px;
    background: var(--auth-card-bg);
    border-radius: var(--auth-radius);
    padding: 2.5rem;
    box-shadow: var(--auth-shadow);
    border: 1px solid var(--auth-border);
}

/* Top accent bar — three brand colors */
.auth-card::before {
    content: '';
    position: absolute;
    inset-inline: 24px;
    top: 0;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: linear-gradient(90deg,
        var(--brand-green) 0%,
        var(--brand-blue) 50%,
        var(--brand-navy) 100%);
    opacity: 0.9;
}

@media (max-width: 575px) {
    .auth-card {
        padding: 1.85rem 1.35rem;
        box-shadow: var(--auth-shadow-soft);
        border-radius: 16px;
    }
}

.auth-card__head {
    margin-bottom: 1.85rem;
    text-align: start;
}

.auth-card__title {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--auth-text);
    margin: 0 0 0.45rem;
    letter-spacing: -0.025em;
    line-height: 1.25;
}

.auth-card__subtitle {
    font-size: 0.95rem;
    color: var(--auth-text-muted);
    margin: 0;
    line-height: 1.55;
    font-weight: 400;
}

/* =============== Tabs (email / phone) =============== */
.auth-tabs {
    display: flex;
    gap: 0.3rem;
    background: #F1F4F9;
    padding: 0.32rem;
    border-radius: 12px;
    margin-bottom: 1.6rem;
    border: 1px solid var(--auth-border);
    list-style: none;
}

.auth-tabs .nav-item { flex: 1; }

.auth-tabs .nav-link {
    width: 100%;
    text-align: center;
    padding: 0.6rem 0.85rem;
    border: none;
    border-radius: 9px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--auth-text-muted);
    background: transparent;
    transition: all 220ms var(--auth-ease);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.auth-tabs .nav-link i {
    font-size: 0.85rem;
    transition: transform 220ms var(--auth-ease);
}

.auth-tabs .nav-link:hover {
    color: var(--auth-text);
}

.auth-tabs .nav-link.active {
    background: #fff;
    color: var(--brand-navy);
    box-shadow: 0 1px 3px rgba(20, 48, 79, 0.10), 0 0 0 1px rgba(20, 48, 79, 0.04);
    font-weight: 700;
}

.auth-tabs .nav-link.active i {
    color: var(--brand-blue);
    transform: scale(1.06);
}

/* =============== Form fields =============== */
.auth-form .form-group {
    margin-bottom: 1.15rem;
}

.auth-form label {
    display: block;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--auth-text);
    margin-bottom: 0.45rem;
    letter-spacing: 0.005em;
}

.auth-form label .required {
    color: #E5484D;
    margin-inline-start: 2px;
}

.auth-form .form-control {
    width: 100%;
    padding: 0.78rem 1rem;
    font-size: 0.95rem;
    color: var(--auth-text);
    background: #fff;
    border: 1.5px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    transition: border-color 180ms var(--auth-ease),
                box-shadow 180ms var(--auth-ease),
                background 180ms var(--auth-ease);
    font-family: inherit;
}

.auth-form .form-control::placeholder {
    color: var(--auth-text-faint);
    opacity: 1;
}

.auth-form .form-control:hover:not(:focus) {
    border-color: var(--auth-border-strong);
}

.auth-form .form-control:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 4px var(--auth-accent-ring);
    background: #fff;
}

.auth-form .form-control.is-invalid {
    border-color: #E5484D;
    background: #FEF2F2;
}

.auth-form .form-control.is-invalid:focus {
    box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.15);
}

.auth-form .invalid-feedback {
    display: block;
    color: #B42318;
    font-size: 0.82rem;
    margin-top: 0.4rem;
    font-weight: 500;
}

/* Password input + toggle */
.auth-input-wrap { position: relative; }

.auth-input-wrap .password-toggle {
    position: absolute;
    inset-inline-end: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--auth-text-faint);
    cursor: pointer;
    padding: 0.45rem;
    font-size: 0.95rem;
    border-radius: 8px;
    transition: color 160ms var(--auth-ease),
                background 160ms var(--auth-ease);
}

.auth-input-wrap .password-toggle:hover {
    color: var(--brand-blue);
    background: var(--auth-accent-soft);
}

.auth-input-wrap input[type="password"],
.auth-input-wrap input[type="text"] {
    padding-inline-end: 2.7rem;
}

/* =============== Inline row (remember + forgot) =============== */
.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.4rem;
}

.auth-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.88rem;
    color: var(--auth-text);
    cursor: pointer;
    margin: 0;
    font-weight: 500;
    user-select: none;
}

.auth-checkbox input {
    width: 17px;
    height: 17px;
    accent-color: var(--brand-blue);
    cursor: pointer;
    margin: 0;
}

.auth-link {
    font-size: 0.88rem;
    color: var(--brand-blue);
    text-decoration: none;
    font-weight: 600;
    transition: color 160ms var(--auth-ease);
    position: relative;
}

.auth-link::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    bottom: -2px;
    height: 1.5px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: start;
    transition: transform 220ms var(--auth-ease);
}

.auth-link:hover {
    color: var(--brand-navy);
    text-decoration: none;
}

.auth-link:hover::after { transform: scaleX(1); }

/* =============== Submit button =============== */
.auth-form .btn-auth {
    width: 100%;
    padding: 0.95rem 1.1rem;
    font-size: 0.97rem;
    font-weight: 700;
    border-radius: var(--auth-radius-sm);
    background: linear-gradient(135deg,
        var(--brand-blue) 0%,
        var(--brand-navy) 100%);
    border: none;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 20px -6px rgba(30, 73, 118, 0.45),
                0 2px 4px rgba(20, 48, 79, 0.12),
                inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition: transform 200ms var(--auth-ease),
                box-shadow 200ms var(--auth-ease),
                filter 200ms var(--auth-ease);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

/* Animated shine sweep */
.auth-form .btn-auth::before {
    content: '';
    position: absolute;
    inset-block: 0;
    inset-inline-start: -120%;
    width: 60%;
    background: linear-gradient(110deg,
        transparent 30%,
        rgba(255, 255, 255, 0.18) 50%,
        transparent 70%);
    transform: skewX(-20deg);
    transition: inset-inline-start 700ms var(--auth-ease);
}

.auth-form .btn-auth:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px -6px rgba(30, 73, 118, 0.55),
                0 4px 8px rgba(20, 48, 79, 0.16),
                inset 0 1px 0 rgba(255, 255, 255, 0.20);
    color: #fff;
    filter: brightness(1.04);
}

.auth-form .btn-auth:hover::before {
    inset-inline-start: 130%;
}

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

.auth-form .btn-auth:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
    filter: grayscale(0.2);
}

/* =============== Alerts =============== */
.auth-alert {
    padding: 0.9rem 1.05rem;
    border-radius: var(--auth-radius-sm);
    font-size: 0.88rem;
    margin-bottom: 1.3rem;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    line-height: 1.5;
    font-weight: 500;
    border: 1px solid transparent;
}

.auth-alert i {
    flex-shrink: 0;
    margin-top: 0.15rem;
    font-size: 1rem;
}

.auth-alert--success {
    background: var(--auth-success-soft);
    color: #14532D;
    border-color: rgba(46, 139, 87, 0.25);
}

.auth-alert--success i { color: var(--brand-green); }

.auth-alert--error {
    background: #FEF2F2;
    color: #991B1B;
    border-color: #FECACA;
}

.auth-alert--info {
    background: var(--auth-accent-soft);
    color: var(--brand-navy);
    border-color: rgba(59, 125, 216, 0.22);
}

.auth-alert--info i { color: var(--brand-blue); }

/* =============== Demo block =============== */
.auth-demo {
    margin-top: 1.6rem;
    padding: 1.05rem 1.15rem;
    background: linear-gradient(180deg, #F8FAFC 0%, #F1F4F9 100%);
    border-radius: var(--auth-radius-sm);
    border: 1px dashed var(--auth-border-strong);
}

.auth-demo h6 {
    font-size: 0.78rem;
    margin: 0 0 0.7rem;
    color: var(--auth-text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.auth-demo h6 i { color: var(--brand-green); }

.auth-demo .auth-demo-buttons {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.auth-demo .btn-demo {
    flex: 1 1 auto;
    padding: 0.5rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 9px;
    border: 1px solid var(--auth-border);
    background: #fff;
    color: var(--auth-text);
    cursor: pointer;
    transition: all 180ms var(--auth-ease);
    font-family: inherit;
}

.auth-demo .btn-demo:hover {
    border-color: var(--brand-blue);
    color: var(--brand-blue);
    background: var(--auth-accent-soft);
    transform: translateY(-1px);
    box-shadow: var(--auth-shadow-sm);
}

/* =============== OTP input =============== */
.auth-otp {
    text-align: center;
    font-size: 1.6rem;
    letter-spacing: 0.6rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
}

/* =============== Footer / bottom links =============== */
.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--auth-text-muted);
}

.auth-footer a {
    color: var(--brand-blue);
    font-weight: 600;
    text-decoration: none;
}

.auth-footer a:hover { text-decoration: underline; }

/* =============== intl-tel-input compat =============== */
.auth-form .iti { width: 100%; }

.auth-form .iti input.form-control {
    padding-inline-start: 92px !important;
}

[dir="rtl"] .auth-form .iti input.form-control {
    padding-inline-start: 1rem !important;
    padding-inline-end: 92px !important;
}

.auth-form .iti__selected-flag {
    border-radius: var(--auth-radius-sm) 0 0 var(--auth-radius-sm);
    background: #F4F6FA;
    border-inline-end: 1.5px solid var(--auth-border);
}

[dir="rtl"] .auth-form .iti__selected-flag {
    border-radius: 0 var(--auth-radius-sm) var(--auth-radius-sm) 0;
    border-inline-end: none;
    border-inline-start: 1.5px solid var(--auth-border);
}

/* =============== Entrance animation =============== */
@keyframes authFadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-card {
    animation: authFadeUp 520ms var(--auth-ease) both;
}

.auth-brand__hero {
    animation: authFadeUp 720ms var(--auth-ease) 80ms both;
}

@media (prefers-reduced-motion: reduce) {
    .auth-card,
    .auth-brand__hero {
        animation: none;
    }
    .auth-form .btn-auth,
    .auth-form .form-control,
    .auth-link::after {
        transition: none;
    }
}

/* =============== Dark mode (opt-in via .auth-supports-dark) =============== */
@media (prefers-color-scheme: dark) {
    body.auth-page.auth-supports-dark {
        background: #0A1628;
    }
    .auth-supports-dark .auth-form-wrap {
        background: #0A1628;
    }
    .auth-supports-dark .auth-card {
        background: #122236;
        border-color: #1E3552;
    }
    .auth-supports-dark .auth-card__title { color: #F1F5F9; }
    .auth-supports-dark .auth-card__subtitle { color: #94A3B8; }
    .auth-supports-dark .auth-form label { color: #E2E8F0; }
    .auth-supports-dark .auth-form .form-control {
        background: #0F1E33;
        border-color: #1E3552;
        color: #F1F5F9;
    }
    .auth-supports-dark .auth-form .form-control:focus {
        border-color: var(--brand-blue);
    }
    .auth-supports-dark .auth-tabs {
        background: #0F1E33;
        border-color: #1E3552;
    }
    .auth-supports-dark .auth-tabs .nav-link.active {
        background: #122236;
        color: #fff;
    }
    .auth-supports-dark .auth-demo {
        background: #0F1E33;
        border-color: #1E3552;
    }
    .auth-supports-dark .auth-demo .btn-demo {
        background: #122236;
        border-color: #1E3552;
        color: #E2E8F0;
    }
}
