/* =====================================================================
   FrostLine – Cold Storage Ops
   Design tokens & khung giao diện cho hệ thống quản lý kho lạnh.
   ===================================================================== */
:root {
  --frost-bg: #EAF6FA;
  --frost-surface: #FFFFFF;
  --frost-navy: #0B2436;
  --frost-navy-2: #133247;
  --frost-cyan: #00B4D8;
  --frost-ice: #90E0EF;
  --frost-warn: #F4A261;
  --frost-danger: #E63946;
  --frost-text: #0B2436;
  --frost-muted: #6B7F8E;
  --frost-border: #D6E7EE;
  --frost-sidebar-w: 248px;
}

[data-frost-theme="dark"] {
  --frost-bg: #071521;
  --frost-surface: #0B2436;
  --frost-text: #EAF6FA;
  --frost-muted: #8FA7B6;
  --frost-border: #1E3F55;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--frost-bg);
  color: var(--frost-text);
  font-variant-numeric: tabular-nums;
}

a { color: var(--frost-cyan); text-decoration: none; }
a:hover { color: var(--frost-navy); }

/* --- Khung tổng thể ---------------------------------------------------- */
.frost-shell { display: flex; min-height: 100vh; }

.frost-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.frost-content { flex: 1; padding: 1.5rem 2rem; }

/* --- Sidebar ----------------------------------------------------------- */
.frost-sidebar {
  width: var(--frost-sidebar-w);
  flex-shrink: 0;
  background: var(--frost-navy);
  color: #EAF6FA;
  display: flex;
  flex-direction: column;
  padding: 1.25rem .75rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.frost-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 0 .5rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.frost-brand-mark {
  font-size: 1.5rem;
  color: var(--frost-ice);
  line-height: 1;
}

.frost-brand-text { line-height: 1.2; }
.frost-brand-text strong { display: block; font-size: 1.05rem; letter-spacing: .02em; }
.frost-brand-text small { color: var(--frost-ice); font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; }

.frost-nav { margin-top: 1rem; }

.frost-nav-section {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(234, 246, 250, .45);
  padding: 1rem .5rem .35rem;
}

.frost-nav-link {
  display: block;
  padding: .5rem .6rem;
  border-radius: .5rem;
  color: #EAF6FA;
  font-size: .9rem;
  margin-bottom: 2px;
}

.frost-nav-link:hover {
  background: var(--frost-navy-2);
  color: #fff;
}

.frost-nav-link.is-pending {
  color: rgba(234, 246, 250, .42);
  cursor: not-allowed;
}

.frost-nav-link.is-active {
  background: rgba(0, 180, 216, .18);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--frost-cyan);
}

/* Icon + badge số đếm trên từng mục menu. */
.frost-nav-icon {
  display: inline-block;
  width: 1.45rem;
  text-align: center;
  margin-right: .1rem;
}

.frost-nav-count {
  float: right;
  min-width: 1.35rem;
  padding: 0 .35rem;
  border-radius: .65rem;
  background: var(--frost-danger, #d9484f);
  color: #fff;
  font-size: .7rem;
  line-height: 1.3rem;
  text-align: center;
  font-weight: 600;
}

/* Nhóm accordion (Danh mục: Sản phẩm / Khách hàng / Kho). */
.frost-nav-subtoggle {
  display: flex;
  align-items: center;
  gap: .1rem;
  width: 100%;
  border: 0;
  background: none;
  color: #EAF6FA;
  font-size: .9rem;
  padding: .5rem .6rem;
  border-radius: .5rem;
  text-align: left;
  cursor: pointer;
}

.frost-nav-subtoggle:hover { background: var(--frost-navy-2); color: #fff; }

.frost-nav-caret {
  margin-left: auto;
  font-size: .7rem;
  opacity: .6;
  transition: transform .15s ease;
}

.frost-nav-group.is-open .frost-nav-caret { transform: rotate(180deg); }

.frost-nav-sub { display: none; padding-left: .9rem; }
.frost-nav-group.is-open .frost-nav-sub { display: block; }
.frost-nav-sub .frost-nav-link { font-size: .86rem; }

/* --- Topbar ------------------------------------------------------------ */
.frost-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 2rem;
  background: var(--frost-surface);
  border-bottom: 1px solid var(--frost-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.frost-search { flex: 1; max-width: 460px; }
.frost-search .form-control { background: var(--frost-bg); border-color: var(--frost-border); }
.frost-topbar-right { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.frost-user { font-size: .85rem; font-weight: 600; }

.frost-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--frost-border);
  border-radius: .5rem;
  background: var(--frost-surface);
  color: var(--frost-text);
}

.frost-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--frost-danger);
  color: #fff;
  font-size: .65rem;
  line-height: 18px;
}

/* --- Footer ------------------------------------------------------------ */
.frost-footer {
  display: flex;
  justify-content: space-between;
  padding: .75rem 2rem;
  font-size: .78rem;
  color: var(--frost-muted);
  border-top: 1px solid var(--frost-border);
}

/* --- KPI cards --------------------------------------------------------- */
.frost-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.frost-kpi {
  background: var(--frost-surface);
  border: 1px solid var(--frost-border);
  border-left: 4px solid var(--frost-cyan);
  border-radius: .75rem;
  padding: 1rem 1.15rem;
}

.frost-kpi.is-warning { border-left-color: var(--frost-warn); }
.frost-kpi.is-danger  { border-left-color: var(--frost-danger); }
.frost-kpi.is-ice     { border-left-color: var(--frost-ice); }

.frost-kpi-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--frost-muted);
}

.frost-kpi-value { font-size: 1.75rem; font-weight: 700; margin-top: .25rem; }
.frost-kpi-value a { color: inherit; text-decoration: none; }
.frost-kpi-value a:hover { color: var(--frost-ice); text-decoration: underline; }
.frost-kpi-meta  { font-size: .78rem; color: var(--frost-muted); }

/* --- Panel ------------------------------------------------------------- */
.frost-panel {
  background: var(--frost-surface);
  border: 1px solid var(--frost-border);
  border-radius: .75rem;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.frost-panel h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

/* --- Sơ đồ kho (heatmap) ------------------------------------------------ */
.frost-zonemap {
  display: grid;
  gap: 4px;
}

.frost-zone {
  aspect-ratio: 1;
  border-radius: .35rem;
  background: var(--frost-ice);
  border: 1px solid var(--frost-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  color: var(--frost-navy);
  cursor: pointer;
  text-decoration: none;
}

.frost-zone:hover { outline: 2px solid var(--frost-cyan); text-decoration: none; }
.frost-zone.lvl-0 { background: #EAF6FA; }
.frost-zone.lvl-1 { background: #BAE6F5; }
.frost-zone.lvl-2 { background: #65D3EF; }
.frost-zone.lvl-3 { background: #00B4D8; color: #fff; }
.frost-zone.lvl-4 { background: #F4A261; color: #fff; }
.frost-zone.lvl-full { background: #E63946; color: #fff; }

/* --- Đăng nhập --------------------------------------------------------- */
.frost-auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.frost-auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--frost-surface);
  border: 1px solid var(--frost-border);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 18px 40px rgba(11, 36, 54, .12);
}

/* --- Responsive -------------------------------------------------------- */
@media (max-width: 991.98px) {
  .frost-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 200;
  }
  body.sidebar-open .frost-sidebar { transform: translateX(0); }
  .frost-content { padding: 1rem; }
  .frost-topbar { padding: .75rem 1rem; }
}

/* --- In (phiếu A4 / tem) ------------------------------------------------ */
@media print {
  .frost-sidebar, .frost-topbar, .frost-footer, .frost-messages { display: none !important; }
  .frost-content { padding: 0; }
  body { background: #fff; }
  .frost-panel { border: none; padding: 0; }
}

/* --- Màn hình danh mục (CRUD) ------------------------------------------ */
.frost-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.frost-breadcrumb { display: flex; gap: .4rem; align-items: center; }
.frost-breadcrumb a { color: var(--frost-muted); }
.frost-breadcrumb a:hover { color: var(--frost-cyan); }

.frost-filter { margin: 0; }

/* --- Thanh lọc gọn cho danh sách phiếu (nhập/xuất) ---------------------- */
.frost-toolbar {
  padding: .75rem 1rem;
  margin-bottom: 1rem;
}
.frost-toolbar-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}
.frost-toolbar-field { position: relative; flex: 1 1 11rem; min-width: 0; }
.frost-toolbar-grow { flex: 1 1 16rem; }
.frost-toolbar-range {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex: 1 1 16rem;
  min-width: 0;
}
.frost-toolbar-range input[type="date"] { flex: 1 1 8.5rem; min-width: 0; }
.frost-toolbar-label {
  font-size: .8125rem;
  color: var(--frost-muted);
  white-space: nowrap;
}
.frost-toolbar-actions { display: flex; align-items: center; gap: .25rem; }
.frost-toolbar-check {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex: 0 0 auto;
  margin: 0;
  font-size: .8125rem;
  color: var(--frost-muted);
  cursor: pointer;
}
.frost-toolbar-check .form-check-input { margin: 0; }
.frost-toolbar-scope {
  margin-top: .5rem;
  padding-top: .5rem;
  border-top: 1px dashed var(--frost-border);
}

/* Gợi ý khi gõ (thay cho <select> khổng lồ của danh mục). */
.frost-ac-host { position: relative; }
.frost-ac {
  position: absolute;
  z-index: 1050;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  overflow: hidden;
  background: var(--frost-surface, #fff);
  border: 1px solid var(--frost-border);
  border-radius: .5rem;
  box-shadow: 0 .5rem 1rem rgba(16, 42, 67, .15);
}
.frost-ac-list {
  list-style: none;
  margin: 0;
  padding: .25rem 0;
  max-height: 16rem;
  overflow-y: auto;
}
.frost-ac-item {
  padding: .35rem .6rem;
  font-size: .8125rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.frost-ac-item.is-active,
.frost-ac-item:hover { background: #EAF6FA; color: var(--frost-navy); }

.frost-cell-strong { font-weight: 600; color: var(--frost-navy); }
.frost-cell-strong:hover { color: var(--frost-cyan); }

.frost-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--frost-muted);
}

.frost-quote {
  border-left: 3px solid var(--frost-cyan);
  padding: .5rem .9rem;
  margin: 0;
  background: var(--frost-bg);
  border-radius: .35rem;
  font-weight: 600;
}

/* Bảng dữ liệu */
.frost-table { margin-bottom: 0; }
.frost-table thead th {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--frost-muted);
  border-bottom: 2px solid var(--frost-border);
  white-space: nowrap;
}
.frost-table thead th a { color: inherit; }
.frost-table tbody td { vertical-align: middle; font-size: .9rem; }
.frost-table tbody tr:hover { background: rgba(0, 180, 216, .05); }

/* Phân trang của django-tables2 */
.frost-table + nav, .frost-panel .pagination { margin-bottom: 0; }
.pagination { --bs-pagination-color: var(--frost-navy); --bs-pagination-active-bg: var(--frost-cyan); --bs-pagination-active-border-color: var(--frost-cyan); }

/* Form danh mục */
.frost-form-panel { max-width: 780px; }
.frost-form-panel .form-label { font-weight: 500; font-size: .875rem; }
.frost-form-panel input, .frost-form-panel select, .frost-form-panel textarea { max-width: 100%; }

/* Sơ đồ kho (heatmap) */
.frost-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: .5rem;
}
.frost-o {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  padding: .5rem .35rem;
  border-radius: .5rem;
  border: 1px solid var(--frost-border);
  background: var(--frost-surface);
  font-size: .72rem;
  line-height: 1.15;
  cursor: default;
  transition: transform .08s ease;
}
.frost-o:hover { transform: translateY(-2px); }
.frost-o-name { font-weight: 600; color: var(--frost-navy); }
[data-frost-theme="dark"] .frost-o-name { color: var(--frost-text); }
.frost-o-pct { color: var(--frost-muted); font-size: .68rem; }
.frost-o.is-empty { background: #F4FBFD; border-style: dashed; }
.frost-o.is-mid { background: rgba(144, 224, 239, .45); border-color: var(--frost-ice); }
.frost-o.is-high { background: rgba(244, 162, 97, .35); border-color: var(--frost-warn); }
.frost-o.is-full { background: rgba(230, 57, 70, .28); border-color: var(--frost-danger); }
[data-frost-theme="dark"] .frost-o.is-empty { background: #0E2433; }

.frost-o-swatch {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  margin-right: .25rem;
  vertical-align: -2px;
  border: 1px solid var(--frost-border);
}
.frost-o-swatch.is-empty { background: #F4FBFD; border-style: dashed; }
.frost-o-swatch.is-mid { background: rgba(144, 224, 239, .45); border-color: var(--frost-ice); }
.frost-o-swatch.is-high { background: rgba(244, 162, 97, .35); border-color: var(--frost-warn); }
.frost-o-swatch.is-full { background: rgba(230, 57, 70, .28); border-color: var(--frost-danger); }

/* ------------------------------------------------------------------ */
/* Tem in (mã QR) — Giai đoạn 4                                        */
/* ------------------------------------------------------------------ */
.frost-label-sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: .75rem;
}
.frost-label {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  border: 1px solid var(--frost-border);
  border-radius: 10px;
  padding: .75rem;
  background: #fff;
}
.frost-label-qr svg { width: 96px; height: 96px; display: block; }
.frost-label-code { font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; }
.frost-label-name { font-size: .875rem; color: var(--frost-navy); }
.frost-label-meta { display: flex; gap: .75rem; font-size: .78rem; color: #4a6377; }
.frost-label-payload { display: block; margin-top: .25rem; font-size: .68rem; color: #7b93a3; }

@media print {
  .frost-sidebar, .frost-topbar, .frost-breadcrumb, .frost-page-head, .no-print { display: none !important; }
  .frost-label-sheet { grid-template-columns: repeat(2, 1fr); gap: .4rem; }
  .frost-label { break-inside: avoid; }
}

/* =====================================================================
   Phiếu nhập / xuất — lưới nhập liệu & tiện ích
   ===================================================================== */

/* Thẻ tóm tắt phiếu (trạng thái + tổng SL/KL) */
.frost-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  background: var(--frost-surface);
  border: 1px solid var(--frost-border);
  border-left: 4px solid var(--frost-cyan);
  border-radius: .75rem;
  padding: .75rem 1.15rem;
  margin-bottom: 1rem;
}
.frost-summary-item { display: flex; flex-direction: column; gap: .2rem; }
.frost-summary-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--frost-muted);
}
.frost-summary-value { font-weight: 700; font-size: 1.15rem; }

/* Lưới chi tiết */
.frost-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.frost-detail-tools { display: flex; gap: .5rem; align-items: center; flex: 1; justify-content: flex-end; }
.frost-scan { flex: 1; max-width: 420px; }
.frost-scan input { border-color: var(--frost-ice); background: var(--frost-bg); }

.frost-detail-table { min-width: 720px; }
.frost-detail-table td { padding: .35rem .5rem; }
.frost-detail-table thead th { padding: .4rem .5rem; }
.frost-detail-table tfoot td { border-top: 2px solid var(--frost-border); padding: .5rem; }
.frost-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 0;
  border-bottom: 1px solid var(--frost-border);
}

.frost-list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.frost-list-item:first-child { padding-top: 0; }

.frost-total { font-weight: 700; color: var(--frost-navy); font-size: 1rem; }
[data-frost-theme="dark"] .frost-total { color: var(--frost-text); }

/* --- Trang "Thiết lập kho" (tab + fragment HTMX) ----------------------- */
.frost-tab-nav { border-bottom-color: var(--frost-border); }
.frost-tab-nav .nav-link { color: var(--frost-muted); }
.frost-tab-nav .nav-link:hover { border-color: transparent; color: var(--frost-navy); }
.frost-tab-nav .nav-link.active {
  font-weight: 600;
  color: var(--frost-navy);
  border-color: var(--frost-border) var(--frost-border) #fff;
  background: var(--frost-bg);
}
[data-frost-theme="dark"] .frost-tab-nav .nav-link.active {
  border-color: var(--frost-border) var(--frost-border) var(--frost-navy-2);
  background: var(--frost-navy-2);
}
.frost-tab-pane { min-height: 8rem; }
.frost-fragment .frost-panel + .frost-panel { margin-top: 1rem; }
.frost-detail-table .ts-wrapper { min-width: 12rem; }
.frost-detail-table input.numeric,
.frost-detail-table input.float { min-width: 6rem; }

/* Danh sách phiếu: chọn hàng loạt */
.frost-bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  margin-bottom: .75rem;
  background: var(--frost-bg);
  border: 1px solid var(--frost-border);
  border-radius: .5rem;
}
.frost-bulk-bar.is-active { border-color: var(--frost-cyan); background: #EAF6FA; }
.frost-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-left: auto;
  opacity: .5;
  transition: opacity .15s ease;
}
.frost-bulk-bar.is-active .frost-bulk-actions { opacity: 1; }
.frost-bulk-actions .form-control { max-width: 14rem; }

/* Hàng nút hành động của form phiếu */.frost-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin-top: 1rem;
}
.frost-actions .btn { white-space: nowrap; }

/* In phiếu (chứng từ) */
.frost-document {
  background: #fff;
  color: #111;
  max-width: 21cm;
  margin: 0 auto;
  padding: 1.2cm;
  border: 1px solid var(--frost-border);
  border-radius: .5rem;
}
.frost-document h1 { font-size: 1.35rem; margin-bottom: .25rem; }
.frost-document .frost-doc-meta { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: .75rem 0; font-size: .9rem; }
.frost-document table { width: 100%; border-collapse: collapse; }
.frost-document table th, .frost-document table td { border: 1px solid #999; padding: .3rem .45rem; font-size: .85rem; }
.frost-document table thead th { background: #f1f5f8; text-align: center; }
.frost-document .frost-doc-sign { display: flex; justify-content: space-between; margin-top: 2.5rem; font-size: .85rem; text-align: center; }
.frost-document .frost-doc-sign > div { width: 30%; }

@media print {
  .frost-document { border: 0; padding: 0; max-width: none; }
  .frost-document .frost-doc-sign { page-break-inside: avoid; }
  .frost-content { padding: 0; }
}

