/* ==========================================================================
   auth.css — professional bilingual auth screens (login / register / reset)
   Brand: deep trust-purple (#200b3f) + gold (#ffcd7c). Font: Tajawal (AR+EN).
   Scoped under .auth-* so it never collides with Bootstrap or style.css.
   Logical properties (inset-inline / padding-inline) keep it correct in RTL.
   ========================================================================== */

html, body { margin: 0; padding: 0; }

.auth-shell {
    --ink: #200b3f;
    --ink-2: #150729;
    --gold: #ffcd7c;
    --gold-2: #e0a45c;
    --surface: #ffffff;
    --ground: #f4f1f8;      /* purple-biased neutral, not a flat grey */
    --text: #241a33;
    --muted: #7b7288;
    --border: #e6e1ee;
    --danger: #ef4444;
    --success: #10b981;

    min-height: 100vh;
    display: flex;
    background: var(--ground);
    color: var(--text);
    font-family: 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Brand panel ---------- */
.auth-brand {
    flex: 1 1 46%;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(2.5rem, 5vw, 4.5rem);
    color: #fff;
    background:
        radial-gradient(120% 80% at 15% 0%, rgba(255,205,124,.16) 0%, transparent 45%),
        linear-gradient(160deg, var(--ink) 0%, var(--ink-2) 100%);
}
/* faint accounting-ledger rules */
.auth-brand::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(0deg, transparent 0 39px, rgba(255,255,255,.045) 39px 40px);
    pointer-events: none;
}
/* oversized summation glyph — a quiet nod to the ledger */
.auth-brand-glyph {
    position: absolute;
    inset-block-end: -6%;
    inset-inline-end: -3%;
    font-size: clamp(14rem, 26vw, 26rem);
    line-height: 1;
    font-weight: 800;
    color: rgba(255,205,124,.07);
    pointer-events: none;
    user-select: none;
}
.auth-brand > * { position: relative; z-index: 1; }

.auth-logo { display: flex; align-items: center; gap: .75rem; font-weight: 800; font-size: 1.4rem; }
.auth-logo-mark {
    width: 2.9rem; height: 2.9rem; border-radius: .85rem;
    display: grid; place-items: center; font-size: 1.4rem; color: var(--ink);
    background: linear-gradient(140deg, var(--gold), var(--gold-2));
    box-shadow: 0 8px 24px -8px rgba(255,205,124,.6);
}
.auth-brand-body { max-width: 30ch; }
.auth-brand-eyebrow {
    display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .12em;
    text-transform: uppercase; color: var(--gold); margin-bottom: 1rem;
}
.auth-brand-title {
    font-size: clamp(1.9rem, 3.4vw, 2.9rem); font-weight: 800; line-height: 1.15;
    text-wrap: balance; margin: 0 0 1rem;
}
.auth-brand-sub { color: rgba(255,255,255,.72); font-size: 1.05rem; line-height: 1.7; margin: 0; }

.auth-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.auth-points li { display: flex; align-items: center; gap: .8rem; color: rgba(255,255,255,.9); font-weight: 500; }
.auth-points .bi {
    flex-shrink: 0; width: 1.9rem; height: 1.9rem; border-radius: .55rem;
    display: grid; place-items: center; font-size: 1rem;
    color: var(--gold); background: rgba(255,205,124,.12);
}

/* ---------- Form side ---------- */
.auth-form-wrap {
    flex: 1 1 54%;
    display: flex; align-items: flex-start; justify-content: center;
    overflow-y: auto;                                  /* tall forms scroll instead of clipping */
    padding: clamp(2rem, 6vh, 4rem) clamp(1.5rem, 4vw, 3rem);
}
/* The card sits toward the top (align-items:flex-start on the wrap), so short
   forms (login / forgot password) don't float in the middle leaving a big top
   gap; tall forms flow down and scroll (overflow-y on the wrap). A little top
   breathing room keeps it from sticking to the edge. */
.auth-card { width: 100%; max-width: 430px; margin-top: clamp(0.5rem, 4vh, 3rem); }

.auth-mobile-logo { display: none; align-items: center; justify-content: center; gap: .6rem; margin-bottom: 1.5rem; font-weight: 800; font-size: 1.3rem; color: var(--ink); }
.auth-mobile-logo .auth-logo-mark { width: 2.4rem; height: 2.4rem; font-size: 1.2rem; }

.auth-head { margin-bottom: 2rem; }
.auth-title { font-size: 1.8rem; font-weight: 800; margin: 0 0 .4rem; letter-spacing: -.01em; }
.auth-subtitle { color: var(--muted); margin: 0; font-size: 1rem; }

.auth-form { display: flex; flex-direction: column; gap: 1.15rem; }
.auth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.auth-field { display: flex; flex-direction: column; gap: .4rem; }
.auth-label { font-size: .9rem; font-weight: 700; color: var(--text); }

.auth-input-wrap { position: relative; display: flex; align-items: center; }
.auth-input-wrap > .bi:first-child {
    position: absolute; inset-inline-start: 1rem; color: var(--muted); font-size: 1.05rem; pointer-events: none;
}
.auth-input, .auth-select {
    width: 100%; font: inherit; font-size: 1rem; color: var(--text);
    background: var(--surface); border: 1.5px solid var(--border); border-radius: .8rem;
    /* Logical padding: the icon is placed with inset-inline-start, so the room for
       it must follow the direction too. The old physical left padding left the
       icon sitting on top of the text on the Arabic (RTL) screens. */
    padding: .85rem 1rem;
    padding-inline-start: 2.9rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
/* Browsers force email/phone inputs to left-to-right even on an Arabic page, while the
   icon still sits at the wrapper's start (the right edge) — reserve the room there. */
[dir="rtl"] .auth-input:is([type="email"], [type="tel"], [type="url"], [type="number"], [dir="ltr"]) {
    padding-left: 1rem; padding-right: 2.9rem;
}
.auth-select { padding-inline-start: 2.9rem; appearance: none; cursor: pointer; }
.auth-input::placeholder { color: #b3aac2; }
.auth-input:focus, .auth-select:focus {
    outline: none; border-color: var(--ink);
    box-shadow: 0 0 0 4px var(--ring, rgba(32,11,63,.12));
}
.auth-input.pw { padding-inline-end: 3rem; }
.auth-toggle {
    position: absolute; inset-inline-end: .5rem; background: none; border: none;
    color: var(--muted); width: 2.2rem; height: 2.2rem; border-radius: .5rem; cursor: pointer;
    display: grid; place-items: center; font-size: 1.05rem;
}
.auth-toggle:hover { color: var(--ink); background: var(--ground); }
.auth-hint { font-size: .82rem; color: var(--muted); }
.auth-error { display: none; font-size: .82rem; color: var(--danger); }
.auth-field.invalid .auth-input, .auth-field.invalid .auth-select { border-color: var(--danger); }
.auth-field.invalid .auth-error { display: block; }
/* main.js adds .was-validated to the form; surface native invalid state on our inputs */
.was-validated .auth-field:has(.auth-input:invalid) .auth-input,
.was-validated .auth-field:has(.auth-select:invalid) .auth-select { border-color: var(--danger); }
.was-validated .auth-field:has(:invalid) .auth-error { display: block; }

.auth-meta { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.auth-check { display: flex; align-items: center; gap: .5rem; font-size: .92rem; color: var(--text); cursor: pointer; }
.auth-check input { width: 1.05rem; height: 1.05rem; accent-color: var(--ink); }
.auth-check.terms { align-items: flex-start; line-height: 1.5; }
.auth-link { color: var(--ink); font-weight: 700; text-decoration: none; }
.auth-link:hover { color: var(--gold-2); text-decoration: underline; }

.auth-btn {
    width: 100%; border: none; cursor: pointer; font: inherit; font-weight: 800; font-size: 1.02rem;
    padding: .95rem 1rem; border-radius: .8rem; color: #fff;
    background: linear-gradient(150deg, #33184f 0%, var(--ink) 55%, var(--ink-2) 100%);
    box-shadow: 0 12px 26px -12px rgba(32,11,63,.7);
    display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
    transition: transform .12s ease, box-shadow .15s ease, filter .15s ease;
    position: relative;
}
.auth-btn::after {
    content: ""; position: absolute; inset-block-end: 0; inset-inline: 18%; height: 2px; border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: .8;
}
.auth-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 16px 30px -12px rgba(32,11,63,.75); filter: brightness(1.06); }
.auth-btn:disabled { opacity: .7; cursor: default; }

.auth-alt { text-align: center; margin: 0; color: var(--muted); font-size: .95rem; }
.auth-divider { display: flex; align-items: center; gap: 1rem; color: var(--muted); font-size: .82rem; margin: .3rem 0; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; background: var(--border); flex: 1; }

.auth-note {
    background: rgba(16,185,129,.08); border: 1px solid rgba(16,185,129,.25); color: #0f7a5a;
    border-radius: .8rem; padding: 1.25rem; text-align: center;
}
.auth-note .bi { font-size: 2.5rem; color: var(--success); }
.auth-back { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem; }
.auth-back:hover { color: var(--ink); }

/* spinner used while submitting */
.auth-spin { width: 1.05rem; height: 1.05rem; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: authspin .6s linear infinite; }
@keyframes authspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .auth-spin { animation: none; } .auth-btn { transition: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .auth-shell { flex-direction: column; }
    .auth-brand { flex: none; padding: 2rem 1.5rem; flex-direction: row; align-items: center; gap: 1rem; }
    .auth-brand-body, .auth-points, .auth-brand-glyph { display: none; }
    .auth-mobile-logo { display: none; }
    .auth-form-wrap { flex: 1; align-items: stretch; padding-top: 1.75rem; }
    .auth-card { margin-block: 0; }   /* top-align on mobile so there's no big gap under the header */
}
@media (max-width: 560px) {
    .auth-row { grid-template-columns: 1fr; }
}


/* Language switch on the auth screens (they render outside the portal shell) */
.auth-lang {
    position: absolute; top: 1rem; inset-inline-end: 1.2rem;
    display: inline-flex; align-items: center; gap: .35rem;
    font-size: .78rem; font-weight: 700; text-decoration: none;
    padding: .34rem .7rem; border-radius: 999px;
    color: #4b2673; background: #f3edfa; border: 1px solid #e4d9f3;
    transition: .15s;
}
.auth-lang:hover { background: #e9ddf8; color: #35164f; }
.auth-card { position: relative; }


/* ==========================================================================
   Layout that holds at every screen size
   The brand panel used to stretch to the height of the form beside it. With
   a long form (sign-up) or a short window it became a tall, mostly empty
   column with its content pushed to the two ends. It is now pinned to the
   window: exactly one viewport tall, while only the form side scrolls.
   ========================================================================== */
@media (min-width: 861px) {
    .auth-shell { align-items: flex-start; }
    .auth-brand {
        flex: 0 0 clamp(320px, 40%, 560px);
        position: sticky; top: 0;
        height: 100vh; height: 100dvh;
        justify-content: center;             /* one centred group, no stretched gaps */
        gap: clamp(1.5rem, 5vh, 3rem);
        padding: clamp(1.75rem, 4vh, 3.5rem) clamp(1.75rem, 3.2vw, 3.5rem);
    }
    .auth-brand .auth-logo { position: absolute; top: clamp(1.5rem, 4vh, 2.5rem); inset-inline-start: clamp(1.75rem, 3.2vw, 3.5rem); }
    .auth-brand-title { font-size: clamp(1.7rem, 2.6vw, 2.6rem); }
    .auth-brand-glyph { font-size: clamp(12rem, 22vw, 22rem); }
    .auth-form-wrap { flex: 1 1 0; min-width: 0; min-height: 100vh; min-height: 100dvh; overflow: visible; align-items: center; }
    .auth-card { margin-block: 0; }
}
/* short windows (small laptops, landscape tablets): keep the panel calm */
@media (min-width: 861px) and (max-height: 700px) {
    .auth-points { display: none; }
    .auth-brand-sub { font-size: .95rem; }
    .auth-form-wrap { align-items: flex-start; padding-block: 1.5rem; }
    .auth-head { margin-bottom: 1.25rem; }
    .auth-form { gap: .9rem; }
}
@media (min-width: 861px) and (max-height: 520px) {
    .auth-brand-sub, .auth-brand-eyebrow { display: none; }
}
/* phones / narrow tablets: a compact brand bar, then the form */
@media (max-width: 860px) {
    .auth-shell { min-height: 100vh; min-height: 100dvh; }
    .auth-brand { padding: .9rem 1.25rem; justify-content: flex-start; }
    .auth-brand .auth-logo { font-size: 1.15rem; }
    .auth-brand .auth-logo-mark { width: 2.2rem; height: 2.2rem; font-size: 1.1rem; }
    .auth-form-wrap { overflow: visible; padding: 1.5rem 1.1rem 2rem; }
    .auth-card { max-width: 480px; margin-inline: auto; }
    .auth-title { font-size: 1.5rem; }
    .auth-head { margin-bottom: 1.4rem; }
}
