/* member/auth.css - The One Academy TH Membership System Styles */

:root {
  --auth-navy: #24166f;
  --auth-purple: #4f46e5;
  --auth-indigo: #6d28d9;
  --auth-cyan: #0284c7;
  --auth-gold: #f6c453;
  --auth-bg: #f8fafc;
  --auth-surface: #ffffff;
  --auth-surface-alt: #f1f5f9;
  --auth-text: #1e293b;
  --auth-text-muted: #64748b;
  --auth-heading: #0f172a;
  --auth-border: #cbd5e1;
  --auth-shadow: 0 20px 45px rgba(36, 22, 111, 0.08);
}

:root[data-theme="dark"] {
  --auth-navy: #818cf8;
  --auth-purple: #6366f1;
  --auth-indigo: #818cf8;
  --auth-cyan: #38bdf8;
  --auth-gold: #facc15;
  --auth-bg: #0a0912;
  --auth-surface: #141124;
  --auth-surface-alt: #1e1b32;
  --auth-text: #eceaf8;
  --auth-text-muted: #a8a3c4;
  --auth-heading: #f8fafc;
  --auth-border: rgba(184, 176, 255, 0.18);
  --auth-shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
}

body {
  background: var(--auth-bg);
  color: var(--auth-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-page-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px 16px 80px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--auth-surface);
  border: 1px solid var(--auth-border);
  border-radius: 28px;
  padding: 36px 32px;
  box-shadow: var(--auth-shadow);
}

.auth-card-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-card-header h1 {
  font-size: 1.8rem;
  color: var(--auth-heading);
  margin: 0 0 8px;
  font-weight: 800;
}

.auth-card-header p {
  color: var(--auth-text-muted);
  font-size: 0.95rem;
  margin: 0;
}

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

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

.form-group label {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--auth-heading);
}

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

.form-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--auth-border);
  background: var(--auth-surface-alt);
  color: var(--auth-text);
  font-size: 0.98rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus {
  border-color: var(--auth-purple);
  box-shadow: 0 0 0 3.5px rgba(79, 70, 229, 0.2);
}

.btn-toggle-password {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--auth-text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
}

.form-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--auth-text-muted);
  cursor: pointer;
  line-height: 1.4;
}

.form-checkbox-label input {
  margin-top: 3px;
  accent-color: var(--auth-purple);
}

.btn-auth-submit {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, var(--auth-navy), var(--auth-purple));
  color: #ffffff !important;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(79, 70, 229, 0.28);
  transition: all 0.2s ease;
  margin-top: 8px;
}

.btn-auth-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(79, 70, 229, 0.38);
}

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

.auth-card-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.92rem;
  color: var(--auth-text-muted);
}

.auth-card-footer a {
  color: var(--auth-purple);
  font-weight: 700;
  text-decoration: none;
}

.auth-card-footer a:hover {
  text-decoration: underline;
}

.auth-error-alert {
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #dc2626;
  font-size: 0.9rem;
  font-weight: 700;
  display: none;
}

:root[data-theme="dark"] .auth-error-alert {
  color: #f87171;
}

/* Google Sign-In Button Styles */
.btn-google-auth {
  width: 100%;
  padding: 13px 18px;
  border-radius: 14px;
  border: 1px solid var(--auth-border);
  background: var(--auth-surface);
  color: var(--auth-heading);
  font-weight: 800;
  font-size: 0.98rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
  text-decoration: none;
  margin-bottom: 20px;
}

.btn-google-auth:hover {
  background: var(--auth-surface-alt);
  border-color: var(--auth-purple);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.google-icon {
  width: 20px;
  height: 20px;
}

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

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

.auth-divider span {
  padding: 0 12px;
}

.privacy-scope-note {
  font-size: 0.82rem;
  color: var(--auth-text-muted);
  background: var(--auth-surface-alt);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px dashed var(--auth-border);
  margin-top: 14px;
  line-height: 1.4;
  text-align: center;
}

/* Profile Page Explicit Scoped Styles */
.profile-card {
  max-width: 520px;
}

.profile-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  margin-bottom: 32px;
}

.profile-hero .profile-avatar-img,
.profile-hero .avatar-badge-large {
  width: 88px !important;
  height: 88px !important;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--auth-purple);
  box-shadow: 0 10px 25px rgba(79, 70, 229, 0.3);
}

.avatar-badge-large {
  background: linear-gradient(135deg, var(--auth-navy), var(--auth-purple));
  color: #ffffff;
  font-size: 2.4rem;
  font-weight: 900;
  display: flex;
  justify-content: center;
  align-items: center;
}

.profile-info-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

.profile-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--auth-surface-alt);
  border-radius: 14px;
  border: 1px solid var(--auth-border);
}

.profile-info-label {
  font-weight: 700;
  color: var(--auth-text-muted);
  font-size: 0.9rem;
}

.profile-info-value {
  font-weight: 800;
  color: var(--auth-heading);
  font-size: 0.95rem;
}

.role-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(2, 132, 199, 0.15);
  color: var(--auth-cyan);
  font-weight: 800;
  font-size: 0.85rem;
}

.btn-signout {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
  color: #dc2626;
  font-weight: 800;
  font-size: 0.98rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

:root[data-theme="dark"] .btn-signout {
  color: #f87171;
}

.btn-signout:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* ==========================================================================
   Header Member Navigation Component (.site-header .member-nav)
   ========================================================================== */
.site-header .member-nav {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* Unauthenticated Login Button */
.site-header .member-login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--auth-purple);
  color: #ffffff !important;
  font-weight: 800;
  font-size: 0.88rem;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
  transition: all 0.2s ease;
}

.site-header .member-login-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.site-header .member-login-btn:focus-visible {
  outline: 3px solid var(--auth-cyan);
  outline-offset: 2px;
}

/* Compact Member Trigger Button */
.site-header .member-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 3px 12px 3px 4px;
  border-radius: 999px;
  background: var(--auth-surface-alt);
  border: 1px solid var(--auth-border);
  color: var(--auth-heading);
  font-family: inherit;
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  user-select: none;
}

.site-header .member-trigger:hover,
.site-header .member-trigger[aria-expanded="true"] {
  border-color: var(--auth-purple);
  background: var(--auth-surface);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.site-header .member-trigger:focus-visible {
  outline: 3px solid var(--auth-purple);
  outline-offset: 2px;
}

/* Trigger Avatar Circle & Images (Scoped 30px x 30px) */
.site-header .member-trigger .member-avatar {
  width: 30px !important;
  height: 30px !important;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, var(--auth-navy), var(--auth-purple));
  color: #ffffff;
  font-weight: 900;
  font-size: 0.9rem;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.site-header .member-trigger .member-avatar-img {
  width: 30px !important;
  height: 30px !important;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.site-header .member-trigger .member-avatar-fallback {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  line-height: 1;
}

.site-header .member-name {
  display: block !important;
  min-width: 0 !important;
  max-width: 140px !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
  color: #1e1b4b !important;
  opacity: 1 !important;
  visibility: visible !important;
  font-weight: 800 !important;
}

:root[data-theme="dark"] .site-header .member-name {
  color: #ffffff !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.site-header .member-caret {
  font-size: 0.75rem;
  color: var(--auth-text-muted);
  transition: transform 0.2s ease;
}

.site-header .member-trigger[aria-expanded="true"] .member-caret {
  transform: rotate(180deg);
}

/* Dropdown Menu Container (Floating Panel) */
.site-header .member-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  max-width: calc(100vw - 32px);
  background: var(--auth-surface);
  border: 1px solid var(--auth-border);
  border-radius: 20px;
  padding: 12px;
  box-shadow: var(--auth-shadow);
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 1000;
  animation: memberDropdownFade 0.18s ease forwards;
}

.site-header .member-dropdown.show {
  display: flex;
}

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

/* Dropdown Top Summary Section */
.site-header .member-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px 12px;
}

.site-header .member-summary-avatar {
  width: 44px !important;
  height: 44px !important;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, var(--auth-navy), var(--auth-purple));
  color: #ffffff;
  font-weight: 900;
  font-size: 1.2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.site-header .member-summary-avatar .member-avatar-img {
  width: 44px !important;
  height: 44px !important;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.site-header .member-summary-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.site-header .member-summary-name {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--auth-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-header .member-summary-email {
  font-size: 0.8rem;
  color: var(--auth-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-header .member-divider {
  height: 1px;
  background: var(--auth-border);
  margin: 4px 0 6px;
}

/* Menu Items */
.site-header .member-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--auth-heading);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  background: transparent;
  border: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 0.18s ease;
}

.site-header .member-menu-item:hover,
.site-header .member-menu-item:focus-visible {
  background: var(--auth-surface-alt);
  color: var(--auth-purple);
  outline: none;
}

.site-header .member-logout-item:hover,
.site-header .member-logout-item:focus-visible {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

:root[data-theme="dark"] .site-header .member-logout-item:hover,
:root[data-theme="dark"] .site-header .member-logout-item:focus-visible {
  color: #f87171;
}

/* Mobile Responsive Optimization (360px - 480px) */
@media (max-width: 480px) {
  .site-header .member-name {
    display: none;
  }

  .site-header .member-trigger {
    padding: 3px 8px 3px 4px;
    gap: 4px;
  }

  .site-header .member-dropdown {
    right: 0;
    width: 220px;
  }
}

/* ==========================================================================
   Strict Header Single-Row Navigation & Member Trigger Responsive Rules
   ========================================================================== */
.site-header .main-nav {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-wrap: nowrap !important;
  white-space: nowrap !important;
  flex-shrink: 1 !important;
  min-width: 0 !important;
  overflow: visible !important;
}

.site-header .main-nav a {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

.site-header .header-actions {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-shrink: 0 !important;
  min-width: 0 !important;
}

.site-header .theme-toggle,
.site-header .menu-toggle {
  flex-shrink: 0 !important;
}

.site-header .member-nav {
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
  flex-shrink: 0 !important;
}

.site-header .member-trigger {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  height: 38px !important;
  padding: 3px 12px 3px 4px !important;
  border-radius: 999px !important;
  background: var(--surface-alt, #f1f5f9) !important;
  border: 1px solid var(--border-color, #cbd5e1) !important;
  color: #1e1b4b !important;
  font-family: inherit !important;
  font-weight: 800 !important;
  font-size: 0.88rem !important;
  cursor: pointer !important;
  outline: none !important;
  transition: all 0.2s ease !important;
  user-select: none !important;
  flex-shrink: 0 !important;
  overflow: hidden !important;
}

:root[data-theme="dark"] .site-header .member-trigger {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
  color: #ffffff !important;
}

.site-header .member-name {
  display: block !important;
  min-width: 0 !important;
  max-width: 140px !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
  color: #1e1b4b !important;
  opacity: 1 !important;
  visibility: visible !important;
  font-weight: 800 !important;
}

:root[data-theme="dark"] .site-header .member-name {
  color: #ffffff !important;
  opacity: 1 !important;
  visibility: visible !important;
}

:root[data-theme="dark"] .site-header .member-caret,
:root[data-theme="dark"] .site-header .member-arrow {
  color: #cbd5e1 !important;
  opacity: 0.9 !important;
}

.site-header .member-trigger-avatar {
  flex-shrink: 0 !important;
}

.site-header .member-arrow {
  flex-shrink: 0 !important;
}

/* ==========================================================================
   Breakpoints for Header Adaptation
   ========================================================================== */

/* Viewport < 1280px: Hide Member Name immediately, compact trigger [ Avatar 30px ] ▾ */
@media (max-width: 1279px) {
  .site-header .member-name {
    display: none !important;
  }

  .site-header .member-trigger {
    padding: 3px 8px 3px 4px !important;
    gap: 4px !important;
  }

  .site-header .main-nav {
    gap: 4px !important;
  }

  .site-header .main-nav a {
    padding: 6px 10px !important;
    font-size: 0.88rem !important;
  }
}

/* Viewport < 1100px: Hide Caret Arrow, Trigger displays ONLY Avatar [ 30px x 30px ] */
@media (max-width: 1099px) {
  .site-header .member-arrow {
    display: none !important;
  }

  .site-header .member-trigger {
    padding: 3px !important;
    gap: 0 !important;
    border-radius: 50% !important;
  }
}

/* Under-Card Legal Links Styling */
.auth-page-container,
.member-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px 80px;
}

.member-legal-links {
  position: static;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
  max-width: 520px;
  margin: 18px auto 32px;
  text-align: center;
  font-size: 0.88rem;
}

.member-legal-links a {
  color: var(--auth-text-muted);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.18s ease;
}

.member-legal-links a:hover,
.member-legal-links a:focus-visible {
  color: var(--auth-purple);
  text-decoration: underline;
}

/* ==========================================================================
   STRICT TOPMOST HEADER & PROFILE DROPDOWN LAYERING FOR ACTIVE LEARNING
   ========================================================================== */
.site-header {
  position: sticky !important;
  top: 0 !important;
  z-index: 2000 !important;
  overflow: visible !important;
}

.site-header .nav-wrap {
  overflow: visible !important;
}

.site-header .header-actions {
  position: relative !important;
  z-index: 2001 !important;
  overflow: visible !important;
}

.site-header .member-nav {
  position: relative !important;
  z-index: 2002 !important;
  overflow: visible !important;
}

.site-header .member-dropdown {
  position: absolute !important;
  top: calc(100% + 8px) !important;
  right: 0 !important;
  z-index: 2003 !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4) !important;
}

.page-shell,
.fma-container,
.active-hero,
.subject-card,
.section-card,
.lab-stage-card,
.sim-viewport {
  z-index: 1;
}

.mobile-nav-backdrop {
  z-index: 1990 !important;
}
.mobile-nav-drawer {
  z-index: 1995 !important;
}


/* --- Central Display Name Styling --- */
.display-name-card-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg-card-subtle, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border-color, rgba(148, 163, 184, 0.15));
  border-radius: 12px;
  margin-bottom: 16px;
}

.profile-info-header-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-info-helptext {
  font-size: 0.82rem;
  color: var(--text-muted, #94a3b8);
  margin: 0;
  line-height: 1.4;
}

.profile-input-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.profile-input-actions .auth-input {
  flex: 1;
  margin-bottom: 0;
}

.btn-save-profile {
  height: 44px;
  padding: 0 18px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  font-family: 'Kanit', sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-save-profile:hover {
  opacity: 0.92;
}

.btn-save-profile:active {
  transform: scale(0.98);
}

.auth-success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #4ade80;
}

@media (max-width: 600px) {
  .profile-input-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-save-profile {
    width: 100%;
  }
}

/* ========================================================================== 
   Central Auth Header hardening (Chat fix 2026-07-30)
   Keeps the injected member trigger compact and prevents broken avatar text.
   ========================================================================== */
.site-header .auth-header-trigger.member-nav {
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
  flex: 0 0 auto !important;
  min-width: 0 !important;
}

.site-header [data-toa-avatar-shell] {
  position: relative;
}

.site-header .member-avatar-img[hidden],
.site-header .member-avatar-fallback[hidden] {
  display: none !important;
}

.site-header .member-avatar-fallback {
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  line-height: 1;
}

.site-header .member-summary-avatar .member-avatar-fallback {
  display: flex;
  font-size: 1.15rem;
  font-weight: 900;
}

.site-header .member-trigger .member-avatar-fallback {
  display: flex;
  font-size: 0.9rem;
  font-weight: 900;
}

.site-header .member-dropdown:not(.show) {
  display: none !important;
}

.site-header .member-dropdown.show {
  display: flex !important;
}
