/*
 * Trang xác thực giao diện v2 (29/09/2026): đăng nhập, đăng ký, xác minh OTP.
 *
 * Độc lập với app.css: các trang này nạp trước khi có phiên, không có shell.
 * Dùng cùng bộ màu với ui-v2.css (xám trung tính, cam chỉ cho nút chính).
 * Mọi quy tắc nằm dưới `.auth-v2` để không đụng các trang auth chưa làm lại.
 */
.auth-v2 {
  --av-bg: #ffffff;
  --av-soft: #f7f6f4;
  --av-border: #e4e4e7;
  --av-border-strong: #d4d4d8;
  --av-text: #18181b;
  --av-text-2: #52525b;
  --av-text-3: #8b8b93;
  --av-brand: #e04f16;
  --av-brand-hover: #c2410c;
  --av-brand-soft: #fff4ed;
  --av-brand-text: #b93815;
  --av-focus: #3e63dd;
  --av-ring: rgba(62, 99, 221, 0.22);
  --av-danger: #c5281c;
  --av-danger-bg: #fdeceb;
  --av-success: #0f7b53;
  margin: 0;
  min-height: 100vh;
  background: var(--av-bg);
  color: var(--av-text);
  font: 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.auth-v2 *,
.auth-v2 *::before,
.auth-v2 *::after { box-sizing: border-box; }
.auth-v2 a { color: var(--av-brand-text); text-decoration: none; font-weight: 500; }
.auth-v2 a:hover { text-decoration: underline; }
.auth-v2 [hidden],
.auth-v2 .hidden { display: none !important; }
.auth-v2 .av-icon { flex-shrink: 0; }

/* ---- Khung chia đôi --------------------------------------------------- */
.av-shell { display: grid; grid-template-columns: minmax(360px, 44%) 1fr; min-height: 100vh; }

.av-brand {
  display: flex;
  flex-direction: column;
  padding: 40px 48px;
  background: var(--av-soft);
  border-right: 1px solid var(--av-border);
}
.av-brand-logo { height: 40px; width: auto; align-self: flex-start; }
.av-brand-body { margin: auto 0; max-width: 440px; padding: 48px 0; }
.av-brand h2 {
  margin: 0 0 12px;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.av-brand h2 em { font-style: normal; color: var(--av-brand); }
.av-brand-lead { margin: 0 0 32px; color: var(--av-text-2); font-size: 15px; line-height: 1.6; }
.av-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; }
.av-points li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; }
.av-point-ic {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--av-border);
  color: var(--av-brand);
}
.av-points strong { display: block; font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.av-points span { color: var(--av-text-2); font-size: 13.5px; line-height: 1.5; }
.av-brand-foot { font-size: 12.5px; color: var(--av-text-3); }

.av-main { display: flex; flex-direction: column; padding: 24px 40px; min-width: 0; }
.av-top { display: flex; justify-content: flex-end; align-items: center; gap: 12px; min-height: 40px; font-size: 13.5px; color: var(--av-text-2); }
.av-top .av-mobile-logo { display: none; height: 32px; margin-right: auto; }
.av-form-wrap { width: 100%; max-width: 400px; margin: auto; padding: 32px 0; }
.av-form-wrap.is-wide { max-width: 480px; }
.av-legal { text-align: center; font-size: 12px; color: var(--av-text-3); }
.av-legal a { color: inherit; font-weight: 400; }

/* ---- Tiêu đề biểu mẫu ------------------------------------------------- */
.av-head { margin-bottom: 28px; }
.av-head h1 { margin: 0 0 6px; font-size: 26px; line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; }
.av-head p { margin: 0; color: var(--av-text-2); font-size: 14.5px; }
.av-head p strong { color: var(--av-text); font-weight: 600; word-break: break-all; }
.av-head-ic {
  width: 48px;
  height: 48px;
  margin-bottom: 20px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--av-brand-soft);
  color: var(--av-brand);
}

/* ---- Trường nhập ------------------------------------------------------ */
.av-form { display: grid; gap: 16px; }
.av-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.av-section { font-size: 12px; font-weight: 600; color: var(--av-text-3); margin: 8px 0 -4px; }
.av-field { display: grid; gap: 6px; min-width: 0; }
.av-field > label,
.av-label-row label { font-size: 13px; font-weight: 500; color: var(--av-text); }
.av-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.av-label-row a { font-size: 13px; }
.av-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--av-border);
  border-radius: 8px;
  background: #fff;
  color: var(--av-text);
  font: inherit;
  font-size: 14.5px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.av-input::placeholder { color: var(--av-text-3); }
.av-input:hover { border-color: var(--av-border-strong); }
.av-input:focus { outline: none; border-color: var(--av-focus); box-shadow: 0 0 0 3px var(--av-ring); }
.av-input[readonly] { background: var(--av-soft); color: var(--av-text-2); }
.av-hint { margin: 0; font-size: 12.5px; color: var(--av-text-3); line-height: 1.45; }

.av-input-wrap { position: relative; }
.av-input-wrap .av-input { padding-right: 42px; }
.av-eye {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--av-text-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.av-eye:hover { color: var(--av-text); background: var(--av-soft); }
.av-eye:focus-visible { outline: 2px solid var(--av-focus); outline-offset: 1px; }
.av-eye .av-eye-off { display: none; }
.av-eye[data-visible="true"] .av-eye-on { display: none; }
.av-eye[data-visible="true"] .av-eye-off { display: inline-flex; }

.av-phone { display: flex; }
.av-phone-prefix {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--av-border);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: var(--av-soft);
  color: var(--av-text-2);
  font-size: 14px;
}
.av-phone .av-input { border-radius: 0 8px 8px 0; }

.av-check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--av-text-2); line-height: 1.5; cursor: pointer; }
.av-check input { margin: 2px 0 0; width: 16px; height: 16px; accent-color: var(--av-brand); flex-shrink: 0; }

/* ---- Nút -------------------------------------------------------------- */
.av-btn {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--av-brand);
  color: #fff;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.12s;
}
.av-btn:hover:not(:disabled) { background: var(--av-brand-hover); }
.av-btn:focus-visible { outline: 2px solid var(--av-focus); outline-offset: 2px; }
.av-btn:disabled { opacity: 0.7; cursor: progress; }
.av-link-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--av-brand-text);
  cursor: pointer;
}
.av-link-btn:disabled { color: var(--av-text-3); cursor: default; font-variant-numeric: tabular-nums; }
.av-link-btn:not(:disabled):hover { text-decoration: underline; }
.av-muted-btn { border: 0; background: none; padding: 0; font: inherit; font-size: 13.5px; color: var(--av-text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.av-muted-btn:hover { color: var(--av-text); }
.av-foot { margin: 4px 0 0; text-align: center; font-size: 13.5px; color: var(--av-text-2); }

/* ---- Thông báo lỗi / lời mời ----------------------------------------- */
.av-error {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--av-danger-bg);
  color: var(--av-danger);
  font-size: 13.5px;
  line-height: 1.45;
}
.av-error::before {
  content: "";
  width: 16px;
  height: 16px;
  margin-top: 1px;
  flex-shrink: 0;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E") center / contain no-repeat;
}
.av-invite {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--av-border);
  background: var(--av-soft);
  font-size: 13.5px;
  color: var(--av-text-2);
}
.av-invite strong { color: var(--av-text); font-weight: 600; }
.av-invite .av-point-ic { width: 32px; height: 32px; }

/* ---- Ô nhập mã OTP ---------------------------------------------------- */
.av-otp { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.av-otp-box {
  height: 52px;
  width: 100%;
  text-align: center;
  border: 1px solid var(--av-border);
  border-radius: 10px;
  background: #fff;
  color: var(--av-text);
  font: inherit;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  caret-color: var(--av-focus);
}
.av-otp-box:hover { border-color: var(--av-border-strong); }
.av-otp-box:focus { outline: none; border-color: var(--av-focus); box-shadow: 0 0 0 3px var(--av-ring); }
.av-otp.is-error .av-otp-box { border-color: var(--av-danger); }
.av-otp-status { margin: -4px 0 0; font-size: 13px; color: var(--av-success); }
.av-otp-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13.5px; color: var(--av-text-2); }
/* Ô mã thật (id cũ, logic cũ đọc/ghi vào đây) — ẩn khỏi mắt nhưng vẫn trong form. */
.av-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }

/* ---- Màn hình hẹp ----------------------------------------------------- */
@media (max-width: 900px) {
  .av-shell { grid-template-columns: 1fr; }
  .av-brand { display: none; }
  .av-top .av-mobile-logo { display: block; }
  .av-main { padding: 16px 20px; }
  .av-form-wrap { padding: 24px 0; }
}
@media (max-width: 480px) {
  .av-grid-2 { grid-template-columns: 1fr; }
  .av-head h1 { font-size: 22px; }
  .av-otp { gap: 6px; }
  .av-otp-box { height: 48px; font-size: 20px; }
}

/* ---- Xác minh email nằm trong khung đăng ký --------------------------- */
.av-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 16px; }
/* Đang chờ mã: ô bị khoá nhưng chữ vẫn đọc rõ để người dùng soát lại. */
.av-fieldset:disabled .av-input,
.av-fieldset:disabled .av-phone-prefix { background: var(--av-soft); color: var(--av-text-2); border-color: var(--av-border); cursor: default; }
.av-fieldset:disabled .av-input::placeholder { color: transparent; }
.av-fieldset:disabled .av-eye,
.av-fieldset:disabled .av-hint { display: none; }
.av-fieldset:disabled .av-check { opacity: 0.7; cursor: default; }
.av-verify {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid var(--av-border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 0 0 4px var(--av-brand-soft);
  scroll-margin: 24px;
}
.av-verify-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.av-verify-ic {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--av-brand-soft);
  color: var(--av-brand);
}
.av-verify h2 { margin: 0 0 2px; font-size: 16px; font-weight: 600; }
.av-verify p { margin: 0; color: var(--av-text-2); font-size: 13.5px; }
.av-verify p strong { color: var(--av-text); font-weight: 600; word-break: break-all; }
.av-verify .av-otp-box { height: 48px; }
@media (max-width: 480px) {
  .av-verify { padding: 16px; }
}

/* ---- Quên / đặt lại mật khẩu ------------------------------------------ */
.auth-v2 a.av-btn,
.auth-v2 a.av-btn:hover { color: #fff; text-decoration: none; }
.av-btn-outline { background: #fff; color: var(--av-text); border: 1px solid var(--av-border); }
.av-btn-outline:hover:not(:disabled) { background: var(--av-soft); }
.auth-v2 a.av-btn-outline,
.auth-v2 a.av-btn-outline:hover { color: var(--av-text); }
.av-back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 24px; font-size: 13.5px; color: var(--av-text-2) !important; font-weight: 500; }
.av-back:hover { color: var(--av-text) !important; text-decoration: none !important; }
.av-head-ic.is-danger { background: var(--av-danger-bg); color: var(--av-danger); }
.av-head-ic.is-success { background: #e8f6ef; color: var(--av-success); }
/* Yêu cầu mật khẩu: tích xanh ngay khi gõ đạt từng điều kiện. */
.av-rules { list-style: none; margin: 2px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 12.5px; color: var(--av-text-3); }
.av-rules li { display: flex; align-items: center; gap: 6px; }
.av-rules li::before {
  content: "";
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1.5px solid var(--av-border-strong);
}
.av-rules li.is-ok { color: var(--av-success); }
.av-rules li.is-ok::before {
  border-color: var(--av-success);
  background: var(--av-success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 9px no-repeat;
}
