/* ==========================================================================
   Trợ lý Zalo – VTVcab · Bộ giao diện dùng chung
   Mọi trang dùng chung token màu, chữ, nút, ô nhập, thẻ, cửa sổ… ở đây.
   ========================================================================== */

:root {
  --font: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f4f9;
  --border: #e4e8f0;
  --border-strong: #cfd6e3;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;

  --primary: #2457e6;
  --primary-hover: #1c47c4;
  --primary-soft: #ebf0ff;
  --primary-text: #1f4fd6;
  --success: #12a150;
  --success-soft: #e7f7ee;
  --warning: #c26a06;
  --warning-soft: #fff4e2;
  --danger: #d92d2d;
  --danger-soft: #fdeceb;
  --violet: #7c3aed;
  --violet-soft: #f1ebff;

  --bubble-me: #e3ebff;
  --bubble-them: #ffffff;

  --sidebar: #0c1733;
  --sidebar-2: #13224a;
  --sidebar-text: #aab6d3;
  --sidebar-active: #ffffff;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .05);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
  --ring: 0 0 0 3px rgba(36, 87, 230, .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --surface: #121a2d;
    --surface-2: #161f35;
    --surface-3: #1b2540;
    --border: #233050;
    --border-strong: #31405f;
    --text: #e6eaf2;
    --text-2: #c3cbdb;
    --muted: #8b97b0;
    --faint: #66728c;
    --primary: #4f7cff;
    --primary-hover: #6b91ff;
    --primary-soft: #1a2750;
    --primary-text: #8fadff;
    --success: #34c477;
    --success-soft: #11291e;
    --warning: #f0a33a;
    --warning-soft: #2e2210;
    --danger: #f06262;
    --danger-soft: #331617;
    --violet: #a78bfa;
    --violet-soft: #241a40;
    --bubble-me: #1e3163;
    --bubble-them: #1a2338;
    --sidebar: #080e1f;
    --sidebar-2: #111b36;
    --shadow-sm: none;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
    --ring: 0 0 0 3px rgba(79, 124, 255, .3);
  }
}

/* ---------- Nền tảng ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
::selection { background: var(--primary-soft); }
.meta { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Bố cục: thanh bên + vùng chính ---------- */
body.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); height: 100vh; overflow: hidden; }
.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 6px; min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #3b82f6, #2457e6 55%, #f97316); font-weight: 800; font-size: 17px; color: #fff;
  box-shadow: 0 4px 14px rgba(36, 87, 230, .45);
}
.brand b { display: block; font-size: 14.5px; line-height: 1.2; }
.brand span { font-size: 11.5px; color: var(--sidebar-text); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px;
  color: var(--sidebar-text); font-weight: 500; text-decoration: none; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, .1); color: var(--sidebar-active); box-shadow: inset 3px 0 0 #5b8cff; }
.nav .count {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px;
  background: #f97316; color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center;
}
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6f7ea3; padding: 14px 11px 6px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px 6px 0; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-foot .meta { color: #8a98bb; font-size: 12px; }
.sb-me { display: flex; align-items: center; gap: 10px; padding: 6px; margin: 0 -6px 4px; border-radius: 10px; color: #fff; text-decoration: none; }
.sb-me:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.me-av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: linear-gradient(135deg, #5b8cff, #2457e6); flex-shrink: 0; }
.sb-me b { display: block; font-size: 13px; line-height: 1.25; }
.sb-me span span, #me-role { font-size: 11.5px; color: #8a98bb; }
.side-foot form { margin: 0; }
.side-foot button { width: 100%; justify-content: flex-start; background: transparent; border-color: rgba(255, 255, 255, .12); color: var(--sidebar-text); }
.side-foot button:hover:not(:disabled) { background: rgba(255, 255, 255, .06); color: #fff; border-color: rgba(255, 255, 255, .2); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 0 24px; min-height: 62px; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.page { flex: 1; overflow: auto; padding: 24px; }
.container { max-width: 1180px; margin: 0 auto; }

/* Thanh tab dưới đáy – chỉ hiện trên điện thoại */
.bottom-nav { display: none; }

/* ---------- Trạng thái (viên thuốc) ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: rgba(148, 163, 184, .15); color: var(--muted); white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: #22c55e; background: rgba(34, 197, 94, .14); }
.pill.warn { color: #f59e0b; background: rgba(245, 158, 11, .15); }
.pill.bad { color: #f87171; background: rgba(248, 113, 113, .15); }
.pill.ok::before { box-shadow: 0 0 0 3px rgba(34, 197, 94, .25); }

/* ---------- Nút ---------- */
button, .btn {
  font: inherit; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  border-radius: var(--radius-sm); padding: 7px 14px; line-height: 1.35; transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
button:hover:not(:disabled), .btn:hover { background: var(--surface-2); border-color: var(--faint); color: var(--text); text-decoration: none; }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(36, 87, 230, .25); }
button.primary:hover:not(:disabled), .btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
button.danger, .btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
button.danger:hover:not(:disabled) { filter: brightness(.95); background: var(--danger); color: #fff; }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover:not(:disabled) { background: var(--surface-3); border-color: transparent; }
button.small, .btn.small { padding: 4px 10px; font-size: 13px; border-radius: 7px; }
button.icon { padding: 7px; }

/* ---------- Ô nhập ---------- */
input[type=text], input[type=search], input[type=number], input[type=password], input[type=email], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 11px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; }
select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }

/* ---------- Thẻ nội dung ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 15px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card h2 svg.i { color: var(--primary-text); }

/* ---------- Nhãn & chip ---------- */
.badge, .tag, .st, .src, .kind {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 9px;
  border-radius: 999px; background: var(--surface-3); color: var(--muted); white-space: nowrap; line-height: 1.6;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  color: var(--chip, var(--muted)); background: color-mix(in srgb, var(--chip, #64748b) 11%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--chip, #64748b) 28%, var(--surface)); white-space: nowrap;
}
.chip button { border: 0; background: none; padding: 0 0 0 2px; color: inherit; font-size: 14px; line-height: 1; box-shadow: none; }
.chip button:hover:not(:disabled) { background: none; color: var(--danger); }

/* ---------- Tab dạng phân đoạn ---------- */
.seg-tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: 10px; }
.seg-tabs button { border: 0; background: transparent; padding: 6px 12px; font-size: 13px; color: var(--muted); border-radius: 8px; box-shadow: none; }
.seg-tabs button:hover:not(:disabled) { background: transparent; color: var(--text); }
.seg-tabs button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }

/* ---------- Cửa sổ ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(8, 14, 31, .5); backdrop-filter: blur(3px); display: none; place-items: center; z-index: 50; padding: 16px; }
.modal-bg.show { display: grid; animation: fade .15s ease; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: min(480px, 100%); max-height: 86vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal h2 { font-size: 16px; margin: 0; padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.modal .body { padding: 14px 20px 18px; overflow-y: auto; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Thông báo nổi ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 8px); background: #0f172a; color: #fff;
  padding: 10px 18px; border-radius: 10px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
  z-index: 60; max-width: min(560px, 90vw); box-shadow: var(--shadow-lg); font-weight: 500;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Trạng thái rỗng ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .empty-icon { width: 46px; height: 46px; border-radius: 14px; margin: 0 auto 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.empty .empty-icon svg.i { width: 22px; height: 22px; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; font-size: 15px; }

/* ---------- Thanh cuộn mảnh ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ---------- Điện thoại ---------- */
@media (max-width: 900px) {
  body.app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 1fr; }
  .sidebar { display: none; }
  .main { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .topbar { padding: 0 16px; min-height: 54px; }
  .topbar h1 { font-size: 16px; }
  .topbar .sub { display: none; }
  .page { padding: 16px; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 600;
    color: var(--muted); text-decoration: none; padding: 4px 0; position: relative;
  }
  .bottom-nav a.active { color: var(--primary-text); }
  .bottom-nav svg.i { width: 21px; height: 21px; }
  .bottom-nav .count { position: absolute; top: 0; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: #f97316; color: #fff; font-size: 10px; display: grid; place-items: center; }
  input[type=text], input[type=search], textarea, select { font-size: 16px; } /* iPhone không tự phóng to khi gõ */
}
