/* ══════════════════════════════════════════════
   Auth modal — Login / Register, gaming dark theme
   Uses site vars (--gold, --bg, --text...) with fallbacks.
   ══════════════════════════════════════════════ */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(176, 106, 255, 0.08), rgba(10, 12, 16, 0.85) 60%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.auth-overlay.open { display: flex; opacity: 1; }

.auth-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, rgba(26, 31, 46, 0.95), rgba(17, 20, 32, 0.95));
  border: 1px solid var(--border, #2a3050);
  border-radius: 14px;
  padding: 28px 26px 24px;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(240, 180, 41, 0.08) inset,
    0 0 40px rgba(176, 106, 255, 0.12);
  transform: translateY(18px) scale(0.98);
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.auth-overlay.open .auth-card { transform: translateY(0) scale(1); }

/* Top accent glow line */
.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 12%; right: 12%; height: 1px;
  background: linear-gradient(90deg, transparent, #ffd86b, #b06aff, #3dffa0, transparent);
  opacity: 0.7;
}

.auth-close {
  position: absolute;
  top: 10px; right: 12px;
  background: transparent;
  border: 0;
  color: var(--text-dim, #7888aa);
  font-size: 1.2rem;
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.auth-close:hover { background: rgba(255,255,255,0.05); color: var(--text, #d4deff); }

.auth-brand {
  text-align: center;
  margin-bottom: 18px;
}
.auth-brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold, #f0b429);
  text-transform: uppercase;
}
.auth-brand-logo::before { content: '⚔'; font-size: 1.1rem; }
.auth-brand-sub {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-dim, #7888aa);
  letter-spacing: 0.04em;
}

/* Tab switcher */
.auth-tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(10, 12, 16, 0.6);
  border: 1px solid var(--border, #2a3050);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
}
.auth-tab-btn {
  position: relative;
  z-index: 2;
  background: transparent;
  border: 0;
  padding: 9px 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim, #7888aa);
  cursor: pointer;
  transition: color 0.2s;
  letter-spacing: 0.03em;
}
.auth-tab-btn.active { color: #0a0c10; }
.auth-tabs-indicator {
  position: absolute;
  top: 4px; bottom: 4px;
  width: calc(50% - 4px);
  background: linear-gradient(135deg, #ffd86b, #f0b429);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(240, 180, 41, 0.35);
  transition: transform 0.28s cubic-bezier(0.5, 1.4, 0.4, 1);
  z-index: 1;
}
.auth-tabs[data-active="register"] .auth-tabs-indicator { transform: translateX(100%); }

/* Form */
.auth-form { display: none; }
.auth-form.active { display: block; animation: authFadeIn 0.22s ease; }
@keyframes authFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-field {
  position: relative;
  margin-bottom: 14px;
}
.auth-field-label {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim, #7888aa);
  margin-bottom: 6px;
}
.auth-field-label .req { color: #ff6b6b; margin-left: 2px; }
.auth-field-label .opt {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-dim, #7888aa);
  opacity: 0.7;
  margin-left: 6px;
}

.auth-input-wrap {
  position: relative;
}
.auth-input {
  width: 100%;
  background: rgba(10, 12, 16, 0.55);
  border: 1px solid var(--border, #2a3050);
  border-radius: 9px;
  padding: 11px 14px;
  color: var(--text, #d4deff);
  font-size: 0.92rem;
  font-family: inherit;
  transition: all 0.18s;
  outline: none;
  box-sizing: border-box;
}
.auth-input::placeholder { color: var(--text-dim, #7888aa); opacity: 0.55; }
.auth-input:hover { border-color: rgba(176, 106, 255, 0.35); }
.auth-input:focus {
  border-color: rgba(240, 180, 41, 0.6);
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.12), 0 0 18px rgba(240, 180, 41, 0.08);
  background: rgba(10, 12, 16, 0.8);
}
.auth-field.has-error .auth-input {
  border-color: rgba(255, 107, 107, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}
.auth-field.is-valid .auth-input {
  border-color: rgba(61, 255, 160, 0.45);
}

.auth-input.with-toggle { padding-right: 42px; }
.auth-pw-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim, #7888aa);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}
.auth-pw-toggle:hover { color: var(--gold, #f0b429); background: rgba(255,255,255,0.04); }
.auth-pw-toggle svg { width: 18px; height: 18px; }

.auth-field-msg {
  display: none;
  margin-top: 5px;
  font-size: 0.75rem;
  line-height: 1.4;
}
.auth-field.has-error .auth-field-msg {
  display: block;
  color: #ff8585;
}
.auth-field.is-valid .auth-field-msg.success {
  display: block;
  color: #5be29a;
}

/* Password strength */
.auth-pw-strength {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.auth-pw-strength-bar {
  flex: 1;
  height: 4px;
  background: rgba(42, 48, 80, 0.6);
  border-radius: 2px;
  transition: background 0.2s;
}
.auth-pw-strength[data-level="1"] .auth-pw-strength-bar:nth-child(-n+1) { background: #ff6b6b; }
.auth-pw-strength[data-level="2"] .auth-pw-strength-bar:nth-child(-n+2) { background: #ffa940; }
.auth-pw-strength[data-level="3"] .auth-pw-strength-bar:nth-child(-n+3) { background: #ffd86b; }
.auth-pw-strength[data-level="4"] .auth-pw-strength-bar:nth-child(-n+4) { background: #3dffa0; }
.auth-pw-strength-label {
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--text-dim, #7888aa);
  text-align: right;
}

/* Submit button */
.auth-submit {
  width: 100%;
  margin-top: 6px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #ffd86b 0%, #f0b429 55%, #c8830a 100%);
  border: 0;
  border-radius: 10px;
  color: #0a0c10;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.18s;
  box-shadow:
    0 6px 20px rgba(240, 180, 41, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.auth-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow:
    0 10px 28px rgba(240, 180, 41, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.auth-submit:active:not(:disabled) { transform: translateY(0); }
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-submit::after {
  content: '';
  position: absolute;
  top: -50%; left: -100%;
  width: 60%; height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  transform: skewX(-25deg);
  transition: left 0.6s;
}
.auth-submit:hover:not(:disabled)::after { left: 130%; }

.auth-submit-spinner {
  display: none;
  width: 16px; height: 16px;
  border: 2px solid rgba(10,12,16,0.25);
  border-top-color: #0a0c10;
  border-radius: 50%;
  animation: authSpin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
.auth-submit.loading .auth-submit-spinner { display: inline-block; }
.auth-submit.loading .auth-submit-text { opacity: 0.7; }
@keyframes authSpin { to { transform: rotate(360deg); } }

/* Top-level form error (banner) */
.auth-form-error {
  display: none;
  margin-bottom: 12px;
  padding: 9px 12px;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: 8px;
  color: #ff8585;
  font-size: 0.82rem;
  line-height: 1.4;
}
.auth-form-error.show { display: block; animation: authShake 0.32s ease; }
@keyframes authShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Hint */
.auth-hint {
  margin-top: 14px;
  font-size: 0.75rem;
  color: var(--text-dim, #7888aa);
  text-align: center;
  line-height: 1.5;
}
.auth-hint b { color: var(--gold-light, #ffd97d); font-weight: 600; }

/* Footer switcher */
.auth-switch {
  margin-top: 14px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-dim, #7888aa);
}
.auth-switch a {
  color: var(--gold, #f0b429);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  margin-left: 4px;
}
.auth-switch a:hover { text-decoration: underline; }

/* Toast */
.auth-toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 10001;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  min-width: 220px;
  max-width: 360px;
  background: linear-gradient(180deg, rgba(26,31,46,0.98), rgba(17,20,32,0.98));
  border: 1px solid var(--border, #2a3050);
  border-left: 3px solid var(--gold, #f0b429);
  border-radius: 9px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
  color: var(--text, #d4deff);
  font-size: 0.86rem;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.auth-toast.show { transform: translateX(0); }
.auth-toast.success { border-left-color: #3dffa0; }
.auth-toast.error { border-left-color: #ff6b6b; }
.auth-toast-icon { font-size: 1.1rem; flex-shrink: 0; }

/* User row (logged-in state) — username + logout icon, no dropdown */
.auth-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 6px 10px;
}
.auth-user-name {
  color: var(--text, #d4deff);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}
.auth-user-logout {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  width: 30px; height: 30px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-dim, #7888aa);
  cursor: pointer;
  transition: all 0.18s;
}
.auth-user-logout:hover {
  background: rgba(255, 107, 107, 0.12);
  transform: translateX(2px);
}
.auth-user-logout img {
  filter: brightness(0.85);
  transition: filter 0.18s;
}
.auth-user-logout:hover img {
  filter: brightness(1) drop-shadow(0 0 4px rgba(255,107,107,0.5));
}

/* "Đăng nhập" trigger button — sidebar / topbar */
.auth-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: linear-gradient(135deg, rgba(240, 180, 41, 0.15), rgba(176, 106, 255, 0.1));
  border: 1px solid rgba(240, 180, 41, 0.3);
  border-radius: 8px;
  color: var(--gold-light, #ffd97d);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
}
.auth-login-btn:hover {
  background: linear-gradient(135deg, rgba(240, 180, 41, 0.25), rgba(176, 106, 255, 0.18));
  border-color: rgba(240, 180, 41, 0.5);
  transform: translateY(-1px);
}

/* Mobile tweaks */
@media (max-width: 480px) {
  .auth-card { padding: 22px 18px 18px; border-radius: 12px; }
  .auth-toast { top: 12px; right: 12px; left: 12px; max-width: none; }
}

/* Light theme overrides */
[data-theme="light"] .auth-overlay {
  background: radial-gradient(ellipse at center, rgba(176, 106, 255, 0.06), rgba(245, 240, 232, 0.85) 60%);
}
[data-theme="light"] .auth-card {
  background: linear-gradient(180deg, rgba(253, 250, 245, 0.98), rgba(245, 240, 232, 0.98));
}
[data-theme="light"] .auth-input {
  background: rgba(255, 255, 255, 0.7);
  color: var(--text, #2a2018);
}
[data-theme="light"] .auth-input:focus { background: rgba(255, 255, 255, 0.95); }
[data-theme="light"] .auth-tab-btn.active { color: #2a2018; }
[data-theme="light"] .auth-submit { color: #2a2018; }
[data-theme="light"] .auth-tabs { background: rgba(255,255,255,0.5); }
