/* ============================================================
   UNIVISTA ERP v2 — Design System (Vanilla CSS)
   Stack: Flask + Jinja2 + Vanilla JS + CSS thuần (KHÔNG React)
   Drop vào templates/base.html: <link rel="stylesheet" href="{{ url_for('static', filename='univista.css') }}">
   ============================================================ */

/* ---- Font ---- */
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700&display=swap');

/* ---- Design tokens ---- */
:root {
  /* Neutrals / ink */
  --uvx-ink:        #1C1C2E;   /* text chính, sidebar active, primary button */
  --uvx-ink-soft:   #5A5A68;
  --uvx-muted:      #9A9AA8;
  --uvx-bg:         #F4F5F7;   /* nền app */
  --uvx-card:       #FFFFFF;
  --uvx-border:     #ECEDF1;
  --uvx-line:       #F0F1F4;

  /* Univista accent (mix 3 công ty) */
  --uvx-gold:       #C99A2E;
  --uvx-gold-soft:  #FBF3DE;

  /* Trạng thái */
  --uvx-green:      #2E9E6B;  --uvx-green-soft:  #E6F4ED;
  --uvx-amber:      #E0A100;  --uvx-amber-soft:  #FBF1D6;
  --uvx-red:        #DC5B4B;  --uvx-red-soft:    #FBE9E6;

  /* Brand 3 công ty (dùng cho chip/badge phân loại) */
  --uvx-fc:         #1A5FA8;  --uvx-fc-soft:     #E8F0F9;   /* FastCons */
  --uvx-pl:         #9A7820;  --uvx-pl-soft:     #F5EFE0;   /* Phú Long */
  --uvx-sh:         #1B4080;  --uvx-sh-soft:     #E7ECF6;   /* StarHouse */

  /* Radius / shadow */
  --uvx-r-sm: 8px; --uvx-r: 11px; --uvx-r-lg: 14px; --uvx-r-xl: 16px;
  --uvx-shadow:    0 1px 3px rgba(20,20,40,.08);
  --uvx-shadow-lg: 0 16px 40px rgba(20,20,40,.30);

  /* Spacing (4pt) */
  --uvx-s1:4px; --uvx-s2:8px; --uvx-s3:12px; --uvx-s4:16px; --uvx-s5:20px; --uvx-s6:24px;
}

.uvx-tnum { font-variant-numeric: tabular-nums; }

/* ============================================================
   APP SHELL — sidebar + topbar
   ============================================================ */
.uvx-app { display: flex; height: 100vh; overflow: hidden; }

.uvx-sidebar {
  width: 236px; flex: 0 0 236px; background: var(--uvx-card);
  border-right: 1px solid var(--uvx-border); display: flex; flex-direction: column;
}
.uvx-sidebar__logo { height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--uvx-line); }
.uvx-logo-badge { width: 30px; height: 30px; border-radius: var(--uvx-r-sm); background: var(--uvx-ink); color: var(--uvx-gold); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.uvx-nav { flex: 1; overflow-y: auto; padding: 12px; }
.uvx-nav__group { padding: 14px 8px 6px; font-size: 10px; font-weight: 700; letter-spacing: .7px; color: #A6A7B2; }
.uvx-nav__item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--uvx-r);
  cursor: pointer; margin-bottom: 2px; font-size: 13px; font-weight: 500; color: var(--uvx-ink-soft);
  text-decoration: none; transition: background .12s;
}
.uvx-nav__item:hover { background: #F7F8FA; }
.uvx-nav__item.is-active { background: var(--uvx-ink); color: #fff; font-weight: 600; }
.uvx-nav__item.is-active svg { stroke: #fff; }
.uvx-nav__item svg { stroke: var(--uvx-muted); flex: 0 0 auto; }
.uvx-nav__label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.uvx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.uvx-topbar { height: 60px; flex: 0 0 60px; background: var(--uvx-card); border-bottom: 1px solid var(--uvx-border); display: flex; align-items: center; gap: 16px; padding: 0 20px; }
.uvx-content { flex: 1; overflow-y: auto; padding: 24px 28px 48px; }
.uvx-search { display: flex; align-items: center; gap: 9px; background: var(--uvx-bg); border: 1px solid var(--uvx-border); border-radius: var(--uvx-r); padding: 8px 12px; color: var(--uvx-muted); font-size: 13px; }
.uvx-avatar { width: 36px; height: 36px; border-radius: var(--uvx-r); background: var(--uvx-ink); color: var(--uvx-gold); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }

/* ============================================================
   CARD
   ============================================================ */
.uvx-card { background: var(--uvx-card); border: 1px solid var(--uvx-border); border-radius: var(--uvx-r-lg); padding: 16px 18px; }
.uvx-card--lg { border-radius: var(--uvx-r-xl); padding: 22px 24px; }
.uvx-card__title { font-size: 14.5px; font-weight: 700; margin: 0 0 14px; }

/* ============================================================
   BUTTON
   ============================================================ */
.uvx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--uvx-r); padding: 10px 16px;
  font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: filter .12s, background .12s; line-height: 1;
}
.uvx-btn:focus-visible { outline: 2px solid var(--uvx-gold); outline-offset: 2px; }
.uvx-btn--primary { background: var(--uvx-ink); color: #fff; }
.uvx-btn--primary:hover { filter: brightness(1.18); }
.uvx-btn--gold { background: var(--uvx-gold); color: var(--uvx-ink); font-weight: 700; }
.uvx-btn--ghost { background: var(--uvx-card); color: var(--uvx-ink-soft); border-color: #E2E3E8; }
.uvx-btn--ghost:hover { background: #F7F8FA; }
.uvx-btn--success { background: var(--uvx-green); color: #fff; }
.uvx-btn--danger  { background: var(--uvx-red); color: #fff; }
.uvx-btn--sm { padding: 7px 13px; font-size: 12.5px; }
.uvx-btn--lg { padding: 13px 22px; font-size: 14.5px; min-height: 48px; } /* mobile hit target >= 48px */
.uvx-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   BADGE / CHIP / PILL
   ============================================================ */
.uvx-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; background: var(--uvx-line); color: var(--uvx-muted); }
.uvx-badge--green { background: var(--uvx-green-soft); color: var(--uvx-green); }
.uvx-badge--amber { background: var(--uvx-amber-soft); color: var(--uvx-amber); }
.uvx-badge--red   { background: var(--uvx-red-soft);   color: var(--uvx-red); }
.uvx-badge--gold  { background: var(--uvx-gold-soft);  color: var(--uvx-pl); }
/* Company chips */
.uvx-chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.uvx-chip--fc { color: var(--uvx-fc); background: var(--uvx-fc-soft); }
.uvx-chip--pl { color: var(--uvx-pl); background: var(--uvx-pl-soft); }
.uvx-chip--sh { color: var(--uvx-sh); background: var(--uvx-sh-soft); }

/* Money mask (số nhạy cảm bị che theo quyền) */
.uvx-mask { color: var(--uvx-muted); letter-spacing: 1px; }
.uvx-mask::before { content: "•••• ₫"; }

/* ============================================================
   KPI CARD
   ============================================================ */
.uvx-kpi { background: var(--uvx-card); border: 1px solid var(--uvx-border); border-radius: var(--uvx-r-lg); padding: 16px 17px; }
.uvx-kpi__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.uvx-kpi__icon { width: 36px; height: 36px; border-radius: var(--uvx-r-sm); display: flex; align-items: center; justify-content: center; }
.uvx-kpi__label { font-size: 12px; color: var(--uvx-muted); font-weight: 500; margin-bottom: 3px; }
.uvx-kpi__value { font-size: 24px; font-weight: 700; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.uvx-kpi__sub { font-size: 11.5px; font-weight: 600; margin-top: 4px; }
.uvx-grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }

/* ============================================================
   NEXT-STEP BANNER ("📍 Bước tiếp theo")
   ============================================================ */
.uvx-next { display: flex; align-items: center; gap: 14px; background: var(--uvx-gold-soft); border: 1px solid rgba(201,154,46,.25); border-radius: var(--uvx-r-xl); padding: 16px 18px; }
.uvx-next__icon { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px; background: #fff; display: flex; align-items: center; justify-content: center; }
.uvx-next__kicker { font-size: 11px; font-weight: 700; letter-spacing: .5px; color: var(--uvx-gold); text-transform: uppercase; margin-bottom: 2px; }
.uvx-next__text { font-size: 15px; font-weight: 600; }

/* ============================================================
   STEPPER (ngang) — "đầy đủ các bước"
   ============================================================ */
.uvx-stepper { display: flex; align-items: flex-start; }
.uvx-stepper__step { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; }
.uvx-stepper__line { position: absolute; top: 18px; left: 50%; right: -50%; height: 3px; background: var(--uvx-border); z-index: 0; }
.uvx-stepper__circle { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; position: relative; z-index: 1; background: #fff; border: 3px solid var(--uvx-border); color: #B6B7C0; }
.uvx-stepper__label { font-size: 12px; font-weight: 500; color: var(--uvx-muted); margin-top: 9px; text-align: center; }
/* states */
.is-done    .uvx-stepper__circle { background: var(--uvx-green); border-color: var(--uvx-green); color: #fff; }
.is-done    .uvx-stepper__line   { background: var(--uvx-green); }
.is-done    .uvx-stepper__label  { color: var(--uvx-ink); }
.is-current .uvx-stepper__circle { border-color: var(--uvx-gold); color: var(--uvx-gold); animation: uvx-pulse 2s infinite; }
.is-current .uvx-stepper__label  { color: var(--uvx-gold); font-weight: 700; }
@keyframes uvx-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(201,154,46,.35); } 50% { box-shadow: 0 0 0 6px rgba(201,154,46,0); } }

/* ============================================================
   TIMELINE (dọc) — luồng duyệt nhiều cấp
   ============================================================ */
.uvx-timeline__row { display: flex; gap: 15px; }
.uvx-timeline__rail { display: flex; flex-direction: column; align-items: center; }
.uvx-timeline__dot { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--uvx-bg); border: 2px solid var(--uvx-border); }
.uvx-timeline__dot.is-done { background: var(--uvx-green); border-color: var(--uvx-green); }
.uvx-timeline__dot.is-current { background: var(--uvx-gold-soft); border-color: var(--uvx-gold); }
.uvx-timeline__connector { width: 2px; flex: 1; min-height: 30px; background: var(--uvx-border); }
.uvx-timeline__connector.is-done { background: var(--uvx-green); }
.uvx-timeline__body { flex: 1; padding-bottom: 16px; }
.uvx-timeline__title { font-size: 14px; font-weight: 600; }
.uvx-timeline__meta { font-size: 12px; color: var(--uvx-muted); margin-top: 2px; }

/* ============================================================
   TABS
   ============================================================ */
.uvx-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--uvx-border); }
.uvx-tab { display: inline-flex; align-items: center; gap: 8px; border: none; background: transparent; cursor: pointer; font-family: inherit; font-size: 13.5px; font-weight: 500; color: var(--uvx-muted); padding: 12px 14px; border-bottom: 2.5px solid transparent; margin-bottom: -1px; }
.uvx-tab.is-active { color: var(--uvx-ink); font-weight: 700; border-bottom-color: var(--uvx-gold); }
.uvx-tab__count { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 20px; background: var(--uvx-line); color: var(--uvx-muted); }
.uvx-tab.is-active .uvx-tab__count { background: var(--uvx-gold-soft); color: var(--uvx-pl); }
.uvx-panel { display: none; }
.uvx-panel.is-active { display: block; }

/* ============================================================
   TABLE
   ============================================================ */
.uvx-table-wrap { background: var(--uvx-card); border: 1px solid var(--uvx-border); border-radius: var(--uvx-r-lg); overflow: hidden; }
.uvx-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.uvx-table thead tr { background: #FAFBFC; text-align: left; color: var(--uvx-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.uvx-table th { padding: 11px 14px; font-weight: 700; }
.uvx-table td { padding: 13px 14px; border-top: 1px solid var(--uvx-line); }
.uvx-table tbody tr.is-selected { background: #FBF8EE; }
.uvx-table .right { text-align: right; }

/* Checkbox */
.uvx-checkbox { width: 18px; height: 18px; border-radius: 5px; cursor: pointer; display: flex; align-items: center; justify-content: center; border: 1.5px solid #CFD0D8; background: #fff; }
.uvx-checkbox.is-checked { border-color: var(--uvx-gold); background: var(--uvx-gold); }
.uvx-checkbox svg { display: none; }
.uvx-checkbox.is-checked svg { display: block; }

/* ============================================================
   DATA STATES — loading / empty / error (chống "Failed to fetch")
   ============================================================ */
.uvx-skel { border-radius: 6px; background: linear-gradient(90deg,#EEEFF2,#F7F8FA,#EEEFF2); background-size: 200% 100%; animation: uvx-shimmer 1.2s infinite; }
@keyframes uvx-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.uvx-state { text-align: center; padding: 40px 16px; }
.uvx-state__icon { margin: 0 auto 12px; }
.uvx-state__title { font-size: 15px; font-weight: 700; color: var(--uvx-ink-soft); }
.uvx-state__hint { font-size: 12.5px; color: var(--uvx-muted); margin: 5px 0 16px; }
.uvx-state--error { background: var(--uvx-red-soft); border-radius: var(--uvx-r); }
.uvx-state--error .uvx-state__title { color: #C0392B; }

/* ============================================================
   MODAL & DRAWER & TOAST
   ============================================================ */
.uvx-overlay { position: fixed; inset: 0; background: rgba(20,20,40,.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.uvx-overlay[hidden] { display: none; }
.uvx-modal { background: #fff; border-radius: 20px; width: 480px; max-width: 95vw; max-height: 90vh; overflow-y: auto; box-shadow: var(--uvx-shadow-lg); animation: uvx-fade .2s ease; }
.uvx-modal__pad { padding: 26px; }
@keyframes uvx-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.uvx-drawer-overlay { position: fixed; inset: 0; background: rgba(20,20,40,.40); z-index: 95; display: flex; justify-content: flex-end; }
.uvx-drawer-overlay[hidden] { display: none; }
.uvx-drawer { width: 460px; max-width: 92vw; height: 100%; background: #fff; overflow-y: auto; box-shadow: -12px 0 40px rgba(20,20,40,.2); animation: uvx-slidein .28s ease; }
@keyframes uvx-slidein { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.uvx-toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--uvx-ink); color: #fff; padding: 13px 20px; border-radius: var(--uvx-r); font-size: 13.5px; font-weight: 600; box-shadow: 0 12px 32px rgba(20,20,40,.32); z-index: 130; display: flex; align-items: center; gap: 9px; animation: uvx-toastin .3s ease; }
.uvx-toast[hidden] { display: none; }
@keyframes uvx-toastin { from { opacity: 0; transform: translate(-50%,20px); } to { opacity: 1; transform: translate(-50%,0); } }

/* Sticky selection bar (gôm PR → PO) */
.uvx-selbar { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); margin-left: 118px; background: var(--uvx-ink); color: #fff; border-radius: var(--uvx-r-xl); padding: 14px 16px 14px 22px; display: flex; align-items: center; gap: 20px; box-shadow: var(--uvx-shadow-lg); z-index: 90; }
.uvx-selbar[hidden] { display: none; }

/* ============================================================
   RESPONSIVE — mobile-first cho GS hiện trường
   ============================================================ */
@media (max-width: 760px) {
  .uvx-sidebar { display: none; }          /* thay bằng bottom-nav (xem .uvx-bottomnav) */
  .uvx-content { padding: 16px; }
  .uvx-grid-kpi { grid-template-columns: 1fr 1fr; }
  .uvx-stepper__label { font-size: 10px; }
  .uvx-selbar { left: 0; right: 0; transform: none; margin: 0 12px; border-radius: var(--uvx-r-lg); }
}
.uvx-bottomnav { display: none; }
@media (max-width: 760px) {
  .uvx-bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--uvx-border); padding: 8px 0 12px; z-index: 80; }
  .uvx-bottomnav a { flex: 1; text-align: center; color: var(--uvx-muted); text-decoration: none; font-size: 10px; }
  .uvx-bottomnav a.is-active { color: var(--uvx-fc); }
}
