/* Mowazaf — server-rendered auth surfaces (login, password, consent).
   Register: brand / pre-login. Composition: a crisp white card floating on a
   living cobalt→turquoise aurora. Cobalt is the protagonist.
   All spatial properties are logical (inline/block) so RTL mirrors automatically. */

:root {
    --primary: #304EA1;        /* Cobalt — brand anchor, CTA, focus ring */
    --primary-dark: #243A78;   /* Hover / pressed */
    --primary-light: #4A5A8A;
    --accent: #4ADDCB;         /* Turquoise — gradient endpoint */
    --accent-dark: #17675C;

    --ink: #1F2A48;            /* Cobalt-tinted near-black: headings */
    --text-body: #33405C;      /* Body text */
    --muted: #6B7793;          /* Secondary copy, labels-helper, placeholders */

    --surface: #FBFCFE;        /* Form-panel surface — tinted, never flat #fff */
    --bg: #F5F8FC;             /* Cloud-white */
    --on-primary: #F6F9FF;     /* Text on cobalt */

    --border: #DFE5F0;
    --border-strong: #CBD4E6;  /* Input border */
    --ring: rgba(48, 78, 161, 0.18);

    --danger: #C9374A;
    --danger-bg: #FCECEE;
    --danger-border: #F2C6CC;
    --success: #0F9D8A;
    --success-bg: #E7F8F4;
    --success-border: #B9EAE0;

    --radius-field: 11px;
    /* Drenched brand gradient: deep cobalt sweeping into turquoise. */
    --brand-gradient: linear-gradient(150deg, #1E3268 0%, #304EA1 44%, #3A6FA6 72%, #4ADDCB 128%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    font-family: 'Poppins', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text-body);
    background: linear-gradient(135deg, #1C2E60 0%, #294386 55%, #2D6E8E 100%);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Living aurora: drifting cobalt + turquoise light blobs behind everything. */
body::before {
    content: "";
    position: fixed;
    inset: -35%;
    z-index: -1;
    background:
        radial-gradient(38% 38% at 18% 24%, rgba(74, 221, 203, 0.50), transparent 62%),
        radial-gradient(44% 44% at 82% 28%, rgba(48, 78, 161, 0.75), transparent 62%),
        radial-gradient(42% 42% at 72% 88%, rgba(74, 221, 203, 0.36), transparent 60%),
        radial-gradient(46% 46% at 22% 82%, rgba(64, 111, 166, 0.60), transparent 62%);
    animation: aurora-drift 26s ease-in-out infinite alternate;
    will-change: transform;
}

/* ---- Floating card ------------------------------------------------------- */

.auth-stage {
    width: 100%;
    max-width: 432px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.auth-card {
    position: relative;
    background: var(--surface);
    border-radius: 22px;
    box-shadow:
        0 32px 70px -28px rgba(12, 22, 52, 0.62),
        0 12px 30px -18px rgba(12, 22, 52, 0.45);
    animation: card-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Subtle gradient ring (turquoise → cobalt) drawn just inside the card edge. */
.auth-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 22px;
    padding: 1px;
    background: linear-gradient(145deg, rgba(74, 221, 203, 0.75), rgba(48, 78, 161, 0.30) 42%, rgba(255, 255, 255, 0) 72%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.auth-card__brand {
    display: flex;
    justify-content: center;
    padding: 34px 0 2px;
}

.auth-card__mark {
    height: 42px;
    width: auto;
}

.auth-card__body {
    padding: 14px 38px 34px;
}

.form-section {
    display: flex;
    flex-direction: column;
}

/* The brand mark crowns the card; suppress any in-form logo to avoid doubling it. */
.form-section .logo {
    display: none;
}

/* Heading + intro center under the crown; field labels stay start-aligned. */
.auth-card__body h1,
.auth-card__body .subtitle {
    text-align: center;
}

/* ---- Type ---------------------------------------------------------------- */

h1 {
    font-size: 26px;
    line-height: 1.22;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin-bottom: 8px;
}

h2 {
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--muted);
    margin-bottom: 4px;
}

p {
    font-size: 15px;
    line-height: 1.6;
    color: var(--muted);
    margin-bottom: 22px;
    max-width: 48ch;
}

.subtitle {
    margin-top: -2px;
    margin-bottom: 26px;
}

/* ---- Fields -------------------------------------------------------------- */

.form-group {
    margin-bottom: 18px;
    position: relative;
}

label,
.form-label {
    display: block;
    margin-bottom: 7px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-body);
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-field);
    font: inherit;
    font-size: 15px;
    color: var(--ink);
    background-color: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control::placeholder {
    color: #9AA3B8;
}

.form-control:focus,
.form-control:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}

/* ---- Buttons ------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-field);
    background-color: var(--primary);
    color: var(--on-primary);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 8px 22px -12px rgba(48, 78, 161, 0.7);
    text-decoration: none;
}

.btn:active {
    background-color: var(--primary-dark);
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ring);
}

.btn:disabled,
.btn[aria-busy="true"] {
    opacity: 0.62;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background-color: transparent;
    color: var(--primary);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    background-color: rgba(48, 78, 161, 0.06);
    box-shadow: none;
}

.btn .spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(246, 249, 255, 0.4);
    border-top-color: var(--on-primary);
    animation: spin 0.6s linear infinite;
}

.buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.buttons .btn,
.buttons .btn-secondary {
    flex: 1;
}

@media (min-width: 520px) {
    .buttons {
        flex-direction: row;
    }
}

/* ---- Links --------------------------------------------------------------- */

a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

a:hover {
    text-decoration: underline;
}

a:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ring);
    border-radius: 4px;
}

.forgot-password-link {
    font-size: 14px;
}

.auth-alt {
    margin-top: 8px;
    font-size: 13.5px;
    color: var(--muted);
}

.auth-alt a {
    margin-inline-start: 4px;
}

/* "Back to sign in" / "Cancel" escape link below a form's primary action. */
.auth-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: center;
    margin-top: 18px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
}

.auth-back:hover {
    color: var(--primary);
    text-decoration: none;
}

.auth-back svg {
    width: 15px;
    height: 15px;
}

[dir="rtl"] .auth-back svg {
    transform: scaleX(-1);
}

/* ---- Validation & status ------------------------------------------------- */

.text-danger {
    color: var(--danger);
    font-size: 13px;
    margin-top: 6px;
    display: block;
}

.validation-summary-errors {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger);
    border-radius: 10px;
    padding: 11px 14px;
    margin-bottom: 18px;
    font-size: 13.5px;
}

.validation-summary-errors ul {
    margin: 0;
    padding-inline-start: 18px;
}

.validation-summary-errors ul li {
    list-style: disc;
}

.validation-summary-errors ul:only-child li:only-child {
    list-style: none;
    margin-inline-start: -18px;
}

.alert {
    position: relative;
    border-radius: 10px;
    border: 1px solid transparent;
    padding: 11px 38px 11px 14px;
    margin-bottom: 18px;
    font-size: 13.5px;
}

.alert-success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--accent-dark);
}

.alert-danger {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger);
}

.alert .btn-close {
    position: absolute;
    inset-inline-end: 8px;
    top: 8px;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: inherit;
    opacity: 0.65;
    cursor: pointer;
    border-radius: 6px;
}

.alert .btn-close::before {
    content: "\00d7";
    font-size: 16px;
    line-height: 1;
}

.alert .btn-close:hover {
    opacity: 1;
}

/* ---- Password reveal toggle ---------------------------------------------- */

.password-toggle-wrapper {
    position: relative;
}

.password-toggle-wrapper .form-control {
    padding-inline-end: 44px;
}

.password-toggle-btn {
    position: absolute;
    inset-inline-end: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.password-toggle-btn:hover {
    color: var(--primary);
    background: rgba(48, 78, 161, 0.06);
}

.password-toggle-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ring);
}

/* ---- Caps Lock hint ------------------------------------------------------ */

.caps-warning {
    display: none;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--danger);
}

.caps-warning.show {
    display: flex;
}

/* ---- Live password rule checklist ---------------------------------------- */

.password-rules {
    margin-top: 12px;
    margin-bottom: 4px;
    display: grid;
    gap: 7px;
}

.password-rules li {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--muted);
    transition: color 0.15s ease;
}

.password-rules .rule-icon {
    flex: none;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1.5px solid var(--border-strong);
    color: transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.password-rules li.ok {
    color: var(--text-body);
}

.password-rules li.ok .rule-icon {
    background: var(--success);
    border-color: var(--success);
    color: var(--on-primary);
}

.confirm-hint {
    display: none;
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--danger);
}

.confirm-hint.show {
    display: block;
}

.confirm-hint.ok {
    color: var(--success);
}

/* ---- Confirmation / status screens --------------------------------------- */

.auth-confirm {
    align-items: center;
    text-align: center;
}

.auth-confirm h1,
.auth-confirm p {
    text-align: center;
}

.auth-confirm p {
    max-width: 38ch;
}

.auth-status-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}

.auth-status-icon.success {
    background: var(--success-bg);
    color: var(--success);
}

.auth-status-icon.info {
    background: rgba(48, 78, 161, 0.09);
    color: var(--primary);
}

.auth-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 6px;
}

/* ---- Footer (below the card, on the aurora) ------------------------------ */

.footer {
    margin-top: 22px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(246, 249, 255, 0.72);
}

.footer a {
    color: rgba(246, 249, 255, 0.82);
    text-decoration: underline;
    font-weight: 400;
}

.footer .footer-sep {
    opacity: 0.4;
}

.footer .lang-toggle {
    color: #FFFFFF;
    font-weight: 500;
    text-decoration: none;
}

.footer .lang-toggle:hover {
    text-decoration: underline;
}

/* ---- Motion -------------------------------------------------------------- */

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes aurora-drift {
    0% {
        transform: translate3d(-2%, -1%, 0) scale(1.05) rotate(0deg);
    }
    100% {
        transform: translate3d(2%, 2%, 0) scale(1.13) rotate(4deg);
    }
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* ---- Responsive ---------------------------------------------------------- */

@media (max-width: 480px) {
    body {
        padding: 24px 16px;
    }

    .auth-card__body {
        padding: 12px 24px 28px;
    }

    .auth-card__brand {
        padding: 28px 0 2px;
    }

    .auth-card__mark {
        height: 38px;
    }

    h1 {
        font-size: 23px;
    }
}

/* ---- CO-323: two-factor authentication pages ---------------------------- */

.mfa-code-input {
    font-size: 20px;
    letter-spacing: 0.18em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.mfa-check {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    cursor: pointer;
}

.mfa-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.mfa-alt {
    text-align: center;
}

.mfa-notice {
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(48, 78, 161, 0.06);
    color: var(--ink);
    padding: 11px 14px;
    margin-bottom: 18px;
    font-size: 13.5px;
}

.mfa-notice--warn {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger);
}

.mfa-steps {
    list-style: decimal;
    padding-inline-start: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 18px;
}

.mfa-step-title {
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 4px;
}

.mfa-step-body {
    font-size: 13.5px;
    color: var(--muted);
    margin: 8px 0 6px;
}

.mfa-qr {
    width: fit-content;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-block: 8px;
}

.mfa-qr img,
.mfa-qr canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.mfa-key,
.mfa-codes code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 15px;
    color: var(--ink);
    word-break: break-all;
}

.mfa-key {
    display: block;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-field);
    user-select: all;
}

a.btn,
a.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.mfa-open-app {
    margin-top: 4px;
}

.mfa-codes {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 12px;
    margin-bottom: 18px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-field);
}

.mfa-codes li {
    text-align: center;
}

.mfa-status {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    font-size: 14px;
}

.mfa-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    color: var(--muted);
}

.mfa-badge--on {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--accent-dark);
}

.mfa-help {
    font-size: 12.5px;
    color: var(--muted);
    margin-top: -4px;
}

.mfa-danger {
    color: var(--danger);
}

.mfa-inline-form {
    text-align: center;
}

.auth-link-button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-weight: 500;
    color: var(--primary);
    cursor: pointer;
}

.auth-link-button:hover {
    text-decoration: underline;
}

@media (max-width: 360px) {
    .mfa-codes {
        grid-template-columns: 1fr;
    }
}
