/*
 * auth.css
 * ServiceProStream — Auth layout styles
 *
 * Extracted from the inline <style> block in views/layouts/auth.php and
 * extended with semantic component classes that replace every inline style=""
 * attribute across the auth view partials.
 *
 * ── Table of contents ───────────────────────────────────────────────────
 *
 *   1.  CSS custom properties (design tokens)
 *   2.  Reset / base
 *   3.  Layout  (.auth-wrapper)
 *   4.  Brand   (.auth-brand)
 *   5.  Card    (.auth-card)
 *   6.  Form controls
 *   7.  Input group (password toggle)
 *   8.  Buttons  (.btn-sps-primary, .btn-sps-ghost)
 *   9.  Divider  (.auth-divider)
 *  10.  Footer   (.auth-footer)
 *  11.  Alerts   (.alert-auth, .alert-*-auth)
 *  12.  Password strength bar (.pw-strength, .pw-strength--*)
 *  13.  Backup codes (.backup-codes-grid, .backup-code)
 *  14.  TOTP input (.totp-input)
 *  15.  Honeypot (.hp-wrapper)
 *  16.  State modifiers  (.auth-card--wide, .auth-card--centered)
 *  17.  Icon display  (.auth-icon)
 *  18.  Setup page  (.setup-steps, .setup-qr-wrapper, .setup-manual)
 *  19.  Status page  (.auth-status, .auth-status--success, --danger)
 *  20.  Inline link variant  (.auth-link-muted, .auth-link-back)
 *  21.  Check-email steps  (.check-email-steps)
 *  22.  2FA verify footer  (.tfa-footer)
 *  23.  Terms notice  (.terms-notice)
 *  24.  Forgot password sent state  (.forgot-sent)
 *  25.  Media queries
 *
 * ── Naming conventions ──────────────────────────────────────────────────
 *
 *   .auth-*         Top-level layout / wrapper elements
 *   .btn-sps-*      SPS branded button variants
 *   .pw-*           Password-strength component
 *   .setup-*        2FA setup page specific
 *   .tfa-*          2FA verify page specific
 *   .check-*        Check-email page specific
 *   Bootstrap utility classes (d-flex, gap-2, mb-3, text-center …) are
 *   used for trivial one-property overrides to avoid class proliferation.
 */

/* =========================================================================
   1. CSS custom properties
   ========================================================================= */

:root {
    --sps-bg:       #0d1117;
    --sps-surface:  #161b22;
    --sps-border:   #30363d;
    --sps-accent:   #2f81f7;
    --sps-accent-h: #1f6feb;
    --sps-text:     #e6edf3;
    --sps-muted:    #8b949e;
    --sps-success:  #238636;
    --sps-danger:   #da3633;

    /* Derived semantic tokens — keeps view code readable */
    --sps-danger-text:    #f85149;
    --sps-success-text:   #3fb950;
    --sps-accent-text:    #58a6ff;
}

/* =========================================================================
   2. Reset / base
   ========================================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    background: var(--sps-bg);
    color: var(--sps-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

/* =========================================================================
   3. Layout
   ========================================================================= */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

/* =========================================================================
   4. Brand
   ========================================================================= */

.auth-brand {
    text-align: center;
    margin-bottom: 28px;
}

.auth-brand .brand-icon {
    width: 48px;
    height: 48px;
    background: var(--sps-accent);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    margin-bottom: 12px;
}

.auth-brand h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--sps-text);
    margin: 0;
    letter-spacing: -0.3px;
}

.auth-brand p {
    color: var(--sps-muted);
    font-size: 13px;
    margin: 4px 0 0;
}

/* =========================================================================
   5. Card
   ========================================================================= */

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--sps-surface);
    border: 1px solid var(--sps-border);
    border-radius: 12px;
    padding: 32px;
}

/** Wider variant — used by 2FA setup which needs more room for QR + inputs */
.auth-card--wide {
    max-width: 520px;
}

/** Centred variant — used by status-only pages (check-email, verify-email) */
.auth-card--centered {
    text-align: center;
}

.auth-card h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 6px;
    color: var(--sps-text);
}

.auth-card .subtitle {
    font-size: 14px;
    color: var(--sps-muted);
    margin: 0 0 24px;
}

/* =========================================================================
   6. Form controls
   ========================================================================= */

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--sps-text);
    margin-bottom: 6px;
}

.form-control,
.form-select {
    background: var(--sps-bg);
    border: 1px solid var(--sps-border);
    border-radius: 8px;
    color: var(--sps-text);
    font-size: 15px;
    padding: 10px 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus,
.form-select:focus {
    background: var(--sps-bg);
    border-color: var(--sps-accent);
    box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.2);
    color: var(--sps-text);
}

.form-control.is-invalid {
    border-color: var(--sps-danger);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(218, 54, 51, 0.2);
}

.invalid-feedback {
    font-size: 12px;
    color: var(--sps-danger-text);
}

/* Center-aligned feedback — used by 2FA verify */
.invalid-feedback--center {
    text-align: center;
}

/* Center-aligned form label — used by 2FA verify */
.form-label--center {
    display: block;
    text-align: center;
}

/* =========================================================================
   7. Input group (password visibility toggle)
   ========================================================================= */

.input-group .form-control {
    border-right: none;
}

.input-group .btn-outline-secondary {
    border-color: var(--sps-border);
    border-left: none;
    border-radius: 0 8px 8px 0;
    color: var(--sps-muted);
    background: var(--sps-bg);
}

.input-group .btn-outline-secondary:hover {
    color: var(--sps-text);
    background: #21262d;
}

/* =========================================================================
   8. Buttons
   ========================================================================= */

.btn-sps-primary {
    background: var(--sps-accent);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    padding: 11px 24px;
    width: 100%;
    transition: background 0.15s, transform 0.05s;
    cursor: pointer;
    display: block;
    text-align: center;
    text-decoration: none;
}

.btn-sps-primary:hover  { background: var(--sps-accent-h); }
.btn-sps-primary:active { transform: scale(0.99); }

.btn-sps-primary:disabled,
.btn-sps-primary[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

/**
 * Ghost variant — secondary actions (copy codes, print) on the 2FA setup page.
 * Replaces the previous pattern of overriding btn-sps-primary with two
 * inline style properties.
 */
.btn-sps-ghost {
    background: #21262d;
    border: 1px solid var(--sps-border);
    border-radius: 8px;
    color: var(--sps-text);
    font-size: 15px;
    font-weight: 600;
    padding: 11px 24px;
    cursor: pointer;
    transition: background 0.15s;
    text-align: center;
}

.btn-sps-ghost:hover  { background: #30363d; }
.btn-sps-ghost:active { transform: scale(0.99); }

/**
 * Inline variant — fixed-width, auto-width button used as a link.
 * Used for the "Sign in now" and "Request new reset link" CTAs on
 * status-only pages where the full-width primary is inappropriate.
 */
.btn-sps-primary--inline {
    display: inline-block;
    width: auto;
    margin-top: 16px;
    padding: 11px 32px;
}

/* =========================================================================
   9. Divider
   ========================================================================= */

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--sps-muted);
    font-size: 12px;
}

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

/* =========================================================================
   10. Footer
   ========================================================================= */

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--sps-muted);
}

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

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

/* =========================================================================
   11. Alerts
   ========================================================================= */

.alert-auth {
    border-radius: 8px;
    font-size: 13px;
    padding: 12px 16px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-danger-auth {
    background: rgba(218, 54, 51, 0.15);
    border-color: rgba(218, 54, 51, 0.4);
    color: var(--sps-danger-text);
}

.alert-success-auth {
    background: rgba(35, 134, 54, 0.15);
    border-color: rgba(35, 134, 54, 0.4);
    color: var(--sps-success-text);
}

.alert-info-auth {
    background: rgba(47, 129, 247, 0.1);
    border-color: rgba(47, 129, 247, 0.3);
    color: var(--sps-accent-text);
}

/* =========================================================================
   12. Password strength bar
   ========================================================================= */

.pw-strength {
    height: 4px;
    width: 0%;                       /* JS-controlled width */
    border-radius: 2px;
    margin-top: 6px;
    background: var(--sps-border);   /* default / empty state */
    transition: width 0.3s, background 0.3s;
}

/* Named colour states — applied by JS via data-pw-score attribute */
.pw-strength[data-pw-score="1"] { background: var(--sps-danger);  width: 20%; }
.pw-strength[data-pw-score="2"] { background: #e3b341;             width: 40%; }
.pw-strength[data-pw-score="3"] { background: #e3b341;             width: 60%; }
.pw-strength[data-pw-score="4"] { background: var(--sps-success);  width: 80%; }
.pw-strength[data-pw-score="5"] { background: var(--sps-success);  width: 100%; }

/* =========================================================================
   13. Backup codes
   ========================================================================= */

.backup-codes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 16px 0;
}

.backup-code {
    background: var(--sps-bg);
    border: 1px solid var(--sps-border);
    border-radius: 6px;
    padding: 8px 12px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 13px;
    text-align: center;
    letter-spacing: 1px;
}

/* =========================================================================
   14. TOTP input
   ========================================================================= */

.totp-input {
    font-size: 28px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    letter-spacing: 8px;
    text-align: center;
    padding: 14px;
}

/* =========================================================================
   15. Honeypot
   ========================================================================= */

.hp-wrapper {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

/* =========================================================================
   16. Auth icon (large emoji / icon on status pages)
   ========================================================================= */

/**
 * Large decorative icon used on status-only pages:
 *   check-email, verify-email, forgot-password (sent), reset-password (expired)
 * Replaces inline font-size + margin-bottom on every page that shows one.
 */
.auth-icon {
    font-size: 52px;
    display: block;
    margin-bottom: 16px;
    line-height: 1;
}

/* Slightly smaller on the 2FA setup success page */
.auth-icon--lg {
    font-size: 40px;
    margin-bottom: 12px;
}

/* =========================================================================
   17. Status headings (success / danger colour variants)
   ========================================================================= */

.auth-heading--success { color: var(--sps-success-text); }
.auth-heading--danger  { color: var(--sps-danger-text);  }

/* Inline error text used below the heading on the expired-token page */
.auth-error-text {
    font-size: 13px;
    color: var(--sps-danger-text);
}

/* =========================================================================
   18. 2FA Setup page components
   ========================================================================= */

/** Numbered instruction steps */
.setup-steps {
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--sps-muted);
}

.setup-steps__item {
    margin-bottom: 8px;
}

.setup-steps__item:last-child {
    margin-bottom: 0;
}

.setup-steps__number {
    color: var(--sps-accent);
    font-weight: 600;
}

/** QR code display area */
.setup-qr-wrapper {
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    background: var(--sps-bg);
    border: 1px solid var(--sps-border);
    border-radius: 8px;
}

.setup-qr-wrapper img {
    width: 200px;
    height: 200px;
    border-radius: 6px;
    image-rendering: pixelated;
}

/** Collapsible manual-entry section */
.setup-manual {
    margin-bottom: 20px;
}

.setup-manual summary {
    font-size: 13px;
    color: var(--sps-muted);
    cursor: pointer;
}

.setup-manual__body {
    margin-top: 10px;
    padding: 12px;
    background: var(--sps-bg);
    border-radius: 6px;
    border: 1px solid var(--sps-border);
}

.setup-manual__label {
    font-size: 11px;
    color: var(--sps-muted);
    margin-bottom: 4px;
}

.setup-manual__secret {
    font-size: 13px;
    letter-spacing: 2px;
    word-break: break-all;
    color: var(--sps-text);
}

/** Skip link below the confirm-code form */
.setup-skip {
    margin-top: 16px;
    text-align: center;
}

.setup-skip a {
    font-size: 13px;
    color: var(--sps-muted);
    text-decoration: none;
}

.setup-skip a:hover {
    color: var(--sps-text);
    text-decoration: underline;
}

/** Backup-code action buttons row */
.setup-backup-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

/** Checkbox row on the backup-codes confirmation */
.setup-backup-confirm {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    margin-bottom: 20px;
    font-size: 14px;
}

.setup-backup-confirm input[type="checkbox"] {
    margin-top: 3px;
    accent-color: var(--sps-accent);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* =========================================================================
   19. 2FA Verify page footer
   ========================================================================= */

.tfa-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--sps-border);
    text-align: center;
}

.tfa-footer__hint {
    font-size: 13px;
    color: var(--sps-muted);
    margin: 0;
}

.tfa-footer__back {
    font-size: 12px;
    color: var(--sps-muted);
    margin-top: 8px;
}

.tfa-footer__back a {
    color: var(--sps-muted);
    text-decoration: none;
}

.tfa-footer__back a:hover {
    color: var(--sps-text);
    text-decoration: underline;
}

/* =========================================================================
   20. Generic auth link variants
   ========================================================================= */

/** Muted back-link used at the bottom of forgot-password and reset-password */
.auth-link-back {
    display: block;
    margin-top: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--sps-muted);
    text-decoration: none;
}

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

/** Small accent link used inside paragraphs (e.g. "try again", "resend") */
.auth-link {
    color: var(--sps-accent);
    text-decoration: none;
}

.auth-link:hover {
    text-decoration: underline;
}

/* =========================================================================
   21. Check-email steps
   ========================================================================= */

.check-email-steps {
    text-align: left;
    margin-top: 24px;
}

.check-email-steps ol {
    margin: 8px 0 0;
    padding-left: 20px;
}

/* =========================================================================
   22. Check-email / forgot-password "sent" state helpers
   ========================================================================= */

.forgot-sent__retry {
    font-size: 13px;
    color: var(--sps-muted);
    margin-top: 16px;
}

.check-email-resend {
    font-size: 13px;
    color: var(--sps-muted);
    margin-top: 20px;
}

/* =========================================================================
   23. Terms / legal notice (register page)
   ========================================================================= */

.terms-notice {
    font-size: 11px;
    color: var(--sps-muted);
    text-align: center;
    margin-top: 12px;
}

.terms-notice a {
    color: var(--sps-accent);
    text-decoration: none;
}

.terms-notice a:hover {
    text-decoration: underline;
}

/* =========================================================================
   24. Login page — forgot password link
   ========================================================================= */

.forgot-link {
    font-size: 12px;
    color: var(--sps-accent);
    text-decoration: none;
}

.forgot-link:hover {
    text-decoration: underline;
}

/* =========================================================================
   25a. Border utility (sps-border colour, not Bootstrap default)
   ========================================================================= */

/**
 * Applies the --sps-border colour to Bootstrap's border-top utility.
 * Used in check-email.php where a divider separates the back-link from
 * the main content without needing an inline style override.
 */
.border-top-sps {
    border-top: 1px solid var(--sps-border) !important;
}

/* =========================================================================
   25. Media queries
   ========================================================================= */

@media (max-width: 480px) {
    .auth-card {
        padding: 24px 20px;
    }

    .setup-backup-actions {
        flex-direction: column;
    }
}

/* =========================================================================
   26. AJAX flash messages (.sps-flash, .sps-alert--*)
   =========================================================================
   Rendered by SPS.showFlash() in core.js. Matches the dashboard flash
   component so behaviour is identical across layouts. Colour tokens use
   the auth `:root` variables; dimmed backgrounds use rgba() following the
   existing pattern in section 11 (alert-*-auth).
   ========================================================================= */

.sps-flash {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    animation: sps-slide-in 0.2s ease;
}

@keyframes sps-slide-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.sps-flash--dismissing {
    opacity: 0;
    transition: opacity 0.4s ease;
}

.sps-flash__text {
    flex: 1;
}

.sps-flash__close {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
}

.sps-flash__close:hover {
    opacity: 1;
}

.sps-alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid transparent;
}

.sps-alert--danger {
    background: rgba(218, 54, 51, 0.15);
    border-color: rgba(218, 54, 51, 0.4);
    color: var(--sps-danger-text);
}

.sps-alert--success {
    background: rgba(35, 134, 54, 0.15);
    border-color: rgba(35, 134, 54, 0.4);
    color: var(--sps-success-text);
}

.sps-alert--warning {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--sps-warning-text);
}

.sps-alert--info {
    background: rgba(47, 129, 247, 0.1);
    border-color: rgba(47, 129, 247, 0.3);
    color: var(--sps-accent-text);
}

/* =========================================================================
   27. Field-level error text (.sps-field-error)
   =========================================================================
   Used by auth.js AuthPage.showFieldErrors(). Placed next to each input
   via [data-field-error="<field>"] and toggled with d-none.
   ========================================================================= */

.sps-field-error {
    font-size: 13px;
    color: var(--sps-danger-text);
    margin-top: 4px;
}


/* =========================================================================
   28. Inline button-as-link (.btn-link-inline)
   =========================================================================
   Used on the check-email page where the resend action changed from an
   <a> tag (GET) to a <button> tag (AJAX POST). Resets button appearance
   to look like an inline text link — same colour/hover as .auth-link.
*/

.btn-link-inline {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: var(--sps-accent-text);
    text-decoration: none;
    cursor: pointer;
    display: inline;
    vertical-align: baseline;
}

.btn-link-inline:hover {
    text-decoration: underline;
    color: var(--sps-accent);
}

.btn-link-inline:disabled {
    color: var(--sps-muted);
    cursor: not-allowed;
    text-decoration: none;
}