﻿:root {
  --color-primary: #435ebe;
  --color-primary-soft: #ebf3ff;
  --color-bg: #f2f7ff;
  --color-surface: #ffffff;
  --color-text: #25396f;
  --color-body: #607080;
  --color-muted: #7c8db5;
  --color-border: #dce7f3;
  --color-danger: #c9364f;
  --sidebar-width: 300px;
  --shadow-card: -8px 12px 18px 0 rgba(25, 42, 70, .08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-body);
  font-family: "Nunito", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  border: 0;
  background: rgba(37, 57, 111, .28);
}

.sidebar-backdrop.show {
  display: block;
}

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  width: var(--sidebar-width);
  overflow-y: auto;
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  transition: left .7s cubic-bezier(.22, 1, .36, 1);
}

.sidebar.show {
  left: 0;
}

.sidebar-header {
  padding: 2rem 2rem 1rem;
}

.brand {
  display: flex;
  gap: .75rem;
  align-items: center;
  color: var(--color-text);
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--color-primary);
  box-shadow: 0 10px 18px rgba(67, 94, 190, .24);
}

.brand-name {
  display: block;
  font-size: 1.15rem;
  color: var(--color-text);
}

.brand-subtitle {
  display: block;
  margin-top: .1rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--color-muted);
}

.sidebar-menu {
  padding: 0 2rem 2rem;
}

.menu,
.submenu {
  padding: 0;
  margin: 0;
  list-style: none;
}

.sidebar-title {
  margin: 1.4rem 0 .55rem;
  color: var(--color-muted);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-link,
.submenu-link {
  display: flex;
  gap: .75rem;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: .7rem 1rem;
  border: 0;
  border-radius: .5rem;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}

.sidebar-link i,
.submenu-link i {
  color: var(--color-muted);
  font-size: 1rem;
  transition: color .2s ease;
}

.sidebar-link:hover,
.submenu-link:hover {
  background: rgb(240, 241, 245);
}

.sidebar-item.active > .sidebar-link {
  color: #fff;
  background: var(--color-primary);
}

.sidebar-item.active > .sidebar-link i {
  color: #fff;
}

.sidebar-link .chevron {
  margin-left: auto;
  font-size: .85rem;
}

.submenu {
  display: grid;
  gap: .12rem;
  padding: .35rem 0 .35rem 1.35rem;
}

.submenu-link {
  min-height: 34px;
  padding: .45rem .75rem;
  color: var(--color-body);
  font-size: .9rem;
  font-weight: 700;
}

.submenu-link.active {
  color: var(--color-primary);
  background: var(--color-primary-soft);
}

.main {
  min-height: 100vh;
  min-width: 0;
  margin-left: var(--sidebar-width);
  padding: 1.35rem 1.5rem 2rem;
  transition: margin-left .7s cubic-bezier(.22, 1, .36, 1);
}

@media (min-width: 1200px) {
  .app-shell.sidebar-collapsed .sidebar {
    left: calc(var(--sidebar-width) * -1);
  }
  .app-shell.sidebar-collapsed .main {
    margin-left: 0;
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: .85rem;
}

.burger-btn,
.icon-btn {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  background: var(--color-surface);
  cursor: pointer;
}

.burger-btn {
  font-size: 1.35rem;
}

.page-title {
  min-width: 0;
}

.page-title h1 {
  margin: 0;
  color: var(--color-text);
  font-size: 1.55rem;
  font-weight: 800;
}

.breadcrumb {
  display: flex;
  gap: .45rem;
  align-items: center;
  margin-top: .15rem;
  color: var(--color-muted);
  font-size: .9rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  gap: .6rem;
  align-items: center;
}

.user-chip {
  display: flex;
  gap: .55rem;
  align-items: center;
  min-height: 42px;
  padding: .45rem .8rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  background: var(--color-surface);
  font-weight: 700;
  white-space: nowrap;
}

.mobile-topbar,
.mobile-sgk-app {
  display: none;
}

.page-content {
  display: grid;
  min-width: 0;
  gap: 1rem;
}

.toolbar,
.section,
#donList,
#donDetail {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.section {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

.table-wrap {
  overflow-x: auto;
}

/* Giu hai bang don hang cuon ngang trong module, khong day rong page canvas. */
.order-data-table-shell {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
}

.order-data-table-shell .dataTables_wrapper,
.order-data-table-shell .dataTables_scroll,
.order-data-table-shell .dataTables_scrollHead,
.order-data-table-shell .dataTables_scrollBody {
  width: 100% !important;
  min-width: 0;
  max-width: 100%;
}

.order-data-table-shell .dataTables_scrollBody {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

.order-data-table-shell .order-table-toolbar,
.order-data-table-shell .order-table-footer {
  padding: .75rem 1rem;
}

.order-data-table-shell .order-table-toolbar {
  display: flex;
  justify-content: flex-end;
  border-bottom: 1px solid var(--color-border);
}

.order-data-table-shell .order-table-footer {
  border-top: 1px solid var(--color-border);
  color: var(--color-body);
  font-size: .85rem;
}

.order-data-table-shell .dataTables_filter {
  float: none;
  margin: 0;
  text-align: right;
}

.order-data-table-shell .dataTables_filter label {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin: 0;
}

.order-data-table-shell .dataTables_filter input {
  min-width: min(280px, 55vw);
  margin-left: 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: .4rem .65rem;
}

#donListTable {
  min-width: 760px;
}

#donDetailTable {
  min-width: 1100px;
}

#donDetailTable .dat-input {
  width: 88px;
}

#donDetailTable .ghichu-input {
  width: 100%;
  min-width: 220px;
}

.bd-data-table {
  min-width: 1420px;
}

.dat-input {
  width: 84px;
  text-align: center;
}

.dat-quantity-editor {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.dat-quantity-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dat-quantity-label,
.dat-quantity-meta {
  color: var(--color-body);
  font-size: 12px;
  white-space: nowrap;
}

.dat-quantity-meta {
  line-height: 1.4;
}

.dat-ordered {
  color: #856404;
  font-weight: 700;
}

.dat-ordered.is-empty {
  color: var(--color-body);
  font-weight: 400;
}

.has-existing-order > td {
  color: #856404 !important;
}

.has-existing-order input {
  color: #856404;
}

.has-new-order > td {
  color: var(--color-primary) !important;
}

.has-new-order input {
  color: var(--color-primary);
}

#tblHangHoa tbody tr.is-row-selected > td {
  background-color: var(--color-primary-soft) !important;
  box-shadow: inset 0 1px 0 rgba(67, 94, 190, .14),
    inset 0 -1px 0 rgba(67, 94, 190, .14);
}

#tblHangHoa tbody tr {
  cursor: pointer;
}

.dat-total {
  font-weight: 700;
  color: #28a745;
}

#user-info {
  font-weight: 700;
}

.low-stock {
  background-color: #ffcccc;
}

.medium-stock {
  background-color: #fff3cd;
}

.high-stock {
  background-color: #d4edda;
}

.over-stock {
  background-color: #cce5ff;
}

#tblHangHoa thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
}

.page-footer {
  margin-top: 1.25rem;
  color: var(--color-body);
  font-size: .85rem;
  text-align: center;
}

.toast-message {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 999;
  display: none;
  padding: 10px 20px;
  border-radius: 6px;
  color: #fff;
  background: #333;
}

/* Toast modifier class — dung voi dathangsgkv3.js (Fix 2a)
   Thay the inline style background cua v2, de thay doi mau khong can sua JS */
.toast-message.toast--success { background: #28a745; }
.toast-message.toast--error   { background: #dc3545; }
.toast-message.toast--warning { background: #b7791f; }
.toast-message.toast--info    { background: #333; }

@media (max-width: 1199.98px) {
  .sidebar {
    left: calc(var(--sidebar-width) * -1);
  }

  .sidebar.show {
    left: 0;
  }

  .main {
    margin-left: 0;
  }
}

@media (max-width: 767.98px) {
  body {
    width: 100%;
    overflow-x: hidden;
    background: #f8fafc;
  }

  .main {
    min-height: 100dvh;
    padding: 0;
  }

  .topbar,
  .toolbar,
  #hangHoaSection,
  .page-footer {
    display: none !important;
  }

  .page-content {
    display: block;
  }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    width: 100vw;
    max-width: 100vw;
    overflow: hidden;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    min-height: 72px;
    padding: 8px 10px;
    border-bottom: 1px solid #e3e8ef;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(12px);
  }

  .mobile-icon-btn {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: #30353b;
    background: transparent;
    font-size: 1.55rem;
  }

  #mobileMenuBtn,
  #mobileBackBtn {
    grid-column: 1;
    grid-row: 1;
  }

  .mobile-title-block {
    grid-column: 2;
    grid-row: 1;
  }

  .mobile-topbar-actions {
    display: flex;
    gap: 2px;
    align-items: center;
    justify-self: end;
    grid-column: 3;
    grid-row: 1;
  }

  .mobile-icon-btn:active {
    background: #edf1f5;
  }

  .mobile-title-block {
    min-width: 0;
    padding: 0 10px;
    text-align: left;
  }

  .mobile-title-block strong,
  .mobile-title-block span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-title-block strong {
    color: #24292f;
    font-size: 1rem;
    font-weight: 800;
  }

  .mobile-title-block span {
    color: #7b8490;
    font-size: .75rem;
  }

  .mobile-sgk-app {
    display: block;
    min-height: calc(100dvh - 72px);
    background: #fff;
  }

  .mobile-branch-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #e9edf2;
    background: #f7f9fb;
  }

  .mobile-branch-bar label {
    color: #68717d;
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  .mobile-branch-bar .form-select {
    width: auto;
    min-width: 142px;
    margin-left: auto;
    border-color: #d7dde5;
    border-radius: 8px;
    color: #2f353d;
    font-weight: 700;
    background-color: #fff;
  }

  .mobile-view {
    display: none;
    animation: mobile-view-in .2s ease-out;
  }

  .mobile-view.is-active {
    display: block;
  }

  @keyframes mobile-view-in {
    from {
      opacity: 0;
      transform: translateX(10px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  .mobile-column-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 54px;
    padding: 0 18px;
    border-bottom: 1px solid #dde2e8;
    color: #24292f;
    background: #fff;
    font-weight: 800;
  }

  .mobile-column-heading small {
    color: #8a939e;
    font-size: .75rem;
    font-weight: 700;
  }

  .mobile-list {
    background: #fff;
  }

  .mobile-list-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 24px;
    gap: 12px;
    align-items: center;
    width: 100%;
    min-height: 38px;
    padding: 12px 16px 12px 20px;
    border: 0;
    border-bottom: 1px solid #e6e9ed;
    color: #50565e;
    background: #fff;
    text-align: left;
  }

  .mobile-list-row:first-child {
    color: #20252b;
  }

  .mobile-list-row span {
    overflow: hidden;
    font-size: 1.05rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-list-row i {
    color: #3e444b;
    font-size: 1.2rem;
  }

  /* === MOBILE SCREEN 2: DataTables product list === */
  .mobile-product-table-wrap {
    width: 100%;
    overflow: hidden;
  }

  /* Container bao ngoai section product de DataTables layout dung */
  #mobileProductView {
    overflow: hidden;
  }

  #tblMobileProduct_wrapper {
    width: 100%;
  }

  #tblMobileProduct_wrapper .dataTables_scroll {
    width: 100%;
  }

  #tblMobileProduct_wrapper .dataTables_scrollBody {
    -webkit-overflow-scrolling: touch;
  }

  #tblMobileProduct {
    min-width: 536px;
    table-layout: fixed;
  }

  #tblMobileProduct thead th {
    height: 48px;
    padding: 10px 24px 10px 8px !important;
    vertical-align: middle;
    line-height: 1.15;
    white-space: nowrap;
  }

  #tblMobileProduct thead th.mobile-col-code,
  #tblMobileProduct tbody td.mobile-col-code {
    width: 112px !important;
    min-width: 112px !important;
    max-width: 112px !important;
  }

  #tblMobileProduct thead th.mobile-col-name,
  #tblMobileProduct tbody td.mobile-col-name {
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
  }

  /* TEN_HH: cat gon max 200px voi dau ... */
  .mobile-ten-hh {
    display: block;
    width: 100%;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }

  /* Ma hang hien thi nho gon */
  .mobile-ma-code {
    font-size: .82rem;
    font-weight: 700;
    /* color: var(--color-text); */
    white-space: nowrap;
  }

  /* So luong co dat thi do dam */
  .mobile-dat-val.has-new-order {
    color: var(--color-primary);
    font-weight: 800;
  }

  /* DAT moi uu tien primary, da dat cu dung mau vang nau. */
  #tblMobileProduct tbody tr.has-new-order td {
    color: var(--color-primary) !important;
  }

  #tblMobileProduct tbody tr.has-existing-order td {
    color: #856404 !important;
  }

  /* Row click duoc tren mobile */
  #tblMobileProduct tbody tr.mobile-product-dt-row {
    cursor: pointer;
  }

  #tblMobileProduct tbody tr.mobile-product-dt-row:hover td {
    background: #f0f4ff;
  }

  /* So co width hop ly tren mobile */
  .dt-num {
    font-variant-numeric: tabular-nums;
    min-width: 56px;
  }

  /* Giam padding cell tren mobile cho go space */
  #tblMobileProduct td,
  #tblMobileProduct th {
    padding: 8px 8px;
    font-size: .83rem;
  }

  #tblMobileProduct tbody td {
    height: 30px;
    overflow: hidden;
    vertical-align: middle;
    white-space: nowrap;
  }

  #tblMobileProduct_wrapper .dtfc-fixed-left {
    background: #fff;
    box-shadow: 3px 0 8px rgba(37, 57, 111, .1);
  }

  #tblMobileProduct_wrapper thead .dtfc-fixed-left {
    z-index: 4;
    background: #f8f9fa;
  }

  #tblMobileProduct_wrapper tbody tr.has-new-order .dtfc-fixed-left {
    color: var(--color-primary) !important;
    background: #fff;
  }

  #tblMobileProduct_wrapper tbody tr.has-existing-order .dtfc-fixed-left {
    color: #856404 !important;
    background: #fff;
  }

  /* DataTables filter thanh search tren mobile */
  #tblMobileProduct_wrapper .dataTables_filter {
    padding: 8px 12px;
    border-bottom: 1px solid #e9edf2;
  }

  #tblMobileProduct_wrapper .dataTables_filter input {
    font-size: .85rem;
  }

  /* Paginate nhon gon */
  #tblMobileProduct_wrapper .dataTables_paginate {
    padding: 6px 12px;
    font-size: .8rem;
  }

  .mobile-detail-card {
    min-height: calc(100dvh - 122px);
    padding: 58px 20px 36px;
    color: #4f555d;
    background:
      radial-gradient(circle at 50% 0, rgba(67, 94, 190, .055), transparent 34%),
      #fff;
    text-align: center;
  }

  .mobile-detail-kicker,
  .mobile-stock-title,
  .mobile-detail-copy span,
  .mobile-note-value span {
    color: #68717d;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
  }

  .mobile-stepper {
    display: grid;
    grid-template-columns: 62px minmax(100px, 1fr) 62px;
    align-items: center;
    max-width: 520px;
    min-height: 76px;
    margin: 14px auto 30px;
    border: 1px solid #cfd5dc;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(37, 57, 111, .06);
  }

  .mobile-stepper button {
    display: grid;
    height: 100%;
    place-items: center;
    border: 0;
    color: #555c65;
    background: transparent;
    font-size: 1.7rem;
  }

  .mobile-stepper input {
    width: 100%;
    height: 74px;
    border: 0;
    outline: 0;
    color: #30363d;
    background: transparent;
    font-size: 1.55rem;
    font-weight: 700;
    text-align: center;
    appearance: textfield;
  }

  .mobile-stepper input::-webkit-inner-spin-button,
  .mobile-stepper input::-webkit-outer-spin-button {
    margin: 0;
    appearance: none;
  }

  .mobile-detail-copy {
    margin-bottom: 36px;
  }

  .mobile-detail-copy h2 {
    max-width: 620px;
    margin: 8px auto 2px;
    color: #30363d;
    font-size: clamp(1.35rem, 6vw, 1.8rem);
    font-weight: 700;
    line-height: 1.3;
  }

  .mobile-detail-copy p {
    margin: 6px 0 0;
    color: #8a939e;
    font-size: .82rem;
  }

  /* Hien thi so da dat trong detail view */
  .mobile-da-dat-label {
    margin-top: 4px;
    color: #856404;
    font-size: .84rem;
    font-weight: 600;
  }

  .mobile-da-dat-label strong {
    color: #856404;
  }

  .mobile-stock-grid { 
    max-width: 620px;
    margin: 10px auto 34px;
    border: 1px solid #d8dde3;
    border-radius: 8px;
    overflow: hidden;
    text-align: left;
  }

  .mobile-stock-grid div + div {
    border-left: 1px solid #d8dde3;
  }

  .mobile-stock-grid dt,
  .mobile-stock-grid dd {
    margin: 0;
    padding: 13px 10px;
  }

  .mobile-stock-grid dt {
    border-bottom: 1px solid #d8dde3;
    color: #343a40;
    font-size: .76rem;
    font-weight: 900;
  }

  .mobile-stock-grid dd {
    color: #343a40;
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  .mobile-note-value span,
  .mobile-note-value strong {
    display: block;
  }

  .mobile-note-value strong {
    margin-top: 5px;
    color: #343a40;
    font-size: 1.25rem;
    font-weight: 700;
  }

  .mobile-save-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    border-radius: 50%;
    color: #fff;
    background: var(--color-primary);
    box-shadow: 0 6px 14px rgba(67, 94, 190, .2);
    font-size: 1.35rem;
  }

  .mobile-save-btn:active {
    transform: translateY(1px);
    background: #354b9a;
    box-shadow: 0 3px 8px rgba(67, 94, 190, .2);
  }

  .mobile-empty-state {
    display: grid;
    min-height: 42vh;
    place-content: center;
    padding: 32px;
    color: #8a939e;
    text-align: center;
  }

  .mobile-empty-state i {
    margin-bottom: 10px;
    font-size: 2rem;
  }

  .mobile-empty-state p {
    margin: 0;
  }

  #donList,
  #donDetail {
    width: 100%;
    min-width: 0;
    max-width: 100vw;
    padding: 16px;
    overflow: hidden;
  }

  .order-data-table-shell .order-table-toolbar,
  .order-data-table-shell .order-table-footer {
    padding: .65rem .75rem;
  }

  .order-data-table-shell .order-table-toolbar {
    justify-content: stretch;
  }

  .order-data-table-shell .dataTables_filter,
  .order-data-table-shell .dataTables_filter label,
  .order-data-table-shell .dataTables_filter input {
    width: 100%;
    min-width: 0;
  }

  .toast-message {
    right: 16px;
    bottom: 16px;
    left: 16px;
    text-align: center;
  }
}
.donListTable-toolbar{
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 10px;
}

.table > tbody > tr.low-stock > * {
  --bs-table-bg: #f3e7e8;
  --bs-table-color: #842029;
}

.table > tbody > tr.medium-stock > * {
  --bs-table-bg: #fff3cd;
  --bs-table-color: #664d03;
}

.table > tbody > tr.high-stock > * {
  --bs-table-bg: #d1e7dd;
  --bs-table-color: #0f5132;
}

.table > tbody > tr.over-stock > * {
  --bs-table-bg: #cff4fc;
  --bs-table-color: #055160;
}