/* ════════════════════════════════════════════════
   Auth — Login, Register, Profile Modals & Header Avatar
   ════════════════════════════════════════════════ */

/* ── Auth Button in Header ── */
.auth-login-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    border: none;
    color: white;
    border-radius: 20px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.auth-login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(109, 40, 217, 0.35);
}
.auth-login-btn svg { width: 14px; height: 14px; }

/* ── User Avatar ── */
.auth-user-avatar {
    position: relative;
    cursor: pointer;
}
.auth-avatar-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font);
    transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.auth-avatar-circle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ── User Dropdown Menu ── */
.auth-user-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #1a1a2e;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.05);
    min-width: 220px;
    z-index: 500;
    overflow: hidden;
    animation: fadeInUp 0.2s ease both;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.auth-menu-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.auth-menu-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}
.auth-menu-email {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.auth-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background var(--transition);
}
.auth-menu-item:hover { background: rgba(255, 255, 255, 0.05); }
.auth-menu-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.auth-menu-divider { height: 1px; background: var(--border); }
.auth-menu-item.logout { color: var(--error); }

/* ══════════════════════════════════════════
   AUTH MODAL (Login / Register)
   ══════════════════════════════════════════ */
.auth-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.auth-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl, 20px);
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 400px;
    padding: 32px;
    animation: fadeInUp 0.35s ease both;
    position: relative;
}

.auth-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color var(--transition);
}
.auth-modal-close:hover { color: var(--text-primary); }

.auth-modal-icon {
    text-align: center;
    font-size: 48px;
    margin-bottom: 12px;
}

.auth-modal-title {
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.auth-modal-subtitle {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ── Form Fields ── */
.auth-field {
    margin-bottom: 16px;
}
.auth-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.auth-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.auth-input-wrapper svg {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}
.auth-field input {
    width: 100%;
    padding: 11px 12px 11px 38px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: all var(--transition);
    box-sizing: border-box;
}
.auth-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}
.auth-field input::placeholder { color: var(--text-muted); }

/* ── Error Message ── */
.auth-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--error);
    margin-bottom: 16px;
    animation: fadeInUp 0.2s ease;
}

/* ── Submit Button ── */
.auth-submit-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    border: none;
    color: white;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 16px;
}
.auth-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(109, 40, 217, 0.4);
}
.auth-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ── Switch link ── */
.auth-switch {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}
.auth-switch a {
    color: var(--accent-light);
    text-decoration: none;
    font-weight: 600;
}
.auth-switch a:hover { text-decoration: underline; }

/* ── Forgot Password Link ── */
.auth-forgot-link {
    text-align: right;
    margin-top: 6px;
}
.auth-forgot-link a {
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}
.auth-forgot-link a:hover {
    color: var(--accent-light);
    text-decoration: underline;
}

/* ── Auth Success Message ── */
.auth-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-size: 13px;
    color: var(--success);
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
    line-height: 1.5;
}

/* ── Forgot Password Form ── */
.auth-forgot-form .auth-switch {
    margin-top: 16px;
}
.auth-forgot-form .auth-switch a {
    color: var(--accent-light);
    font-weight: 600;
}

/* ══════════════════════════════════════════
   PROFILE MODAL
   ══════════════════════════════════════════ */
.profile-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.profile-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl, 20px);
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 420px;
    padding: 28px;
    animation: fadeInUp 0.35s ease both;
    position: relative;
}

.profile-modal-close {
    position: absolute;
    top: 16px; right: 16px;
    background: none; border: none;
    color: var(--text-muted);
    font-size: 20px; cursor: pointer;
    transition: color var(--transition);
}
.profile-modal-close:hover { color: var(--text-primary); }

.profile-header {
    text-align: center;
    margin-bottom: 24px;
}
.profile-header h3 {
    font-size: 20px; font-weight: 800;
    margin: 0 0 4px;
}
.profile-header p {
    font-size: 13px; color: var(--text-muted); margin: 0;
}

/* Color picker */
.profile-color-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.profile-color-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.profile-color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
}
.profile-color-option:hover { transform: scale(1.15); }
.profile-color-option.active {
    border-color: white;
    box-shadow: 0 0 0 2px var(--accent);
    transform: scale(1.15);
}

/* Accent color (app theme) picker */
.profile-accent-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.profile-accent-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}
.profile-accent-option:hover { transform: scale(1.15); }
.profile-accent-option.active {
    border-color: white;
    box-shadow: 0 0 0 2px currentColor, 0 0 12px currentColor;
    transform: scale(1.15);
}
.profile-accent-option.active::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.profile-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 20px 0 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.profile-save-btn {
    width: 100%;
    padding: 11px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    border: none;
    color: white;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: 20px;
}
.profile-save-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(109, 40, 217, 0.35);
}
.profile-save-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.profile-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-size: 12px;
    color: var(--error);
    margin-top: 12px;
}
.profile-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-size: 12px;
    color: var(--success);
    margin-top: 12px;
}

/* ── Export Data Zone ── */
.profile-export-zone {
    margin-top: 24px;
    padding: 16px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-lg);
    background: rgba(59, 130, 246, 0.04);
}
.profile-export-title {
    font-size: 13px;
    font-weight: 700;
    color: #60a5fa;
    margin-bottom: 6px;
}
.profile-export-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0 0 12px;
}
.profile-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.profile-export-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: #60a5fa;
    transform: translateY(-1px);
}
.profile-export-btn svg { flex-shrink: 0; }

/* ── Danger Zone (Delete Account) ── */
.profile-danger-zone {
    margin-top: 24px;
    padding: 16px;
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-lg);
    background: rgba(239, 68, 68, 0.04);
}
.profile-danger-title {
    font-size: 13px;
    font-weight: 700;
    color: #ef4444;
    margin-bottom: 8px;
}
.profile-danger-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0 0 12px;
}
.profile-delete-btn {
    width: 100%;
    padding: 10px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.profile-delete-btn:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}
.profile-delete-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.profile-modal {
    max-height: 90vh;
    overflow-y: auto;
    scrollbar-width: thin;
}

/* ── Light Mode ── */
.light-mode .auth-modal,
.light-mode .profile-modal {
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15);
}
.light-mode .auth-field input {
    background: rgba(0, 0, 0, 0.02);
}
.light-mode .auth-user-menu {
    background: #ffffff;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0,0,0,0.06);
}
.light-mode .auth-menu-item:hover {
    background: rgba(0, 0, 0, 0.04);
}
.light-mode .profile-color-option.active {
    border-color: #333;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .auth-modal, .profile-modal {
        padding: 24px 20px;
        max-width: 100%;
    }
    .auth-modal-title { font-size: 20px; }
}

/* ── Animations ── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ══════════════════════════════════════════
   GOOGLE SIGN-IN
   ══════════════════════════════════════════ */
.auth-google-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
    min-height: 44px;
}
.auth-google-wrap > div {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* "hoặc" divider */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Google avatar image in header */
.auth-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all var(--transition);
}
.auth-avatar-img:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}


/* ════════════════════════════════════════════════
   Mobile Responsive
   ════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .auth-modal { padding: 24px 16px; max-width: 100%; border-radius: 16px; }
    .auth-modal-icon { font-size: 32px; }
    .auth-modal-title { font-size: 20px; }
    .auth-input-wrapper { padding: 10px 12px; }
    .auth-submit-btn { padding: 12px; font-size: 14px; }
    .auth-modal-overlay { padding: 12px; }

    /* Profile modal */
    .profile-modal { max-width: 100%; padding: 20px 14px; }
    .profile-avatar-section { flex-direction: column; align-items: center; }
    .profile-form-grid { grid-template-columns: 1fr; }
    .profile-tabs { flex-wrap: wrap; gap: 4px; }
    .profile-tab { font-size: 12px; padding: 6px 10px; }
}


/* Avatar Upload */
.profile-avatar-upload { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.profile-avatar-preview { width: 56px; height: 56px; border-radius: 50%; background: #8b5cf6; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; font-weight: 700; overflow: hidden; flex-shrink: 0; }
.profile-avatar-actions { display: flex; flex-direction: column; gap: 4px; }
.profile-upload-btn { display: inline-block; padding: 6px 14px; border-radius: 8px; background: rgba(139,92,246,0.1); border: 1px solid rgba(139,92,246,0.3); color: #a78bfa; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.profile-upload-btn:hover { background: rgba(139,92,246,0.2); }
.profile-avatar-hint { font-size: 11px; color: var(--text-muted, #64748b); }
.light-mode .profile-upload-btn { background: rgba(139,92,246,0.06); color: #7c3aed; }

/* ── Profile toggle row (notifications) ── */
.profile-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    margin-bottom: 8px;
}
.profile-toggle-info {
    flex: 1;
    min-width: 0;
}
.profile-toggle-label {
    font-size: 14px;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 2px;
}
.profile-toggle-desc {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.4;
}

/* Toggle switch */
.profile-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.profile-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.profile-switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 99px;
    transition: background 0.2s ease;
}
.profile-switch-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}
.profile-switch input:checked + .profile-switch-slider {
    background: #8b5cf6;
}
.profile-switch input:checked + .profile-switch-slider::before {
    transform: translateX(20px);
}
