/* ==========================================================================
   LinguaLevels - Authentication & User Profile Styling
   Philosophy: Clean Editorial, Minimalist, Accessible.
   ========================================================================== */

/* Top Header User Profile & Sign-in Trigger */
.header-auth-section {
  display: flex;
  align-items: center;
  position: relative;
}

.auth-btn-signin {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.95rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.auth-btn-signin:hover {
  background-color: var(--bg-hover);
  color: var(--accent);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .auth-btn-signin:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* Logged-in User Chip */
.user-profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.65rem 0.3rem 0.35rem;
  background-color: var(--bg-tertiary);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.18s ease;
}

[data-theme="dark"] .user-profile-chip {
  border-color: rgba(255, 255, 255, 0.1);
}

.user-profile-chip:hover {
  background-color: var(--bg-hover);
}

.user-avatar-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
}

.user-name-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-level-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-full);
  background-color: var(--accent-light);
  color: var(--accent);
}

/* User Profile Dropdown Menu */
.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  width: 240px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.15);
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 100;
  animation: dropdownFadeIn 0.15s ease-out;
}

[data-theme="dark"] .user-dropdown-menu {
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.4);
  border-color: #2c2c2c;
}

.user-dropdown-menu.active {
  display: flex;
}

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

.dropdown-user-info {
  padding: 0.6rem 0.75rem 0.75rem;
  border-bottom: 1px solid var(--bg-tertiary);
  margin-bottom: 0.25rem;
}

.dropdown-email {
  font-size: 0.76rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-menu-links {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.15rem 0;
}

.dropdown-theme-section {
  padding: 0.5rem 0.75rem 0.6rem;
  border-top: 1px solid var(--bg-tertiary);
  border-bottom: 1px solid var(--bg-tertiary);
  margin: 0.25rem 0;
}

.dropdown-section-title {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.dropdown-theme-selector {
  display: flex;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}

.dropdown-theme-selector .theme-btn {
  flex: 1;
  width: auto;
  height: 28px;
  padding: 0 0.35rem;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 0.75rem;
  font-weight: 500;
  gap: 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dropdown-theme-selector .theme-btn:hover {
  color: var(--text-primary);
  transform: none;
}

.dropdown-theme-selector .theme-btn.active {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

.dropdown-item-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.12s ease;
  text-align: left;
}

.dropdown-item-btn:hover {
  background-color: var(--bg-tertiary);
}

.dropdown-item-btn.logout-btn {
  color: #dc2626;
  border-top: 1px solid var(--bg-tertiary);
  margin-top: 0.25rem;
  padding-top: 0.65rem;
}

[data-theme="dark"] .dropdown-item-btn.logout-btn {
  color: #f87171;
}

/* ==========================================================================
   Auth Modal & Forms
   ========================================================================== */
.auth-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 1rem;
}

.auth-modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.auth-modal-box,
.auth-modal-card {
  background-color: var(--bg-secondary);
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid var(--bg-tertiary);
}

.auth-modal-backdrop.active .auth-modal-box,
.auth-modal-backdrop.active .auth-modal-card {
  transform: scale(1) translateY(0);
}

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

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

.auth-brand-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--text-primary);
  font-size: 1.05rem;
}

.auth-modal-close-btn,
.auth-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  transition: background-color 0.12s ease, color 0.12s ease;
}

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

/* Settings Segmented Options - Tab-like (Matches Theme Selector) */
.settings-segmented-row {
  display: flex;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
  box-sizing: border-box;
}

.settings-segmented-row button {
  flex: 1;
  width: auto;
  height: 28px;
  padding: 0 0.35rem;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 0.75rem;
  font-weight: 500;
  gap: 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.settings-segmented-row button:hover {
  color: var(--text-primary);
  background: transparent;
  transform: none;
}

.settings-segmented-row button.active {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

/* Modal Tabs */
.auth-tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--bg-tertiary);
  padding: 0 1.5rem;
  gap: 1.25rem;
}

.auth-tab-btn {
  background: transparent;
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.65rem 0.1rem;
  cursor: pointer;
  position: relative;
  transition: color 0.15s ease;
}

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

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

/* Modal Form Body */
.auth-form-container {
  padding: 1.5rem;
}

.auth-form {
  display: none;
  flex-direction: column;
  gap: 1.1rem;
}

.auth-form.active {
  display: flex;
}

.auth-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.auth-field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-tertiary);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-ui);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
  background-color: var(--bg-secondary);
}

[data-theme="dark"] .auth-input:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.auth-input-password {
  padding-right: 2.4rem;
}

.auth-pw-toggle {
  position: absolute;
  right: 0.65rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
}

.auth-pw-toggle:hover {
  color: var(--text-primary);
}

.auth-level-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-tertiary);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-ui);
  cursor: pointer;
}

.auth-level-select:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem;
  background-color: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
  margin-top: 0.35rem;
}

.auth-submit-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.auth-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.auth-notice-box {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  line-height: 1.4;
  display: none;
}

.auth-notice-box.error {
  display: block;
  background-color: var(--error-bg);
  color: var(--error-text);
  border: 1px solid rgba(155, 28, 28, 0.15);
}

.auth-notice-box.success {
  display: block;
  background-color: var(--success-bg);
  color: var(--success-text);
  border: 1px solid rgba(30, 70, 32, 0.15);
}

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

/* OAuth2 Google Button & Divider */
.auth-oauth-container {
  padding: 0 1.5rem 0.25rem;
}

.btn-oauth-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-oauth-google:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--text-muted);
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 0.85rem 0 0.35rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--bg-tertiary);
}

.auth-divider span {
  padding: 0 0.75rem;
}

.auth-forgot-row {
  display: flex;
  justify-content: flex-end;
  margin-top: -0.25rem;
  margin-bottom: 0.5rem;
}

.auth-link-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.8rem;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-link-btn:hover {
  opacity: 0.85;
}

.auth-back-row {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.auth-form-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.25rem;
}
