/*!
 * Badran HR — Modern Authentication UI
 * Login + Forgot Password design system (Light & Dark)
 * Self-contained: no external CSS framework required.
 * --------------------------------------------------------------
 * Reuses legacy hook classes (.text-box, .text-button, .text-checkbox,
 * #LoginWindow, .login-error, .fp-message) so the existing PHP/OTP
 * jQuery injection keeps working with the new look automatically.
 */

/* ============================================================
   Design tokens
   ============================================================ */
   :root {
    /* Brand — Daffah / Badran crimson */
    --brand-red: #ab2228;        /* sampled from the logo */
    --brand-red-2: #c62b33;      /* hover / mid */
    --brand-red-3: #e0454d;      /* highlight */
    --brand-maroon: #7a151b;     /* deep */
    --brand-gold: #c9a227;       /* Shell-A gold (16-Sep-2026) */

    /* Light theme surfaces - warm off-whites taken from daffah.sa, matching
       the app canvas (#FBFBF9) so login and dashboard share one ground. */
    --bg-app: #fbfbf9;
    --bg-grad-1: #fbfbf9;
    --bg-grad-2: #f6f2ef;
    --card-bg: rgba(255, 255, 255, 0.84);
    --card-border: rgba(255, 255, 255, 0.9);
    --card-shadow: 0 30px 60px -20px rgba(48, 12, 14, 0.3), 0 10px 24px -12px rgba(48, 12, 14, 0.22);

    --field-bg: rgba(255, 255, 255, 0.72);
    --field-solid: #f7f3f4;   /* opaque equivalent for autofill masking */
    --field-border: rgba(86, 18, 21, 0.14);
    --field-border-focus: var(--brand-red);
    --field-ring: rgba(171, 34, 40, 0.16);

    --text-strong: #1c1416;
    --text-body: #43383a;
    --text-muted: #8a7d7f;
    --text-on-brand: #ffffff;

    --accent: var(--brand-red);
    /* Deep, single-family brand button - the old bright #e0454d highlight
       looked candy next to the burgundy panel. */
    --accent-grad: linear-gradient(90deg, #521b25 0%, #ac2228 100%);
    --btn-shadow: 0 14px 26px -10px rgba(140, 27, 33, 0.55);

    --error: #d23b46;
    --error-bg: rgba(210, 59, 70, 0.1);
    --success: #16a34a;
    --success-bg: rgba(22, 163, 74, 0.12);

    --radius-card: 24px;
    --radius-field: 12px;
    --radius-btn: 12px;

    --font-sans: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
    /* neutral warm-slate foundation so the red pops */
    --bg-app: #0f0c0d;
    --bg-grad-1: #171213;
    --bg-grad-2: #0a0809;
    --card-bg: rgba(30, 24, 26, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-shadow: 0 36px 70px -24px rgba(0, 0, 0, 0.82), 0 10px 30px -14px rgba(0, 0, 0, 0.6);

    --field-bg: rgba(255, 255, 255, 0.045);
    --field-solid: #1b1618;   /* opaque equivalent for autofill masking */
    --field-border: rgba(255, 255, 255, 0.12);
    --field-border-focus: var(--brand-red-3);
    --field-ring: rgba(224, 69, 77, 0.2);

    --text-strong: #f7f1f2;
    --text-body: #d9cbcd;
    --text-muted: #9b8c8e;

    --accent: var(--brand-red-3);
    --accent-grad: linear-gradient(135deg, #ab2228 0%, #d2333b 50%, #e0454d 120%);
    --btn-shadow: 0 16px 30px -12px rgba(224, 69, 77, 0.5);

    --error: #ff6b75;
    --error-bg: rgba(255, 107, 117, 0.12);
    --success: #4ade80;
    --success-bg: rgba(74, 222, 128, 0.14);
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body.auth-body {
    font-family: var(--font-sans);
    color: var(--text-body);
    background: var(--bg-app);
    /* Brand-only ambience: the old violet/cyan blobs read as "generic SaaS"
       and fought the burgundy. Blush + warm gold instead (daffah.sa family). */
    background-image:
        radial-gradient(1100px 700px at 88% -10%, rgba(172, 34, 40, 0.10), transparent 60%),
        radial-gradient(900px 600px at -5% 110%, rgba(240, 179, 91, 0.10), transparent 55%),
        linear-gradient(135deg, var(--bg-grad-1), var(--bg-grad-2));
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    overflow-x: hidden;
    transition: background-color .4s ease, color .4s ease;
}

a { text-decoration: none; }

/* ============================================================
   Shell / split layout
   ============================================================ */
.auth-shell {
    position: relative;
    width: 100%;
    max-width: 1180px;
    min-height: 700px;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    border-radius: var(--radius-card);
    overflow: hidden;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    -webkit-backdrop-filter: blur(22px);
    backdrop-filter: blur(22px);
    animation: shell-in .7s cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes shell-in {
    from { opacity: 0; transform: translateY(22px) scale(.985); }
    to   { opacity: 1; transform: none; }
}

/* ---------- Branding panel (left) ---------- */
.auth-brand {
    position: relative;
    padding: 54px 48px;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    background:
        /* Same burgundy as the dashboard hero (official daffah.sa #521B25
           family) so sign-in and the app read as one product. */
        /* Shell-A rail family: #3a1219 -> #521b25 -> #7a2530 */
        linear-gradient(135deg, rgba(58, 18, 25, 0.97) 0%, rgba(82, 27, 37, 0.94) 55%, rgba(122, 37, 48, 0.90) 100%),
        var(--brand-cover, #521b25);
    background-size: cover;
    background-position: center;
}

/* Shell-A decor: soft gold disc top-right, thin ring bottom-left (no blur, no animation) */
.auth-brand::before,
.auth-brand::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}
.auth-brand::before {
    width: 420px; height: 420px;
    top: -120px; right: -120px;
    background: rgba(201, 162, 39, 0.12);
    animation: float-a 14s ease-in-out infinite;
}
.auth-brand::after {
    width: 360px; height: 360px;
    bottom: -140px; left: -80px;
    border: 60px solid rgba(255, 255, 255, 0.04);
    animation: float-b 16s ease-in-out infinite;
}
@keyframes float-a { 50% { transform: translate(-14px, 16px); } }
@keyframes float-b { 50% { transform: translate(12px, -14px); } }

.brand-top { position: relative; z-index: 2; display: flex; align-items: center; gap: 14px; }
.brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px; height: 48px;
    border-radius: 13px;
    background: #ffffff;
    box-shadow: 0 8px 20px -10px rgba(0, 0, 0, 0.55);
}
.brand-logo img { height: 22px; width: auto; display: block; }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: .5px; line-height: 1.15; }
.brand-name small { display: block; font-weight: 600; font-size: 10px; opacity: .7; letter-spacing: 1.8px; text-transform: uppercase; }

.brand-mid { position: relative; z-index: 2; margin: auto 0; }
.brand-mid h1 {
    font-size: 40px;
    line-height: 1.1;
    font-weight: 900;
    margin: 0 0 16px;
    letter-spacing: -.5px;
}
.brand-mid h1 span { color: var(--brand-gold); }
.brand-mid p { font-size: 15px; line-height: 1.65; opacity: .85; max-width: 44ch; margin: 0; }

.brand-features { position: relative; z-index: 2; list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 13px; }
.brand-features li { display: flex; align-items: center; gap: 12px; font-size: 14px; opacity: .92; }
.brand-features .dot {
    width: 36px; height: 36px; flex: 0 0 36px;
    display: grid; place-items: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--brand-gold);
}

.brand-foot { position: relative; z-index: 2; font-size: 12px; opacity: .62; letter-spacing: .2px; display: flex; justify-content: space-between; gap: 12px; }

/* ---------- Form panel (right) ---------- */
.auth-panel {
    position: relative;
    padding: 52px 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: transparent;
}

.auth-head { margin-bottom: 26px; }
.auth-head .mobile-logo { display: none; }
.auth-head h2 { font-size: 28px; font-weight: 900; color: #521b25; margin: 0 0 6px; letter-spacing: -.3px; }
[data-theme="dark"] .auth-head h2 { color: var(--text-strong); }
.auth-head p { font-size: 14px; color: var(--text-muted); margin: 0; line-height: 1.55; }
.auth-head .ar { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; opacity: .85; }

/* legacy h1 (used by injected OTP markup) */
#LoginWindow h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-strong);
    margin: 0 0 18px;
    letter-spacing: -.3px;
}

/* ============================================================
   Form fields (legacy hook classes restyled)
   ============================================================ */
.field-label {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-body);
    margin: 0 0 7px 2px;
    letter-spacing: .2px;
}

.text-box {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 0 14px;
    height: 52px;
    background: var(--field-bg);
    border: 1.5px solid var(--field-border);
    border-radius: var(--radius-field);
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.text-box:focus-within {
    border-color: var(--field-border-focus);
    box-shadow: 0 0 0 4px var(--field-ring);
    background: var(--field-bg);
}
.text-box i {
    color: var(--text-muted);
    font-size: 15px;
    width: 18px;
    text-align: center;
    transition: color .2s ease;
    float: none;
    margin: 0;
}
.text-box:focus-within i { color: var(--accent); }

.text-box input[type='text'],
.text-box input[type='password'],
.text-box input[type='email'],
.text-box input[type='number'] {
    flex: 1 1 auto;
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-strong);
    font-family: var(--font-sans);
    font-size: 14.5px;
    font-weight: 500;
    padding: 0;
    float: none;
}
.text-box input::placeholder { color: var(--text-muted); opacity: .85; font-weight: 400; }

/* Neutralize browser autofill so it blends with the field in both themes */
.text-box input:-webkit-autofill,
.text-box input:-webkit-autofill:hover,
.text-box input:-webkit-autofill:focus,
.text-box input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--text-strong);
    caret-color: var(--text-strong);
    -webkit-box-shadow: 0 0 0 1000px var(--field-solid) inset;
    box-shadow: 0 0 0 1000px var(--field-solid) inset;
    transition: background-color 9999s ease-in-out 0s;
    border-radius: inherit;
}

/* password reveal */
.pw-toggle {
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 15px;
    line-height: 0;
    transition: color .2s ease;
}
.pw-toggle:hover { color: var(--accent); }

/* spacing between stacked fields */
.field-group + .field-group { margin-top: 16px; }

/* ---------- Options row ---------- */
.auth-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
}
.text-checkbox {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    color: var(--text-body);
    width: auto;
    padding: 0;
    margin: 0;
    cursor: pointer;
    user-select: none;
}
.text-checkbox input[type='checkbox'] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px; height: 18px;
    border: 1.5px solid var(--field-border);
    border-radius: 6px;
    background: var(--field-bg);
    cursor: pointer;
    position: relative;
    transition: background .2s ease, border-color .2s ease;
    flex: 0 0 auto;
}
.text-checkbox input[type='checkbox']:checked {
    background: var(--accent-grad);
    border-color: transparent;
}
.text-checkbox input[type='checkbox']:checked::after {
    content: "";
    position: absolute;
    left: 5px; top: 1.5px;
    width: 5px; height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.text-checkbox span { color: var(--text-body) !important; font-size: 13px; font-weight: 500; }

.auth-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    transition: opacity .2s ease;
}
.auth-link:hover { opacity: .7; text-decoration: underline; }

/* ============================================================
   Button (legacy .text-button restyled)
   ============================================================ */
.text-button {
    width: 100%;
    margin-top: 24px;
    background: transparent;
    border: none;
    border-radius: var(--radius-btn);
    padding: 0;
}
.text-button input[type='submit'],
.btn-auth {
    width: 100%;
    height: 52px;
    border: none;
    border-radius: var(--radius-btn);
    background: var(--accent-grad);
    background-size: 180% 180%;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .4px;
    cursor: pointer;
    box-shadow: var(--btn-shadow);
    transition: transform .18s ease, box-shadow .25s ease, background-position .5s ease, filter .2s ease;
}
.text-button input[type='submit']:hover,
.btn-auth:hover {
    transform: translateY(-2px);
    background-position: 100% 0;
    box-shadow: 0 20px 34px -12px rgba(171, 34, 40, 0.7);
}
.text-button input[type='submit']:active,
.btn-auth:active { transform: translateY(0); }
.text-button input[type='submit']:focus-visible,
.btn-auth:focus-visible { outline: 3px solid var(--field-ring); outline-offset: 2px; }
.text-button input[type='submit']:disabled,
.btn-auth:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ============================================================
   Messages
   ============================================================ */
.login-error {
    width: 100%;
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--error);
}
.login-error:empty { display: none; }
.login-error:not(:empty) {
    background: var(--error-bg);
    border: 1px solid color-mix(in srgb, var(--error) 28%, transparent);
    border-radius: 12px;
    padding: 11px 14px;
    animation: msg-in .35s ease both;
}

.fp-message { margin-top: 16px; font-size: 13px; line-height: 1.6; color: var(--success); text-align: center; }
.fp-message:empty { display: none; }
.fp-message:not(:empty) {
    background: var(--success-bg);
    border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
    border-radius: 14px;
    padding: 14px 16px;
    color: var(--text-body);
    animation: msg-in .35s ease both;
}
.fp-message.error { color: var(--error); background: var(--error-bg); border-color: color-mix(in srgb, var(--error) 28%, transparent); }
.fp-message b { color: var(--text-strong); }

@keyframes msg-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.fp-back {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent) !important;
    transition: gap .2s ease, opacity .2s ease;
}
.fp-back:hover { gap: 11px; opacity: .8; }
.auth-foot { text-align: center; margin-top: 14px; }
.auth-help { margin-top: auto; padding-top: 28px; font-size: 12.5px; color: var(--text-muted); }
.auth-panel.has-help .auth-head { margin-top: auto; }   /* form block centred between top edge and the help line */
.auth-help b { color: var(--text-strong); font-weight: 700; }
.auth-foot .muted { font-size: 12.5px; color: var(--text-muted); }

/* ============================================================
   Theme toggle
   ============================================================ */
.theme-toggle {
    position: fixed;
    top: 22px; right: 22px;
    z-index: 50;
    width: 44px; height: 44px;
    display: grid; place-items: center;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    color: var(--text-strong);
    cursor: pointer;
    font-size: 17px;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 22px -12px rgba(0, 0, 0, 0.4);
    transition: transform .2s ease, box-shadow .2s ease;
}
.theme-toggle:hover { transform: translateY(-2px) rotate(-8deg); }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* hide scrollbars on the locked auth screen */
body.auth-body::-webkit-scrollbar { width: 0; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; max-width: 460px; min-height: 0; }
    .auth-brand { display: none; }
    .auth-panel { padding: 44px 34px; }
    .auth-head .mobile-logo {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 22px;
    }
    .auth-head .mobile-logo .brand-logo {
        padding: 8px 13px;
        border: 1px solid var(--field-border);
    }
    .auth-head .mobile-logo img { height: 22px; width: auto; }
    .auth-head .mobile-logo span { font-weight: 700; font-size: 17px; color: var(--text-strong); }
}

@media (max-width: 480px) {
    body.auth-body { padding: 16px; }
    .auth-panel { padding: 34px 22px; }
    .auth-head h2 { font-size: 22px; }
    .theme-toggle { top: 14px; right: 14px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .auth-shell, .auth-brand::before, .auth-brand::after, .login-error, .fp-message { animation: none !important; }
    * { transition-duration: .01ms !important; }
}
