/* ===================================================================
   Trang tài khoản: đăng nhập, đăng ký, xác minh, quên/đặt lại mật khẩu
   Màu & font theo theme mặc định của expense-app
   =================================================================== */
:root {
  --bg: #ececec;
  --surface: #ffffff;
  --ink: #111111;
  --muted: #5f5f5f;
  --border: #cdcdcd;
  --border-soft: #e3e3e3;
  --danger: #b3261e;
  --danger-ink: #8c1d18;
  --success-ink: #2b2b2b;
  --strong: #111111;
  --ring: 0 0 0 3px rgba(17, 17, 17, 0.14);
  --panel: linear-gradient(120deg, #050505 0%, #111111 40%, #262626 75%, #3a3a3a 100%);
  --slide: 1.6s;
  --ease-slide: cubic-bezier(0.7, 0, 0.3, 1);
  font-family: "Be Vietnam Pro", system-ui, "Segoe UI", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  font-size: 14px;
  background-color: var(--bg);
  /* Lưới chấm xám nhạt, trung tính cho mọi ứng dụng */
  background-image: radial-gradient(rgba(17, 17, 17, 0.09) 1px, transparent 1.5px);
  background-size: 22px 22px;
}

/* Lúc mới tải trang: tắt mọi hiệu ứng, để mảng màu đứng sẵn đúng chỗ (JS bỏ class này sau 1 khung hình) */
.is-loading *, .is-loading *::before, .is-loading *::after {
  transition: none !important;
  animation: none !important;
}

/* ===== Đổi ngôn ngữ: góc trên phải màn hình, có nền riêng nên nằm trên nền nào cũng đọc được ===== */
.lang {
  position: fixed; z-index: 10; top: 16px; right: 16px;
  display: flex; gap: 2px; padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.lang a {
  display: inline-flex; align-items: center;
  min-height: 32px; padding: 0 12px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  color: var(--muted); text-decoration: none;
}
.lang a:hover { color: var(--ink); }
.lang a[aria-current="true"] { color: #ffffff; background: var(--ink); }
.lang a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Khung ngoài chiếm hết chiều ngang, căn thẻ vào giữa */
.auth { width: 100%; display: flex; justify-content: center; }

/* ===== Khung thẻ ===== */
.card {
  position: relative;
  width: min(960px, 100%);
  height: 640px;
  overflow: hidden;
  overflow: clip;  /* clip: không cho trình duyệt tự cuộn thẻ khi focus vào ô nhập bị che */
  background: var(--surface);
  border-radius: 28px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 24px 60px rgba(0, 0, 0, 0.16);
}

/* ===== Hai bên form ===== */
.side {
  position: absolute;
  top: 0;
  z-index: 1;
  width: 50%;
  height: 100%;
  /* Ẩn: mờ đi ngay */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}
.side-login { right: 0; }
.side-register { left: 0; }

/* Hiện: đợi mảng màu che kín (~giữa hành trình) rồi mới hiện */
.auth[data-side="login"] .side-login,
.auth[data-side="register"] .side-register {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease 0.75s, visibility 0s linear 0.75s;
}

/* ===== Các bước trong cùng một bên (đổi tại chỗ: trượt nhẹ lên + mờ) ===== */
.step {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  gap: 12px;
  padding: 32px 56px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition: opacity 0.25s ease, transform 0.35s ease, visibility 0s linear 0.25s;
}
.auth[data-mode="login"] .step[data-step="login"],
.auth[data-mode="forgot"] .step[data-step="forgot"],
.auth[data-mode="reset"] .step[data-step="reset"],
.auth[data-mode="register"] .step[data-step="register"],
.auth[data-mode="verify"] .step[data-step="verify"] {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.35s ease 0.15s, transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) 0.15s, visibility 0s;
}

/* ===== Mảng màu: khối rộng 300%, bo góc lớn, trượt ngang ===== */
.panel {
  position: absolute;
  z-index: 2;
  top: 0;
  left: -250%;           /* phía Đăng nhập: chỉ lộ phần đuôi bên trái */
  width: 300%;
  height: 100%;
  border-radius: 150px;
  background: var(--panel);
  transition: left var(--slide) var(--ease-slide);
}
.auth[data-side="register"] .panel { left: 50%; }   /* phía Đăng ký: lộ phần đầu bên phải */

/* ===== Chữ trên mảng màu ===== */
.ptext {
  position: absolute;
  z-index: 3;
  top: 0;
  width: 50%;
  height: 100%;
  padding: 0 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  color: #ffffff;
  transition: transform 0.7s var(--ease-slide) 0.9s, opacity 0.5s ease 0.9s, visibility 0s;
}
.ptext-login { left: 0; }
.ptext-register { right: 0; }

.auth[data-side="register"] .ptext-login,
.auth[data-side="login"] .ptext-register {
  opacity: 0;
  visibility: hidden;
  transition: transform 0.7s var(--ease-slide), opacity 0.4s ease, visibility 0s linear 0.7s;
}
.auth[data-side="register"] .ptext-login { transform: translateX(-120%); }
.auth[data-side="login"] .ptext-register { transform: translateX(120%); }

.brand { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; letter-spacing: 0.01em; }
.brand-mark { width: 34px; height: 38px; color: #ffffff; }
.brand-mark svg { display: block; width: 100%; height: 100%; }

.pt-variant { display: none; flex-direction: column; align-items: center; gap: 12px; }
.auth[data-mode="login"] .pt-variant[data-for="login"],
.auth[data-mode="forgot"] .pt-variant[data-for="forgot"],
.auth[data-mode="reset"] .pt-variant[data-for="reset"],
.auth[data-mode="register"] .pt-variant[data-for="register"],
.auth[data-mode="verify"] .pt-variant[data-for="verify"] {
  display: flex;
  animation: pt-in 0.45s ease both;
}
@keyframes pt-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.pt-title { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.pt-text { margin: 0; max-width: 300px; font-size: 14px; line-height: 1.55; opacity: 0.85; }

.btn-ghost {
  margin-top: 4px;
  display: inline-flex; align-items: center;
  height: 42px; padding: 0 24px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  color: #ffffff; font-weight: 700; text-decoration: none;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }
.btn-ghost:focus-visible { outline: 2px solid #ffffff; outline-offset: 3px; }

/* ===== Nội dung form ===== */
h1 { margin: 0 0 2px; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.lead { margin: 0; color: var(--muted); line-height: 1.55; }
.lead strong { color: var(--ink); }
.hint { margin: -2px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.back { margin: 2px 0 0; font-size: 13px; text-align: center; }
.back a, .link-sm { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.link-sm { font-size: 12px; }

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.label { font-size: 12px; font-weight: 600; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.optional { font-weight: 500; color: var(--muted); }

.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.input:focus { outline: none; border-color: var(--ink); box-shadow: var(--ring); }
.input.is-invalid { border-color: var(--danger); }
.field-error { font-size: 12px; color: var(--danger-ink); }

.pw { position: relative; display: block; }
.pw .input { padding-right: 64px; }
.pw-toggle {
  position: absolute; top: 4px; right: 4px;
  height: 36px; padding: 0 10px;
  font: inherit; font-size: 12px; font-weight: 600;
  color: var(--ink); background: none; border: none; border-radius: 8px; cursor: pointer;
}
.pw-toggle:hover { background: rgba(17, 17, 17, 0.06); }

.btn-primary {
  height: 44px;
  font: inherit; font-size: 15px; font-weight: 700;
  color: #ffffff; background: var(--ink);
  border: none; border-radius: 10px; cursor: pointer;
}
.btn-primary:hover { background: #333333; }
.btn-primary:focus-visible, .btn-google:focus-visible, .link-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.btn-google {
  height: 44px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 15px; font-weight: 600; text-decoration: none;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
}
.btn-google:hover { border-color: var(--muted); }
.g-mark {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--muted);
  border: 1.5px solid var(--border);
}

.divider { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }

.alert { margin: 0; padding: 9px 12px; border-radius: 10px; font-size: 13px; line-height: 1.45; }
.alert-error { color: var(--danger-ink); background: #fceeec; border: 1px solid #f1c9c4; }
.alert-success { color: var(--success-ink); background: #f2f2f2; border: 1px solid #d6d6d6; }

/* Độ mạnh mật khẩu */
.strength { display: flex; align-items: center; gap: 8px; }
.strength-bars { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.strength-bars i { height: 4px; border-radius: 2px; background: var(--border-soft); }
.strength-label { min-width: 64px; font-size: 11px; font-weight: 600; text-align: right; color: var(--muted); }
.strength[data-score="1"] i:nth-child(-n+1) { background: var(--danger); }
.strength[data-score="2"] i:nth-child(-n+2) { background: #8a8a8a; }
.strength[data-score="3"] i:nth-child(-n+3),
.strength[data-score="4"] i { background: var(--strong); }
.strength[data-score="3"] .strength-label,
.strength[data-score="4"] .strength-label { color: var(--success-ink); }

/* Ô mã 6 số: MỘT ô nhập thật; khi có JS thì phủ trong suốt lên 6 ô vẽ */
.otp { position: relative; }
.otp-input { font-size: 22px; font-weight: 700; letter-spacing: 0.5em; text-align: center; font-variant-numeric: tabular-nums; }
.otp-slots { display: none; }
.js .otp-slots { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.js .otp-input { position: absolute; inset: 0; height: 100%; opacity: 0; cursor: text; }
.otp-slots span {
  height: 52px;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: #f5f5f5;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.otp-slots span:not(:empty) { background: var(--surface); }
.otp-slots span.is-active { border-color: var(--ink); box-shadow: var(--ring); }
.otp-slots span.is-active:empty::after { content: ""; width: 2px; height: 24px; background: var(--ink); animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.otp:has(.is-invalid) .otp-slots span { border-color: var(--danger); }

.resend { margin: 0; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; color: var(--muted); }
.link-btn {
  padding: 4px; font: inherit; font-weight: 700;
  color: var(--ink); background: none; border: none; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:disabled { cursor: default; text-decoration: none; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ===== Điện thoại: mảng màu trượt DỌC ===== */
@media (max-width: 720px) {
  .lang { top: 20px; right: 20px; }
  body { padding: 12px; place-items: stretch; }
  .card { width: 100%; height: calc(100dvh - 24px); min-height: 640px; border-radius: 24px; }

  .side { width: 100%; height: 72%; left: 0; right: auto; }
  .side-login { top: auto; bottom: 0; }
  .side-register { top: 0; }
  .step { padding: 24px 22px; }

  .panel { left: 0; top: -272%; width: 100%; height: 300%; border-radius: 64px; transition: top var(--slide) var(--ease-slide); }
  .auth[data-side="register"] .panel { left: 0; top: 72%; }

  .ptext { width: 100%; height: 28%; left: 0; right: auto; padding: 0 24px; gap: 8px; }
  .ptext-login { top: 0; }
  .ptext-register { top: auto; bottom: 0; }
  .auth[data-side="register"] .ptext-login { transform: translateY(-130%); }
  .auth[data-side="login"] .ptext-register { transform: translateY(130%); }
  .pt-variant { gap: 6px; }
  .pt-title { font-size: 22px; }
  .pt-text { display: none; }
  .btn-ghost { height: 36px; padding: 0 18px; }
}

/* Người dùng bật "giảm chuyển động": đổi màn hình tức thì */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01s !important; transition-delay: 0s !important; animation: none !important; }
}
