/*
 * Sign-in and password reset pages (theme/pos/views/login.ejs, forgotpassword.ejs).
 * A two-panel layout: brand panel on one side, the form on a plain white panel.
 * Class names used by the pages' scripts (.step.active/.completed, .step-container.active,
 * .requirement.met, .resend-link.disabled, .shake, .strength-*) are kept.
 */
:root {
    --au-primary: #0F5132;
    --au-primary-hover: #276246;
    --au-primary-soft: #edf2ff;
    --au-ink: #101828;
    --au-text: #344054;
    --au-muted: #667085;
    --au-line: #d0d5dd;
    --au-line-soft: #eaecf0;
    --au-bg: #f5f6f8;
    --au-brand: #1d2939;
    --au-brand-2: #101828;
    --au-success: #12805c;
    --au-danger: #c4320a;
    --au-radius: 6px;
    --au-ring: 0 0 0 3px rgba(var(--primary-rgb), .16);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body.mp-auth {
    margin: 0;
    padding: 0;
    display: block;
    min-height: 100vh;
    background: var(--au-bg);
    color: var(--au-text);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Arabic', 'Noto Sans Devanagari', 'Noto Sans Bengali', 'Noto Sans JP', 'Noto Sans SC', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Shell ---------- */
.auth-shell {
    display: grid;
    grid-template-columns: minmax(320px, 42%) 1fr;
    min-height: 100vh;
}
.auth-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2rem;
    padding: 2.5rem 3rem;
    color: #e4e7ec;
    background:
        radial-gradient(1200px 600px at -10% -20%, rgba(59, 91, 219, .35), transparent 60%),
        linear-gradient(180deg, var(--au-brand) 0%, var(--au-brand-2) 100%);
    overflow: hidden;
}
.auth-brand::after {
    /* fine grid texture */
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, .04) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .04) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
}
.auth-brand > * { position: relative; z-index: 1; }
.auth-logo { display: inline-flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; }
.auth-logo img { height: 40px; width: auto; background: #fff; border-radius: var(--au-radius); padding: 4px 8px; }
.auth-logo span { font-size: 1.15rem; font-weight: 600; letter-spacing: .01em; }
.auth-brand h1 { color: #fff; font-size: 2rem; font-weight: 600; line-height: 1.25; letter-spacing: -.02em; margin: 0 0 .75rem; }
.auth-brand p.lead-text { color: #c4cad6; font-size: 1rem; margin: 0; max-width: 30rem; }
.auth-points { list-style: none; margin: 2rem 0 0; padding: 0; display: grid; gap: .9rem; }
.auth-points li { display: flex; align-items: flex-start; gap: .75rem; color: #d0d5dd; font-size: .95rem; }
.auth-points i {
    flex: 0 0 auto;
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--au-radius);
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .12);
    color: #fff;
    font-size: .8rem;
}
.auth-brand-foot { color: #98a2b3; font-size: .8rem; }

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4.5rem 1.5rem 2.5rem;
    background: #fff;
}
.auth-card { width: 100%; max-width: 420px; }
.auth-card.wide { max-width: 460px; }
.auth-head { margin-bottom: 1.75rem; }
.auth-head .auth-icon {
    width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--au-radius);
    background: var(--au-primary-soft);
    color: var(--au-primary);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}
.auth-head h2 { color: var(--au-ink); font-size: 1.6rem; font-weight: 600; letter-spacing: -.015em; margin: 0 0 .35rem; }
.auth-head p { color: var(--au-muted); margin: 0; }

/* ---------- Form controls ---------- */
.mp-auth .form-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .4rem;
    color: var(--au-text);
    font-size: .875rem;
    font-weight: 500;
}
.mp-auth .form-label > i { display: none; }
.mp-auth .form-label a { font-weight: 500; }
.mp-auth a { color: var(--au-primary); text-decoration: none; }
.mp-auth a:hover { color: var(--au-primary-hover); text-decoration: underline; }
.mp-auth .auth-logo, .mp-auth .auth-logo:hover { color: #fff; text-decoration: none; }

.mp-auth .input-group { position: relative; display: flex; align-items: stretch; width: 100%; }
.mp-auth .input-group .form-control,
.mp-auth .form-control {
    height: 44px;
    width: 100%;
    border: 1px solid var(--au-line);
    border-radius: var(--au-radius) !important;
    background: #fff;
    color: var(--au-ink);
    font-size: .95rem;
    padding: 0 .9rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.mp-auth .input-group .form-control { padding-inline-start: 2.6rem; margin: 0 !important; }
.mp-auth .input-group .form-control:has(+ .toggle-password),
.mp-auth .input-group .toggle-password ~ .form-control { padding-inline-end: 2.75rem; }
.mp-auth .form-control::placeholder { color: #98a2b3; }
.mp-auth .form-control:focus { border-color: var(--au-primary); box-shadow: var(--au-ring); outline: none; }
.mp-auth .input-icon {
    position: absolute;
    top: 0; bottom: 0;
    inset-inline-start: 0;
    width: 2.6rem;
    display: flex; align-items: center; justify-content: center;
    color: #98a2b3;
    font-size: .9rem;
    z-index: 6;
    pointer-events: none;
}
.mp-auth .toggle-password {
    position: absolute;
    top: 0; bottom: 0;
    inset-inline-end: 0;
    width: 2.75rem;
    display: flex; align-items: center; justify-content: center;
    border: 0;
    background: transparent;
    color: #98a2b3;
    z-index: 6;
    cursor: pointer;
}
.mp-auth .toggle-password:hover { color: var(--au-text); }
.mp-auth .toggle-password:focus-visible { outline: 2px solid var(--au-primary); outline-offset: -4px; border-radius: var(--au-radius); }
.mp-auth .form-text { color: var(--au-muted); font-size: .8rem; margin-top: .4rem; }
.mp-auth .form-check { display: flex; align-items: center; gap: .5rem; padding-inline-start: 0; margin: 0; min-height: 0; }
.mp-auth .form-check-input { float: none; margin: 0; width: 1rem; height: 1rem; border-color: var(--au-line); }
.mp-auth .form-check-input:checked { background-color: var(--au-primary); border-color: var(--au-primary); }
.mp-auth .form-check-label { color: var(--au-text); font-size: .875rem; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.1rem 0 1.5rem; }

/* ---------- Buttons ---------- */
.btn-login, .btn-reset, .btn-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    height: 44px;
    padding: 0 1.1rem;
    border-radius: var(--au-radius);
    font-size: .95rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease;
}
.btn-login, .btn-reset {
    border: 1px solid var(--au-primary);
    background: var(--au-primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}
.btn-login { width: 100%; }
.btn-login:hover, .btn-reset:hover { background: var(--au-primary-hover); border-color: var(--au-primary-hover); }
.btn-login:focus-visible, .btn-reset:focus-visible, .btn-back:focus-visible { box-shadow: var(--au-ring); outline: none; }
.btn-login:disabled, .btn-reset:disabled { opacity: .65; cursor: not-allowed; }
.btn-back { border: 1px solid var(--au-line); background: #fff; color: var(--au-text); }
.btn-back:hover { background: #f9fafb; color: var(--au-ink); }
.auth-actions { display: grid; grid-template-columns: auto 1fr; gap: .75rem; }
.auth-actions .btn-reset { width: 100%; }
.auth-actions .btn-reset span { overflow: hidden; text-overflow: ellipsis; }

/* ---------- Alerts ---------- */
.mp-auth .alert {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    border-radius: var(--au-radius);
    border: 1px solid;
    padding: .75rem .9rem;
    font-size: .875rem;
    margin-bottom: 1.25rem;
}
.mp-auth .alert.d-none { display: none !important; }
.mp-auth .alert > i { margin: .2rem 0 0 !important; }
.mp-auth .alert-info { background: #f5f8ff; border-color: #d1e0ff; color: #2d3f8f; }
.mp-auth .alert-success { background: #ecfdf3; border-color: #abefc6; color: #085d3a; }
.mp-auth .alert-warning { background: #fffaeb; border-color: #fedf89; color: #93370d; }
.mp-auth .alert-danger { background: #fef3f2; border-color: #fecdca; color: #b42318; }

/* ---------- Footer ---------- */
.auth-foot { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--au-line-soft); color: var(--au-muted); font-size: .875rem; text-align: center; }
.auth-foot p { margin: 0; }
.auth-foot .auth-copy { display: none; margin-top: .5rem; font-size: .8rem; }

/* ---------- Password reset steps ---------- */
.reset-steps { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 0 1.75rem; }
.reset-steps::before {
    content: '';
    position: absolute;
    top: 15px;
    inset-inline: 12.5%;
    height: 2px;
    background: var(--au-line-soft);
}
.step { position: relative; display: flex; flex-direction: column; align-items: center; gap: .45rem; text-align: center; min-width: 0; }
.step-circle {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--au-line);
    background: #fff;
    color: var(--au-muted);
    font-size: .85rem;
    font-weight: 600;
    position: relative;
    z-index: 1;
}
.step-label { color: var(--au-muted); font-size: .75rem; font-weight: 500; line-height: 1.2; padding: 0 .2rem; }
.step.active .step-circle { border-color: var(--au-primary); background: var(--au-primary); color: #fff; }
.step.active .step-label { color: var(--au-ink); font-weight: 600; }
.step.completed .step-circle { border-color: var(--au-success); background: var(--au-success); color: transparent; }
.step.completed .step-circle::after { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; color: #fff; position: absolute; font-size: .75rem; }
.step.completed .step-label { color: var(--au-success); }

.step-container { display: none; }
.step-container.active { display: block; animation: auFade .25s ease-out; }

.code-boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; margin-bottom: 1rem; }
.mp-auth .code-boxes .verification-digit {
    width: 100% !important;
    height: 52px !important;
    padding: 0;
    text-align: center;
    font-size: 1.35rem !important;
    font-weight: 600 !important;
    font-variant-numeric: tabular-nums;
}
.countdown-timer { color: var(--au-ink); font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-bottom: .25rem; }
.resend-link { color: var(--au-muted); font-size: .85rem; }
.resend-link a { font-weight: 500; }
.resend-link.disabled a { color: #98a2b3; pointer-events: none; text-decoration: none; }

.password-strength { margin-top: .75rem; }
.strength-meter { height: 6px; border-radius: 3px; background: var(--au-line-soft); overflow: hidden; }
.strength-fill { height: 100%; width: 0; border-radius: 3px; transition: width .25s ease, background-color .25s ease; }
.strength-text { margin-top: .35rem; color: var(--au-muted); font-size: .8rem; }
.strength-weak { background: #d92d20; width: 25%; }
.strength-fair { background: #dc6803; width: 50%; }
.strength-good { background: #1570ef; width: 75%; }
.strength-strong { background: var(--au-success); width: 100%; }
.password-requirements { margin-top: .9rem; padding: .85rem 1rem; border: 1px solid var(--au-line-soft); border-radius: var(--au-radius); background: #fcfcfd; }
.password-requirements h6 { margin: 0 0 .5rem; color: var(--au-ink); font-size: .8rem; font-weight: 600; }
.requirement { display: flex; align-items: center; gap: .5rem; color: var(--au-muted); font-size: .8rem; line-height: 1.8; }
.requirement i { width: 12px; font-size: .45rem; text-align: center; }
.requirement.met { color: var(--au-success); }
.requirement.met i { font-size: .75rem; }

.reset-success { text-align: center; }
.success-icon { width: 64px; height: 64px; margin: 0 auto 1rem; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: #ecfdf3; color: var(--au-success); font-size: 1.9rem; }
.reset-success h3 { color: var(--au-ink); font-size: 1.25rem; font-weight: 600; margin: 0 0 .5rem; }
.reset-success p { color: var(--au-muted); margin: 0 0 1.5rem; }
.reset-success .auth-actions { grid-template-columns: 1fr 1fr; }

/* ---------- Motion ---------- */
@keyframes auFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.shake { animation: shake .45s ease-in-out; }
.pulse { animation: none; }
@media (prefers-reduced-motion: reduce) { .step-container.active, .shake { animation: none; } }

/* ---------- Responsive ---------- */
.auth-mobile-logo { display: none !important; margin-bottom: 1.5rem; }
.auth-mobile-logo img { height: 36px; }
@media (max-width: 991.98px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .auth-panel { align-items: flex-start; padding-top: 5rem; }
    .auth-foot .auth-copy { display: block; }
    .auth-mobile-logo { display: inline-flex !important; }
}
@media (max-width: 420px) {
    .auth-panel { padding-inline: 1rem; }
    .auth-actions { grid-template-columns: 1fr; }
    .auth-actions .btn-back { order: 2; }
    .reset-success .auth-actions { grid-template-columns: 1fr; }
    .code-boxes { gap: .35rem; }
    .step-label { font-size: .7rem; }
}

/* RTL */
[dir="rtl"] .fa-arrow-left { transform: scaleX(-1); }
[dir="rtl"] .fa-sign-in-alt { transform: scaleX(-1); }
