/* Xưởng Phim AI – giao diện "phòng dựng phim": nền xanh than, đèn tally hổ phách, dải phim làm thanh tiến độ */
:root {
  --bg: #141a26;
  --panel: #1b2332;
  --raised: #232d40;
  --line: #2f3b52;
  --text: #e9edf4;
  --muted: #8f9bb0;
  --dim: #66728a;
  --amber: #f2a93b;
  --amber-ink: #2a1a02;
  --teal: #37c3a7;
  --red: #f0635a;
  --blue: #74a9ff;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Bricolage Grotesque', 'Be Vietnam Pro', system-ui, sans-serif;
  --nav-w: 232px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--amber); color: var(--amber-ink); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 16px; }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--raised); color: var(--text);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: #47577a; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.btn.primary:hover { background: #ffb94f; }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn.lg { height: 52px; padding: 0 22px; font-size: 16px; }
.btn.block { width: 100%; }
.icon-btn { width: 32px; padding: 0; }

/* ---------- Ô nhập ---------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; background: #111723; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; color: var(--text); outline: none; transition: border-color .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--amber); }
.textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.hint { font-size: 12.5px; color: var(--dim); }

/* Chip chọn (thời lượng, khung hình...) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 34px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: #111723; color: var(--muted); font-weight: 600; font-size: 13.5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
}
.chip:hover { color: var(--text); }
.chip[aria-pressed='true'] { border-color: var(--amber); color: var(--text); background: rgba(242, 169, 59, .12); }
.chip .extra { color: var(--amber); font-weight: 500; font-size: 12px; }
.ratio-shape { display: inline-block; border: 1.5px solid currentColor; border-radius: 2px; }

/* ---------- Bố cục ứng dụng ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.nav {
  position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line);
  background: #111723; display: flex; flex-direction: column; padding: 18px 12px; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-family: var(--display); font-weight: 800; font-size: 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 7px; background: var(--amber); position: relative; flex: none;
}
.brand-mark::before, .brand-mark::after {
  content: ''; position: absolute; left: 4px; right: 4px; height: 3px;
  background: repeating-linear-gradient(90deg, var(--amber-ink) 0 3px, transparent 3px 6px);
}
.brand-mark::before { top: 4px; }
.brand-mark::after { bottom: 4px; }
.nav a.item {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 500; font-size: 14.5px;
}
.nav a.item:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.item.active { background: var(--raised); color: var(--text); }
.nav a.item.active svg { color: var(--amber); }
.nav svg { width: 19px; height: 19px; flex: none; }
.nav .spacer { flex: 1; }
.nav .badge { margin-left: auto; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; display: flex; align-items: center; gap: 12px; padding: 0 24px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(20, 26, 38, .92);
  backdrop-filter: blur(8px); z-index: 20;
}
.topbar h1 { font-size: 20px; }
.topbar .grow { flex: 1; }
.balance {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 12px;
  border: 1px solid var(--line); border-radius: 999px; font-weight: 600;
}
.balance b { color: var(--amber); }
.content { padding: 24px; max-width: 1400px; width: 100%; }

.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 11px 16px; margin: 16px 24px 0;
  border: 1px solid #5a4520; background: rgba(242, 169, 59, .08); border-radius: var(--r-md); font-size: 14px;
}
.notice .x { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head .grow { flex: 1; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--raised); color: var(--muted); white-space: nowrap;
}
.badge.amber { background: rgba(242, 169, 59, .15); color: var(--amber); }
.badge.teal { background: rgba(55, 195, 167, .14); color: var(--teal); }
.badge.red { background: rgba(240, 99, 90, .14); color: var(--red); }
.badge.blue { background: rgba(116, 169, 255, .14); color: var(--blue); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.dot.live { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- Trang tạo video ---------- */
.studio { display: grid; grid-template-columns: minmax(380px, 520px) 1fr; gap: 24px; align-items: start; }
.composer { display: grid; gap: 20px; padding: 20px; }
.composer .section { display: grid; gap: 8px; }
.prompt-wrap { position: relative; }
.prompt-wrap .counter { position: absolute; right: 10px; bottom: 8px; font-size: 12px; color: var(--dim); }
.mention-pop {
  position: absolute; z-index: 30; min-width: 200px; max-height: 240px; overflow: auto;
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: 0 12px 30px rgba(0,0,0,.35);
}
.mention-pop button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; border: 0; background: none; cursor: pointer; text-align: left;
}
.mention-pop button[aria-selected='true'], .mention-pop button:hover { background: var(--line); }
.mention-pop img, .mention-pop .vthumb { width: 30px; height: 30px; object-fit: cover; border-radius: 4px; background: #000; }

.refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.ref {
  position: relative; aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; background: #0d121c; border: 1px solid var(--line);
}
.ref img, .ref video { width: 100%; height: 100%; object-fit: cover; }
.ref .tag {
  position: absolute; left: 4px; bottom: 4px; padding: 1px 5px; border-radius: 4px; font-size: 11px; font-weight: 600;
  background: rgba(10, 14, 22, .82); color: var(--amber); cursor: pointer;
}
.ref .rm {
  position: absolute; right: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: rgba(10, 14, 22, .82); color: var(--text); cursor: pointer; font-size: 14px; line-height: 22px;
}
.drop {
  aspect-ratio: 1; border: 1.5px dashed var(--line); border-radius: var(--r-sm); display: grid; place-items: center;
  color: var(--muted); cursor: pointer; font-size: 12px; text-align: center; padding: 6px; background: #111723;
}
.drop:hover, .drop.over { border-color: var(--amber); color: var(--text); }
.drop svg { width: 22px; height: 22px; margin: 0 auto 2px; }

.models { display: grid; gap: 8px; }
.model {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 11px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: #111723; cursor: pointer; text-align: left;
}
.model b { font-weight: 600; }
.model .note { font-size: 12.5px; color: var(--muted); }
.model .price { grid-row: span 2; align-self: center; color: var(--muted); font-size: 13px; }
.model[aria-pressed='true'] { border-color: var(--amber); background: rgba(242, 169, 59, .08); }
.model[aria-pressed='true'] .price { color: var(--amber); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch {
  width: 40px; height: 22px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .15s;
}
.switch::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: transform .15s;
}
input:checked + .switch { background: var(--amber); }
input:checked + .switch::after { transform: translateX(18px); background: var(--amber-ink); }
.toggle input { position: absolute; opacity: 0; }
.toggle input:focus-visible + .switch { outline: 2px solid var(--amber); outline-offset: 2px; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-sm); background: #111723; }
.stepper button { width: 34px; height: 34px; border: 0; background: none; cursor: pointer; font-size: 18px; color: var(--muted); }
.stepper button:hover { color: var(--text); }
.stepper span { min-width: 28px; text-align: center; font-weight: 600; }

.submit-bar { display: grid; gap: 10px; padding-top: 4px; }
.queue-line { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Dải phim (thanh tiến độ) ---------- */
.strip {
  --frames: 14;
  position: relative; display: grid; grid-template-columns: repeat(var(--frames), 1fr); gap: 3px;
  padding: 7px 4px; background: #0b0f17; border-radius: 4px;
}
.strip::before, .strip::after {
  content: ''; position: absolute; left: 4px; right: 4px; height: 3px;
  background: repeating-linear-gradient(90deg, #2c3546 0 4px, transparent 4px 9px);
}
.strip::before { top: 2px; }
.strip::after { bottom: 2px; }
.strip i { height: 12px; border-radius: 1.5px; background: #1e2738; transition: background .4s; }
.strip i.on { background: var(--amber); }
.strip.done i { background: var(--teal); }
.strip.fail i.on { background: var(--red); }
.strip.wait i:nth-child(odd) { animation: wait 2.4s ease-in-out infinite; }
@keyframes wait { 50% { background: #2a3448; } }

/* ---------- Thẻ video ---------- */
.jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.jobs.live { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.job { display: flex; flex-direction: column; overflow: hidden; }
.job .screen {
  position: relative; aspect-ratio: 16 / 9; background: #0b0f17; display: grid; place-items: center; overflow: hidden;
}
.job .screen video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.job .screen .state { text-align: center; padding: 14px; width: 100%; }
.job .screen .big { font-family: var(--display); font-size: 26px; font-weight: 700; }
.job .body { padding: 12px 14px 14px; display: grid; gap: 8px; flex: 1; }
.job .prompt { font-size: 13.5px; color: #c9d1de; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.job .meta { display: flex; flex-wrap: wrap; gap: 5px; }
.job .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.job .err { font-size: 12.5px; color: var(--red); }
.job .thumbs { display: flex; gap: 4px; }
.job .thumbs img { width: 26px; height: 26px; border-radius: 4px; object-fit: cover; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 10px 14px; color: var(--muted); font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button[aria-selected='true'] { color: var(--text); border-color: var(--amber); }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 20px; align-items: center; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* ---------- Nạp tiền ---------- */
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pack {
  border: 1px solid var(--line); background: #111723; border-radius: var(--r-md); padding: 14px; cursor: pointer; text-align: left;
  display: grid; gap: 2px;
}
.pack[aria-pressed='true'] { border-color: var(--amber); background: rgba(242, 169, 59, .08); }
.pack .vnd { font-family: var(--display); font-size: 20px; font-weight: 700; }
.pack .pts { color: var(--muted); font-size: 13px; }
.pack .bonus { color: var(--teal); font-size: 12.5px; font-weight: 600; }
.pay { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
.pay img.qr { width: 240px; min-height: 240px; border-radius: var(--r-md); background: #fff; color: #333; font-size: 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr auto; gap: 8px 14px; align-items: center; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-weight: 600; word-break: break-all; }

/* ---------- Bảng ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid #253046; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td.wrap { max-width: 360px; }

/* ---------- Hỗ trợ ---------- */
.thread { display: grid; gap: 10px; max-height: 420px; overflow: auto; padding: 4px; }
.msg { max-width: 80%; padding: 9px 13px; border-radius: 12px; background: var(--raised); white-space: pre-wrap; font-size: 14px; }
.msg.me { margin-left: auto; background: rgba(242, 169, 59, .14); }
.msg time { display: block; font-size: 11px; color: var(--dim); margin-top: 3px; }

/* ---------- Hộp thoại & thông báo ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(6, 9, 15, .7); display: grid; place-items: center; z-index: 100; padding: 16px;
  animation: fade .15s ease;
}
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); animation: rise .18s ease; }
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; font-size: 18px; }
.modal-body { padding: 20px; display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 200; }
.toast {
  padding: 11px 16px; border-radius: var(--r-sm); background: var(--raised); border: 1px solid var(--line); border-left: 3px solid var(--teal);
  box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: 360px; font-size: 14px; animation: rise .2s ease;
}
.toast.err { border-left-color: var(--red); }

/* ---------- Đăng nhập ---------- */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr;
}
.auth-art { position: relative; overflow: hidden; background: #0e131d; border-right: 1px solid var(--line); padding: 40px; display: flex; flex-direction: column; }
.auth-art h1 { font-size: 44px; max-width: 12ch; margin-top: auto; }
.auth-art p { color: var(--muted); max-width: 44ch; }
.auth-form { display: grid; place-items: center; padding: 32px; }
.auth-form form { width: min(380px, 100%); display: grid; gap: 14px; }
.auth-switch { display: flex; background: #111723; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px; }
.auth-switch button { flex: 1; height: 36px; border: 0; background: none; border-radius: 4px; font-weight: 600; color: var(--muted); cursor: pointer; }
.auth-switch button[aria-selected='true'] { background: var(--raised); color: var(--text); }
.err-text { color: var(--red); font-size: 13.5px; min-height: 1em; }

/* Bảng điều phối (admin) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { padding: 16px; }
.kpi .v { font-family: var(--display); font-size: 26px; font-weight: 700; margin-top: 4px; }
.kpi .s { font-size: 12.5px; color: var(--muted); }
.slots { display: flex; flex-wrap: wrap; gap: 3px; }
.slots i { width: 14px; height: 18px; border-radius: 2px; background: #1e2738; }
.slots i.busy { background: var(--amber); }
.slots.off i { background: #2a2230; }
.keyrow { display: grid; grid-template-columns: 200px 1fr 120px; gap: 16px; align-items: center; padding: 12px 18px; border-bottom: 1px solid #253046; }
.keyrow:last-child { border-bottom: 0; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; }
.bars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.bars .b span { width: 100%; background: var(--amber); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars .b small { font-size: 10.5px; color: var(--dim); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stack { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; align-items: start; }

/* ---------- Điện thoại ---------- */
@media (max-width: 1100px) {
  .studio { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: 62px; width: auto; flex-direction: row;
    padding: 6px; z-index: 50; border-right: 0; border-top: 1px solid var(--line); justify-content: space-around;
  }
  .nav .brand, .nav .spacer, .nav .hide-m { display: none; }
  .nav a.item { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; flex: 1; justify-content: center; }
  .nav .badge { display: none; }
  .main { padding-bottom: 70px; }
  .topbar { padding: 0 14px; }
  .content { padding: 14px; }
  .notice { margin: 12px 14px 0; }
  .row2, .grid2 { grid-template-columns: 1fr; }
  .pay { grid-template-columns: 1fr; }
  .pay img.qr { margin: 0 auto; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .keyrow { grid-template-columns: 1fr; gap: 8px; }
  .balance .lbl { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.btn svg { width: 18px; height: 18px; flex: none; }
