/*
 * Fix 1: Modal popups trapped by parent transform
 * 
 * .animate-fade-in uses @keyframes fade-in which has transform: translateY(12px).
 * With animation-fill-mode: both, the browser retains a transform on the element
 * AFTER animation completes. Any parent with an active transform creates a new
 * "containing block" that traps position:fixed children (modals).
 * 
 * Solution: After animation completes, remove the transform that creates
 * the containing block. This frees position:fixed descendants.
 */

.animate-fade-in {
  animation: fade-in-notransform var(--duration-slow) var(--ease-out) both !important;
}

@keyframes fade-in-notransform {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/*
 * Fix 2: Ensure server layout doesn't clip fixed overlays (modals)
 * Keep kds-layout as-is (overflow: hidden is intentional for KDS screens)
 */
.server-layout {
  overflow: clip !important;
}

/*
 * Fix 3: Allow scrolling in snack KDS grid
 * The kds-layout uses overflow:hidden + 100vh which is correct for the header.
 * The kds-grid (main content) needs to scroll when there are many orders.
 */
.kds-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4, 16px);
  padding: var(--space-4, 16px);
  overflow-y: auto;
  min-height: 0;
  align-content: start;
}

/*
 * Fix 4: Snack summary bar — fixed bottom bar showing product totals
 */
.snack-summary-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  font-family: var(--font-body, 'Inter', sans-serif);
  transition: transform 0.3s cubic-bezier(.16, 1, .3, 1);
}

.snack-summary-bar:empty {
  transform: translateY(100%);
}

.snack-summary-bar__label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #f59e0b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
  margin-right: 4px;
}

.snack-summary-bar__chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.75rem;
  color: #e8e6e3;
  flex-shrink: 0;
  transition: background 0.15s;
}

.snack-summary-bar__chip:hover {
  background: rgba(255, 255, 255, 0.1);
}

.snack-summary-bar__qty {
  font-weight: 700;
  color: #f59e0b;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.snack-summary-bar__name {
  font-weight: 400;
  color: #ccc;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Add bottom padding to kds-grid when summary bar is present */
.kds-layout:has(.snack-summary-bar) .kds-grid {
  padding-bottom: 52px;
}

/* Scrollbar styling for snack summary bar */
.snack-summary-bar::-webkit-scrollbar {
  height: 3px;
}
.snack-summary-bar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}

/*
 * Fix 5: KDS sort toggle — oldest first (FIFO) mode
 * Handled entirely via JS CSS order property on children.
 */

.kds-sort-toggle {
  background: none;
  border: 1px solid var(--color-border, rgba(255,255,255,0.08));
  border-radius: var(--radius-sm, 6px);
  color: var(--color-text-secondary, #8b8b8b);
  font-size: 1.2rem;
  padding: var(--space-2, 8px) var(--space-3, 12px);
  cursor: pointer;
  transition: all var(--duration-fast, 0.15s) var(--ease-out, cubic-bezier(.16,1,.3,1));
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
}
.kds-sort-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--color-text-primary, #e8e6e3);
}
.kds-sort-toggle:active {
  transform: scale(0.93);
}
.kds-sort-toggle--active {
  color: var(--color-accent-primary, #c9a96e);
  border-color: var(--color-border-accent, rgba(201,169,110,0.3));
}
.kds-sort-toggle--active:hover {
  background: var(--color-accent-primary-muted, rgba(201,169,110,0.15));
}
