/* ===== dc_monthly_bagged_details_html (HTML form, scoped) =====
   Monthly bagged-items dialog, opened by px_form_alert from
   dispatch_confirmation_html/dc_monthly_card_html/__init__.py.

   Loaded eagerly from anvil.yaml native_deps.head_html. Every rule here comes
   from the form's old <style> block; nothing is added and nothing is dropped.

   SCOPE. Every rule is :where(.mbd-container), which adds zero specificity and
   so cannot change which rule wins -- EXCEPT the .mbd-table family, which names
   .mbd-container as a REAL ancestor class. Those rules sit on the same elements
   as the shared .px-table family (the tables carry class="mbd-table px-table"),
   and a head link loses a specificity tie with theme.css on order, so they win
   on specificity instead. The pair that actually ties is .mbd-table th vs .px-table th
   (background, font-size, font-weight); .mbd-table.px-table tr vs .px-table tr
   ties on padding with the same value. The rest of the family takes the same
   treatment so the family's internal order is unchanged -- in particular the
   @media overrides .mbd-table { min-width: unset } and .mbd-table.px-table td
   must sit at the same specificity as their base rules or the mobile layout
   would silently lose to the 600px min-width.

   .mbd-table-scroll and the .mbd-row-* classes deliberately stay
   :where()-scoped. .mbd-table-scroll has no theme.css competitor, and the row
   classes are meant to LOSE to the shared @media .px-table tr rule, which reads
   the --px-row-bg custom property they set -- lifting them would break that.

   The root rule stays BARE and byte-identical, carrying exactly the
   declarations it carries today: this app does NOT apply the guide's
   screen-root rule, and this form is a dialog body rather than
   a screen in any case.

   [data-theme="dark"] sits on <html>, an ancestor of the root, so the scope
   goes after it.

   NO DESIGNER GATE. Nothing here hides content that only JavaScript reveals,
   so there is no live class to gate on.

   @keyframes mbdFadeIn and mbdRowReveal are already form-prefixed, so neither
   needs a rename. No url(), no @font-face, no html rule and no :root block.
   .themed-scrollbar stays the dependency's and is not declared here. */

.mbd-container {
  --accent: #fbbf24; --accent-text: #422006;
  --accent-hover: #f59e0b;
  --accent-subtle: rgba(251,191,36,0.12);
  --px-loading-accent: #fbbf24;
  font-family: var(--px-font);
  color: var(--px-text-primary);
  background: var(--px-bg-deep);
  position: relative;
  isolation: isolate;
  z-index: 0;
  max-height: 80vh;
  overflow-y: auto;
}

:where(.mbd-container) .mbd-content {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: mbdFadeIn 0.3s ease;
}

@keyframes mbdFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Section Cards */
:where(.mbd-container) .mbd-section {
  background: var(--px-bg-card);
  border: 1px solid var(--px-border);
  border-radius: 10px;
  box-shadow: var(--px-shadow);
  overflow: hidden;
}

:where(.mbd-container) .mbd-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 16px;
  background: var(--px-bg-elevated);
  border: 0;
  border-bottom: 1px solid var(--px-border);
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
  user-select: none;
  transition: background 0.2s;
}

:where(.mbd-container) .mbd-section-header:hover {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

:where(.mbd-container) .mbd-section-header:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

:where(.mbd-container) .mbd-section-title {
  font-family: var(--px-font);
  font-size: 15px;
  font-weight: 600;
  color: var(--px-text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

:where(.mbd-container) .mbd-section-title::before {
  content: '';
  width: 3px;
  height: 18px;
  background: var(--accent);
  border-radius: 2px;
}

:where(.mbd-container) .mbd-section-toggle {
  font-size: 14px;
  color: var(--px-text-muted);
  transition: transform 0.2s;
}

:where(.mbd-container) .mbd-section.collapsed .mbd-section-toggle {
  transform: rotate(-90deg);
}

:where(.mbd-container) .mbd-section.collapsed .mbd-section-body {
  display: none;
}

:where(.mbd-container) .mbd-section-body {
  padding: 12px;
}

/* Count and Legend */
:where(.mbd-container) .mbd-count-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--px-bg-elevated);
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 13px;
}

:where(.mbd-container) .mbd-count-label {
  font-weight: 600;
  color: var(--px-text-primary);
}

:where(.mbd-container) .mbd-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--px-text-secondary);
}

:where(.mbd-container) .mbd-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

:where(.mbd-container) .mbd-legend-dot.cancelled { background: #FFDDDD; border: 1px solid #ef4444; }
:where(.mbd-container) .mbd-legend-dot.active { background: #FFD0A0; border: 1px solid #f97316; }
:where(.mbd-container) .mbd-legend-dot.unlabelled { background: #FFF9E1; border: 1px solid #eab308; }
:where(.mbd-container) .mbd-legend-dot.labelled { background: #d1fae5; border: 1px solid #10b981; }

/* Search Row */
:where(.mbd-container) .mbd-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

:where(.mbd-container) .mbd-search-input {
  flex: 1;
  min-width: 100px;
  font-family: var(--px-font);
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid var(--px-border);
  border-radius: 6px;
  background: var(--px-input-bg);
  color: var(--px-text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

:where(.mbd-container) .mbd-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

:where(.mbd-container) .mbd-search-input::placeholder {
  color: var(--px-text-muted);
}

:where(.mbd-container) .mbd-clear-btn {
  font-family: var(--px-font);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border: 1px solid var(--px-border);
  border-radius: 6px;
  background: var(--px-bg-elevated);
  color: var(--px-text-secondary);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s, background-color 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

:where(.mbd-container) .mbd-clear-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Table */
:where(.mbd-container) .mbd-table-scroll {
  max-height: 300px;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--px-border);
  border-radius: 6px;
}

.mbd-container .mbd-table {
  min-width: 600px;
}

.mbd-container .mbd-table th {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #1e293b;
  font-family: var(--px-mono);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.mbd-container .mbd-table td {
  font-size: 13px;
  color: var(--px-text-secondary);
}

/* Row status backgrounds for Available table */
:where(.mbd-container) .mbd-row-cancelled { --px-row-bg: #FFDDDD; background: var(--px-row-bg); }
:where(.mbd-container) .mbd-row-active-owing { --px-row-bg: #FFD0A0; background: var(--px-row-bg); }
:where(.mbd-container) .mbd-row-unlabelled { --px-row-bg: #FFF9E1; background: var(--px-row-bg); }

[data-theme="dark"] :where(.mbd-container) .mbd-row-cancelled { --px-row-bg: rgba(239, 68, 68, 0.2); }
[data-theme="dark"] :where(.mbd-container) .mbd-row-active-owing { --px-row-bg: rgba(249, 115, 22, 0.2); }
[data-theme="dark"] :where(.mbd-container) .mbd-row-unlabelled { --px-row-bg: rgba(234, 179, 8, 0.15); }

:where(.mbd-container) .mbd-no-results {
  text-align: center;
  padding: 24px;
  color: var(--px-text-muted);
  font-size: 13px;
  font-style: italic;
}

/* Row reveal animation */
.mbd-container .mbd-table tbody tr {
  animation: mbdRowReveal 0.25s ease both;
}

@keyframes mbdRowReveal {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Responsive */
@media (max-width: 768px) {
  :where(.mbd-container) .mbd-content { padding: 12px; gap: 12px; }
  :where(.mbd-container) .mbd-search-row { flex-direction: column; }
  :where(.mbd-container) .mbd-search-input { min-width: 100%; }
  :where(.mbd-container) .mbd-count-row { flex-direction: column; align-items: flex-start; gap: 6px; }

  .mbd-container .mbd-table { min-width: unset; }
  :where(.mbd-container) .mbd-table-scroll { max-height: none; }

  .mbd-container .mbd-table.px-table td { word-break: break-word; }
  .mbd-container .mbd-table.px-table tr { padding: 14px 16px; }
}
