/* =====================================================================
   UI kit v6.12 — select tự thiết kế (dropdown trên PC / bottom sheet trên mobile) + hộp thoại (confirm / alert / prompt / modal)
   Dùng chung website + admin. Class tiền tố ux-. Biến màu lấy từ --surface / --border / --primary… của từng khu.
   ===================================================================== */
:root { color-scheme: dark; }
html, body { color-scheme: dark; }
select, input, textarea, button { color-scheme: dark; }

/* ---------- select ---------- */
.ux-sel { position: relative; display: block; min-width: 0; max-width: 100%; }
.ux-sel > select.ux-native { position: absolute !important; inset: 0; width: 100% !important; height: 100% !important; opacity: 0; pointer-events: none; z-index: -1; }
.ux-btn { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 42px; padding: 8px 12px; margin: 0;
  border: 1px solid rgba(255,255,255,.12); border-radius: 10px; background: #101112; color: var(--text, #dcdcdc); font: inherit; font-size: 15px; line-height: 1.35; text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.ux-btn:hover { border-color: rgba(255,255,255,.22); }
.ux-btn:focus-visible, .ux-btn[aria-expanded=true] { outline: none; border-color: var(--primary, #d27a70); box-shadow: 0 0 0 3px var(--primary-soft, rgba(210,122,112,.18)); }
.ux-btn[disabled] { opacity: .55; cursor: not-allowed; }
.ux-btn .ux-lab { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ux-btn .ux-lab.is-ph { color: var(--muted, #8d9095); }
.ux-btn svg { flex: none; width: 14px; height: 14px; color: var(--muted, #8d9095); transition: transform .18s; }
.ux-btn[aria-expanded=true] svg { transform: rotate(180deg); }
.ux-sel.is-sm .ux-btn { min-height: 34px; padding: 5px 10px; font-size: 14px; border-radius: 9px; }
.admin-table .ux-btn { min-height: 36px; font-size: 14px; }

.ux-back { position: fixed; inset: 0; z-index: 1390; background: rgba(0,0,0,.55); opacity: 0; transition: opacity .18s; }
.ux-back.is-in { opacity: 1; }
.ux-pop { position: fixed; z-index: 1400; display: flex; flex-direction: column; background: var(--surface, #1a1b1d); color: var(--text, #dcdcdc);
  border: 1px solid rgba(255,255,255,.1); border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.6); overflow: hidden; }
.ux-pop[hidden], .ux-back[hidden] { display: none; }
.ux-pop-h { display: none; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 6px; font-weight: 800; font-size: 16px; color: #fff; }
.ux-pop-s { padding: 8px; border-bottom: 1px solid var(--border, rgba(255,255,255,.06)); }
.ux-pop-s input { width: 100%; min-height: 38px; padding: 7px 11px; border-radius: 9px; border: 1px solid rgba(255,255,255,.12); background: #101112; color: inherit; font: inherit; font-size: 15px; outline: none; }
.ux-pop-s input:focus { border-color: var(--primary, #d27a70); }
.ux-list { flex: 1 1 auto; overflow: auto; padding: 6px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.ux-opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; font-size: 15px; line-height: 1.35; cursor: pointer; color: var(--text, #dcdcdc); }
.ux-opt .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ux-opt.is-act, .ux-opt:hover { background: var(--surface-2, #222326); }
.ux-opt.is-on { color: var(--primary-2, #e0958c); font-weight: 700; }
.ux-opt.is-on::after { content: ""; flex: none; width: 16px; height: 16px; 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='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%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='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E") center/contain no-repeat; }
.ux-opt.is-dis { opacity: .4; cursor: not-allowed; }
.ux-grp { padding: 10px 12px 4px; font-size: 11.5px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--muted, #8d9095); }
.ux-none { padding: 14px; text-align: center; color: var(--muted, #8d9095); font-size: 14px; }
@media (max-width: 640px) {
  .ux-pop.is-sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: auto !important; max-width: none !important; max-height: 78vh; border-radius: 18px 18px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom); transform: translateY(100%); transition: transform .22s cubic-bezier(.2,.8,.2,1); }
  .ux-pop.is-sheet.is-in { transform: none; }
  .ux-pop.is-sheet .ux-pop-h { display: flex; }
  .ux-pop.is-sheet .ux-pop-h::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 4px; background: rgba(255,255,255,.18); }
  .ux-pop.is-sheet .ux-opt { padding: 13px 12px; }
}

/* ---------- hộp thoại ---------- */
.ux-modal { position: fixed; inset: 0; z-index: 1300; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0,0,0,.6); opacity: 0; transition: opacity .18s; }
.ux-modal.is-in { opacity: 1; }
.ux-dlg { display: flex; flex-direction: column; width: 100%; max-width: 460px; max-height: calc(100vh - 32px); background: var(--surface, #1a1b1d); color: var(--text, #dcdcdc); border: 1px solid rgba(255,255,255,.1); border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.65); transform: translateY(10px) scale(.98); transition: transform .2s cubic-bezier(.2,.8,.2,1); }
.ux-modal.is-in .ux-dlg { transform: none; }
.ux-dlg.is-wide { max-width: 640px; }
.ux-dlg-h { display: flex; align-items: center; gap: 12px; padding: 16px 18px 0; }
.ux-dlg-ic { flex: none; width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--primary-soft, rgba(210,122,112,.13)); color: var(--primary-2, #e0958c); }
.ux-dlg-ic svg { width: 22px; height: 22px; }
.ux-dlg-ic.is-danger { background: rgba(239,68,68,.15); color: #f19a9a; }
.ux-dlg-t { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 800; color: #fff; line-height: 1.3; }
.ux-dlg-x { flex: none; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--muted, #8d9095); cursor: pointer; font-size: 0; }
.ux-dlg-x:hover { background: var(--surface-2, #222326); color: #fff; }
.ux-dlg-x svg { width: 18px; height: 18px; }
.ux-dlg-b { padding: 14px 18px 4px; overflow: auto; overscroll-behavior: contain; font-size: 15px; line-height: 1.55; }
.ux-dlg-b p { margin: 0 0 10px; }
.ux-dlg-b label { display: block; margin: 0 0 6px; font-size: 13.5px; font-weight: 700; color: #e6e6e8; }
.ux-dlg-b .ux-fld { margin-bottom: 14px; }
.ux-dlg-b input[type=text], .ux-dlg-b input[type=search], .ux-dlg-b input[type=password] { width: 100%; min-height: 44px; padding: 9px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.14); background: #101112; color: inherit; font: inherit; font-size: 16px; outline: none; box-sizing: border-box; }
.ux-dlg-b input:focus { border-color: var(--primary, #d27a70); box-shadow: 0 0 0 3px var(--primary-soft, rgba(210,122,112,.18)); }
.ux-dlg-b .ux-chk { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; font-size: 14px; color: var(--text); margin: 0; cursor: pointer; }
.ux-dlg-b .ux-chk input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary, #d27a70); flex: none; }
.ux-dlg-f { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px 16px; }
.ux-dlg-f .ux-b { min-height: 44px; padding: 0 20px; border-radius: 11px; border: 1px solid transparent; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; background: var(--primary, #d27a70); color: #fff; }
.ux-dlg-f .ux-b:hover { filter: brightness(1.08); }
.ux-dlg-f .ux-b.is-ghost { background: transparent; border-color: rgba(255,255,255,.16); color: var(--text, #dcdcdc); }
.ux-dlg-f .ux-b.is-danger { background: #dc2626; }
.ux-dlg-f .ux-b[disabled] { opacity: .5; cursor: not-allowed; }
.ux-dlg-err { margin: 0 0 10px; color: #f19a9a; font-size: 13.5px; }
.ux-note { color: var(--muted, #8d9095); font-size: 13px; }
@media (max-width: 640px) {
  .ux-modal { align-items: flex-end; padding: 0; }
  .ux-dlg { max-width: none; border-radius: 20px 20px 0 0; border-bottom: 0; max-height: 90vh; padding-bottom: env(safe-area-inset-bottom); transform: translateY(100%); }
  .ux-dlg-f { position: sticky; bottom: 0; background: var(--surface, #1a1b1d); }
  .ux-dlg-f .ux-b { flex: 1; }
}
body.ux-lock { overflow: hidden; }
