/* =============================================================
   NAMI CRM — auth surfaces (admin login, client login/register,
   password reset, invite accept) in the "Ink & Signal" system.
   Loaded after login/css/style.css. Presentation only: no markup,
   route, field, or script depends on anything in this file.
   ============================================================= */

:root {
    --nm-ink: #131820;
    --nm-ink-soft: #1D2430;
    --nm-paper: #F7F7F6;
    --nm-surface: #FFFFFF;
    --nm-graphite: #59616E;
    --nm-graphite-soft: #7C8492;
    --nm-hairline: #E4E6E9;
    --nm-hairline-strong: #D3D7DC;
    --nm-accent: #1B4D8F;
    --nm-accent-hover: #163F76;
    --nm-accent-wash: #ECF1F8;
    --nm-risk: #A63229;
    --nm-radius: 10px;
    --nm-radius-sm: 6px;
    --nm-font: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, sans-serif;
    --nm-mono: "IBM Plex Mono", ui-monospace, monospace;
}

html[dir="rtl"] body,
body[dir="rtl"] { --nm-font: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif; }

*, .container, .form-wrap, .input-field input, form button, .footer {
    font-family: var(--nm-font);
}

body {
    background: var(--nm-paper);
    color: var(--nm-graphite);
    -webkit-font-smoothing: antialiased;
}

/* The legacy admin login is the visual reference for this screen. Keep its
   compact centered card while the client auth screens retain the shared shell. */
.auth-admin-page {
    background: #f8f8f8;
}

.auth-admin-page .container {
    display: block;
}

.auth-admin-page .image-side,
.auth-admin-page .selectLanguage,
.auth-admin-page .form-wrap > img.logo,
.auth-admin-page .form-wrap > .footer {
    display: none;
}

.auth-admin-page .form-side {
    min-height: 100vh;
    padding: 72px 20px 20px;
    background: transparent;
    align-items: flex-start;
}

.auth-admin-page .form-wrap {
    width: 450px;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    background: #fff;
    border: 1px solid #e9e9e9;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .08);
    overflow: hidden;
}

.auth-admin-page .legacy-auth-header {
    padding: 22px 30px 18px;
    border-bottom: 1px solid #eeeeee;
    color: #526273;
    font-size: 28px;
    font-weight: 400;
    text-align: center;
}

.auth-admin-page .legacy-auth-body {
    padding: 30px;
}

.auth-admin-page .legacy-auth-body .form-group {
    display: grid;
    gap: 16px;
    margin: 0 0 14px;
}

.auth-admin-page .legacy-auth-body .input-field input {
    width: 100%;
    height: 43px;
    padding: 10px;
    border: 0;
    border-radius: 5px;
    background: #f1f1f1;
    color: #526273;
    font-size: 14px;
}

.auth-admin-page .legacy-auth-body button {
    width: 100%;
    height: 47px;
    margin: 0;
    border: 0;
    border-radius: 6px;
    background: #638cf0;
    color: #fff;
    font-size: 17px;
    font-weight: 400;
}

.auth-admin-page .legacy-auth-link,
.auth-admin-page .legacy-auth-signup {
    font-size: 14px;
    line-height: 1.5;
}

.auth-admin-page .legacy-auth-link { margin-top: 7px; }
.auth-admin-page .legacy-auth-signup { margin-top: 20px; color: #526273; }
.auth-admin-page .legacy-auth-body a { color: #2875bd; text-decoration: none; }

@media (max-width: 576px) {
    .auth-admin-page .form-side { padding: 25px 15px; }
    .auth-admin-page .legacy-auth-body { padding: 24px 20px; }
}

/* Keep the admin card at the same top offset as the legacy sign-in screen. */
.auth-admin-page .form-side { align-items: flex-start; }

/* Client portal keeps the original split-screen login surface. The admin
   login has its compact card above, while client auth must remain compatible
   with the legacy screen at /{locale}/client/login. */
.auth-client-page,
.auth-client-page * {
    font-family: "Almarai", sans-serif;
}

.auth-client-page .container { flex-direction: row; }
.auth-client-page .image-side {
    flex: 2;
    height: 100vh;
    min-height: 600px;
    background-size: cover;
    background-position: center;
    clip-path: polygon(0 0, 85% 0, 100% 100%, 0 100%);
}
.auth-client-page .form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: #fff;
}
.auth-client-page .form-wrap {
    width: 80%;
    max-width: 700px;
    margin: auto;
    padding: 32px;
    text-align: center;
    background: #fff;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
}
.auth-client-page .form-wrap img.logo {
    display: block;
    max-width: 300px;
    max-height: 150px;
    margin: 0 auto 20px;
}
.auth-client-page .auth-heading { margin-bottom: 24px; }
.auth-client-page .auth-heading h1 { margin: 4px 0 8px; }
.auth-client-page .auth-heading p { margin: 0; line-height: 1.6; }
.auth-client-page .auth-links { justify-content: center; }

@media (max-width: 768px) {
    .auth-client-page .container { flex-direction: column; }
    .auth-client-page .image-side { display: none; }
    .auth-client-page .form-side { min-height: 100vh; }
}

/* ---------- The panel ----------
   The photograph carries its own colour; nothing is laid over it. Only
   a single accent rule marks the seam between panel and form. */
.image-side,
.animation {
    flex: 1.15;
    position: relative;
    overflow: hidden;
}

.image-side {
    /* Set here, not by script: the page must render without JavaScript. */
    background-image: url("../imgs/1.webp");
    background-size: cover;
    background-position: center;
    background-color: #E9EAEC;
}

[dir="ltr"] .image-side,
[dir="rtl"] .image-side {
    clip-path: none;
}

/* One measured accent line — the same spine the app uses for state. */
.image-side::after,
.animation::after {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: 3px;
    background: var(--nm-accent);
}

.animation #globe canvas { position: relative; z-index: 1; }

/* ---------- Form side ---------- */
.form-side {
    flex: 1;
    background: var(--nm-paper);
    padding: 2rem 1.5rem;
}

.form-wrap {
    width: 100%;
    max-width: 27rem;
    text-align: start;
    background: transparent;
    padding: 0;
}

@media (min-width: 576px) {
    .form-wrap { padding: 0; }
}

.form-wrap img.logo {
    max-height: 40px;
    max-width: 180px;
    margin: 0 0 2rem;
    object-fit: contain;
}

[dir="rtl"] .form-wrap img.logo { margin-inline: 0 auto; }

.auth-heading { margin-bottom: 1.75rem; }

.auth-feedback {
    border: 1px solid var(--nm-hairline-strong);
    border-radius: var(--nm-radius-sm);
    padding: .75rem .875rem;
    margin: 0 0 1.25rem;
    font-size: .8125rem;
    line-height: 1.5;
}

.auth-feedback-error {
    color: var(--nm-risk);
    background: #FFF5F3;
    border-color: #E7B5AE;
}

.auth-feedback-success {
    color: #166534;
    background: #F0FDF4;
    border-color: #A7D7B1;
}

.auth-feedback strong { display: block; margin-bottom: .25rem; }
.auth-feedback ul { margin: .25rem 0 0; padding-inline-start: 1.25rem; }

.auth-kicker {
    display: block;
    font-family: var(--nm-mono);
    font-size: .6875rem;
    font-weight: 500;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--nm-graphite-soft);
    margin-bottom: .625rem;
}

.form-wrap h1,
.auth-heading h1 {
    font-size: 1.875rem;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.03em;
    color: var(--nm-ink);
    margin: 0 0 .5rem;
}

.form-wrap p,
.auth-heading p {
    font-size: .875rem;
    color: var(--nm-graphite);
    margin: 0;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .form-wrap h1, .auth-heading h1 { font-size: 1.5rem; }
}

/* ---------- Fields ---------- */
.form-group { gap: 1rem; margin-bottom: 1rem; }

.input-field label {
    font-size: .8125rem;
    font-weight: 550;
    color: var(--nm-ink);
    margin-bottom: .375rem;
}

.input-field input {
    padding: .6875rem .75rem;
    border: 1px solid var(--nm-hairline-strong);
    border-radius: var(--nm-radius-sm);
    background: var(--nm-surface);
    color: var(--nm-ink);
    font-size: .875rem;
    transition: border-color .12s ease, box-shadow .12s ease;
}

.input-field input::placeholder { color: var(--nm-graphite-soft); }

.input-field input:focus {
    border-color: var(--nm-accent);
    box-shadow: 0 0 0 3px var(--nm-accent-wash);
}

@media (max-width: 576px) {
    .input-field input { font-size: .875rem; padding: .625rem .6875rem; }
}

.account-type-options {
    gap: .75rem;
    font-size: .8125rem;
    color: var(--nm-graphite);
    min-height: auto;
    margin-top: .375rem;
}

/* Account type reads as a choice of two cards, not a pair of dots. */
.account-type-options label {
    border: 1px solid var(--nm-hairline-strong);
    border-radius: var(--nm-radius-sm);
    padding: .5rem .75rem;
    background: var(--nm-surface);
    cursor: pointer;
    transition: border-color .12s ease, background-color .12s ease;
}

.account-type-options label:hover { border-color: var(--nm-accent); background: var(--nm-accent-wash); }
.account-type-options label:has(input:checked) { border-color: var(--nm-accent); background: var(--nm-accent-wash); color: var(--nm-ink); font-weight: 550; }
.account-type-options input { accent-color: var(--nm-accent); }

/* ---------- Remember / forgot row ---------- */
.check { margin-top: 1rem; font-size: .8125rem; color: var(--nm-graphite); }
.check a { color: var(--nm-accent); font-weight: 550; }
.check a:hover { color: var(--nm-accent-hover); text-decoration: underline; }
.check input::after { border-color: var(--nm-hairline-strong); border-radius: 4px; }
.check input:checked::after { background: var(--nm-accent); border-color: var(--nm-accent); }

/* ---------- Primary action ---------- */
form button {
    margin-top: 1.5rem;
    height: 44px;
    border-radius: var(--nm-radius-sm);
    background: var(--nm-accent);
    color: #fff;
    font-size: .875rem;
    font-weight: 550;
    letter-spacing: -0.005em;
    transition: background-color .12s ease, transform .06s ease;
}

form button:hover { background: var(--nm-accent-hover); }
form button:active { transform: translateY(1px); }

#registerPanel form button,
#forgotPanel form button,
#forgotPanel + form button { margin-top: 1.5rem; }

/* ---------- Secondary links ---------- */
.auth-links {
    justify-content: flex-start;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--nm-hairline);
    font-size: .8125rem;
    color: var(--nm-graphite-soft);
}

.auth-links a { color: var(--nm-accent); font-weight: 550; }
.auth-links a:hover { color: var(--nm-accent-hover); }

.auth-panel { animation: nm-auth-in .18s ease-out; }

@keyframes nm-auth-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Language switch ---------- */
.selectLanguage {
    top: 1.5rem;
    right: 1.5rem;
    gap: .25rem;
    padding: .1875rem .375rem;
    border: 1px solid var(--nm-hairline);
    border-radius: var(--nm-radius-sm);
    background: var(--nm-surface);
    box-shadow: 0 1px 2px rgba(19, 24, 32, .04);
}

[dir="ltr"] .selectLanguage { left: unset; right: 1.5rem; padding: .1875rem .375rem; }
[dir="rtl"] .selectLanguage { right: unset; left: 1.5rem; }

.selectLanguage .icon { padding: 0 .25rem; display: flex; }
.selectLanguage .icon svg { width: 15px; height: 15px; filter: grayscale(1); opacity: .45; }

.selectLanguage select {
    padding: .25rem .375rem;
    font-size: .75rem;
    font-weight: 550;
    color: var(--nm-ink);
    cursor: pointer;
}

/* ---------- Footer ---------- */
.footer {
    padding: 1rem 0 0;
    text-align: start;
    font-size: .75rem;
    color: var(--nm-graphite-soft);
}

/* The mono face carries Latin only, so Arabic copy keeps the sans. */
html[lang="ar"] .auth-kicker { font-family: var(--nm-font); letter-spacing: .06em; }

.footer a { color: var(--nm-graphite); font-weight: 500; }
.footer a:hover { color: var(--nm-accent); }

/* ---------- Validation & toasts on auth ---------- */
.error, .invalid-feedback, .text-danger { color: var(--nm-risk) !important; font-size: .75rem; }

/* ---------- Small screens: a clean sheet, not frosted glass ---------- */
@media (max-width: 992px) {
    .animation, .image-side { display: none; }

    .form-wrap {
        background: var(--nm-surface);
        backdrop-filter: none;
        border: 1px solid var(--nm-hairline);
        border-radius: var(--nm-radius);
        padding: 1.5rem;
        z-index: 1;
    }
}

@media (max-width: 768px) {
    .form-side { padding: 1.5rem 1rem; align-items: flex-start; }
    .selectLanguage { top: 1rem; }
    [dir="ltr"] .selectLanguage { right: 1rem; }
    [dir="rtl"] .selectLanguage { left: 1rem; }
}

/* ---------- Quality floor ---------- */
:focus-visible { outline: 2px solid var(--nm-accent); outline-offset: 2px; border-radius: 3px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* =============================================================
   Form layout — one column of meaning, paired only where the two
   fields are genuinely one thing (a name, a password + its match).
   ============================================================= */
.auth-panel form { width: 100%; }

.form-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .875rem 1rem;
    margin-bottom: 0;
}

/* Single-field forms (sign in, recovery) keep one column. */
.auth-panel form .form-group:has(> .input-field:only-child) { grid-template-columns: 1fr; }

.input-field { display: flex; flex-direction: column; min-width: 0; }

/* Full-width fields: email, account type, company name. */
#registerPanel form .form-group > .input-field:nth-child(3),
#registerPanel form .form-group > .account-type-field,
#registerPanel form .form-group > #companyNameField,
.auth-panel form .form-group > .input-field:only-child {
    grid-column: 1 / -1;
}

/* Sign in and recovery: stack, never split a credential pair. */
#loginPanel form .form-group,
#forgotPanel form .form-group,
#resetPanel form .form-group,
#invitePanel form .form-group {
    grid-template-columns: 1fr;
    gap: .875rem;
}

/* The register screen carries more fields, so it gets more room. */
body:has(#registerPanel) .form-wrap { max-width: 32rem; }

@media (max-width: 576px) {
    .form-group { grid-template-columns: 1fr; }
    body:has(#registerPanel) .form-wrap { max-width: 100%; }
}

/* Text fields sit on a consistent 42px rhythm across every auth screen.
   Choice controls keep their own size. */
.input-field input:not([type="checkbox"]):not([type="radio"]) {
    width: 100%;
    height: 42px;
    line-height: 1.2;
}

.account-type-options input[type="radio"] {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    margin: 0;
}

.input-field label {
    display: flex;
    align-items: center;
    gap: .25rem;
    min-height: 1.25rem;
}

/* Account type: two selectable cards on their own line. */
.account-type-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem;
    margin-top: 0;
}

.account-type-options label {
    justify-content: flex-start;
    align-items: center;
    gap: .5rem;
    min-height: 42px;
    font-size: .8125rem;
    white-space: nowrap;
}

/* Remember me sits on the same rhythm as the fields above it. */
.check-field { margin-top: .875rem; }

.check-field > div {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.check-field label { margin: 0; font-size: .8125rem; font-weight: 400; color: var(--nm-graphite); }

.check-field input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--nm-accent);
    cursor: pointer;
}

/* Errors read as one block above the form, in the interface's voice. */
.alert-danger {
    background: #FAECEA;
    border: 1px solid rgba(166, 50, 41, .22);
    border-inline-start: 3px solid var(--nm-risk);
    border-radius: var(--nm-radius-sm);
    color: var(--nm-risk);
    padding: .75rem .875rem;
    font-size: .8125rem;
    margin-bottom: 1rem;
}

.alert-danger ul { margin: 0; padding-inline-start: 1rem; }
