/* ===========================================
   AUTH MODAL - Light Theme
   Compact Modal-based Authentication
   =========================================== */

/* Alpine.js x-cloak */
[x-cloak] { display: none !important; }

/* =========================================
   1. CSS CUSTOM PROPERTIES
   ========================================= */

:root {
    --auth-modal-bg: rgba(0, 0, 0, 0.5);
    --auth-modal-card-bg: #ffffff;
    --auth-modal-card-border: rgba(0, 0, 0, 0.1);
    --auth-modal-width: 420px;
    --auth-modal-max-height: 90vh;

    --auth-primary: var(--primary-color, #000769);
    --auth-text-primary: #1a1a2e;
    --auth-text-secondary: #4a4a68;
    --auth-text-muted: #8c8ca1;
    --auth-input-bg: #f8f9fa;
    --auth-input-border: #e1e5eb;
    --auth-input-focus: var(--primary-color, #000769);
    --auth-error: #dc3545;
    --auth-success: #28a745;
}

/* =========================================
   2. MODAL OVERLAY
   ========================================= */

.auth-modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--auth-modal-bg);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* Alpine.js transitions */
.auth-modal-enter { transition: opacity 0.3s ease; }
.auth-modal-enter-start { opacity: 0; }
.auth-modal-enter-end { opacity: 1; }
.auth-modal-leave { transition: opacity 0.2s ease; }
.auth-modal-leave-start { opacity: 1; }
.auth-modal-leave-end { opacity: 0; }

/* =========================================
   3. MODAL CARD
   ========================================= */

.auth-modal {
    position: relative;
    width: 100%;
    max-width: var(--auth-modal-width);
    max-height: var(--auth-modal-max-height);
    background: var(--auth-modal-card-bg);
    border: 1px solid var(--auth-modal-card-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* =========================================
   4. MODAL HEADER
   ========================================= */

.auth-modal-header {
    padding: 1.5rem 1.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.auth-modal-logo {
    height: 32px;
    width: auto;
}

.auth-modal-close {
    background: var(--auth-input-bg);
    border: 1px solid var(--auth-input-border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--auth-text-muted);
    transition: all 0.2s ease;
}

.auth-modal-close:hover {
    background: var(--auth-input-border);
    color: var(--auth-text-primary);
}

.auth-modal-close svg {
    width: 18px;
    height: 18px;
}

/* =========================================
   5. TABS NAVIGATION
   ========================================= */

.auth-tabs {
    display: flex;
    padding: 1.25rem 1.5rem 0;
    gap: 0.5rem;
    border-bottom: 1px solid var(--auth-input-border);
}

.auth-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 0.75rem 0.5rem;
    color: var(--auth-text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    font-family: inherit;
}

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

.auth-tab.active {
    color: var(--auth-primary);
}

.auth-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--auth-primary);
    border-radius: 2px 2px 0 0;
}

/* =========================================
   6. MODAL BODY & PANELS
   ========================================= */

.auth-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(var(--auth-modal-max-height) - 120px);
}

.auth-panel {
    display: none;
}

.auth-panel.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* =========================================
   7. FORM STYLES
   ========================================= */

.auth-form-compact {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Step Header */
.auth-step-header {
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-step-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--auth-text-primary);
    margin: 0 0 0.5rem;
}

.auth-step-subtitle {
    font-size: 0.875rem;
    color: var(--auth-text-muted);
    margin: 0;
}

/* Back Button */
.auth-step-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: var(--auth-text-muted);
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0;
    margin-bottom: 1rem;
    transition: color 0.2s;
}

.auth-step-back:hover {
    color: var(--auth-primary);
}

.auth-step-back svg {
    width: 16px;
    height: 16px;
}

/* =========================================
   8. INPUT FIELDS
   ========================================= */

.auth-field-compact {
    position: relative;
}

.auth-field-icon-compact {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--auth-text-muted);
    pointer-events: none;
    z-index: 1;
}

.auth-input-compact {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    background: var(--auth-input-bg);
    border: 1px solid var(--auth-input-border);
    border-radius: 10px;
    font-size: 0.9375rem;
    color: var(--auth-text-primary);
    transition: all 0.2s ease;
    font-family: inherit;
}

.auth-input-compact:focus {
    outline: none;
    border-color: var(--auth-input-focus);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 7, 105, 0.1);
}

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

.auth-input-compact.is-invalid {
    border-color: var(--auth-error);
}

.auth-input-compact:disabled {
    background: var(--auth-input-border);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Password Toggle */
.auth-password-toggle-compact {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--auth-text-muted);
    transition: color 0.2s;
}

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

/* Error Message */
.auth-error-compact {
    display: block;
    font-size: 0.75rem;
    color: var(--auth-error);
    margin-top: 0.25rem;
    padding-left: 0.25rem;
}

/* =========================================
   9. ALERTS
   ========================================= */

.auth-alert-compact {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    text-align: center;
}

.auth-alert-error-compact {
    background: rgba(220, 53, 69, 0.1);
    color: var(--auth-error);
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.auth-alert-success-compact {
    background: rgba(40, 167, 69, 0.1);
    color: var(--auth-success);
    border: 1px solid rgba(40, 167, 69, 0.2);
}

/* =========================================
   10. BUTTONS
   ========================================= */

.auth-btn-compact {
    width: 100%;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    position: relative;
}

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

.auth-btn-primary-compact:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
}

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

.auth-btn-primary-compact.loading {
    color: transparent;
}

.auth-btn-primary-compact.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* =========================================
   11. PASSWORD STRENGTH
   ========================================= */

.auth-strength-compact {
    display: flex;
    gap: 4px;
    margin-bottom: 0.25rem;
}

.auth-strength-bar-compact {
    flex: 1;
    height: 4px;
    background: var(--auth-input-border);
    border-radius: 2px;
    transition: background 0.2s;
}

.auth-strength-bar-compact.active.weak { background: var(--auth-error); }
.auth-strength-bar-compact.active.fair { background: #f59e0b; }
.auth-strength-bar-compact.active.good { background: #10b981; }
.auth-strength-bar-compact.active.strong { background: var(--auth-success); }

.auth-strength-label {
    font-size: 0.75rem;
    color: var(--auth-text-muted);
    text-align: right;
}

/* =========================================
   12. OTP INPUT
   ========================================= */

.auth-otp-compact {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin: 1rem 0;
}

.auth-otp-input-compact {
    width: 56px;
    height: 56px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    background: var(--auth-input-bg);
    border: 2px solid var(--auth-input-border);
    border-radius: 12px;
    color: var(--auth-text-primary);
    transition: all 0.2s ease;
    font-family: inherit;
}

.auth-otp-input-compact:focus {
    outline: none;
    border-color: var(--auth-primary);
    background: #fff;
}

.auth-otp-input-compact.filled {
    border-color: var(--auth-primary);
    background: rgba(0, 7, 105, 0.05);
}

/* =========================================
   13. RESEND SECTION
   ========================================= */

.auth-resend-compact {
    text-align: center;
    margin-top: 0.5rem;
}

.auth-resend-timer-compact {
    font-size: 0.875rem;
    color: var(--auth-text-muted);
}

.auth-resend-btn-compact {
    background: none;
    border: none;
    color: var(--auth-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    transition: opacity 0.2s;
}

.auth-resend-btn-compact:hover {
    opacity: 0.8;
}

.auth-resend-btn-compact:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =========================================
   14. SOCIAL LOGIN
   ========================================= */

.auth-divider-compact {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0.5rem 0;
}

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

.auth-divider-compact span {
    font-size: 0.8125rem;
    color: var(--auth-text-muted);
    white-space: nowrap;
}

.auth-social-compact {
    display: flex;
    gap: 0.75rem;
}

.auth-social-btn-compact {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--auth-input-bg);
    border: 1px solid var(--auth-input-border);
    border-radius: 10px;
    color: var(--auth-text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.auth-social-btn-compact:hover {
    background: var(--auth-input-border);
    color: var(--auth-text-primary);
}

/* =========================================
   15. FOOTER LINKS
   ========================================= */

.auth-footer-compact {
    text-align: center;
    font-size: 0.875rem;
    color: var(--auth-text-muted);
    margin-top: 0.5rem;
}

.auth-link-compact {
    color: var(--auth-primary);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

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

/* Forgot Password Link */
.auth-forgot-compact {
    text-align: right;
    margin-top: -0.5rem;
}

.auth-forgot-compact a {
    font-size: 0.8125rem;
    color: var(--auth-primary);
    text-decoration: none;
    transition: opacity 0.2s;
}

.auth-forgot-compact a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* =========================================
   16. LEGAL TEXT
   ========================================= */

.auth-legal-compact {
    font-size: 0.75rem;
    color: var(--auth-text-muted);
    text-align: center;
    line-height: 1.5;
    margin-top: 0.5rem;
}

.auth-legal-compact a {
    color: var(--auth-primary);
    text-decoration: none;
}

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

/* =========================================
   17. RECAPTCHA
   ========================================= */

.auth-recaptcha-compact {
    display: flex;
    justify-content: center;
    margin: 0.5rem 0;
}

/* =========================================
   18. RESPONSIVE
   ========================================= */

@media (max-width: 480px) {
    .auth-modal {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 95vh;
    }

    .auth-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

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

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