/**
 * OneTimeLogin — Shared Auth SDK Base Styles
 * Pure CSS foundation for all auth pages across partner sites.
 * No external dependencies (no Tailwind, no icon libraries).
 *
 * Theme: driven by CSS custom properties, set dynamically by auth-base.js
 */

/* ============================================
   1. CSS Custom Properties (Dark mode default)
   ============================================ */
:root {
    --otl-primary: #2563eb;
    --otl-secondary: #1e40af;
    --otl-bg: #111827;
    --otl-card-bg: #1f2937;
    --otl-text: #f9fafb;
    --otl-text-muted: #9ca3af;
    --otl-border: #374151;
    --otl-error: #ef4444;
    --otl-success: #10b981;
    --otl-warning: #f59e0b;
    --otl-info: #3b82f6;
    --otl-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --otl-radius: 0.5rem;
    --otl-radius-lg: 0.75rem;
    --otl-radius-xl: 1rem;
    --otl-transition: 0.2s ease;
}

/* ============================================
   2. Light Mode (.otl-light on container)
   ============================================ */
.otl-light {
    --otl-bg: #f3f4f6;
    --otl-card-bg: #ffffff;
    --otl-text: #111827;
    --otl-text-muted: #6b7280;
    --otl-border: #d1d5db;
}

/* ============================================
   3. Reset & Base (scoped to .otl-container)
   ============================================ */
.otl-container *,
.otl-container *::before,
.otl-container *::after {
    box-sizing: border-box;
}

/* ============================================
   4. Layout — Full-page centered container
   ============================================ */
.otl-container {
    font-family: var(--otl-font);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--otl-bg);
    color: var(--otl-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   5. Card — Glassmorphism
   ============================================ */
.otl-card {
    width: 100%;
    max-width: 28rem;
    margin: 0 auto;
    background: rgba(31, 41, 55, 0.8);
    backdrop-filter: blur(1.25rem);
    -webkit-backdrop-filter: blur(1.25rem);
    border: 0.0625rem solid rgba(255, 255, 255, 0.08);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow:
        0 1.25rem 1.5625rem -0.3125rem rgba(0, 0, 0, 0.3),
        0 0.5rem 0.625rem -0.375rem rgba(0, 0, 0, 0.2);
    animation: otl-fade-in 0.4s ease-out, otl-slide-up 0.4s ease-out;
}

.otl-light .otl-card {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow:
        0 1.25rem 1.5625rem -0.3125rem rgba(0, 0, 0, 0.1),
        0 0.5rem 0.625rem -0.375rem rgba(0, 0, 0, 0.05);
}

/* ============================================
   6. Logo
   ============================================ */
.otl-logo {
    display: block;
    max-height: 3rem;
    width: auto;
    margin: 0 auto 1.5rem auto;
    object-fit: contain;
}

/* ============================================
   7. Typography helpers
   ============================================ */
.otl-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin: 0 0 0.5rem 0;
    color: var(--otl-text);
}

.otl-subtitle {
    font-size: 0.875rem;
    text-align: center;
    color: var(--otl-text-muted);
    margin: 0 0 1.5rem 0;
}

/* ============================================
   8. Form Elements — Label
   ============================================ */
.otl-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--otl-text-muted);
    margin-bottom: 0.375rem;
}

/* ============================================
   9. Form Elements — Input
   ============================================ */
.otl-input {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--otl-font);
    font-size: 0.95rem;
    color: var(--otl-text);
    background: rgba(31, 41, 55, 0.5);
    border: 0.0625rem solid rgba(75, 85, 99, 0.5);
    border-radius: var(--otl-radius-lg);
    outline: none;
    transition: border-color var(--otl-transition),
                box-shadow var(--otl-transition),
                background var(--otl-transition);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.otl-input::placeholder {
    color: #6b7280;
}

.otl-input:focus {
    background: rgba(31, 41, 55, 0.8);
    border-color: var(--otl-primary);
    box-shadow: 0 0 0 0.1875rem rgba(37, 99, 235, 0.15);
}

.otl-input.otl-input-error {
    border-color: var(--otl-error);
    box-shadow: 0 0 0 0.1875rem rgba(239, 68, 68, 0.12);
}

.otl-light .otl-input {
    background: rgba(249, 250, 251, 0.8);
    border-color: var(--otl-border);
    color: var(--otl-text);
}

.otl-light .otl-input::placeholder {
    color: #9ca3af;
}

.otl-light .otl-input:focus {
    background: #ffffff;
    border-color: var(--otl-primary);
    box-shadow: 0 0 0 0.1875rem rgba(37, 99, 235, 0.1);
}

/* Form group wrapper */
.otl-form-group {
    margin-bottom: 1.25rem;
}

/* ============================================
   10. Password Field — Toggle inside input
   ============================================ */
.otl-password-wrapper {
    position: relative;
}

.otl-password-wrapper .otl-input {
    padding-right: 3rem;
}

.otl-password-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--otl-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--otl-transition);
    min-width: 2.75rem;
    min-height: 2.75rem;
}

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

.otl-password-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* ============================================
   11. Buttons — Primary
   ============================================ */
.otl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-family: var(--otl-font);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--otl-radius-lg);
    cursor: pointer;
    transition: all var(--otl-transition);
    text-decoration: none;
    line-height: 1;
    min-height: 2.75rem;
    -webkit-appearance: none;
}

.otl-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.otl-btn-primary {
    background: linear-gradient(135deg, var(--otl-primary), var(--otl-secondary));
    color: #ffffff;
    box-shadow: 0 0.125rem 0.5rem rgba(37, 99, 235, 0.25);
}

.otl-btn-primary:hover:not(:disabled) {
    box-shadow: 0 0.25rem 1.25rem rgba(37, 99, 235, 0.4);
    transform: translateY(-0.0625rem);
}

.otl-btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

/* ============================================
   12. Buttons — SSO (distinct from primary)
   ============================================ */
.otl-btn-sso {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #ffffff;
    box-shadow: 0 0.125rem 0.5rem rgba(22, 163, 74, 0.3);
}

.otl-btn-sso:hover:not(:disabled) {
    background: linear-gradient(135deg, #15803d, #166534);
    box-shadow: 0 0.25rem 1rem rgba(22, 163, 74, 0.4);
    transform: translateY(-0.0625rem);
}

.otl-btn-sso:active:not(:disabled) {
    transform: scale(0.98);
}

.otl-btn-sso svg {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

/* ============================================
   13. Divider — "── or ──"
   ============================================ */
.otl-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--otl-text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

/* ============================================
   14. Alert Messages
   ============================================ */
.otl-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--otl-radius-lg);
    font-size: 0.875rem;
    line-height: 1.5;
    border-left: 0.25rem solid transparent;
    animation: otl-fade-in 0.25s ease-out;
    position: relative;
}

.otl-alert-icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.1rem;
}

.otl-alert-text {
    flex: 1;
    min-width: 0;
}

.otl-alert-dismiss {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: inherit;
    opacity: 0.6;
    transition: opacity var(--otl-transition);
    font-size: 1.25rem;
    line-height: 1;
    min-width: 2.75rem;
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.otl-alert-dismiss:hover {
    opacity: 1;
}

.otl-alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-left-color: var(--otl-error);
    color: #fca5a5;
}

.otl-light .otl-alert-error {
    background: rgba(239, 68, 68, 0.08);
    color: #b91c1c;
}

.otl-alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-left-color: var(--otl-success);
    color: #6ee7b7;
}

.otl-light .otl-alert-success {
    background: rgba(16, 185, 129, 0.08);
    color: #047857;
}

.otl-alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: var(--otl-info);
    color: #93c5fd;
}

.otl-light .otl-alert-info {
    background: rgba(59, 130, 246, 0.08);
    color: #1d4ed8;
}

/* Shake animation for error alert */
.otl-alert-error.otl-shake {
    animation: otl-shake 0.4s ease-out;
}

/* ============================================
   15. Code Input — 6 digit boxes
   ============================================ */
.otl-code-container {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.otl-code-input {
    width: 3rem;
    height: 3.5rem;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--otl-font);
    color: var(--otl-text);
    background: rgba(31, 41, 55, 0.5);
    border: 0.125rem solid var(--otl-border);
    border-radius: var(--otl-radius);
    outline: none;
    transition: border-color var(--otl-transition),
                box-shadow var(--otl-transition);
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.otl-code-input::-webkit-outer-spin-button,
.otl-code-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.otl-code-input:focus {
    border-color: var(--otl-primary);
    box-shadow: 0 0 0 0.1875rem rgba(37, 99, 235, 0.15);
}

.otl-code-input.otl-code-filled {
    border-color: var(--otl-primary);
    background: rgba(37, 99, 235, 0.08);
}

.otl-light .otl-code-input {
    background: rgba(249, 250, 251, 0.8);
    border-color: var(--otl-border);
    color: var(--otl-text);
}

.otl-light .otl-code-input:focus {
    background: #ffffff;
}

/* ============================================
   16. Trust Badge
   ============================================ */
.otl-trust-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    margin-top: 1.5rem;
    padding: 0.5rem 0;
    font-size: 0.75rem;
    color: var(--otl-text-muted);
    opacity: 0.7;
    transition: opacity var(--otl-transition);
}

.otl-trust-badge:hover {
    opacity: 1;
}

.otl-trust-badge svg {
    width: 0.875rem;
    height: 0.875rem;
    flex-shrink: 0;
}

/* ============================================
   17. Modal Overlay
   ============================================ */
.otl-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(0.25rem);
    -webkit-backdrop-filter: blur(0.25rem);
    animation: otl-fade-in 0.2s ease-out;
}

.otl-modal-container {
    width: 100%;
    max-width: 28rem;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--otl-card-bg);
    border: 0.0625rem solid var(--otl-border);
    border-radius: 1rem;
    padding: 2rem;
    position: relative;
    box-shadow: 0 1.5625rem 3.125rem -0.75rem rgba(0, 0, 0, 0.5);
    animation: otl-slide-up 0.3s ease-out;
}

.otl-light .otl-modal-container {
    box-shadow: 0 1.5625rem 3.125rem -0.75rem rgba(0, 0, 0, 0.15);
}

.otl-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--otl-text-muted);
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--otl-transition);
    min-width: 2.75rem;
    min-height: 2.75rem;
    border-radius: var(--otl-radius);
}

.otl-modal-close:hover {
    color: var(--otl-text);
}

.otl-modal-close svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* ============================================
   18. Loading Spinner
   ============================================ */
.otl-spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 0.125rem solid rgba(255, 255, 255, 0.25);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: otl-spin 0.6s linear infinite;
}

.otl-spinner-lg {
    width: 2rem;
    height: 2rem;
    border-width: 0.1875rem;
}

.otl-spinner-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.otl-light .otl-spinner {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: var(--otl-primary);
}

/* ============================================
   19. Link Styles
   ============================================ */
.otl-link {
    color: var(--otl-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--otl-transition);
    cursor: pointer;
}

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

.otl-text-center {
    text-align: center;
}

.otl-text-sm {
    font-size: 0.875rem;
}

.otl-text-muted {
    color: var(--otl-text-muted);
}

.otl-mt-1 { margin-top: 0.5rem; }
.otl-mt-2 { margin-top: 1rem; }
.otl-mt-3 { margin-top: 1.5rem; }
.otl-mb-1 { margin-bottom: 0.5rem; }
.otl-mb-2 { margin-bottom: 1rem; }
.otl-mb-3 { margin-bottom: 1.5rem; }

/* ============================================
   20. Animations
   ============================================ */
@keyframes otl-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-0.25rem); }
    20%, 40%, 60%, 80% { transform: translateX(0.25rem); }
}

@keyframes otl-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes otl-slide-up {
    from { opacity: 0; transform: translateY(1rem); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes otl-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ============================================
   21. Responsive — Mobile-first
   ============================================ */
@media (max-width: 40rem) {
    .otl-card {
        max-width: 100%;
        border-radius: var(--otl-radius-xl);
        padding: 1.5rem;
    }

    .otl-modal-container {
        max-width: 100%;
        border-radius: var(--otl-radius-xl);
        padding: 1.5rem;
    }

    .otl-code-input {
        width: 2.5rem;
        height: 3rem;
        font-size: 1.25rem;
    }

    .otl-code-container {
        gap: 0.375rem;
    }

    .otl-title {
        font-size: 1.25rem;
    }
}

/* Ensure minimum touch targets everywhere */
@media (pointer: coarse) {
    .otl-btn,
    .otl-input,
    .otl-code-input,
    .otl-password-toggle,
    .otl-alert-dismiss,
    .otl-modal-close {
        min-height: 2.75rem;
    }
}

/* ============================================
   22. Checkbox & link row (remember-me pattern)
   ============================================ */
.otl-form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
}

.otl-form-options label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--otl-text-muted);
    cursor: pointer;
}

.otl-form-options input[type="checkbox"] {
    accent-color: var(--otl-primary);
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* ============================================
   23. Footer text
   ============================================ */
.otl-footer-text {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--otl-text-muted);
}

/* ============================================
   24. Visually hidden (accessibility)
   ============================================ */
.otl-sr-only {
    position: absolute;
    width: 0.0625rem;
    height: 0.0625rem;
    padding: 0;
    margin: -0.0625rem;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   25. Field-level errors
   ============================================ */
.otl-has-error .otl-input { border-color: var(--otl-error); }
.otl-input-error { border-color: var(--otl-error) !important; }
.otl-field-error {
    display: block;
    color: var(--otl-error);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

/* ============================================
   26. Form row (side-by-side fields)
   ============================================ */
.otl-form-row {
    display: flex;
    gap: 1rem;
}
.otl-form-row > * {
    flex: 1;
    min-width: 0;
}

/* ============================================
   27. Alt link (register/login switch)
   ============================================ */
.otl-alt-link {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--otl-text-muted);
}
.otl-alt-link a {
    color: var(--otl-primary);
    text-decoration: none;
    font-weight: 500;
}
.otl-alt-link a:hover {
    text-decoration: underline;
}

/* ============================================
   28. Remember me label
   ============================================ */
.otl-remember-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--otl-text-muted);
    cursor: pointer;
    font-size: 0.875rem;
}

/* ============================================
   29. Checkbox group + label (terms, custom)
   ============================================ */
.otl-checkbox-group {
    margin-bottom: 1rem;
}
.otl-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    color: var(--otl-text-muted);
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1.5;
}
.otl-checkbox-label input[type="checkbox"] {
    accent-color: var(--otl-primary);
    width: 1.125rem;
    height: 1.125rem;
    min-width: 1.125rem;
    margin-top: 0.125rem;
    cursor: pointer;
}
.otl-checkbox-label a {
    color: var(--otl-primary);
    text-decoration: none;
    font-weight: 500;
}
.otl-checkbox-label a:hover {
    text-decoration: underline;
}
