/* ========================================
   AUTHENTICATION MODALS
   ======================================== */

/* Auth Modal Overlay */
.auth-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.auth-modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

/* Auth Modal Container */
.auth-modal {
    background: var(--bg-primary);
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
}

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Auth Modal Header */
.auth-modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.auth-modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.auth-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

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

/* Auth Modal Body */
.auth-modal-body {
    padding: 24px;
}

/* Auth Message (Error/Success) */
.auth-message {
    display: none;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.95rem;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

.auth-message.active {
    display: block;
}

.auth-message.error {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.auth-message.success {
    background: #efe;
    color: #3a3;
    border: 1px solid #cfc;
}

[data-theme="dark"] .auth-message.error {
    background: #4a2020;
    color: #ff6b6b;
    border-color: #6a3030;
}

[data-theme="dark"] .auth-message.success {
    background: #204a20;
    color: #6bff6b;
    border-color: #306a30;
}

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

/* Modal Shake Animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}

.auth-modal.shake {
    animation: shake 0.5s ease-in-out;
}

/* Auth Form */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-form-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.auth-form-input {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.auth-form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(221, 116, 71, 0.1);
}

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

.auth-form-input.error {
    border-color: #ef4444;
}

/* Password Input Wrapper */
.password-input-wrapper {
    position: relative;
}

.password-input-wrapper .auth-form-input {
    padding-right: 45px;
}

.password-toggle-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

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

.password-toggle-btn i {
    font-size: 1.1rem;
}

.auth-form-error {
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: 4px;
    display: none;
}

.auth-form-error.active {
    display: block;
}

/* Remember Me Checkbox */
.auth-checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.auth-checkbox-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

/* Auth Button */
.auth-submit-btn {
    padding: 14px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.auth-submit-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(221, 116, 71, 0.3);
}

.auth-submit-btn:active {
    transform: translateY(0);
}

[data-theme="dark"] .auth-submit-btn {
    background: var(--primary-color);
    color: var(--white);
}

[data-theme="dark"] .auth-submit-btn:hover {
    background: var(--primary-color);
    opacity: 0.9;
}

[data-theme="dark"] .auth-submit-btn:disabled {
    background: #475569;
    color: #cbd5e1;
}

[data-theme="dark"] .auth-submit-btn.loading::after {
    border-color: rgba(255, 255, 255, 0.7);
    border-top-color: transparent;
}

.auth-submit-btn:disabled {
    background: #cbd5e1;
    color: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.auth-submit-btn.loading {
    position: relative;
    color: transparent;
}

.auth-submit-btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid white;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

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

/* Auth Switch (Toggle between Login/Register) */
.auth-switch {
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
}

.auth-switch-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-switch-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease;
}

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

/* Success/Error Messages */
.auth-message {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 16px;
    display: none;
}

.auth-message.active {
    display: block;
}

.auth-message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.auth-message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Password Strength Indicator */
.password-strength {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.password-strength-bar {
    height: 4px;
    flex: 1;
    background: #e5e7eb;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.password-strength-bar.active {
    background: #10b981;
}

.password-strength-bar.weak {
    background: #ef4444;
}

.password-strength-bar.medium {
    background: #f59e0b;
}

.password-strength-bar.strong {
    background: #10b981;
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .auth-modal {
        width: 95%;
        max-height: 95vh;
    }

    .auth-modal-header {
        padding: 20px 20px 12px;
    }

    .auth-modal-title {
        font-size: 1.25rem;
    }

    .auth-modal-body {
        padding: 20px;
    }

    .auth-form-input {
        padding: 10px 14px;
        font-size: 16px; /* Prevents iOS zoom */
    }
}

