/* WAH! PHOTOS — giao diện tối lấy cảm hứng từ Frame.io */
:root {
  --bg: #0d0e12;
  --bg-1: #14161c;
  --bg-2: #1b1e26;
  --bg-3: #242833;
  --line: #2b2f3b;
  --line-soft: #23262f;
  --txt: #e8eaf0;
  --txt-2: #9aa1b1;
  --txt-3: #6a7183;
  --accent: #5b53ff;
  --accent-hi: #6f68ff;
  --ok: #2fbf71;
  --warn: #f5a623;
  --danger: #ef4b5a;
  --radius: 10px;
  --header-h: 56px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--txt);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #333846; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- primitives ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 14px;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: #2d3140; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hi); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--txt-2); }
.btn.ghost:hover { background: var(--bg-2); color: var(--txt); }
.btn.danger { border-color: #55232a; color: #ff8b96; background: transparent; }
.btn.danger:hover { background: #2a1518; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 34px; padding: 0; justify-content: center; }

.input, textarea.input, select.input {
  width: 100%; height: 36px; padding: 0 12px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 8px; outline: none;
}
textarea.input { height: auto; padding: 9px 12px; resize: vertical; min-height: 76px; line-height: 1.5; }
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--txt-3); }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; margin-bottom: 6px; color: var(--txt-2); font-size: 12.5px; }

.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.muted { color: var(--txt-2); }
.dim { color: var(--txt-3); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  background: var(--bg-3); font-size: 11.5px; color: var(--txt-2);
}
.chip.ok { background: rgba(47, 191, 113, .15); color: #6fe0a4; }
.chip.warn { background: rgba(245, 166, 35, .15); color: #ffc766; }
.chip.acc { background: rgba(91, 83, 255, .18); color: #b0abff; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h); display: flex; align-items: center; gap: 14px;
  padding: 0 18px; background: rgba(20, 22, 28, .92);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: .2px; }
.brand .dot {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: linear-gradient(140deg, #ff7a45, var(--accent)); font-size: 11px; font-weight: 800; color: #fff;
}
.crumb { color: var(--txt-2); }
.crumb b { color: var(--txt); font-weight: 600; }

/* ---------- layout ---------- */
.wrap { max-width: 1400px; margin: 0 auto; padding: 22px 18px 80px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 21px; font-weight: 650; }

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--line-soft); margin-bottom: 18px;
}

/* ---------- project cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.card {
  background: var(--bg-1); border: 1px solid var(--line-soft);
  border-radius: 12px; overflow: hidden; cursor: pointer;
  transition: transform .14s, border-color .14s;
}
.card:hover { transform: translateY(-2px); border-color: var(--line); }
.card .thumb {
  aspect-ratio: 16/10; background: var(--bg-2) center/cover no-repeat;
  display: grid; place-items: center; color: var(--txt-3);
}
.card .meta { padding: 11px 13px 13px; }
.card .meta h3 { margin: 0 0 5px; font-size: 14.5px; font-weight: 600; }
.card .meta .sub { font-size: 12px; color: var(--txt-3); display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- grid ảnh ---------- */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(var(--tile, 220px), 1fr)); }
.tile {
  position: relative; background: var(--bg-1); border: 1px solid var(--line-soft);
  border-radius: 10px; overflow: hidden; cursor: pointer;
  transition: border-color .12s;
}
.tile:hover { border-color: #3a4152; }
.tile.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile .ph { aspect-ratio: 1/1; background: var(--bg-2); display: block; overflow: hidden; }
.tile .ph img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s; }
.tile .ph img.on { opacity: 1; }
.tile .cap {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 9px; font-size: 12px; color: var(--txt-2);
  border-top: 1px solid var(--line-soft);
}
.tile .cap .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .badges { position: absolute; top: 8px; left: 8px; display: flex; gap: 5px; }
.tile .pickbtn {
  position: absolute; top: 7px; right: 7px; width: 26px; height: 26px;
  border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .55);
  background: rgba(0, 0, 0, .45); backdrop-filter: blur(4px);
  display: grid; place-items: center; opacity: 0; transition: opacity .12s;
  cursor: pointer; color: #fff;
}
.tile:hover .pickbtn, .tile .pickbtn.on { opacity: 1; }
.tile .pickbtn.on { background: var(--ok); border-color: var(--ok); }
.tile .pickbtn.changes { background: var(--warn); border-color: var(--warn); color: #201400; }

.badge-dot {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: 10px; font-weight: 700; background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px);
}

/* ---------- lightbox ---------- */
.lb { position: fixed; inset: 0; z-index: 100; background: #08090c; display: none; grid-template-rows: var(--header-h) 1fr; }
.lb.open { display: grid; }
.lb-head {
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  border-bottom: 1px solid var(--line-soft); background: var(--bg-1);
}
.lb-body { display: grid; grid-template-columns: 1fr 0; min-height: 0; transition: grid-template-columns .18s; }
.lb-body.with-panel { grid-template-columns: 1fr 340px; }
.stage { position: relative; display: grid; place-items: center; min-width: 0; padding: 20px; overflow: hidden; }
.stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; border-radius: 4px; }
.nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(20, 22, 28, .8); display: grid; place-items: center; cursor: pointer;
}
.nav:hover { background: var(--bg-3); }
.nav.prev { left: 16px; } .nav.next { right: 16px; }

.panel { border-left: 1px solid var(--line-soft); background: var(--bg-1); display: flex; flex-direction: column; overflow: hidden; }
.panel .p-head { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); font-weight: 600; }
.panel .p-body { flex: 1; overflow-y: auto; padding: 12px 14px; }
.panel .p-foot { border-top: 1px solid var(--line-soft); padding: 10px 12px; }

.cmt { margin-bottom: 14px; }
.cmt .who { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; background: var(--accent); color: #fff; flex: none;
}
.cmt .body { white-space: pre-wrap; word-break: break-word; background: var(--bg-2); padding: 8px 10px; border-radius: 8px; }
.cmt .when { font-size: 11.5px; color: var(--txt-3); }

.filmstrip {
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px;
  border-top: 1px solid var(--line-soft); background: var(--bg-1);
}
.filmstrip img {
  height: 54px; width: 54px; object-fit: cover; border-radius: 5px;
  border: 2px solid transparent; cursor: pointer; opacity: .55; flex: none;
}
.filmstrip img.cur { border-color: var(--accent); opacity: 1; }

/* ---------- modal ---------- */
.mask { position: fixed; inset: 0; background: rgba(4, 5, 8, .72); display: none; place-items: center; z-index: 200; padding: 20px; }
.mask.open { display: grid; }
.modal {
  width: min(520px, 100%); background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); overflow: hidden;
}
.modal h2 { margin: 0; padding: 16px 18px; font-size: 16px; border-bottom: 1px solid var(--line-soft); }
.modal .m-body { padding: 18px; max-height: 65vh; overflow-y: auto; }
.modal .m-foot { padding: 12px 18px; border-top: 1px solid var(--line-soft); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- gate (màn hình nhập mật khẩu) ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate-box { width: min(400px, 100%); background: var(--bg-1); border: 1px solid var(--line); border-radius: 16px; padding: 30px; box-shadow: var(--shadow); }
.gate-box .brand { justify-content: center; margin-bottom: 6px; font-size: 16px; }
.gate-box h1 { text-align: center; font-size: 19px; margin: 12px 0 4px; }
.gate-box p.sub { text-align: center; color: var(--txt-2); margin: 0 0 22px; }
.err { color: #ff8b96; font-size: 13px; min-height: 18px; margin-top: 4px; }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 80px 20px; color: var(--txt-3); }
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--bg-3); border: 1px solid var(--line); padding: 10px 16px;
  border-radius: 10px; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s; z-index: 500;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.selbar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); z-index: 60;
}
.tabs { display: flex; gap: 4px; }
.tab { padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--txt-2); font-size: 13px; }
.tab.on { background: var(--bg-3); color: var(--txt); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.tbl th { color: var(--txt-3); font-weight: 500; font-size: 12px; }

@media (max-width: 720px) {
  .lb-body.with-panel { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .panel { max-height: 45vh; border-left: none; border-top: 1px solid var(--line-soft); }
  .wrap { padding: 16px 12px 90px; }
}
