/* ================================================================
   auth-popup.css — popup ĐĂNG NHẬP / ĐĂNG KÝ (dùng được ở mọi trang)
   Khung popup, nền mờ, nút X ở đây cũng dùng chung cho popup Nạp tiền (.popup-surplus)
   Dùng lại biến màu trong style.css (--surface, --accent, --line...)

   Ẩn/hiện:
   - .popup-log            : thêm/bỏ class .active  (theo .need-active trong style.css)
   - .tab                  : thêm .active cho tab đang chọn
   - .auth-box             : thêm .active cho form đang chọn
                             (nếu chưa form nào có .active thì mặc định hiện form đăng nhập)
   - .result .error        : thêm .active khi có lỗi
   ================================================================ */

/* ---------- Khung popup + nền mờ (dùng chung cho mọi popup) ---------- */
.popup-log,.popup-surplus{
  position:fixed;
  inset:0;
  margin:auto;
  z-index:1000;                         /* nằm trên header (z-index:40) */
  width:min(420px, calc(100% - 32px));
  height:fit-content;
  max-height:calc(100dvh - 32px);
  overflow:auto;
  background:var(--surface);
  color:var(--ink);
  border:1px solid var(--line);
  border-radius:20px;
  padding:22px 24px 26px;
  /* lớp bóng thứ 2 phủ kín màn hình = nền tối phía sau popup */
  box-shadow:0 24px 60px rgba(10,10,20,.25), 0 0 0 100vmax rgba(10,10,20,.55);
  overscroll-behavior:contain;
}
.popup-log.need-active.active,
.popup-surplus.need-active.active{
  display:block;
  animation:ap-in .22s ease-out;
}
/* Khóa cuộn trang phía sau khi popup đang mở */
body:has(.popup-log.active),body:has(.popup-surplus.active){overflow:hidden}

/* ---------- Nút đóng (X) ---------- */
.popup-log .close-popup-log,
.popup-surplus .close-popup-surplus{
  position:absolute;top:14px;right:14px;
  width:34px;height:34px;border-radius:10px;
  display:grid;place-items:center;
  color:var(--muted);cursor:pointer;
  transition:background .15s,color .15s;
}
.popup-log .close-popup-log::before,
.popup-surplus .close-popup-surplus::before{
  content:"\f00d";                      /* xmark */
  font-family:"Font Awesome 6 Free";font-weight:900;font-size:16px;
}
.popup-log .close-popup-log:hover,
.popup-surplus .close-popup-surplus:hover{background:var(--accent-soft);color:var(--accent)}

/* ---------- Tab Đăng nhập / Đăng ký ---------- */
.popup-log .tabs{
  display:grid;grid-template-columns:1fr 1fr;gap:4px;
  margin:4px 46px 22px 0;               /* chừa chỗ cho nút X bên phải */
  padding:4px;
  background:var(--bg);
  border:1px solid var(--line);
  border-radius:12px;
}
.popup-log .tabs::before,.popup-log .tabs::after{display:none} /* bỏ clearfix nếu có */
.popup-log .tab{
  text-align:center;
  padding:9px 10px;border-radius:9px;
  font-weight:600;font-size:14.5px;color:var(--muted);
  cursor:pointer;user-select:none;
  transition:background .15s,color .15s,box-shadow .15s;
}
.popup-log .tab:hover{color:var(--ink)}
.popup-log .tab.active{
  background:var(--surface);color:var(--accent);
  box-shadow:0 1px 3px rgba(26,26,36,.12);
}
/* Chưa tab nào active → tô tab đăng nhập */
.popup-log .tabs:not(:has(.tab.active)) .tab-login{
  background:var(--surface);color:var(--accent);
  box-shadow:0 1px 3px rgba(26,26,36,.12);
}

/* ---------- Form ---------- */
.popup-log .auth-box{display:none;flex-direction:column;gap:16px;margin:0}
.popup-log .auth-box.active{display:flex;animation:ap-fade .2s ease-out}
.popup-log .pop-contents:not(:has(.auth-box.active)) .auth-box-login{display:flex}

.popup-log .form-group{display:flex;flex-direction:column;gap:7px;margin:0}
.popup-log label{font-weight:600;font-size:14px;color:var(--ink);line-height:1.4}

.popup-log .form-control{
  width:100%;
  font:inherit;font-size:15px;color:var(--ink);
  background:var(--bg);
  border:1px solid var(--line);
  border-radius:11px;
  padding:11px 14px;
  outline:none;
  transition:border-color .15s,box-shadow .15s,background .15s;
}
.popup-log .form-control:focus{
  border-color:var(--accent);
  background:var(--surface);
  box-shadow:0 0 0 3px var(--accent-soft);
}

/* ---------- Thông báo lỗi ---------- */
.popup-log .result{display:flex;flex-direction:column}
.popup-log .result .error.need-active.active{
  display:flex;align-items:center;gap:10px;
  padding:11px 14px;border-radius:11px;
  font-size:14px;font-weight:500;line-height:1.45;
  background:color-mix(in srgb, #E5484D 10%, var(--surface));
  color:#D93036;
  border:1px solid color-mix(in srgb, #E5484D 30%, transparent);
  animation:ap-fade .2s ease-out;
}
.popup-log .result .error::before{
  content:"\f06a";                      /* circle-exclamation */
  font-family:"Font Awesome 6 Free";font-weight:900;font-size:15px;flex:0 0 auto;
}

/* ---------- Nút submit ----------
   style.css có .form-submit{display:none} và [type="submit"]{width:120px;...}
   nên ghi đè bằng selector cụ thể hơn. */
.popup-log input[type="submit"].form-submit{
  display:block;
  width:100%;
  margin:4px 0 0;
  font:inherit;font-weight:600;font-size:15px;color:#fff;
  background:linear-gradient(105deg,var(--accent),var(--accent-2));
  border:0;border-radius:11px;
  padding:13px 20px;cursor:pointer;
  transition:filter .15s,transform .05s,opacity .15s;
}
.popup-log input[type="submit"].form-submit:hover{filter:brightness(1.08)}
.popup-log input[type="submit"].form-submit:active{transform:translateY(1px)}
.popup-log input[type="submit"].form-submit:disabled{
  opacity:.55;cursor:not-allowed;filter:none;transform:none;
}

/* ---------- Hiệu ứng ---------- */
@keyframes ap-in{from{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}
@keyframes ap-fade{from{opacity:0}to{opacity:1}}

/* ---------- Mobile ---------- */
@media (max-width:480px){
  .popup-log,.popup-surplus{padding:18px 16px 22px;border-radius:16px}
  .popup-log .close-popup-log,
  .popup-surplus .close-popup-surplus{top:10px;right:10px}
  .popup-log .tabs{margin-right:42px}
}

@media (prefers-reduced-motion:reduce){
  .popup-log.need-active.active,
  .popup-surplus.need-active.active,
  .popup-log .auth-box.active,
  .popup-log .result .error.need-active.active{animation:none}
}