/* =========================================================
   Quản lý sản phẩm — giao diện
   Tông trầm: nền xám rêu, chữ màu mực, nhấn xanh tùng.
   Chữ: Bricolage Grotesque cho tiêu đề, Be Vietnam Pro cho nội dung.
   ========================================================= */
@import url("https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600&family=Bricolage+Grotesque:opsz,wght@12..96,500..800&display=swap");

:root {
  --paper: #e8ebe7;      /* nền trang */
  --surface: #f6f7f5;    /* bảng, hộp thoại */
  --raised: #ffffff;     /* ô nhập */
  --ink: #1e2925;        /* chữ chính */
  --muted: #5e6a65;      /* chữ phụ */
  --faint: #8a948f;
  --line: #d2d8d3;
  --line-soft: #e2e6e2;

  --spruce: #2d4f48;     /* màu nhấn chính */
  --spruce-dark: #213b36;
  --spruce-tint: #dfe8e4;
  --brick: #8c3a2e;      /* xoá, lỗi */
  --brick-tint: #f1e2de;
  --ochre: #85672b;      /* chờ xử lý */
  --ochre-tint: #efe7d5;

  --radius-sm: 5px;
  --radius: 8px;
  --radius-lg: 12px;

  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Bricolage Grotesque", "Be Vietnam Pro", system-ui, sans-serif;
  font-family: var(--font);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--spruce); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--spruce-dark); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--spruce); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Tiêu đề ---------- */
.login-mark, .login-card h1, header.top .brand, .toolbar h2, .modal h3 {
  font-family: var(--display);
  font-optical-sizing: auto;
}

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--raised); border-color: #b9c2bc; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--spruce); border-color: var(--spruce); color: #f3f6f4; }
.btn-primary:hover { background: var(--spruce-dark); border-color: var(--spruce-dark); color: #fff; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { background: transparent; border-color: transparent; color: var(--brick); }
.btn-danger:hover { background: var(--brick-tint); border-color: transparent; color: var(--brick); }
.btn-danger-solid { background: var(--brick); border-color: var(--brick); color: #fbf3f1; }
.btn-danger-solid:hover { background: #722e24; border-color: #722e24; color: #fff; }

/* ---------- Ô nhập ---------- */
input[type=text], input[type=password], input[type=url], input[type=search] {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--raised);
}
input::placeholder { color: var(--faint); }
input:focus { outline: none; border-color: var(--spruce); box-shadow: 0 0 0 3px var(--spruce-tint); }

/* ---------- Đăng nhập ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid; grid-template-columns: minmax(280px, 5fr) 7fr;
}
.login-side {
  background: var(--spruce); color: #dfe8e4;
  padding: 56px 48px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-mark {
  font-size: clamp(44px, 5.4vw, 76px); line-height: 1.03; font-weight: 750;
  letter-spacing: -0.035em; color: #f2f5f3;
}
.login-note { max-width: 32ch; margin: 0; color: #b8c9c2; font-size: 15px; }
.login-card {
  align-self: center; justify-self: center;
  width: 100%; max-width: 360px; padding: 32px 24px;
}
.login-card h1 { margin: 0 0 6px; font-size: 30px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.15; }
.login-card p.sub { margin: 0 0 28px; color: var(--muted); }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 500; margin-bottom: 6px; }
.login-card .btn { width: 100%; height: 40px; margin-top: 4px; }
.error { color: var(--brick); min-height: 20px; margin: 4px 0 10px; }

@media (max-width: 760px) {
  .login-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-side { padding: 28px 24px; }
  .login-mark { font-size: 34px; }
  .login-mark br { display: none; }
  .login-note { display: none; }
  .login-card { align-self: start; padding-top: 32px; }
}

/* ---------- Khung trang ---------- */
header.top {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 28px;
  background: var(--spruce); color: #e6eeea;
  position: sticky; top: 0; z-index: 5;
}
header.top .brand { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; color: #f3f6f4; }
header.top .user { display: flex; align-items: center; gap: 14px; color: #b8c9c2; }
header.top .user .btn {
  background: transparent; border-color: rgba(230, 238, 234, .28); color: #e6eeea;
}
header.top .user .btn:hover { background: rgba(255, 255, 255, .08); border-color: rgba(230, 238, 234, .5); }

main { padding: 28px; max-width: 1440px; margin: 0 auto; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar h2 {
  margin: 0 auto 0 0; font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1;
  display: flex; align-items: baseline; gap: 10px;
}
.toolbar .search { width: 280px; }
.count { font-family: var(--font); letter-spacing: 0; color: var(--muted); font-weight: 400; font-size: 15px; font-variant-numeric: tabular-nums; }

.notice {
  display: none; margin-bottom: 16px; padding: 10px 14px;
  border-radius: var(--radius-sm); border-left: 3px solid currentColor;
}
.notice.show { display: block; }
.notice.ok { background: var(--spruce-tint); color: var(--spruce-dark); }
.notice.err { background: var(--brick-tint); color: var(--brick); }

/* ---------- Bảng ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; min-width: 1120px; }
th, td { padding: 12px 14px; text-align: left; vertical-align: top; }
td { border-top: 1px solid var(--line-soft); }
th {
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; white-space: nowrap;
}
tbody tr:hover td { background: #f0f2ef; }
tbody tr:first-child td { border-top: 0; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td:first-child { color: var(--muted); font-variant-numeric: tabular-nums; }
td.name { max-width: 340px; font-weight: 500; }
td.name .code { color: var(--muted); font-size: 12.5px; font-weight: 400; margin-top: 2px; font-variant-numeric: tabular-nums; }
td.links a { display: block; font-size: 13px; white-space: nowrap; line-height: 1.7; }
td.date { white-space: nowrap; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.empty { padding: 56px 24px; text-align: center; color: var(--muted); }
tbody tr:hover td.empty { background: transparent; }

.thumbs { display: flex; gap: 4px; flex-wrap: wrap; width: 132px; }
.thumbs img {
  width: 40px; height: 40px; object-fit: cover; display: block;
  border-radius: 4px; background: var(--line-soft); cursor: zoom-in;
}
.thumbs .more {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--line-soft); border-radius: 4px; font-size: 12px; color: var(--muted);
}
.thumbs .none { color: var(--faint); font-size: 12.5px; }

td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 2px; }

.pager {
  display: flex; justify-content: flex-end; align-items: center; gap: 10px;
  margin-top: 14px; color: var(--muted); font-variant-numeric: tabular-nums;
}

/* ---------- Trạng thái Facebook ---------- */
td.fbcell { white-space: nowrap; }
td.fbcell .date { color: var(--faint); font-size: 12px; margin-top: 2px; }
.fb { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); text-decoration: none; }
.fb::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.fb.posted { color: var(--spruce); font-weight: 500; }
.fb.posted:hover { text-decoration: underline; }
.fb.queued { color: var(--ochre); }
.fb.failed { color: var(--brick); cursor: help; }
.fb.posting, .fb.draft { color: var(--muted); }
.fb.none { color: var(--faint); }
.fb.none::before { background: transparent; border: 1px solid currentColor; }

/* ---------- Hộp thoại ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 20; display: none;
  align-items: flex-start; justify-content: center; padding: 48px 16px; overflow-y: auto;
  background: rgba(24, 33, 30, .42);
}
.modal-backdrop.show { display: flex; }
.modal {
  width: 100%; max-width: 640px; padding: 26px 28px 24px;
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px -20px rgba(18, 28, 25, .45);
}
.modal h3 { margin: 0 0 4px; font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.modal .sub {
  margin: 0 0 20px; color: var(--muted); font-size: 13px;
  white-space: pre-wrap; overflow: hidden; text-overflow: ellipsis;
}
.modal-section { margin-bottom: 20px; }
.modal-section > label { display: block; font-weight: 500; margin-bottom: 8px; }
.row { display: flex; gap: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.dropzone {
  padding: 22px; text-align: center; color: var(--muted); cursor: pointer;
  border: 1px dashed #b5bfb9; border-radius: var(--radius); background: var(--raised);
  transition: border-color .12s, background-color .12s;
}
.dropzone:focus-visible, .dropzone.drag { outline: none; border-color: var(--spruce); background: var(--spruce-tint); }
.dropzone strong { color: var(--ink); font-weight: 500; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.gallery .tile { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--line-soft); }
.gallery .tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .tile .x {
  position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(24, 33, 30, .72); color: #fff;
  font-size: 14px; line-height: 22px; cursor: pointer;
}
.gallery .tile .x:hover { background: var(--brick); }
.gallery .tile .tag {
  position: absolute; left: 5px; bottom: 5px; padding: 1px 6px; border-radius: 3px;
  background: rgba(24, 33, 30, .72); color: #fff; font-size: 11px;
}
.gallery .tile.pending { outline: 2px solid var(--spruce); outline-offset: -2px; }
.gallery-empty { color: var(--faint); font-size: 13px; }

.lightbox {
  position: fixed; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center;
  background: rgba(18, 26, 23, .86); cursor: zoom-out;
}
.lightbox.show { display: flex; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: var(--radius); }

/* ---------- Hộp xác nhận ---------- */
.confirm-backdrop { z-index: 40; align-items: center; }
.modal.confirm { max-width: 440px; padding: 24px; }
@media (prefers-reduced-motion: no-preference) {
  .confirm-backdrop.show .modal.confirm { animation: rise .16s ease-out; }
  @keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
}
.confirm-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.confirm-head h3 { margin: 0; font-size: 21px; }
.confirm-icon {
  width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--brick-tint); color: var(--brick); font-weight: 600; font-size: 16px;
}
.confirm-body p { margin: 0 0 10px; }
.confirm-product {
  display: flex; gap: 14px; align-items: center; padding: 12px; margin-bottom: 14px;
  background: var(--raised); border: 1px solid var(--line-soft); border-radius: var(--radius);
}
.confirm-product img, .confirm-product .noimg {
  width: 56px; height: 56px; flex: none; border-radius: var(--radius-sm); object-fit: cover; background: var(--line-soft);
}
.confirm-product .noimg { display: grid; place-items: center; font-size: 11px; color: var(--faint); }
.confirm-product .meta { min-width: 0; }
.confirm-product .meta .title {
  font-weight: 500; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.confirm-product .meta .sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.confirm-notes { margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.confirm-notes li { position: relative; margin: 6px 0; padding-left: 16px; }
.confirm-notes li::before {
  content: ""; position: absolute; left: 2px; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: var(--spruce);
}
.confirm-notes li.warn { color: var(--brick); }
.confirm-notes li.warn::before { background: var(--brick); }
.modal.confirm .error { min-height: 0; margin: 12px 0 0; }
.modal.confirm .modal-actions { margin-top: 20px; }

/* ---------- Khác ---------- */
.spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .btn, .dropzone { transition: none; }
}

@media (max-width: 760px) {
  header.top { padding: 0 16px; }
  main { padding: 20px 16px; }
  .toolbar h2 { width: 100%; font-size: 26px; }
  .toolbar .search { width: 100%; }
  .toolbar .btn { flex: 1; }
  .modal { padding: 22px 18px; }
}
