/* ========================================
   Section 1: CSS variables & body background
   Owners: lattice_log/templates/base.html (global), mdc_tokens.css
   ======================================== */
/* Token-driven overrides (keep the “plant-friendly” look, but derive from design tokens). */
:root {
  /* Background + surfaces lean green (reduce “big white” feel). */
  --bg-soft: linear-gradient(
    180deg,
    rgb(var(--mdc-color-background)) 0%,
    rgb(var(--mdc-color-primary-container)) 55%,
    rgb(var(--mdc-color-background)) 100%
  );

  /* Surfaces should track tokens (dark mode will switch tokens). */
  --surface: rgb(var(--mdc-color-surface));
  --surface-90: rgb(var(--mdc-color-surface) / 0.90);
  --surface-80: rgb(var(--mdc-color-surface) / 0.80);
  --surface-70: rgb(var(--mdc-color-surface) / 0.70);
  --surface-60: rgb(var(--mdc-color-surface) / 0.60);
  --surface-50: rgb(var(--mdc-color-surface) / 0.50);

  /* Safe-area insets (iOS notch + home indicator). */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  /*
   * Cap scrollable dropdown panels (Choices.js, kebab menus, searchable selects) so lists
   * never extend past the viewport. Used by vendor-choices.overrides and surfaces tables.
   */
  --ll-dropdown-max-height: min(
    22rem,
    calc(100vh - 4rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))
  );
}

@supports (height: 100dvh) {
  :root {
    --ll-dropdown-max-height: min(
      22rem,
      calc(100dvh - 4rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))
    );
  }
}

html.dark {
  --bg-soft: linear-gradient(
    180deg,
    rgb(var(--mdc-color-background)) 0%,
    rgb(var(--mdc-color-surface)) 55%,
    rgb(var(--mdc-color-background)) 100%
  );
}

body {
  background-image: var(--bg-soft);
}

/* Toggle switch fallback when peer styles fail. */
.toggle-switch .toggle-track {
  transition: background-color var(--mdc-motion-duration-medium) var(--mdc-motion-easing-standard);
}

.toggle-switch .toggle-thumb {
  transform: translateX(0);
  transition: transform var(--mdc-motion-duration-medium) var(--mdc-motion-easing-standard);
}

.toggle-switch input:checked ~ .toggle-track {
  background-color: rgb(var(--mdc-color-primary));
}

.toggle-switch input:checked ~ .toggle-thumb {
  transform: translateX(1.25rem);
}

/* Prevent background scroll when mobile sheet is open. */
body.mobile-sheet-open {
  overflow: hidden;
}

/* Reference data edit modal (Alpine-driven): prevent background scroll when open (mobile bottom sheet + desktop). */
body.edit-modal-open {
  overflow: hidden;
}

/* Plant type form: progressive columns (Crop → Group → Variety) slide-in active state */
.plant-type-column--conditional {
  flex: 0 0 0;
  min-width: 0;
  max-width: 0;
}
.plant-type-column--conditional.plant-type-column--active {
  flex: 1 1 0;
  min-width: 14rem;
  max-width: 24rem;
  max-height: none;
  opacity: 1;
  pointer-events: auto;
  overflow: visible;
}
.plant-type-column.is-selected {
  box-shadow: 0 0 0 2px rgb(var(--mdc-color-primary));
}

/* Multi-pane slide-in forms (Create Plant Type, Create Item) — Reference Data aesthetic */
.form-pane {
  transition: max-height 0.35s ease-out, opacity 0.3s ease-out, margin 0.3s ease-out;
  overflow: hidden;
}
.form-pane--hidden {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
  pointer-events: none;
  visibility: hidden;
}
.form-pane--active {
  max-height: 120rem;
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}
.form-pane-actions {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgb(226 232 240);
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem 0.75rem;
}
.dark .form-pane-actions {
  border-top-color: rgb(71 85 105);
}

/* Multi-pane side-by-side layout (Create Item, Create Batch) — Reference Data card styling */
.multi-pane-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: stretch;
}
@media (min-width: 768px) {
  .multi-pane-form {
    flex-wrap: nowrap;
    gap: 1.5rem;
  }
}
.multi-pane-form .pane {
  flex: 1 1 100%;
  min-width: 0;
  transition: flex 0.35s ease-out, max-width 0.35s ease-out, opacity 0.3s ease-out;
  overflow: hidden;
  /* Mobile: only active panes visible (stacked) */
  display: none;
  opacity: 0;
  pointer-events: none;
}
.multi-pane-form .pane.pane--active {
  display: block;
  opacity: 1;
  pointer-events: auto;
  overflow: visible;
}
@media (min-width: 768px) {
  .multi-pane-form .pane {
    display: block;
    flex: 0 0 0;
    max-width: 0;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
  }
  .multi-pane-form .pane.pane--active {
    flex: 1 1 0;
    min-width: 14rem;
    max-width: 100%;
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    overflow: visible;
  }
}
/* Drill-down row: horizontal card layout (Reference Data 2-column style) */
.drill-down-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: stretch;
}
@media (min-width: 768px) {
  .drill-down-row {
    flex-wrap: nowrap;
    gap: 1.5rem;
  }
}
/* Each hierarchy level in its own card — exact Reference Data card styling */
.drill-down-card {
  border-radius: 1rem;
  border: 1px solid rgb(226 232 240);
  background: white;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  padding: 1.5rem;
  transition: flex 0.35s ease-out, max-width 0.35s ease-out, opacity 0.3s ease-out, box-shadow 0.2s ease-out;
  min-width: 0;
}
.dark .drill-down-card {
  border-color: rgb(71 85 105);
  background: rgb(30 41 59);
}
.drill-down-card.is-selected {
  box-shadow: 0 0 0 2px rgb(var(--mdc-color-primary));
}
@media (min-width: 768px) {
  .drill-down-card {
    flex: 1 1 0;
    min-width: 14rem;
    max-width: 22rem;
  }
  .drill-down-card.drill-down-card--next {
    flex: 0 0 0;
    min-width: 0;
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    padding-left: 0;
    padding-right: 0;
  }
  .drill-down-card.drill-down-card--next.drill-down-card--active {
    flex: 1 1 0;
    min-width: 14rem;
    max-width: 22rem;
    opacity: 1;
    pointer-events: auto;
    overflow: visible;
    padding: 1.5rem;
  }
}
@media (max-width: 767px) {
  .drill-down-card {
    flex: 1 1 100%;
  }
  .drill-down-card.drill-down-card--next {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
    border: none;
  }
  .drill-down-card.drill-down-card--next.drill-down-card--active {
    max-height: 20rem;
    opacity: 1;
    padding: 1.5rem;
    margin-top: 0;
    border: 1px solid rgb(226 232 240);
  }
  .dark .drill-down-card.drill-down-card--next.drill-down-card--active {
    border-color: rgb(71 85 105);
  }
}

/* Product form: stacked columns (Group, Variety) when used inside a single card */
.product-column-stack {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
}
.product-column-stack.product-column--active {
  max-height: 20rem;
  opacity: 1;
  pointer-events: auto;
  overflow: visible;
}
/* Product form: color child column (inline) */
.product-color-child-wrap {
  min-width: 0;
  max-width: 100%;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0;
  margin: 0;
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
}
.product-color-child-wrap.product-column--active {
  max-height: 20rem;
  opacity: 1;
  padding: 0;
  margin-top: 0.5rem;
  overflow: visible;
}

/* ========================================
   Section 4: Global input sizing (iOS zoom prevention)
   Owners: most templates with bare inputs; complements Section 5 .form-control
   ======================================== */
/* Global form controls: 44px min-height and 16px font to prevent iOS zoom (mobile-first). */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  min-height: 44px;
  font-size: 16px;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

/* Compact footer (reduced padding and tighter layout). */
.footer-compact .flex {
  line-height: 1.35;
}

/* Staff content: reserve bottom space when fixed tab bar is visible (mobile) so primary actions can scroll above it. Align with md breakpoint (768px). */
@media (max-width: 767px) {
  body.has-mobile-tabbar .staff-content {
    padding-bottom: 7rem; /* match inventory list pb-28; clear fixed tab bar */
  }
}

/* Mobile bottom tab bar primitives (token-driven). */
.mobile-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 120;
  padding-bottom: var(--safe-bottom);
  background-color: var(--surface);
  border-top: 2px solid rgb(var(--mdc-color-outline));
  box-shadow: 0 -4px 16px -8px rgb(0 0 0 / 0.15);
}

.mobile-tabbar-inner {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.25rem;
  max-width: 48rem;
  margin: 0 auto;
  padding: 0.5rem 0.25rem;
}

.mobile-tabbar-inner--five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.mobile-tab {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  min-height: 2.75rem; /* 44px minimum touch target */
  padding: 0.375rem 0.25rem;
  border-radius: 0.75rem;
  font-weight: 600;
  color: rgb(var(--mdc-color-on-surface-muted));
  background: transparent;
  border: 1px solid transparent;
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-tab:active {
  transform: scale(0.95);
}

.mobile-tab:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgb(var(--mdc-focus-ring) / 0.25);
}

.mobile-tab.is-active {
  color: rgb(var(--mdc-color-primary));
  background-color: rgb(var(--mdc-color-primary-container) / 0.75);
  border-color: rgb(var(--mdc-color-primary) / 0.30);
  font-weight: 700;
  transform: scale(1.02);
  box-shadow: 0 4px 12px -2px rgb(var(--mdc-color-primary) / 0.25);
}

.mobile-tab.is-active:active {
  transform: scale(0.98);
}

.mobile-tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mobile-tab-label {
  font-size: 0.6875rem;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

/* Mobile “More” sheet. */
/* z-index above inventory sticky bar (z-[145]) and filters slide-over (z-[150]) so sheet links are clickable when opened from /staff */
.mobile-sheet {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.mobile-sheet:not(.hidden) {
  pointer-events: auto;
}

.mobile-sheet.hidden {
  display: none;
}

.mobile-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(15 23 42 / 0.45);
  animation: mobile-sheet-backdrop-in 200ms ease-out;
}

.mobile-sheet-panel {
  position: relative;
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  border-top-left-radius: 1.25rem;
  border-top-right-radius: 1.25rem;
  border: 1px solid rgb(var(--mdc-color-outline));
  border-bottom: 0;
  background-color: var(--surface);
  padding-bottom: calc(0.75rem + var(--safe-bottom));
  box-shadow: 0 20px 70px -40px rgb(0 0 0 / 0.45);
  animation: mobile-sheet-slide-up 250ms cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes mobile-sheet-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes mobile-sheet-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.mobile-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem 0.5rem 1rem;
  border-bottom: 1px solid rgb(var(--mdc-color-outline));
}

.mobile-sheet-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  color: rgb(var(--mdc-color-on-surface-muted));
}

.mobile-sheet-close:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.4);
  color: rgb(var(--mdc-color-on-surface));
}

.mobile-sheet-body {
  padding: 0.75rem 1rem;
}

.mobile-sheet-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  border-radius: 0.75rem;
  border: 1px solid rgb(var(--mdc-color-outline));
  background-color: rgb(var(--mdc-color-background) / 0.35);
  padding: 0.625rem 0.75rem;
  font-weight: 600;
  color: rgb(var(--mdc-color-on-surface));
  transition: background-color 150ms ease, border-color 150ms ease;
}

.mobile-sheet-link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: rgb(var(--mdc-color-on-surface-muted));
}

.mobile-sheet-link:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.45);
  border-color: rgb(var(--mdc-color-primary) / 0.20);
}

.mobile-sheet-link:hover .mobile-sheet-link-icon {
  color: rgb(var(--mdc-color-primary));
}

/* Floating Action Button (FAB) for mobile */
.fab {
  position: fixed;
  z-index: 130;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem; /* 56px */
  height: 3.5rem; /* 56px */
  border-radius: 9999px;
  background-color: rgb(var(--mdc-color-primary));
  color: rgb(var(--mdc-color-on-primary));
  box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.25), 0 8px 10px -6px rgb(0 0 0 / 0.25);
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.fab:hover {
  box-shadow: 0 20px 35px -8px rgb(0 0 0 / 0.35), 0 10px 15px -8px rgb(0 0 0 / 0.35);
  transform: scale(1.05);
}

.fab:active {
  transform: scale(0.95);
}

/* FAB: mobile-default position (above tab bar + safe area). Hidden on desktop via md: in template or below. */
.fab {
  bottom: calc(7rem + var(--safe-bottom));
  right: 1rem;
}

/* Hide FAB on desktop (md breakpoint and up) */
@media (min-width: 768px) {
  .fab {
    display: none;
  }
}

/* ========================================
   Section 5: Form controls (.form-control)
   Owners: components/field_input.html, field_select.html, field_textarea.html,
           field_datepicker.html, field_password.html,
           components/list_filter_bar.html, list_filter_bar_fields_only.html,
           components/generic_filter_bar.html (search + primary select)
   ======================================== */
.form-control:active:not(:disabled) {
  border-color: rgb(var(--mdc-color-outline) / 0.9);
  transition: border-color var(--mdc-motion-duration-short) var(--mdc-motion-easing-standard);
}

.form-control:focus:not(:disabled) {
  outline: none;
  border-color: rgb(var(--mdc-color-input-border-focus));
  box-shadow: 0 0 0 2px rgb(var(--mdc-focus-ring-input) / var(--mdc-input-focus-ring-opacity));
}

.form-control:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  color: rgb(var(--mdc-color-on-surface-disabled));
}

.form-control[readonly] {
  background-color: rgb(var(--mdc-color-input-readonly-bg));
  cursor: default;
}

.form-control.invalid:not(:focus),
.form-control.is-invalid:not(:focus),
.form-control[aria-invalid="true"]:not(:focus) {
  border-color: rgb(var(--mdc-color-error));
  background-color: rgb(var(--mdc-color-input-error-bg));
}

.form-control.invalid:focus,
.form-control.is-invalid:focus,
.form-control[aria-invalid="true"]:focus {
  border-color: rgb(var(--mdc-color-error));
  box-shadow: 0 0 0 2px rgb(var(--mdc-color-error) / 0.38);
}

/* List filter bar: token-based primary button and clear button */
.list-filter-submit {
  background-color: rgb(var(--mdc-color-primary));
  border-color: rgb(var(--mdc-color-primary));
  color: white;
}
.list-filter-submit:hover {
  opacity: 0.95;
}
.list-filter-submit:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgb(var(--mdc-focus-ring) / 0.4);
}
/* Programmatic focus (e.g. JS) when :focus pseudo is not set */
.list-filter-input.focus {
  outline: none;
  border-color: rgb(var(--mdc-color-input-border-focus));
  box-shadow: 0 0 0 2px rgb(var(--mdc-focus-ring-input) / var(--mdc-input-focus-ring-opacity));
}

/* ========================================
   Filter bar: token-based, accessible
   (list pages: Inventory, Catalog, Products, Seasons)
   ======================================== */
.filter-bar {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgb(var(--mdc-color-outline));
  border-radius: 0.75rem;
  background-color: var(--surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}

.filter-bar-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1 1 auto;
}
.filter-bar-field:first-of-type {
  min-width: 8rem;
}
@media (min-width: 640px) {
  .filter-bar-field {
    flex: 0 0 auto;
    width: auto;
  }
}

.filter-bar-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: rgb(var(--mdc-color-on-surface));
  white-space: nowrap;
}
.filter-bar-label.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.filter-bar-input {
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: rgb(var(--mdc-color-on-surface));
  background-color: var(--surface);
  border: 1px solid rgb(var(--mdc-color-outline));
  border-radius: var(--mdc-radius-input);
  width: 100%;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.filter-bar-input::placeholder {
  color: rgb(var(--mdc-color-on-surface-muted));
  opacity: 1;
}
@media (min-width: 640px) {
  .filter-bar-input {
    min-height: 40px;
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
  }
}

.filter-bar .filter-bar-field input[type="search"].filter-bar-input {
  min-width: 0;
}
@media (min-width: 640px) {
  .filter-bar .filter-bar-field input[type="search"].filter-bar-input {
    width: 12rem;
  }
}

.filter-bar .filter-bar-field select.filter-bar-input {
  min-width: 0;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%23475569' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.25em 1.25em;
  padding-right: 2rem;
}
@media (min-width: 640px) {
  .filter-bar .filter-bar-field select.filter-bar-input {
    width: 8rem;
  }
}

.filter-bar .filter-bar-field input[type="number"].filter-bar-input {
  width: 100%;
}
@media (min-width: 640px) {
  .filter-bar .filter-bar-field input[type="number"].filter-bar-input {
    width: 4rem;
  }
}

.filter-bar .filter-bar-field .filter-bar-date-wrap {
  position: relative;
  width: 100%;
}
@media (min-width: 640px) {
  .filter-bar .filter-bar-field .filter-bar-date-wrap {
    width: 8.5rem;
  }
}
.filter-bar .filter-bar-field .filter-bar-date-wrap .filter-bar-input {
  padding-left: 2.25rem;
}
.filter-bar .filter-bar-date-icon {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  padding-left: 0.75rem;
  pointer-events: none;
  z-index: 10;
  color: rgb(var(--mdc-color-on-surface-muted));
  display: flex;
  align-items: center;
}

.filter-bar-checkbox-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  min-height: 44px;
  padding: 0.25rem 0;
}
@media (min-width: 640px) {
  .filter-bar-checkbox-wrap {
    min-height: 0;
  }
}
.filter-bar-checkbox-wrap input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  accent-color: rgb(var(--mdc-color-primary));
  border-radius: 0.25rem;
}
.filter-bar-checkbox-wrap .filter-bar-label {
  margin: 0;
}

.filter-bar-select-multi-wrap {
  width: 100%;
  min-width: 0;
}
@media (min-width: 640px) {
  .filter-bar-select-multi-wrap {
    min-width: 18rem;
    width: 18rem;
    flex-shrink: 0;
  }
}

.filter-bar-actions {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .filter-bar-actions {
    flex-direction: row;
    align-items: center;
    margin-left: auto;
  }
}

.filter-bar-submit {
  display: inline-flex;
  height: 44px;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgb(var(--mdc-color-on-primary));
  background-color: rgb(var(--mdc-color-primary));
  border: 1px solid rgb(var(--mdc-color-primary));
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color var(--mdc-motion-duration-short) var(--mdc-motion-easing-standard),
    border-color var(--mdc-motion-duration-short) var(--mdc-motion-easing-standard);
}
.filter-bar-submit:hover {
  background-color: rgb(var(--mdc-color-primary-hover));
  border-color: rgb(var(--mdc-color-primary-hover));
}
.filter-bar-submit:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgb(var(--mdc-focus-ring) / 0.4);
}
/* Let clicks hit the button, not the icon (fixes Cypress/real clicks on Apply in slide-over) */
.filter-bar-submit svg {
  pointer-events: none;
}
@media (min-width: 640px) {
  .filter-bar-submit {
    height: 40px;
    padding: 0.375rem 1rem;
  }
}

.filter-bar-clear {
  display: inline-flex;
  height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgb(var(--mdc-color-on-surface));
  background-color: var(--surface);
  border: 1px solid rgb(var(--mdc-color-outline));
  border-radius: 0.5rem;
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.filter-bar-clear:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.35);
  border-color: rgb(var(--mdc-color-primary) / 0.25);
}
.filter-bar-clear:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgb(var(--mdc-focus-ring) / 0.4);
}
@media (min-width: 640px) {
  .filter-bar-clear {
    height: 40px;
    padding: 0.375rem 1rem;
  }
}

/* Filter bar wrapper (e.g. inventory page) — token-based container and toggle */
.filter-bar-container {
  border: 1px solid rgb(var(--mdc-color-outline));
  border-radius: 0.75rem;
  background-color: var(--surface);
}
.filter-bar-toggle-btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.75rem;
  text-align: left;
  font-size: 0.875rem;
  color: rgb(var(--mdc-color-on-surface));
  background: none;
  border: none;
  cursor: pointer;
}
@media (min-width: 768px) {
  .filter-bar-toggle-btn {
    display: none;
  }
}
.filter-bar-container-inner {
  padding: 0.5rem 0.75rem;
}
@media (min-width: 640px) {
  .filter-bar-container-inner {
    padding: 0.5rem 0.75rem;
  }
}
/* Embedded list filter (form_extra_class="filter-bar--embedded"): higher specificity than .filter-bar alone */
.filter-bar-container-inner > form.filter-bar.filter-bar--embedded,
form.filter-bar.filter-bar--embedded {
  padding: 0.5rem;
  border: none;
  border-radius: 0.5rem;
  box-shadow: none;
}
@media (min-width: 640px) {
  .filter-bar-container-inner > form.filter-bar.filter-bar--embedded,
  form.filter-bar.filter-bar--embedded {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }
}

/* Accessibility utility (Tailwind's `sr-only`) — keep in overrides so it works even if Tailwind isn't rebuilt.
   reason: !important — screen-reader clipping pattern must beat any component padding/display from Flowbite/forms. */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border-width: 0 !important;
}

/* User menu avatar sizing: keep it visually aligned with the header theme toggle button. */
.user-menu-avatar {
  width: 34px;
  height: 34px;
}

/*
 * Flowbite / custom dropdown panels (not Choices.js — those live in vendor-choices.overrides.css).
 * Keeps long menus within the viewport; --ll-dropdown-max-height is defined on :root in this file.
 */
#user-menu-dropdown {
  max-height: var(--ll-dropdown-max-height, min(22rem, calc(100vh - 4rem)));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

[data-searchable-select-root] [id^="dropdown-"] {
  max-height: var(--ll-dropdown-max-height, min(22rem, calc(100vh - 4rem)));
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}

[data-searchable-select-root] [id^="dropdown-"] > ul {
  max-height: none !important;
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
}

/* Anchor color is inherited by default (Tailwind preflight).
   Opt-in via the `.link` component class (see static/src/input.css) for real
   content links; everything else (buttons, nav, tabs, table sort controls,
   card wrappers) inherits parent text color. This intentionally eliminates
   the old `a { color }` / `a:visited` / `a:hover` globals that were
   repainting button-styled and table-header anchors. */



/* ========================================
   ACCESSIBILITY: WCAG AA COLOR CONTRAST
   ======================================== */

/* Improve contrast for slate text utilities (light mode) */
.text-slate-500 {
  color: rgb(100 116 139); /* Darker than default for better contrast */
}

.text-slate-400 {
  color: rgb(148 163 184); /* Slightly darker */
}

/* Placeholder text contrast */
::placeholder {
  color: rgb(100 116 139);
  opacity: 1;
}

/* Status badge text: improve contrast; primary/success use token */
.text-emerald-700 {
  color: rgb(var(--mdc-color-primary));
}

.text-amber-700 {
  color: rgb(146 64 14); /* Darker amber for better contrast */
}

.text-sky-700 {
  color: rgb(3 105 161); /* Darker sky for better contrast */
}

.text-cyan-700 {
  color: rgb(14 116 144); /* Darker cyan for better contrast */
}

.text-rose-800 {
  color: rgb(159 18 57); /* Rose-800 instead of rose-700 for better contrast */
}

.text-violet-800 {
  color: rgb(91 33 182); /* Violet-800 instead of violet-700 for better contrast */
}

/* Current page in pagination - token-driven */
.border-emerald-300.bg-emerald-500\/10 {
  background-color: rgb(var(--mdc-color-primary) / 0.2);
  border-color: rgb(var(--mdc-color-primary));
}

.text-emerald-800 {
  color: rgb(var(--mdc-color-on-primary-container));
}

/* Ensure focus rings are visible (WCAG 2.4.7); dark mode uses background for ring offset */
.focus\:ring-2:focus {
  --tw-ring-offset-width: 2px;
  --tw-ring-offset-color: #fff;
}
html.dark .focus\:ring-2:focus,
html.dark .focus\:ring-offset-1:focus {
  --tw-ring-offset-color: rgb(var(--mdc-color-background));
}

/* Button hover states: sleek lift + subtle shadow (smooth in AND out). */
.inventory-actions .bg-primary,
.inventory-actions .bg-danger,
.inventory-actions .bg-primaryContainer,
.inventory-actions .btn-action-outline,
.table-actions .bg-primary,
.table-actions .bg-danger,
.table-actions .bg-primaryContainer,
.table-actions .btn-action-outline {
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}
.inventory-actions .bg-primary:hover,
.inventory-actions .bg-danger:hover,
.table-actions .bg-primary:hover,
.table-actions .bg-danger:hover {
  filter: brightness(0.96);
}
.inventory-actions .bg-primaryContainer:hover,
.table-actions .bg-primaryContainer:hover {
  filter: brightness(0.95);
}
.inventory-actions .btn-action-outline:hover,
.table-actions .btn-action-outline:hover {
  box-shadow: 0 2px 6px -2px rgb(0 0 0 / 0.1);
}

/* Subtle lift on card hovers (smooth in AND out). */
.hover\:shadow-lg {
  transition: box-shadow 200ms ease, transform 200ms ease;
}

.hover\:shadow-lg:hover {
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  transform: translateY(-1px);
}

/* Improve border/link hover feedback (smooth in AND out). */
.border.hover\:bg-slate-50 {
  transition: transform 150ms ease;
}

.border.hover\:bg-slate-50:hover {
  transform: translateY(-1px);
}

/* Choices.js theme: see vendor-choices.overrides.css (ticket 05). */

/* Bulk Select Mode Styling (concrete properties — this file is not processed by Tailwind) */
.bulk-select-active {
  box-shadow: 0 0 0 2px rgb(var(--mdc-color-primary) / 0.5);
  background-color: rgb(var(--mdc-color-primary) / 0.05);
}

.bulk-select-active .bulk-checkbox {
  opacity: 1;
}

.bulk-checkbox {
  opacity: 0;
  transition: opacity 200ms ease;
}

.bulk-select-active .bulk-checkbox {
  opacity: 1;
}

/* Staff layout: keep content within viewport with or without sidebar */
#main-content {
  min-width: 0;
}
.drill-down-row {
  min-width: 0;
}
.drill-down-card {
  min-width: 0;
}

/* App sidebar (desktop): left nav for /staff/ pages.
   Fixed 4rem gutter; inner nav overlays content on hover/focus-within. */
.app-sidebar {
  width: 4rem;
}

.app-sidebar .app-sidebar-nav {
  position: absolute;
  top: 0;
  left: 0;
  width: 4rem;
  height: 100%;
  max-height: 100vh;
  background-color: rgb(var(--mdc-color-background));
  border-right: 1px solid rgb(var(--mdc-color-outline) / 0.25);
  overflow: hidden;
  transition: width 180ms ease-out, box-shadow 180ms ease-out;
  z-index: 40;
}

.app-sidebar:hover .app-sidebar-nav,
.app-sidebar:focus-within .app-sidebar-nav {
  width: 14rem;
  overflow-y: auto;
  box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

.app-sidebar .app-sidebar-label,
.app-sidebar .app-sidebar-section-title {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 120ms ease-out;
}

.app-sidebar:hover .app-sidebar-label,
.app-sidebar:hover .app-sidebar-section-title,
.app-sidebar:focus-within .app-sidebar-label,
.app-sidebar:focus-within .app-sidebar-section-title {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.app-sidebar .app-side-nav-link {
  justify-content: center;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.app-sidebar:hover .app-side-nav-link,
.app-sidebar:focus-within .app-side-nav-link {
  justify-content: flex-start;
}

.app-sidebar .app-side-nav-link:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.5);
}

.app-side-nav-link:focus {
  outline: 2px solid rgb(var(--mdc-color-primary));
  outline-offset: 2px;
}

/* Desktop app nav tabs (horizontal tabs; sidebar uses .app-side-nav-link) - token-based for light and dark */
.app-nav-tab {
  border: 1px solid rgb(var(--mdc-color-outline));
  background-color: rgb(var(--mdc-color-surface));
  color: rgb(var(--mdc-color-on-surface));
  transition: background-color var(--mdc-motion-duration-short) var(--mdc-motion-easing-standard),
    border-color var(--mdc-motion-duration-short) var(--mdc-motion-easing-standard),
    color var(--mdc-motion-duration-short) var(--mdc-motion-easing-standard);
}

.app-nav-tab:hover {
  background-color: rgb(var(--mdc-color-primary-container) / 0.35);
  border-color: rgb(var(--mdc-color-primary) / 0.25);
  color: rgb(var(--mdc-color-on-surface));
}

.app-nav-tab[aria-current="page"] {
  background-color: rgb(var(--mdc-color-primary-container) / 0.6);
  border-color: rgb(var(--mdc-color-primary) / 0.35);
  color: rgb(var(--mdc-color-primary));
  font-weight: 700;
}

/* Per-user table column preferences: hide columns */
th.table-column-hidden,
td.table-column-hidden {
  display: none;
}

.table-column-draggable {
  cursor: grab;
  user-select: none;
}

.table-column-draggable:active {
  cursor: grabbing;
}



