/* Đăng nhập / đăng xuất (tính năng dang_nhap). Chỉ nạp trên trang dang-nhap, dang-xuat (layout auth). Dùng biến màu của app.css. */
body.qa-auth { min-height: 100vh; min-height: 100dvh; background: var(--qa-side); }

.qa-dn {
  position: relative; isolation: isolate; overflow: hidden;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(28px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  background:
    radial-gradient(900px 520px at 0% 0%, rgba(47, 107, 255, .38), transparent 62%),
    radial-gradient(700px 480px at 100% 100%, rgba(106, 140, 255, .22), transparent 60%),
    linear-gradient(165deg, #0a1430 0%, var(--qa-side) 48%, var(--qa-side-2) 100%);
}

/* Nền: dải đường với vạch kẻ giữa — gợi hình ảnh đường tập lái, rất nhạt */
.qa-dn-bg { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.qa-dn-bg::before, .qa-dn-road {
  content: ""; position: absolute; left: -20vmax; width: 140vmax; transform: rotate(-14deg);
}
.qa-dn-bg::before {
  bottom: 4vh; height: 22vmax;
  background: linear-gradient(180deg, rgba(255, 255, 255, .025), rgba(255, 255, 255, .06));
  border-top: 1px solid rgba(255, 255, 255, .07); border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.qa-dn-road {
  bottom: calc(4vh + 11vmax - 2px); height: 3px; opacity: .22;
  background: repeating-linear-gradient(90deg, rgba(255, 210, 92, .8) 0 44px, transparent 44px 92px);
}

.qa-dn-wrap { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; }

/* Thương hiệu */
.qa-dn-brand { text-align: center; color: #fff; margin-bottom: 20px; }
.qa-dn-logo {
  width: 64px; height: 64px; border-radius: 18px; margin-bottom: 12px;
  display: inline-grid; place-items: center;
  background: linear-gradient(135deg, #2f6bff, #6a8cff);
  box-shadow: 0 12px 30px rgba(31, 94, 255, .45), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.qa-dn-logo .qa-icon { width: 36px; height: 36px; color: #fff; }
.qa-dn-logo.has-img { background: #fff; box-shadow: 0 12px 30px rgba(3, 10, 30, .35); overflow: hidden; }
.qa-dn-logo img { width: 100%; height: 100%; object-fit: contain; padding: 6px; display: block; }
.qa-dn-center { font-size: 19px; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; overflow-wrap: anywhere; }
.qa-dn-tagline { margin: 4px 0 0; color: var(--qa-side-text); font-size: 13px; }
.qa-dn-points { display: none; }

.qa-dn-panel { width: 100%; display: flex; flex-direction: column; align-items: center; }

/* Thẻ */
.qa-dn-card {
  width: 100%; background: #fff; color: var(--qa-text);
  border-radius: 18px; padding: 24px 20px 20px;
  box-shadow: 0 24px 60px rgba(3, 10, 30, .45), 0 2px 6px rgba(3, 10, 30, .2);
}
.qa-dn-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.qa-dn-sub { margin: 6px 0 18px; color: var(--qa-muted); font-size: 14px; }

/* Trường nhập */
.qa-dn-field { margin-bottom: 14px; }
.qa-dn-field > label { display: block; font-size: 13px; font-weight: 600; color: var(--qa-text-2); margin-bottom: 6px; }
.qa-dn-control { position: relative; }
.qa-dn-control > .qa-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 19px; height: 19px; color: var(--qa-muted); pointer-events: none; }
.qa-dn-input {
  width: 100%; height: 48px; padding: 0 14px 0 44px;
  border: 1px solid var(--qa-border-strong); border-radius: 12px;
  background: var(--qa-surface-2); color: var(--qa-text);
  font: 16px/1.2 var(--qa-font); /* 16px: iOS không tự phóng to khi gõ */
  transition: border-color .12s, box-shadow .12s, background .12s;
  -webkit-appearance: none; appearance: none;
}
.qa-dn-input::placeholder { color: #9aa6b8; }
.qa-dn-input:focus { outline: 0; border-color: var(--qa-primary); background: #fff; box-shadow: 0 0 0 4px rgba(31, 94, 255, .14); }
.qa-dn-input.has-eye { padding-right: 52px; }
.qa-dn-input.qa-dn-input-plain { padding-left: 14px; }
.qa-dn-input[readonly] { color: var(--qa-text-2); }
.qa-dn-code { letter-spacing: .28em; font-variant-numeric: tabular-nums; }
.qa-dn-code::placeholder { letter-spacing: normal; }
.qa-dn-hint { display: block; margin-top: 6px; color: var(--qa-muted); font-size: 12.5px; }
.qa-dn-error { margin-top: 6px; color: var(--qa-red); font-size: 13px; }
.qa-dn-field.has-error .qa-dn-input { border-color: var(--qa-red); background: #fff; }
.qa-dn-field.has-error .qa-dn-input:focus { box-shadow: 0 0 0 4px rgba(217, 54, 54, .14); }
.qa-dn-field.has-error .qa-dn-hint { display: none; }

.qa-dn-eye, .qa-dn-icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 10px; background: transparent; color: var(--qa-muted); cursor: pointer;
}
.qa-dn-eye { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); }
.qa-dn-eye:hover, .qa-dn-icon-btn:hover { color: var(--qa-text); background: rgba(16, 24, 40, .05); }
.qa-dn-eye:focus-visible, .qa-dn-icon-btn:focus-visible, .qa-dn-link:focus-visible, .qa-dn-check input:focus-visible { outline: 2px solid var(--qa-primary); outline-offset: 2px; }
.qa-dn-eye .qa-icon, .qa-dn-icon-btn .qa-icon { width: 20px; height: 20px; }
.qa-dn-eye .qa-dn-eye-hide, .qa-dn-eye[aria-pressed="true"] .qa-dn-eye-show { display: none; }
.qa-dn-eye[aria-pressed="true"] .qa-dn-eye-hide { display: block; }

/* Captcha ảnh của NukeViet */
.qa-dn-captcha-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qa-dn-captcha-img { height: 44px; width: auto; max-width: 150px; border-radius: 10px; border: 1px solid var(--qa-border); background: #fff; }
.qa-dn-captcha-row .qa-dn-input { flex: 1 1 110px; min-width: 0; text-transform: uppercase; letter-spacing: .12em; }
.qa-dn-captcha-row .qa-dn-input::placeholder { text-transform: none; letter-spacing: normal; }

/* Ghi nhớ + quên mật khẩu */
.qa-dn-row { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; margin: 2px 0 18px; }
.qa-dn-check { display: inline-flex; align-items: center; gap: 9px; min-height: 36px; font-size: 14px; color: var(--qa-text-2); cursor: pointer; user-select: none; }
.qa-dn-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--qa-primary); }
.qa-dn-forgot { font-size: 14px; font-weight: 600; padding: 8px 0; }
.qa-dn-link { padding: 8px 0; border: 0; background: none; color: var(--qa-primary); font: 600 14px var(--qa-font); cursor: pointer; border-radius: 6px; }
.qa-dn-link:hover { color: var(--qa-primary-600); text-decoration: underline; }

/* Nút chính */
.qa-dn-submit {
  width: 100%; height: 50px; padding: 0 18px; border: 0; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(135deg, var(--qa-primary), #3f76ff); color: #fff;
  font: 600 16px var(--qa-font); text-decoration: none; cursor: pointer;
  box-shadow: 0 10px 22px rgba(31, 94, 255, .32);
  transition: filter .15s, transform .08s, box-shadow .15s;
}
.qa-dn-submit:hover { color: #fff; filter: brightness(1.06); }
.qa-dn-submit:active { transform: translateY(1px); box-shadow: 0 6px 14px rgba(31, 94, 255, .3); }
.qa-dn-submit:focus-visible { outline: 0; box-shadow: 0 0 0 4px rgba(31, 94, 255, .32); }
.qa-dn-submit[disabled] { cursor: progress; filter: saturate(.8) brightness(.97); }
.qa-dn-submit .qa-icon { width: 19px; height: 19px; }
.qa-dn-submit.is-loading .qa-icon { display: none; }
.qa-dn-spinner { display: none; width: 18px; height: 18px; flex: none; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: qa-dn-spin .7s linear infinite; }
.qa-dn-spinner.is-dark { display: inline-block; border-color: rgba(31, 94, 255, .2); border-top-color: var(--qa-primary); }
.qa-dn-submit.is-loading .qa-dn-spinner { display: inline-block; }
@keyframes qa-dn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .qa-dn-spinner { animation-duration: 1.8s; } .qa-dn-submit { transition: none; } }

.qa-dn-secondary {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 46px; margin-top: 10px;
  border-radius: 12px; border: 1px solid var(--qa-border-strong); background: #fff; color: var(--qa-text-2); font-weight: 600;
}
.qa-dn-secondary:hover { background: var(--qa-surface-2); color: var(--qa-text); }

/* Thông báo */
.qa-dn-alert {
  display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; padding: 11px 13px;
  border-radius: 12px; font-size: 13.5px; line-height: 1.5;
  background: var(--qa-red-50); color: #8f1f1f; overflow-wrap: anywhere;
}
.qa-dn-alert > .qa-icon { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.qa-dn-alert > div { min-width: 0; }
.qa-dn-alert.is-amber { background: var(--qa-amber-50); color: #7a4a00; }
.qa-dn-alert.is-green { background: var(--qa-green-50); color: #0c5f30; }
.qa-dn-alert.is-blue { background: var(--qa-primary-50); color: #1c3d8f; }
.qa-dn-alert a { color: inherit; font-weight: 600; text-decoration: underline; }
.qa-dn-alert .qa-dn-alert-btn {
  display: inline-flex; align-items: center; margin-top: 8px; height: 36px; padding: 0 14px;
  border-radius: 9px; background: var(--qa-primary); color: #fff; text-decoration: none; font-weight: 600;
}
.qa-dn-alert .qa-dn-alert-btn:hover { background: var(--qa-primary-600); color: #fff; }

/* Xác thực hai bước */
.qa-dn-2fa { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; padding: 12px; border-radius: 12px; background: var(--qa-primary-50); color: #1c3d8f; }
.qa-dn-2fa > .qa-icon { width: 26px; height: 26px; flex: none; color: var(--qa-primary); }
.qa-dn-2fa b { display: block; font-size: 14.5px; }
.qa-dn-2fa p { margin: 2px 0 0; font-size: 13px; }

/* Tài khoản đang đăng nhập */
.qa-dn-who { display: flex; align-items: center; gap: 12px; margin: 14px 0 16px; padding: 12px; border-radius: 12px; background: var(--qa-surface-2); border: 1px solid var(--qa-border); }
.qa-dn-who > div { min-width: 0; }
.qa-dn-who b { display: block; font-size: 15px; overflow-wrap: anywhere; }
.qa-dn-who small { display: block; color: var(--qa-muted); font-size: 12.5px; overflow-wrap: anywhere; }
.qa-dn-avatar { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--qa-primary-50); color: var(--qa-primary); font-weight: 700; font-size: 17px; }
.qa-dn-busy { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px 0 6px; color: var(--qa-text-2); font-weight: 500; }

.qa-dn-alt { margin: 16px 0 0; text-align: center; font-size: 13px; color: var(--qa-muted); }

/* Gợi ý cài ứng dụng (PWA) */
.qa-dn-install { margin-top: 16px; }
.qa-dn-install-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .08);
  color: #fff; font: 500 13.5px var(--qa-font); cursor: pointer;
}
.qa-dn-install-btn:hover { background: rgba(255, 255, 255, .14); }
.qa-dn-install-btn .qa-icon { width: 17px; height: 17px; }

/* Chân trang */
.qa-dn-foot {
  margin-top: 22px; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 10px;
  max-width: 760px; text-align: center; font-size: 12.5px; line-height: 1.6; color: rgba(183, 195, 219, .85);
}
.qa-dn-foot i { font-style: normal; opacity: .6; }
.qa-dn-foot a { color: #fff; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.qa-dn-foot a:hover { color: #fff; text-decoration: underline; }
.qa-dn-foot .qa-icon { width: 15px; height: 15px; }
@media (max-width: 559px) {
  .qa-dn-foot { flex-direction: column; gap: 2px; }
  .qa-dn-foot i { display: none; }
}

/* Màn hình hẹp (≤ 360px) */
@media (max-width: 360px) {
  .qa-dn { padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right)); }
  .qa-dn-card { padding: 20px 16px 16px; border-radius: 16px; }
  .qa-dn-card h1 { font-size: 20px; }
}
/* Điện thoại xoay ngang / màn thấp: thu gọn phần thương hiệu */
@media (max-height: 560px) and (max-width: 959px) {
  .qa-dn { justify-content: flex-start; }
  .qa-dn-brand { display: flex; align-items: center; gap: 12px; text-align: left; margin-bottom: 14px; }
  .qa-dn-logo { width: 44px; height: 44px; border-radius: 13px; margin: 0; }
  .qa-dn-logo .qa-icon { width: 26px; height: 26px; }
}
@media (min-width: 480px) {
  .qa-dn-card { padding: 32px 32px 26px; }
}
/* Máy tính: 2 cột — giới thiệu bên trái, thẻ đăng nhập bên phải */
@media (min-width: 960px) {
  .qa-dn-wrap { max-width: 1040px; display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 72px; align-items: center; }
  .qa-dn-brand { text-align: left; margin: 0; }
  .qa-dn-logo { width: 72px; height: 72px; border-radius: 20px; margin-bottom: 22px; }
  .qa-dn-logo .qa-icon { width: 40px; height: 40px; }
  .qa-dn-center { font-size: 34px; line-height: 1.2; }
  .qa-dn-tagline { font-size: 16px; margin-top: 10px; }
  .qa-dn-points { display: grid; gap: 14px; margin: 32px 0 0; padding: 0; list-style: none; }
  .qa-dn-points li { display: flex; align-items: center; gap: 12px; color: #dfe6f5; font-size: 15px; }
  .qa-dn-points .qa-icon { width: 38px; height: 38px; padding: 9px; border-radius: 11px; background: rgba(255, 255, 255, .08); color: #9fb7ff; }
}
@media print { .qa-dn-bg, .qa-dn-install { display: none !important; } }
