/**
 * auth.css - Authentication Pages Styling
 * Version: 4.0 - Aligned with SaaS Design System (styles.css v11.0)
 * Only loaded on login.php, register.php, verify.php, and similar standalone auth pages.
 * Tokens are re-declared here so auth pages remain self-contained (no styles.css needed).
 */

/* ========================================================================
   CSS VARIABLES — Mirrors styles.css v11.0 design tokens exactly
   ======================================================================== */
:root {
    /* Brand */
    --brand-primary:    #2563eb;
    --brand-dark:       #1e40af;
    --brand-light:      #eff6ff;

    /* Text */
    --text-primary:     #0f172a;
    --text-secondary:   #475569;
    --text-muted:       #9ca3af;

    /* Backgrounds */
    --bg-primary:       #ffffff;
    --bg-secondary:     #f8fafc;

    /* Borders */
    --border-light:     #e5e7eb;

    /* Radius */
    --radius-sm:  6px;
    --radius-md:  8px;
    --radius-lg:  12px;
    --radius-xl:  16px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);

    /* Transitions */
    --transition-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Status */
    --success:      #059669;
    --success-bg:   #ecfdf5;
    --success-text: #065f46;
    --warning:      #d97706;
    --warning-bg:   #fffbeb;
    --warning-text: #92400e;
    --danger:       #dc2626;
    --danger-bg:    #fef2f2;
    --danger-text:  #991b1b;
    --info:         #0284c7;
    --info-bg:      #f0f9ff;
    --info-text:    #075985;
}

/* ========================================================================
   BASE
   ======================================================================== */
body.auth-page {
    background: var(--bg-secondary);
    min-height: 100vh;
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================================================
   LAYOUT
   ======================================================================== */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-wrapper {
    width: 100%;
    max-width: 448px;
}

/* ========================================================================
   CARD
   ======================================================================== */
.auth-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.auth-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

/* ========================================================================
   HEADER — Clean flat design with top brand accent
   ======================================================================== */
.auth-header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    border-top: 3px solid var(--brand-primary);
    padding: 2rem 2rem 1.5rem;
    text-align: center;
}

.auth-logo {
    margin-bottom: 1rem;
}

.auth-logo .logo-img {
    height: 40px;
    width: auto;
}

.auth-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.375rem 0;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.auth-header p {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ========================================================================
   BODY
   ======================================================================== */
.auth-body {
    padding: 2rem;
    background: var(--bg-primary);
}

/* ========================================================================
   FORM — Matches styles.css form design
   ======================================================================== */
.form-floating {
    position: relative;
    margin-bottom: 1.25rem;
}

.form-floating > .form-control,
.form-floating > .form-select {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    font-weight: 400;
    color: #111827;
    line-height: 1.5;
    box-shadow: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    height: auto;
    min-height: 48px;
}

.form-floating > .form-control:focus,
.form-floating > .form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
    outline: none;
    background: #ffffff;
}

.form-floating > label {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 0.625rem 0.875rem;
    pointer-events: none;
    border: 1px solid transparent;
    transform-origin: 0 0;
    transition: var(--transition-fast);
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.9375rem;
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label,
.form-floating > .form-select:focus ~ label,
.form-floating > .form-select:not([value=""]):valid ~ label,
.form-floating > .form-control.has-value ~ label {
    transform: scale(0.8) translateY(-0.5rem) translateX(0.1rem);
    padding: 0.2rem 0.4rem;
    background: #ffffff;
    border-radius: 4px;
    color: var(--brand-primary);
    font-weight: 500;
    font-size: 0.9375rem;
}

.form-floating > .form-control:not(:placeholder-shown)::placeholder,
.form-floating > .form-control:focus::placeholder,
.form-floating input::placeholder {
    color: transparent !important;
    opacity: 0 !important;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.375rem;
    display: block;
}

.form-control,
.form-select {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    font-weight: 400;
    color: #111827;
    line-height: 1.5;
    box-shadow: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
    outline: none;
    background: #ffffff;
}

.form-control::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.form-text {
    font-size: 0.8125rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* ========================================================================
   PASSWORD TOGGLE
   ======================================================================== */
.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    z-index: 10;
    padding: 0.375rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: color var(--transition-fast), background var(--transition-fast);
    line-height: 1;
}

.password-toggle:hover {
    color: var(--brand-primary);
    background: var(--brand-light);
}

/* ========================================================================
   BUTTONS — Flat solid colors matching styles.css .btn-primary
   ======================================================================== */
.auth-body .btn {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: var(--radius-md);
    padding: 0.5rem 1.25rem;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    line-height: 1;
    transition: background var(--transition-fast), border-color var(--transition-fast),
                box-shadow var(--transition-fast), transform var(--transition-fast);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}

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

.auth-body .btn-primary {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}

.auth-body .btn-primary:hover,
.auth-body .btn-primary:focus {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.auth-body .btn-primary:active {
    transform: translateY(1px);
}

.auth-body .btn-outline-primary {
    background: transparent;
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.auth-body .btn-outline-primary:hover {
    background: var(--brand-light);
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.auth-body .btn-outline-success {
    background: transparent;
    border-color: var(--success);
    color: var(--success);
}

.auth-body .btn-outline-success:hover {
    background: var(--success-bg);
    color: var(--success);
}

/* Loading state */
.btn.loading {
    position: relative;
    color: transparent !important;
    cursor: not-allowed;
    pointer-events: none;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
}

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

/* ========================================================================
   FORM VALIDATION
   ======================================================================== */
.was-validated .form-control:invalid,
.form-control.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

.was-validated .form-control:valid,
.form-control.is-valid {
    border-color: var(--success);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.08);
}

.invalid-feedback {
    font-size: 0.8125rem;
    font-weight: 500;
    margin-top: 0.375rem;
    color: var(--danger);
}

.valid-feedback {
    font-size: 0.8125rem;
    font-weight: 500;
    margin-top: 0.375rem;
    color: var(--success);
}

/* ========================================================================
   ALERTS — Matches styles.css SaaS override style
   ======================================================================== */
.auth-body .alert {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    border-left: none;
    margin-bottom: 1.25rem;
    padding: 0.875rem 1rem;
    font-size: 0.9rem;
    font-weight: 400;
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
}

.auth-body .alert-success {
    background: #f0fdf4;
    border-color: #d1fae5;
    color: var(--success-text);
}

.auth-body .alert-danger {
    background: var(--danger-bg);
    border-color: #fee2e2;
    color: var(--danger-text);
}

.auth-body .alert-warning {
    background: var(--warning-bg);
    border-color: #fde68a;
    color: var(--warning-text);
}

.auth-body .alert-info {
    background: var(--info-bg);
    border-color: #bae6fd;
    color: var(--info-text);
}

.auth-body .alert .alert-icon {
    flex-shrink: 0;
    font-size: 1rem;
    margin-top: 1px;
    opacity: 0.8;
}

/* ========================================================================
   REGISTER OPTION CARDS
   ======================================================================== */
.register-options {
    display: grid;
    gap: 0.875rem;
    margin-top: 1.25rem;
}

/* Register page flex card container */
.register-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.875rem;
    justify-content: center;
    margin-top: 1.25rem;
}

.register-cards .register-option-card {
    flex: 0 1 380px;
}

.register-option-card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
                transform var(--transition-fast);
    text-decoration: none;
    color: var(--text-primary);
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
}

.register-option-card:hover {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
    transform: translateY(-1px);
    color: var(--text-primary);
    text-decoration: none;
}

.register-option-card .icon {
    font-size: 2rem;
    color: var(--brand-primary);
    margin-bottom: 0.75rem;
    display: block;
}

.register-option-card h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.register-option-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

.register-option-card:hover h4 {
    color: var(--brand-primary);
}

/* ========================================================================
   REGISTRATION FORM PAGES — tester, reviewer, business
   ======================================================================== */

/* Wrapper for enabled registration pages (overrides sidebar margin) */
.auth-reg-page {
    margin-left: 0 !important;
    background: var(--bg-secondary);
    padding: 2rem 0 3rem;
    min-height: calc(100vh - 130px);
}

/* Full-page centered notice when registration is disabled */
.auth-reg-closed {
    margin-left: 0 !important;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    text-align: center;
    padding: 2rem;
    overflow: hidden;
}

.auth-reg-closed-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 3rem 3.5rem;
    max-width: 480px;
    width: 100%;
}

.auth-reg-closed-card .bi {
    font-size: 3.5rem;
}

.auth-reg-closed-card h4 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.auth-reg-closed-card p {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ========================================================================
   LINKS & TEXT
   ======================================================================== */
.auth-body a {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.auth-body a:hover {
    color: var(--brand-dark);
}

.auth-footer-text {
    text-align: center;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.divider {
    display: flex;
    align-items: center;
    margin: 1.25rem 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

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

.divider::before { margin-right: 0.875rem; }
.divider::after  { margin-left:  0.875rem; }

/* ========================================================================
   CHECKBOXES & RADIOS
   ======================================================================== */
.form-check { margin-bottom: 0.875rem; }

.form-check-input {
    border: 1px solid var(--border-light);
    border-radius: 4px;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.form-check-input:checked {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.form-check-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

.form-check-label {
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 400;
    cursor: pointer;
}

/* ========================================================================
   VERIFICATION PAGE (verify.php)
   ======================================================================== */
.verification-card {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.verification-section {
    padding: 1.25rem;
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    margin-bottom: 1.25rem;
}

.verification-icon {
    font-size: 3rem;
    color: var(--brand-primary);
}

.verified-badge {
    background-color: var(--success);
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    display: inline-block;
    font-size: 0.875rem;
    font-weight: 500;
}

.pending-badge {
    background-color: var(--warning);
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    display: inline-block;
    font-size: 0.875rem;
    font-weight: 500;
}

.pending-approval-card {
    background: linear-gradient(135deg, var(--info-bg) 0%, #bbdefb 100%);
    border: none;
    border-radius: var(--radius-lg);
}

.pending-approval-icon {
    font-size: 5rem;
    color: var(--info);
}

#phoneVerifyStep2 {
    animation: auth-fadeIn 0.3s ease-in;
}

@keyframes auth-fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ========================================================================
   RESPONSIVE
   ======================================================================== */
@media (max-width: 1023px) {
    .auth-container { padding: 1.5rem 1rem; }
    .auth-header    { padding: 1.75rem 1.75rem 1.25rem; }
    .auth-body      { padding: 1.75rem; }
}

@media (max-width: 767px) {
    .auth-container { padding: 1rem 0.5rem; }

    .auth-header { padding: 1.5rem 1.25rem 1rem; }
    .auth-header h1 { font-size: 1.375rem; }

    .auth-body { padding: 1.5rem 1.25rem; }

    .form-floating { margin-bottom: 1rem; }

    .form-floating > .form-control,
    .form-floating > .form-select,
    .form-control,
    .form-select {
        font-size: 16px !important; /* prevent iOS zoom */
        min-height: 44px;
    }

    .auth-body .btn {
        width: 100%;
        height: 44px;
        font-size: 0.9375rem;
    }

    .register-options { gap: 0.75rem; }
    .register-options { grid-template-columns: 1fr !important; }

    .register-cards .register-option-card { flex: 0 1 100%; }

    .register-option-card {
        padding: 1rem;
    }

    .register-option-card .icon { font-size: 1.75rem; }
    .register-option-card h4   { font-size: 0.9375rem; }
}

@media (max-width: 575px) {
    .auth-container { padding: 0.5rem 0.25rem; }

    .auth-header { padding: 1.25rem 1rem 0.875rem; }
    .auth-header h1 { font-size: 1.25rem; }

    .auth-body { padding: 1.25rem 1rem; }

    .register-option-card { padding: 0.875rem; }
    .register-option-card .icon { font-size: 1.5rem; }
    .register-option-card p { font-size: 0.8125rem; }
}

/* ========================================================================
   ACCESSIBILITY
   ======================================================================== */
.form-control:focus-visible,
.form-select:focus-visible,
.btn:focus-visible,
.form-check-input:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: high) {
    :root {
        --border-light:  #000000;
        --text-muted:    #333333;
        --brand-primary: #1d4ed8;
    }

    .form-control,
    .form-select {
        border-width: 2px;
    }
}

/* ========================================================================
   PRINT
   ======================================================================== */
@media print {
    .auth-container { padding: 0; background: white; }
    .auth-card { box-shadow: none; border: 1px solid #000; }
    .auth-header { border-top: 3px solid #000; }
    .btn { border: 1px solid #000; background: white; color: black; }
}
