/* ============================================================
   Trung Nguyên HRM — Design System
   Warm Vietnamese heritage: espresso brown + bronze gold
   ============================================================ */

:root {
  /* Brand accent (tweakable) */
  --accent: #B07B2E;        /* bronze gold */
  --accent-deep: #8C5E1F;
  --accent-soft: #E9D4AC;
  --accent-wash: #F4E8D2;

  /* Coffee neutrals */
  --espresso: #2A1C16;      /* darkest, text + dark surfaces */
  --coffee: #4A342A;
  --mocha: #6B4E3D;
  --latte: #9A8475;
  --foam: #C9BBAC;

  /* Paper / surfaces (light) */
  --bg: #F6EFE4;
  --bg-2: #EFE6D7;
  --surface: #FFFDF9;
  --surface-2: #FBF5EB;
  --line: #E6DAC6;
  --line-strong: #D8C8AE;

  /* Text */
  --ink: #2A1C16;
  --ink-2: #5C4A3E;
  --ink-3: #8A7868;
  --on-accent: #FFFBF2;

  /* Semantic (status) */
  --pass: #4F7A4A;          /* Đạt — sage green */
  --pass-bg: #E7F0E2;
  --hold: #B8852B;          /* Cân nhắc — amber */
  --hold-bg: #F6EACB;
  --fail: #AE5238;          /* Không đạt — terracotta */
  --fail-bg: #F4E0D7;
  --info: #4A6B8A;          /* neutral blue-slate */
  --info-bg: #E2EAF1;

  /* Density (tweakable) */
  --density: 1;
  --pad-card: calc(20px * var(--density));
  --gap: calc(16px * var(--density));
  --row-h: calc(56px * var(--density));

  /* Type */
  --font-display: 'Lora', Georgia, serif;
  --font-ui: 'Be Vietnam Pro', system-ui, sans-serif;

  /* Shape */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 26px;

  /* Shadow (warm-tinted) */
  --sh-sm: 0 1px 2px rgba(42,28,22,.06), 0 1px 3px rgba(42,28,22,.05);
  --sh: 0 2px 8px rgba(42,28,22,.07), 0 8px 24px rgba(42,28,22,.06);
  --sh-lg: 0 8px 30px rgba(42,28,22,.12), 0 24px 60px rgba(42,28,22,.10);
  --sh-pop: 0 12px 40px rgba(42,28,22,.18);
}

/* Dark mode (tweakable) */
[data-theme="dark"] {
  --bg: #1C130F;
  --bg-2: #241812;
  --surface: #29191130;
  --surface: #2A1C15;
  --surface-2: #33231A;
  --line: #3E2C22;
  --line-strong: #4E382B;
  --ink: #F3E9DA;
  --ink-2: #D2C0AE;
  --ink-3: #9E8A78;
  --accent-wash: #3A2A18;
  --accent-soft: #5A431F;
  --pass-bg: #1E2C1C;
  --hold-bg: #322611;
  --fail-bg: #321A12;
  --info-bg: #1A2630;
  --sh-sm: 0 1px 2px rgba(0,0,0,.3);
  --sh: 0 2px 10px rgba(0,0,0,.35);
  --sh-lg: 0 10px 36px rgba(0,0,0,.5);
  --sh-pop: 0 14px 44px rgba(0,0,0,.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}
#root { height: 100%; }

h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 600; color: var(--ink); line-height: 1.15; letter-spacing: -0.01em; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-soft); color: var(--espresso); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 20px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--latte); background-clip: padding-box; border: 3px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 256px 1fr; height: 100%; overflow: hidden; }
.app.collapsed { grid-template-columns: 76px 1fr; }

/* Sidebar */
.sidebar {
  background: linear-gradient(180deg, var(--espresso), #1f140f);
  color: var(--foam);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  position: relative;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  background: radial-gradient(circle at 30% 25%, var(--accent), var(--accent-deep) 75%);
  display: grid; place-items: center;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.3), 0 4px 14px rgba(176,123,46,.4);
}
.brand-mark span { font-family: var(--font-display); font-weight: 700; color: #fff; font-size: 20px; }
.brand-name { font-family: var(--font-display); font-weight: 600; color: #FBF1DE; font-size: 16px; line-height: 1.1; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--latte); letter-spacing: .04em; text-transform: uppercase; }
.collapsed .brand-name, .collapsed .brand-sub, .collapsed .nav-label, .collapsed .nav-section, .collapsed .side-foot-text { display: none; }
.collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }

.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: #7a6453; margin: 16px 10px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: #C9B5A2; font-weight: 500; font-size: 14px;
  transition: all .15s ease; position: relative; width: 100%; text-align: left;
}
.nav-item svg { flex: none; width: 19px; height: 19px; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #F3E3CE; }
.nav-item.active { background: linear-gradient(90deg, rgba(176,123,46,.28), rgba(176,123,46,.1)); color: #FBEFD9; }
.nav-item.active::before { content:''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.collapsed .nav-item { justify-content: center; padding: 11px; }
.nav-badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; }
.collapsed .nav-badge { display: none; }
.nav-item.soon { opacity: .8; }
.tag-soon { margin-left: auto; font-size: 9.5px; letter-spacing: .05em; background: rgba(255,255,255,.1); color: #d8c3aa; padding: 2px 6px; border-radius: 5px; text-transform: uppercase; font-weight: 600; }
.collapsed .tag-soon { display: none; }

.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 10px; }
.side-foot .avatar { width: 34px; height: 34px; flex: none; }
.side-foot-text { line-height: 1.2; overflow: hidden; }
.side-foot-text b { color: #F3E3CE; font-size: 13px; font-weight: 600; display: block; white-space: nowrap; }
.side-foot-text span { color: var(--latte); font-size: 11.5px; }
.collapsed .side-foot { justify-content: center; }

/* Main */
.main { display: flex; flex-direction: column; overflow: hidden; min-width: 0; background: var(--bg); }
.topbar {
  height: 64px; flex: none; display: flex; align-items: center; gap: 14px;
  padding: 0 24px; border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg) 80%, transparent); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.icon-btn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--ink-2); transition: all .15s; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.search {
  flex: 1; max-width: 420px; display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px;
  padding: 9px 14px; color: var(--ink-3); transition: all .15s;
}
.search:focus-within { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-wash); }
.search input { border: none; background: none; outline: none; flex: 1; color: var(--ink); }
.search input::placeholder { color: var(--ink-3); }
.topbar-spacer { flex: 1; }

.lang-toggle { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.lang-toggle button { padding: 5px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.lang-toggle button.on { background: var(--surface); color: var(--accent-deep); box-shadow: var(--sh-sm); }

.content { flex: 1; overflow-y: auto; overflow-x: hidden; }
.page { max-width: 1320px; margin: 0 auto; padding: 28px 28px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { font-size: 27px; }
.page-sub { color: var(--ink-2); font-size: 14.5px; margin-top: 4px; }
.eyebrow { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-deep); font-weight: 600; }

/* ---------- Reusable ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-sm); }
.card-pad { padding: var(--pad-card); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  transition: all .15s ease; white-space: nowrap; border: 1px solid transparent;
}
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 2px 8px rgba(176,123,46,.3); }
.btn-primary:hover { background: var(--accent-deep); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(176,123,46,.4); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--latte); }
.btn-soft { background: var(--accent-wash); color: var(--accent-deep); }
.btn-soft:hover { background: var(--accent-soft); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 20px; white-space: nowrap; flex: none; }
.chip-pass { background: var(--pass-bg); color: var(--pass); }
.chip-hold { background: var(--hold-bg); color: var(--hold); }
.chip-fail { background: var(--fail-bg); color: var(--fail); }
.chip-info { background: var(--info-bg); color: var(--info); }
.chip-neutral { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

.tag { display: inline-flex; align-items: center; font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 7px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }

.avatar { border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; font-family: var(--font-ui); overflow: hidden; }

.divider { height: 1px; background: var(--line); border: none; margin: var(--gap) 0; }

/* Progress / meter */
.meter { height: 8px; border-radius: 20px; background: var(--bg-2); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 20px; background: var(--accent); }
.ring { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-linecap: round; }

/* Tooltip-ish label */
.kbd { font-family: var(--font-ui); font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink-3); }

/* Toast */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  display: flex; align-items: center; gap: 12px; background: var(--espresso); color: #F3E3CE;
  padding: 13px 18px; border-radius: 12px; box-shadow: var(--sh-pop); font-size: 14px; font-weight: 500;
  animation: toastIn .3s cubic-bezier(.2,.8,.2,1); max-width: 360px;
}
.toast .ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--accent); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }

/* Modal / drawer */
.scrim { position: fixed; inset: 0; background: rgba(30,18,12,.5); backdrop-filter: blur(3px); z-index: 100; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 96vw);
  background: var(--bg); box-shadow: var(--sh-lg); z-index: 101;
  display: flex; flex-direction: column; animation: drawerIn .32s cubic-bezier(.2,.85,.25,1);
}
@keyframes drawerIn { from { transform: translateX(40px); opacity: .4; } }

/* Grid helpers */
.grid { display: grid; gap: var(--gap); }
.row { display: flex; align-items: center; gap: var(--gap); }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.input, .textarea, .select {
  width: 100%; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 11px 13px; color: var(--ink); transition: all .15s; outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.55; }

/* spinner + kanban drop */
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
/* clean number inputs (criteria weights / thresholds) */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.crit-inp:focus { outline: none; }
.board-col.drop { background: var(--accent-wash) !important; outline: 2px dashed var(--accent-soft); outline-offset: -4px; }

/* fade-in for page transitions — transform-only so content is never hidden if the
   animation clock is paused (screenshots / first paint). Opacity stays at base 1. */
.fade-in { animation: pageRise .35s ease; }
@keyframes pageRise { from { transform: translateY(8px); } }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } }

.stagger > * { animation: pageRise .4s ease backwards; }
.stagger > *:nth-child(1){animation-delay:.02s}
.stagger > *:nth-child(2){animation-delay:.06s}
.stagger > *:nth-child(3){animation-delay:.10s}
.stagger > *:nth-child(4){animation-delay:.14s}
.stagger > *:nth-child(5){animation-delay:.18s}
.stagger > *:nth-child(6){animation-delay:.22s}

/* Mobile */
.mobile-only { display: none; }
.mobile-nav { display: none; }
@media (max-width: 880px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--espresso); padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around; box-shadow: 0 -4px 20px rgba(0,0,0,.2);
  }
  .mobile-nav button { display: flex; flex-direction: column; align-items: center; gap: 3px; color: #b59f8c; font-size: 10px; font-weight: 600; padding: 4px 8px; border-radius: 9px; flex:1; }
  .mobile-nav button svg { width: 21px; height: 21px; }
  .mobile-nav button.active { color: var(--accent); }
  .content { padding-bottom: 70px; }
  .page { padding: 18px 16px 40px; }
  .page-title { font-size: 22px; }
  .topbar { padding: 0 16px; height: 58px; }
  .mobile-only { display: revert; }
  .desktop-only { display: none !important; }
  .drawer { width: 100vw; }
}
