/* ============================================================
   Minh Két Ta Vui Vẻ — phong cách Threads
   Tối giản, đơn sắc (đen/trắng/xám), Inter, bo góc lớn, nút pill,
   kẻ mảnh, nhiều khoảng trắng. Giữ nguyên tên class.
   ============================================================ */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --fill: #f5f5f5;        /* nền phụ / hover */
  --fill-2: #fafafa;
  --ink: #0a0a0a;         /* chữ chính (gần đen) */
  --ink-2: #44474c;
  --ink-soft: #999999;    /* chữ phụ xám kiểu Threads */
  --line: #ededed;        /* kẻ mảnh */
  --line-2: #dbdbdb;      /* viền input */

  --accent: #0a0a0a;      /* hành động chính = đen */
  --danger: #ed4956;
  --ok: #1a9e6c;
  --warn: #c97a12;

  --fb: #1877f2;
  --ig: #dd2a7b;
  --th: #000000;

  --r-card: 16px;
  --r-input: 12px;
  --r-pill: 999px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;

  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-soft); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px;
}
.sidebar__brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.brand-icon { width: 36px; height: 36px; border-radius: 10px; flex: 0 0 36px; display: block; }
.brand-dot { display: none; }
.brand-mark { font-weight: 800; font-size: 17px; line-height: 1.12; letter-spacing: -0.02em; color: var(--ink); }
.brand-mark em { font-style: normal; color: var(--ink); }
.brand-sub { font-size: 12px; color: var(--ink-soft); margin-top: 5px; font-weight: 500; }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 11px; font-weight: 600; color: var(--ink-soft); margin: 16px 12px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 12px; border-radius: 12px;
  color: var(--ink); font-size: 15px; font-weight: 500;
  transition: background .12s;
}
.nav-item i { display: inline-block; width: 22px; text-align: center; font-size: 18px; color: var(--ink); }
.nav-item:hover { background: var(--fill); text-decoration: none; }
.nav-item.active { background: var(--fill); font-weight: 700; }

.sidebar__user {
  margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 11px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--ink);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; flex: 0 0 36px;
}
.sidebar__user .meta { min-width: 0; flex: 1; }
.sidebar__user .meta strong { font-size: 14px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user .meta span { font-size: 12px; color: var(--ink-soft); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 14px 30px;
  display: flex; align-items: center; gap: 16px;
}
.topbar__title { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.topbar__spacer, .spacer { flex: 1; }
.content { padding: 26px 30px 64px; max-width: 1040px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 27px; font-weight: 800; line-height: 1.15; }
.page-head p { margin: 7px 0 0; color: var(--ink-soft); font-size: 15px; }

/* ---------- Buttons (pill) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-weight: 600; font-size: 14px;
  padding: 10px 18px; border-radius: var(--r-pill); border: 1px solid transparent;
  cursor: pointer; transition: background .12s, border-color .12s, opacity .12s; white-space: nowrap;
  background: var(--fill); color: var(--ink); line-height: 1.1;
}
.btn i { font-size: 13px; }
.btn:hover { background: #ebebeb; text-decoration: none; }
.btn--primary { background: var(--ink); color: #fff; }
.btn--primary:hover { background: #2a2a2a; }
.btn--outline { background: #fff; border-color: var(--line-2); color: var(--ink); }
.btn--outline:hover { background: var(--fill); border-color: #c2c2c2; }
.btn--ghost { background: transparent; color: var(--ink-soft); }
.btn--ghost:hover { background: var(--fill); color: var(--ink); }
.btn--danger { background: #fff; color: var(--danger); border-color: #f3c4c9; }
.btn--danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--sm { padding: 6px 13px; font-size: 13px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); margin-bottom: 16px; overflow: hidden; }
.card__head { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.card__title { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px; }
.card__title i { color: var(--ink); font-size: 16px; }
.card__body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }

/* ---------- Stat ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 18px; }
.stat__num, .stat__num.grad {
  font-weight: 800; font-size: 30px; line-height: 1; letter-spacing: -0.03em;
  color: var(--ink); -webkit-text-fill-color: var(--ink); background: none;
}
.stat__label { color: var(--ink-soft); font-size: 13px; margin-top: 8px; display: flex; align-items: center; gap: 7px; font-weight: 500; }
.stat__label i { color: var(--ink-soft); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 7px; color: var(--ink); }
.input, .textarea, .select {
  width: 100%; font-family: var(--font); font-size: 15px; color: var(--ink);
  padding: 11px 14px; border: 1px solid var(--line-2); border-radius: var(--r-input); background: #fff;
  transition: border-color .12s;
}
.input::placeholder, .textarea::placeholder { color: #b3b3b3; }
.textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--ink); }
.hint { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- Badge & chip (pill) ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: var(--r-pill); background: var(--fill); color: var(--ink-2); }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge--draft { color: #6b6b6b; }
.badge--pending_review { color: var(--warn); background: #fbf0e0; }
.badge--approved { color: #1d6fd6; background: #e8f1fd; }
.badge--scheduled { color: #6b3fd1; background: #efeafe; }
.badge--publishing { color: #c026a3; background: #fbe9f6; }
.badge--published { color: var(--ok); background: #e6f6ee; }
.badge--partially_failed { color: var(--warn); background: #fbf0e0; }
.badge--failed, .badge--rejected { color: var(--danger); background: #fdeaed; }

.channel-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 4px 11px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: #fff; color: var(--ink-2);
}
.channel-chip i { font-size: 13px; }
.channel-chip--facebook { color: var(--fb); border-color: #bcd5fb; background: #f0f6ff; }
.channel-chip--instagram { color: var(--ig); border-color: #f3c2d6; background: #fdeff5; }
.channel-chip--threads { color: #000; border-color: #d4d4d4; background: #f6f6f6; }

/* ---------- Xem trước đa kênh = thẻ bài kiểu MXH ---------- */
.previews { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.preview { border: 1px solid var(--line); border-radius: var(--r-card); background: #fff; overflow: hidden; }
.preview__head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px; font-weight: 600; font-size: 14px; }
.preview__head .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 14px; flex: 0 0 30px; }
.preview--facebook .preview__head .dot { background: var(--fb); }
.preview--instagram .preview__head .dot { background: linear-gradient(45deg, #f58529, #dd2a7b, #8134af); }
.preview--threads .preview__head .dot { background: #000; }
.preview__caption { padding: 0 14px 14px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: var(--ink); max-height: 230px; overflow: auto; }
.preview__media { margin: 0 14px 14px; border-radius: 12px; background: var(--fill); aspect-ratio: 1 / 1; display: grid; place-items: center; color: var(--ink-soft); overflow: hidden; }
.preview__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview--instagram .preview__media { aspect-ratio: 4 / 5; }
.preview--threads .preview__media { display: none; }
.preview--threads.has-media .preview__media { display: grid; aspect-ratio: 16 / 9; }

/* ---------- Hàng chờ ---------- */
.queue { display: flex; flex-direction: column; }
.queue__lane { display: grid; grid-template-columns: 116px 1fr; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.queue__lane:last-child { border-bottom: none; }
.lane__label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.lane__track { display: flex; gap: 8px; flex-wrap: wrap; min-height: 30px; align-items: center; }
.queue-item { display: inline-flex; flex-direction: column; gap: 1px; padding: 8px 13px; border-radius: 12px; background: var(--fill); max-width: 250px; }
.queue-item .t { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.queue-item .x { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Bảng ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 13px; color: var(--ink-soft); padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
.table td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td strong { font-weight: 600; font-size: 15px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--fill-2); }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 56px 20px; color: var(--ink-soft); }
.empty > i { font-size: 32px; color: var(--ink); opacity: .22; margin-bottom: 14px; display: block; }
.empty h3 { font-size: 18px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.empty p { color: var(--ink-soft); }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #fff; }
.auth__card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 38px 32px; }
.auth__brand { text-align: center; margin-bottom: 26px; }
.auth__brand .brand-mark { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; }
.auth__brand .brand-sub { font-size: 13px; color: var(--ink-soft); margin-top: 5px; }
.auth h1 { font-size: 21px; font-weight: 800; margin: 0 0 4px; text-align: center; }
.auth .sub { color: var(--ink-soft); font-size: 14px; margin-bottom: 24px; text-align: center; }
.auth .switch { text-align: center; margin-top: 20px; font-size: 14px; color: var(--ink-soft); }
.auth .switch a { color: var(--ink); font-weight: 600; }

/* ---------- Alert ---------- */
.alert { padding: 11px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 16px; display: none; }
.alert.show { display: block; }
.alert--error { background: #fdeaed; color: var(--danger); }
.alert--success { background: #e6f6ee; color: var(--ok); }

/* ---------- Helpers ---------- */
.flex { display: flex; } .items-center { align-items: center; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.wrap { flex-wrap: wrap; } .between { justify-content: space-between; } .mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.divider { height: 0; border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Accessibility ---------- */
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: sticky; top: 0; z-index: 30; flex-direction: row; align-items: center; gap: 8px; overflow-x: auto; padding: 10px 14px; border-right: none; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(12px); }
  .sidebar__brand { padding: 0 12px 0 4px; flex: 0 0 auto; }
  .brand-mark { font-size: 17px; }
  .sidebar__nav { flex-direction: row; margin-top: 0; flex: 1; gap: 4px; }
  .nav-section, .sidebar__user .meta, .brand-sub { display: none; }
  .nav-item { padding: 9px 11px; white-space: nowrap; gap: 8px; }
  .sidebar__user { margin-top: 0; padding-top: 0; border-top: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid--2, .grid--3, .previews, .form-row { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .queue__lane { grid-template-columns: 90px 1fr; }
}
