/* === Tab bar === */
.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-4);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  flex: 1;
  min-height: var(--tap-target-min);
  padding: var(--space-3) var(--space-4);
  background: none;
  border: none;
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}

.tab-btn.active { color: var(--color-primary); font-weight: 600; }

.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-primary);
}

/* === Product chips === */
.product-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: 16px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: white;
  margin: 2px;
}

.product-chip.fertilizer { background: var(--color-product-fertilizer); }
.product-chip.fiesta     { background: var(--color-product-fiesta); }
.product-chip.grub       { background: var(--color-product-grub); }
.product-chip.aerify     { background: var(--color-product-aerify); }
.product-chip.adjuvant   { background: var(--color-product-adjuvant); }
.product-chip.supergreen { background: var(--color-product-supergreen); }

/* === Product selector buttons (Daily Fill) === */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.product-btn {
  min-height: var(--tap-target-min);
  padding: var(--space-3);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
  font-size: var(--font-size-base);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  text-align: center;
  transition: all 0.15s;
}

.product-btn::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 6px;
  height: 100%;
  background: var(--bar-color, var(--color-border));
}

.product-btn.fertilizer { --bar-color: var(--color-product-fertilizer); }
.product-btn.fiesta     { --bar-color: var(--color-product-fiesta); }
.product-btn.grub       { --bar-color: var(--color-product-grub); }
.product-btn.aerify     { --bar-color: var(--color-product-aerify); }
.product-btn.adjuvant   { --bar-color: var(--color-product-adjuvant); }
.product-btn.supergreen { --bar-color: var(--color-product-supergreen); }

.product-btn.selected {
  background: var(--color-primary-bg);
  border-color: var(--color-primary);
  font-weight: 600;
}

.product-btn:active { transform: scale(0.98); }

/* === Tank gauge === */
.tank-gauge {
  width: 80px;
  height: 120px;
  border: 2px solid var(--color-text);
  border-radius: var(--radius-md);
  position: relative;
  background: #f5f5f5;
  overflow: hidden;
  flex-shrink: 0;
}

.tank-gauge .fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--color-primary);
  transition: height 0.3s ease, background-color 0.15s;
}

.tank-gauge .fill.fertilizer { background: var(--color-product-fertilizer); }
.tank-gauge .fill.fiesta     { background: var(--color-product-fiesta); }
.tank-gauge .fill.grub       { background: var(--color-product-grub); }
.tank-gauge .fill.aerify     { background: var(--color-product-aerify); }
.tank-gauge .fill.adjuvant   { background: var(--color-product-adjuvant); }
.tank-gauge .fill.supergreen { background: var(--color-product-supergreen); }
.tank-gauge .fill.mixed {
  background: linear-gradient(135deg,
    var(--color-product-fertilizer) 0% 25%,
    var(--color-product-fiesta) 25% 50%,
    var(--color-product-grub) 50% 75%,
    var(--color-product-aerify) 75% 100%);
}

.tank-gauge .label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
  font-size: var(--font-size-sm);
}

/* === Toast notifications === */
/* Bottom-center: the user's eyes live near the sticky Save bar, not the top-right corner. */
.toast-container {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 110px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: 360px;
  max-width: 90vw;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-2);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  color: white;
  font-weight: 500;
  pointer-events: auto;
  animation: toast-in 0.25s ease;
}

.toast.success { background: var(--color-success); }
.toast.error   { background: var(--color-error); }
.toast.info    { background: var(--color-info); }
.toast.warning { background: var(--color-warning); color: #333; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === Modal overlay === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal h3 { margin-top: 0; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

/* === Sticky bottom action bar === */
.sticky-bottom {
  position: sticky;
  bottom: 0;
  background: var(--color-card);
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
  margin: var(--space-4) calc(-1 * var(--space-5)) calc(-1 * var(--space-5));
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}

/* === Tank panel (Daily Fill) === */
.tank-panel {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

.tank-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-3);
}

.tank-panel-body { display: flex; gap: var(--space-3); align-items: flex-start; }

.tank-panel-controls { flex: 1; }

.toggle-row {
  display: flex;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.toggle-btn {
  flex: 1;
  min-height: var(--tap-target-min);
  padding: var(--space-2);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
  cursor: pointer;
  font-size: var(--font-size-base);
}

.toggle-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.tank-panel-title h4 { margin: 0; }
.tank-panel-title .text-muted { display: block; font-size: var(--font-size-sm); }

/* Per-panel outcome badge: shows what the panel will save as */
.panel-status {
  padding: 4px 12px;
  border-radius: 14px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  white-space: nowrap;
}
.panel-status.will-fill     { background: var(--status-active-bg); color: var(--status-active-fg); }
.panel-status.log-only      { background: var(--status-inactive-bg); color: var(--status-inactive-fg); }
.panel-status.needs-reading { background: var(--status-warning-bg); color: var(--status-warning-fg); }

/* The dipstick reading is the app's most important input — size it like one. */
.dipstick-input {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  text-align: center;
  min-height: 56px;
}
.dipstick-last-hint { display: block; margin-top: 4px; }

.mix-last-hint { display: block; margin-top: 4px; }

/* Live summary line in the sticky save bar */
.save-summary { margin-bottom: var(--space-2); font-weight: 500; }

/* Persistent validation error anchored in the sticky save bar */
.save-error {
  background: var(--status-critical-bg);
  color: var(--status-critical-fg);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-2);
  font-weight: 600;
}

.tank-panel.has-error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 2px var(--color-error);
}

/* === Segmented control (Fleet Status filters) === */
.segmented {
  display: inline-flex;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.segmented-btn {
  min-height: var(--tap-target-min);
  padding: var(--space-2) var(--space-3);
  border: none;
  background: var(--color-card);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  border-right: 2px solid var(--color-border);
}
.segmented-btn:last-child { border-right: none; }
.segmented-btn.selected {
  background: var(--color-primary);
  color: white;
}

/* === Filter chips (History) — glove-friendly multi-select === */
.filter-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.filter-chip {
  min-height: var(--tap-target-min);
  padding: var(--space-1) var(--space-3);
  border: 2px solid var(--color-border);
  border-radius: 22px;
  background: var(--color-card);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.filter-chip.selected {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}
.filter-chip:active { transform: scale(0.97); }

/* Post-save handoff card */
.saved-handoff { text-align: center; }
.saved-handoff-headline {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-success);
  margin-bottom: var(--space-3);
}
.saved-handoff-done {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-success);
  margin: var(--space-3) 0 0;
}

/* Component rows: iPad-friendly touch targets */
.component-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap-target-min);
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}
.component-row:last-child { border-bottom: none; }
.component-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}
.component-row .component-name { flex: 1; font-weight: 500; }
.component-row .component-amounts {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.component-row .component-amounts small { font-size: var(--font-size-sm); }
.component-row.omitted { opacity: 0.5; }

/* Coercion warning: fill panel with 0 gallons will save as log-only */
.log-only-hint {
  margin-top: var(--space-1);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--status-warning-bg);
  color: var(--status-warning-fg);
  font-size: var(--font-size-sm);
}

/* === Concentrate calc panel === */
.calc-panel {
  background: var(--color-primary-bg);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-top: var(--space-3);
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: var(--font-size-sm);
}

.calc-panel-row { display: flex; justify-content: space-between; padding: 2px 0; }
.calc-panel-row.total { border-top: 1px solid var(--color-primary); margin-top: var(--space-1); padding-top: var(--space-1); font-weight: 600; }

/* === Drawer (slide-in panel) === */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9000;
  display: flex;
  justify-content: flex-end;
}

.drawer {
  background: var(--color-card);
  width: 480px;
  max-width: 100vw;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.15);
  animation: drawer-slide-in 0.2s ease;
}

@keyframes drawer-slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@media (max-width: 600px) {
  .drawer { width: 100%; }
  .drawer-overlay { background: var(--color-card); }
}

/* === Status badges === */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  white-space: nowrap;
}
.status-badge.active   { background: var(--status-active-bg); color: var(--status-active-fg); }
.status-badge.warning  { background: var(--status-warning-bg); color: var(--status-warning-fg); }
.status-badge.critical { background: var(--status-critical-bg); color: var(--status-critical-fg); }
.status-badge.pending  { background: var(--status-pending-bg); color: var(--status-pending-fg); }
.status-badge.inactive { background: var(--status-inactive-bg); color: var(--status-inactive-fg); }

/* === Loading skeleton === */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
  display: inline-block;
}
.skeleton-line { height: 1em; width: 100%; margin-bottom: 6px; }
.skeleton-card { height: 120px; width: 100%; }

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: var(--space-5) var(--space-3);
  color: var(--color-text-muted);
}
.empty-state-icon { font-size: 2em; margin-bottom: var(--space-2); opacity: 0.5; }
.empty-state-text { margin-bottom: var(--space-3); }
