/* ==========================================================================
   Payment Gateway Dashboard — Authentication Pages
   Dark theme, fintech professional design
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ---------- Design Tokens ---------- */
:root {
    --auth-bg: #020617;
    --auth-surface: rgba(15, 23, 42, 0.7);
    --auth-surface-solid: #0f172a;
    --auth-input-bg: #1e293b;
    --auth-border: #334155;
    --auth-border-focus: #3b82f6;
    --auth-text: #f8fafc;
    --auth-text-secondary: #94a3b8;
    --auth-text-muted: #64748b;
    --auth-accent: #3b82f6;
    --auth-accent-hover: #2563eb;
    --auth-accent-glow: rgba(59, 130, 246, 0.25);
    --auth-green: #22c55e;
    --auth-green-muted: rgba(34, 197, 94, 0.15);
    --auth-destructive: #ef4444;
    --auth-destructive-muted: rgba(239, 68, 68, 0.12);
    --auth-warning: #f59e0b;
    --auth-warning-muted: rgba(245, 158, 11, 0.12);
    --auth-radius: 12px;
    --auth-radius-sm: 8px;
    --auth-radius-xs: 6px;
    --auth-transition: 200ms ease;
    --auth-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ---------- Reset for Auth Pages ---------- */
.auth-page *,
.auth-page *::before,
.auth-page *::after {
    box-sizing: border-box;
}

/* ---------- Page Background ---------- */
.auth-page {
    font-family: var(--auth-font);
    background: var(--auth-bg);
    color: var(--auth-text);
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle grid pattern overlay */
.auth-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 25% 25%, rgba(59, 130, 246, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(34, 197, 94, 0.03) 0%, transparent 50%);
    pointer-events: none;
}

/* Geometric accent — top-left glow */
.auth-page::after {
    content: '';
    position: absolute;
    top: -200px;
    left: -200px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

/* ---------- Auth Card ---------- */
.auth-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--auth-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    padding: 40px 36px 36px;
    z-index: 1;
}

/* Top accent line */
.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 24px;
    right: 24px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--auth-accent), var(--auth-green), transparent);
    border-radius: 2px;
}

/* ---------- Logo / Brand ---------- */
.auth-brand {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--auth-accent), #1d4ed8);
    border-radius: var(--auth-radius-sm);
    margin-bottom: 16px;
}

.auth-logo svg {
    width: 28px;
    height: 28px;
    color: #fff;
}

.auth-brand-name {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--auth-text);
    margin: 0 0 4px;
    line-height: 1.2;
}

.auth-brand-subtitle {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--auth-text-muted);
    margin: 0;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ---------- Page Title ---------- */
.auth-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--auth-text);
    margin: 0 0 8px;
    text-align: center;
}

.auth-description {
    font-size: 0.875rem;
    color: var(--auth-text-secondary);
    margin: 0 0 24px;
    text-align: center;
    line-height: 1.5;
}

/* ---------- Form Groups ---------- */
.auth-form-group {
    margin-bottom: 20px;
    position: relative;
}

.auth-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--auth-text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

/* Input wrapper for icon placement */
.auth-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-icon {
    position: absolute;
    left: 12px;
    width: 18px;
    height: 18px;
    color: var(--auth-text-muted);
    pointer-events: none;
    transition: color var(--auth-transition);
}

.auth-input {
    width: 100%;
    padding: 11px 12px 11px 40px;
    background: var(--auth-input-bg);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-xs);
    color: var(--auth-text);
    font-family: var(--auth-font);
    font-size: 0.9375rem;
    line-height: 1.5;
    outline: none;
    transition: border-color var(--auth-transition), box-shadow var(--auth-transition);
}

.auth-input::placeholder {
    color: var(--auth-text-muted);
}

.auth-input:focus {
    border-color: var(--auth-border-focus);
    box-shadow: 0 0 0 3px var(--auth-accent-glow);
}

.auth-input:focus ~ .auth-input-icon {
    color: var(--auth-accent);
}

/* Input without icon */
.auth-input--no-icon {
    padding-left: 12px;
}

/* Password toggle */
.auth-password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--auth-text-muted);
    border-radius: var(--auth-radius-xs);
    transition: color var(--auth-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-password-toggle:hover {
    color: var(--auth-text-secondary);
}

.auth-password-toggle:focus-visible {
    outline: 2px solid var(--auth-accent);
    outline-offset: 2px;
}

.auth-password-toggle svg {
    width: 18px;
    height: 18px;
}

/* ---------- Validation / Errors ---------- */
.auth-field-error {
    display: flex;
    align-items: flex-start;
    gap: 5px;
    margin-top: 6px;
    font-size: 0.8125rem;
    color: var(--auth-destructive);
    line-height: 1.4;
}

.auth-field-error svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    margin-top: 1px;
}

.auth-error-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: var(--auth-destructive-muted);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--auth-radius-xs);
    margin-bottom: 20px;
    font-size: 0.8125rem;
    color: #fca5a5;
    line-height: 1.5;
}

.auth-error-banner svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--auth-destructive);
    margin-top: 1px;
}

.auth-error-banner ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ---------- Form Options Row ---------- */
.auth-options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 8px;
}

/* Remember me checkbox */
.auth-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: var(--auth-text-secondary);
    cursor: pointer;
    user-select: none;
}

.auth-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--auth-border);
    border-radius: 4px;
    background: var(--auth-input-bg);
    cursor: pointer;
    position: relative;
    transition: background var(--auth-transition), border-color var(--auth-transition);
    flex-shrink: 0;
}

.auth-checkbox:checked {
    background: var(--auth-accent);
    border-color: var(--auth-accent);
}

.auth-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 4.5px;
    top: 1.5px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.auth-checkbox:focus-visible {
    outline: 2px solid var(--auth-accent);
    outline-offset: 2px;
}

/* ---------- Links ---------- */
.auth-link {
    font-size: 0.8125rem;
    color: var(--auth-accent);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--auth-transition);
}

.auth-link:hover {
    color: var(--auth-text);
    text-decoration: underline;
}

.auth-link:focus-visible {
    outline: 2px solid var(--auth-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ---------- Primary Button ---------- */
.auth-btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    background: var(--auth-accent);
    color: #fff;
    border: none;
    border-radius: var(--auth-radius-xs);
    font-family: var(--auth-font);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--auth-transition), box-shadow var(--auth-transition), transform 100ms ease;
    min-height: 44px;
}

.auth-btn-primary:hover:not(:disabled) {
    background: var(--auth-accent-hover);
    box-shadow: 0 4px 16px var(--auth-accent-glow);
}

.auth-btn-primary:active:not(:disabled) {
    transform: scale(0.985);
}

.auth-btn-primary:focus-visible {
    outline: 2px solid var(--auth-accent);
    outline-offset: 2px;
}

.auth-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Spinner inside button */
.auth-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: auth-spin 0.6s linear infinite;
}

@keyframes auth-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Secondary / Ghost Button ---------- */
.auth-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: transparent;
    color: var(--auth-text-secondary);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-xs);
    font-family: var(--auth-font);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--auth-transition), color var(--auth-transition), border-color var(--auth-transition);
    min-height: 44px;
}

.auth-btn-secondary:hover {
    background: var(--auth-input-bg);
    color: var(--auth-text);
    border-color: var(--auth-text-muted);
}

.auth-btn-secondary:focus-visible {
    outline: 2px solid var(--auth-accent);
    outline-offset: 2px;
}

/* ---------- Divider ---------- */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
    color: var(--auth-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--auth-border);
}

/* ---------- Footer Links ---------- */
.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.8125rem;
    color: var(--auth-text-muted);
}

.auth-footer a {
    color: var(--auth-accent);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.auth-footer a:focus-visible {
    outline: 2px solid var(--auth-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ---------- Security Badge ---------- */
.auth-security-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 32px;
    font-size: 0.75rem;
    color: var(--auth-text-muted);
    letter-spacing: 0.02em;
}

.auth-security-badge svg {
    width: 14px;
    height: 14px;
    color: var(--auth-green);
}

/* ---------- MFA: OTP Digit Boxes ---------- */
.auth-otp-group {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
}

.auth-otp-input {
    width: 48px;
    height: 56px;
    text-align: center;
    font-family: var(--auth-font);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--auth-text);
    background: var(--auth-input-bg);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-xs);
    outline: none;
    transition: border-color var(--auth-transition), box-shadow var(--auth-transition);
    caret-color: var(--auth-accent);
}

.auth-otp-input:focus {
    border-color: var(--auth-border-focus);
    box-shadow: 0 0 0 3px var(--auth-accent-glow);
}

.auth-otp-input.filled {
    border-color: var(--auth-accent);
}

/* Hidden real input for form binding */
.auth-otp-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* ---------- MFA: Mode Toggle ---------- */
.auth-mode-toggle {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--auth-border);
}

/* ---------- Lockout: Icon ---------- */
.auth-lockout-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: var(--auth-destructive-muted);
    border-radius: 50%;
}

.auth-lockout-icon svg {
    width: 32px;
    height: 32px;
    color: var(--auth-destructive);
}

.auth-lockout-icon--warning {
    background: var(--auth-warning-muted);
}

.auth-lockout-icon--warning svg {
    color: var(--auth-warning);
}

/* ---------- Lockout: Message ---------- */
.auth-lockout-message {
    font-size: 0.875rem;
    color: var(--auth-text-secondary);
    text-align: center;
    line-height: 1.6;
    margin-bottom: 28px;
}

/* ---------- Info Banner ---------- */
.auth-info-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: var(--auth-radius-xs);
    margin-bottom: 20px;
    font-size: 0.8125rem;
    color: #93c5fd;
    line-height: 1.5;
}

.auth-info-banner svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--auth-accent);
    margin-top: 1px;
}

/* ---------- Password Strength Meter ---------- */
.auth-strength-meter {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.auth-strength-bar {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--auth-border);
    transition: background 200ms ease;
}

.auth-strength-bar.active-weak { background: #ef4444; }
.auth-strength-bar.active-fair { background: #f59e0b; }
.auth-strength-bar.active-good { background: #3b82f6; }
.auth-strength-bar.active-strong { background: #22c55e; }

.auth-strength-label {
    font-size: 0.75rem;
    margin-top: 4px;
    font-weight: 500;
}

.auth-strength-label--weak { color: #ef4444; }
.auth-strength-label--fair { color: #f59e0b; }
.auth-strength-label--good { color: #3b82f6; }
.auth-strength-label--strong { color: #22c55e; }

.auth-strength-requirements {
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--auth-text-muted);
    line-height: 1.6;
}

.auth-strength-requirements span {
    display: block;
}

.auth-strength-requirements .met { color: #22c55e; }
.auth-strength-requirements .unmet { color: var(--auth-text-muted); }

/* ---------- Remember Me Tooltip ---------- */
.auth-tooltip-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.auth-tooltip-icon {
    width: 14px;
    height: 14px;
    color: var(--auth-text-muted);
    cursor: help;
    margin-left: 4px;
}

.auth-tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--auth-surface-solid, #0f172a);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-xs);
    padding: 8px 12px;
    font-size: 0.75rem;
    color: var(--auth-text-secondary);
    white-space: nowrap;
    z-index: 10;
    transition: opacity 150ms ease, visibility 150ms ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.auth-tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--auth-border) transparent transparent transparent;
}

.auth-tooltip-wrapper:hover .auth-tooltip-text,
.auth-tooltip-wrapper:focus-within .auth-tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* ---------- Cookie Consent Banner ---------- */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: var(--auth-surface-solid, #0f172a);
    border-top: 1px solid var(--auth-border, #334155);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 0.8125rem;
    color: var(--auth-text-secondary, #94a3b8);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
    animation: consent-slide-up 300ms ease-out;
}

@keyframes consent-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.cookie-consent__text {
    max-width: 600px;
    line-height: 1.5;
}

.cookie-consent__text a {
    color: var(--auth-accent, #3b82f6);
    text-decoration: none;
}

.cookie-consent__text a:hover {
    text-decoration: underline;
}

.cookie-consent__accept {
    padding: 8px 20px;
    background: var(--auth-accent, #3b82f6);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 200ms ease;
    font-family: inherit;
}

.cookie-consent__accept:hover {
    background: #2563eb;
}

/* ---------- Session Timeout Modal ---------- */
.session-timeout-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.session-timeout-card {
    background: var(--color-surface-raised, #1e293b);
    border: 1px solid var(--color-border-subtle, #334155);
    border-radius: 12px;
    padding: 32px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.session-timeout-icon {
    width: 48px;
    height: 48px;
    color: var(--color-warning, #f59e0b);
    margin: 0 auto 16px;
}

.session-timeout-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text, #f1f5f9);
    margin: 0 0 8px;
}

.session-timeout-message {
    font-size: 0.875rem;
    color: var(--color-text-secondary, #94a3b8);
    margin: 0 0 8px;
    line-height: 1.5;
}

.session-timeout-countdown {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-warning, #f59e0b);
    margin: 12px 0 20px;
    font-variant-numeric: tabular-nums;
}

.session-timeout-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.session-timeout-actions .btn-extend {
    padding: 10px 24px;
    background: var(--brand-primary, #3b82f6);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.session-timeout-actions .btn-extend:hover {
    background: #2563eb;
}

.session-timeout-actions .btn-logout {
    padding: 10px 24px;
    background: transparent;
    color: var(--color-text-muted, #64748b);
    border: 1px solid var(--color-border-subtle, #334155);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.session-timeout-actions .btn-logout:hover {
    background: rgba(255,255,255,0.05);
    color: var(--color-text, #f1f5f9);
}

/* ---------- Last Login Banner ---------- */
.last-login-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(59, 130, 246, 0.06);
    border-bottom: 1px solid var(--color-border, #1e293b);
    font-size: 0.75rem;
    color: var(--color-text-muted, #64748b);
}

.last-login-banner svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.last-login-banner__dismiss {
    background: none;
    border: none;
    color: var(--color-text-muted, #64748b);
    cursor: pointer;
    padding: 2px;
    margin-left: 8px;
    display: flex;
}

.last-login-banner__dismiss:hover {
    color: var(--color-text, #f1f5f9);
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .auth-page {
        padding: 16px;
    }

    .auth-card {
        padding: 32px 24px 28px;
        border-radius: var(--auth-radius-sm);
    }

    .auth-otp-input {
        width: 42px;
        height: 50px;
        font-size: 1.25rem;
    }

    .auth-otp-group {
        gap: 6px;
    }
}

@media (max-width: 360px) {
    .auth-otp-input {
        width: 38px;
        height: 46px;
        font-size: 1.125rem;
    }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .auth-spinner {
        animation-duration: 1.5s;
    }

    .auth-input,
    .auth-btn-primary,
    .auth-btn-secondary,
    .auth-link,
    .auth-password-toggle,
    .auth-input-icon {
        transition: none;
    }

    .auth-btn-primary:active:not(:disabled) {
        transform: none;
    }
}
