/* ─────────────────────────────────────────────────────────────────────
   BHS Design Tokens — Gov-ready: Navy + Action Green + Open Sans/Poppins
   See docs/form-design-system.md §13
   ───────────────────────────────────────────────────────────────────── */
:root {
  --app-shell-gutter: clamp(0.75rem, 1.5vw, 1.5rem);
  --page-surface-padding-y: clamp(1rem, 1vw + 0.75rem, 1.5rem);
  --page-surface-padding-x: clamp(0.875rem, 1vw + 0.75rem, 1.5rem);

  /* ── Brand: Trustworthy Navy ── */
  --bhs-navy:        #172f55;   /* primary, headings, nav text */
  --bhs-navy-dark:   #00193d;   /* darker emphasis */
  --bhs-navy-50:     #e8edf5;   /* navy tint surface */
  --bhs-navy-hover:  #3d5277;

  /* ── Action: Green CTA ── */
  --bhs-green:       #08833d;   /* primary CTA, success */
  --bhs-green-hover: #30975c;
  --bhs-green-50:    #e6f4eb;

  /* ── Accents ── */
  --bhs-orange:      #f19400;   /* warning */
  --bhs-red:         #b3261e;   /* error */

  /* ── Neutrals (light, gov-ready) ── */
  --bhs-white:       #ffffff;
  --bhs-canvas:      #f9f9f9;   /* page bg */
  --bhs-gray-soft:   #f5f5f5;   /* input bg / tertiary */
  --bhs-gray-border: #dfdfdf;   /* borders / dividers */
  --bhs-text-mute:   #6b7280;
  --bhs-page-bg:     #f9f9f9;

  /* ── Shadows (minimal — DON'T exceed 2px per design DO/DON'T) ── */
  --bhs-shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.04);
  --bhs-shadow:     0 2px 4px rgba(0, 0, 0, 0.06);
  --bhs-shadow-lg:  0 4px 8px rgba(0, 0, 0, 0.08);
  --bhs-focus-ring: 0 0 0 3px rgba(8, 131, 61, 0.25); /* action-green ring */
}

html,
body {
  overflow-x: hidden;
}

body {
  background: var(--bhs-page-bg);
  color: var(--bhs-navy);
  font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

h1, h2, h3, h4, h5, h6,
.mud-typography-h1, .mud-typography-h2, .mud-typography-h3,
.mud-typography-h4, .mud-typography-h5, .mud-typography-h6 {
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  color: var(--bhs-navy);
}

.app-shell {
  min-height: 100dvh;
}

/* App-bar: white nav, navy text, hairline bottom border */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 1300;
  border-bottom: 1px solid var(--bhs-gray-border);
  background-color: var(--bhs-white) !important;
  box-shadow: var(--bhs-shadow-sm);
}

.app-logo-bolt {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--bhs-navy);
  color: var(--bhs-white);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  margin-left: 4px;
  font-family: "Poppins", sans-serif;
}

.app-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--bhs-navy);
}

.app-drawer .mud-drawer-content {
  background: var(--bhs-white);
  border-right: 1px solid var(--bhs-gray-border);
}

.app-drawer-header {
  padding-inline: 1rem;
}

/* ── MudBlazor surface overrides (8px radius per design system) ── */
.mud-paper { border-radius: 8px; }
.mud-card  { border-radius: 8px; box-shadow: var(--bhs-shadow-sm); }
.mud-button { border-radius: 8px; text-transform: none; font-family: "Open Sans", sans-serif; font-weight: 600; }

/* Primary action: Action Green (per design DO: green exclusively for primary actions) */
.mud-button-filled-primary {
  background-color: var(--bhs-green) !important;
  color: var(--bhs-white) !important;
  box-shadow: var(--bhs-shadow-sm);
}
.mud-button-filled-primary:hover {
  background-color: var(--bhs-green-hover) !important;
  box-shadow: var(--bhs-shadow);
}

/* Navy variant cho secondary header chips / nav highlight */
.mud-chip { border-radius: 8px; font-weight: 600; font-family: "Open Sans", sans-serif; }

.mud-input-outlined-border {
  border-color: var(--bhs-gray-border);
}
.mud-input-outlined:hover .mud-input-outlined-border {
  border-color: var(--bhs-navy);
}
.mud-input-outlined.mud-input-focused .mud-input-outlined-border {
  border-color: var(--bhs-green) !important;
  border-width: 1.5px;
}

/* Focus ring — green per Action color */
.mud-button:focus-visible,
.mud-icon-button:focus-visible,
.mud-input-control:focus-within {
  outline: none;
  box-shadow: var(--bhs-focus-ring);
}

/* Save bar surface */
.bhs-form-footer {
  background: var(--bhs-canvas) !important;
  border-top: 1px solid var(--bhs-gray-border);
  border-radius: 8px;
}

/* Root tenant switcher (chỉ hiển thị cho Root) */
.bhs-root-tenant-form { margin: 0; display: flex; align-items: center; }
.bhs-root-tenant-select {
  border: 1px solid var(--bhs-navy);
  background: var(--bhs-navy-50);
  color: var(--bhs-navy);
  border-radius: 8px;
  padding: 6px 28px 6px 12px;
  font-family: "Open Sans", sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 220px;
}
.bhs-root-tenant-select:focus { outline: none; box-shadow: var(--bhs-focus-ring); }

/* ── Dashboard ─────────────────────────────────────────────────────── */

.bhs-dash-hero {
  background: linear-gradient(135deg, var(--bhs-navy-50) 0%, var(--bhs-white) 100%);
  border: 1px solid var(--bhs-gray-border);
  border-radius: 8px;
}

.bhs-dash-title {
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  color: var(--bhs-navy);
  margin-bottom: 4px;
}

.bhs-kpi-card {
  display: flex;
  gap: 12px;
  background: var(--bhs-white);
  border: 1px solid var(--bhs-gray-border);
  border-radius: 8px;
  padding: 16px;
  min-height: 110px;
  box-shadow: var(--bhs-shadow-sm);
}
.bhs-kpi-icon {
  width: 48px; height: 48px;
  border-radius: 8px;
  background: var(--bhs-gray-soft);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.bhs-kpi-body { flex: 1; min-width: 0; }
.bhs-kpi-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--bhs-text-mute);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.bhs-kpi-value {
  font-family: "Poppins", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--bhs-navy);
  line-height: 1.2;
  margin-top: 4px;
  word-break: break-word;
}
.bhs-kpi-unit {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--bhs-text-mute);
}
.bhs-kpi-delta {
  display: inline-flex; align-items: center; gap: 2px;
  margin-top: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
}
.bhs-kpi-delta-up   { color: var(--bhs-green); }
.bhs-kpi-delta-down { color: var(--bhs-red); }
.bhs-kpi-delta-empty {
  margin-top: 6px;
  font-size: 0.8125rem;
  color: var(--bhs-text-mute);
}

.bhs-mini-card {
  background: var(--bhs-white);
  border: 1px solid var(--bhs-gray-border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  min-height: 96px;
}
.bhs-mini-icon { margin-bottom: 4px; }
.bhs-mini-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bhs-text-mute);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 2px;
}
.bhs-mini-value {
  font-family: "Poppins", sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  word-break: break-word;
}
.bhs-mini-value-navy  { color: var(--bhs-navy); }
.bhs-mini-value-green { color: var(--bhs-green); }
.bhs-mini-value-red   { color: var(--bhs-red); }

/* Chart bars (doanh thu 7 ngày) */
.bhs-chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  height: 200px;
  padding: 8px 0;
}
.bhs-chart-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}
.bhs-chart-bar-value {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--bhs-text-mute);
  margin-bottom: 4px;
  white-space: nowrap;
}
.bhs-chart-bar {
  width: 100%;
  background: linear-gradient(180deg, var(--bhs-green) 0%, var(--bhs-green-hover) 100%);
  border-radius: 6px 6px 0 0;
  min-height: 2px;
  transition: opacity 0.15s;
}
.bhs-chart-bar:hover { opacity: 0.85; }
.bhs-chart-bar-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bhs-navy);
  margin-top: 6px;
}

/* Hình thức thanh toán bars */
.bhs-ht-row { margin-bottom: 14px; }
.bhs-ht-row-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bhs-navy);
  margin-bottom: 4px;
}
.bhs-ht-label { flex: 1; }
.bhs-ht-pct {
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  color: var(--bhs-navy);
}
.bhs-ht-progress {
  height: 8px;
  background: var(--bhs-gray-soft);
  border-radius: 4px;
  overflow: hidden;
}
.bhs-ht-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.bhs-ht-value {
  font-size: 0.8125rem;
  color: var(--bhs-text-mute);
  margin-top: 2px;
  text-align: right;
}

.h-100 { height: 100%; }

/* Promo / highlight surface (cho dashboard / banner) */
.bhs-promo-card {
  background: linear-gradient(135deg, var(--bhs-orange) 0%, #c87800 100%);
  color: var(--bhs-white);
  border-radius: 8px;
  padding: 16px;
}

.bhs-success-card {
  background: linear-gradient(135deg, var(--bhs-green) 0%, var(--bhs-green-hover) 100%);
  color: var(--bhs-white);
  border-radius: 8px;
  padding: 16px;
}

.app-nav-menu {
  padding: 0.25rem 0.5rem 1rem;
}

.app-nav-button {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.main-content-shell {
  padding: calc(64px + var(--app-shell-gutter)) var(--app-shell-gutter) var(--app-shell-gutter);
}

.page-surface {
  padding: var(--page-surface-padding-y) var(--page-surface-padding-x);
  border-radius: 18px;
}

.page-toolbar {
  gap: 1rem;
  flex-wrap: wrap;
}

.page-toolbar-intro,
.page-toolbar-panel {
  min-width: 0;
}

.page-toolbar-panel {
  margin-left: auto;
}

.page-toolbar-actions {
  justify-content: flex-end;
  gap: 0.5rem;
}

.page-toolbar-filters {
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page-toolbar-select {
  width: clamp(11rem, 22vw, 18rem);
  max-width: 100%;
}

.page-toolbar-field {
  width: clamp(12rem, 24vw, 18rem);
  max-width: 100%;
}

.split-page-shell {
  min-height: calc(100dvh - 7.5rem);
}

.split-page-filter-panel {
  height: 100%;
}

/* Layout dùng cho các trang có sidebar lọc (TestBase pattern):
   Desktop: chiếm chiều cao còn lại sau AppBar, sidebar + nội dung side-by-side, cuộn bên trong panel.
   Mobile: chiều cao tự nhiên, sidebar nằm TRÊN, nội dung TRÔNG nội dung NẰM DƯỚI, cuộn dọc cả trang. */
.app-page-shell {
  height: calc(100dvh - 64px);
  overflow: hidden;
}

@media (max-width: 959.98px) {
  .app-page-shell {
    height: auto;
    overflow: visible;
  }
}

.page-data-grid {
  height: calc(100dvh - 10rem);
}

.page-data-grid .mud-table-toolbar {
  gap: 0.75rem;
  flex-wrap: wrap;
}

.responsive-data-grid {
  width: 100%;
}

.responsive-table-shell {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.responsive-detail-table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  min-width: 42rem;
}

@media (max-width: 959.98px) {
  .main-content-shell {
    padding: 72px 0.75rem 1rem;
  }

  .page-surface {
    padding: 1rem;
  }

  .page-toolbar {
    flex-direction: column !important;
  }

  .page-toolbar-panel {
    width: 100%;
    margin-left: 0;
    align-items: stretch !important;
  }

  .page-toolbar-actions,
  .page-toolbar-filters {
    justify-content: stretch;
  }

  .page-toolbar-actions > *,
  .page-toolbar-filters > * {
    flex: 1 1 100%;
  }

  .page-toolbar-select,
  .page-toolbar-field {
    width: 100%;
  }

  .split-page-shell {
    min-height: auto;
  }

  .split-page-filter-panel {
    height: auto;
  }

  .page-data-grid {
    height: auto !important;
  }

  .page-data-grid .mud-table-toolbar .mud-spacer {
    display: none;
  }

  .page-data-grid .mud-table-toolbar .mud-button-root {
    width: 100%;
    margin-left: 0 !important;
  }

  .responsive-detail-table {
    min-width: 34rem;
  }
}

@media (max-width: 599.98px) {
  .app-title {
    font-size: 1rem;
  }

  .page-toolbar-actions,
  .page-toolbar-filters {
    width: 100%;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .page-toolbar-actions > *,
  .page-toolbar-filters > * {
    width: 100%;
    flex: 0 0 auto;
    max-width: 100%;
  }

  .page-toolbar-actions .mud-menu,
  .page-toolbar-actions .mud-menu-activator {
    width: 100%;
  }

  .page-toolbar-actions .mud-button-root,
  .page-toolbar-actions .mud-menu,
  .page-toolbar-actions .mud-menu-activator,
  .page-toolbar-filters .mud-input-control,
  .page-toolbar-filters .mud-input-control-root {
    width: 100% !important;
    max-width: 100%;
  }

  .page-toolbar-actions .mud-button-root,
  .page-toolbar-actions .mud-menu-activator,
  .page-toolbar-filters .mud-input-control {
    justify-content: center;
  }

  .responsive-data-grid .mud-table-cell {
    min-width: 0;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.35rem;
  }

  .responsive-data-grid .mud-table-cell-label {
    flex: 0 0 auto !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .responsive-data-grid .mud-table-cell > :not(.mud-table-cell-label) {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
  }

  .responsive-data-grid .mud-typography {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .user-list-grid .user-list-identity,
  .user-list-grid .user-list-email,
  .user-list-grid .user-list-roles,
  .user-list-grid .user-list-actions {
    width: 100%;
    min-width: 0;
  }

  .user-list-grid .user-list-identity,
  .user-list-grid .user-list-email,
  .user-list-grid .user-list-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .user-list-grid .user-list-identity-text {
    min-width: 0;
    flex: 1 1 0;
  }

  .user-list-grid .user-list-value,
  .user-list-grid .user-list-department {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .user-list-grid .user-list-roles,
  .user-list-grid .user-list-actions {
    gap: 0.25rem;
  }

  .user-list-grid .mud-chip {
    max-width: 100%;
  }

  .user-list-grid .mud-icon-button {
    margin-left: 0;
  }

  .responsive-detail-table {
    min-width: 30rem;
  }
}
