@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --wonder-green: #1C4F2A;
  --wonder-green-dark: #163d20;
  --wonder-green-light: #2a6b39;
  --wonder-sage: #EEF3E8;
  --wonder-sage-dark: #d8e6cc;
  --wonder-sage-mid: #c5d9b5;
}

* { box-sizing: border-box; }

body {
  background-color: var(--wonder-sage);
  font-family: 'Inter', system-ui, sans-serif;
  color: #1a1a1a;
}

/* ── MODAL ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
}
.modal-box {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  max-width: 520px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  max-height: 90vh;
  overflow-y: auto;
}

/* ── COLD RAIL GRID ──────────────────────────────────────── */
.cold-rail-grid {
  display: grid;
  gap: 4px;
  background: var(--wonder-green-dark);
  border: 3px solid var(--wonder-green-dark);
  border-radius: 10px;
  padding: 4px;
  overflow-x: auto;
}

/* ── DRY RAIL GRID ───────────────────────────────────────── */
/* Purple-tinted border & background to distinguish from cold rail */
.dry-rail-grid {
  background: #4c1d95;  /* deep purple */
  border-color: #4c1d95 !important;
}

.dry-rail-pan {
  min-height: 50px;
  max-height: 90px;
}

/* Filled dry-rail pan: soft lavender background */
.dry-rail-pan.filled {
  background: #f5f3ff !important;
  border-color: #7c3aed !important;
}

/* Empty dry-rail pan: slightly lavender tinted */
.dry-rail-pan.empty {
  background: #faf8ff !important;
  border-color: #c4b5fd !important;
  border-style: dashed !important;
  color: #c4b5fd !important;
}

.dry-rail-pan:hover {
  border-color: #7c3aed !important;
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15) !important;
}

.pan-cell {
  background: white;
  border: 2px solid #ccc;
  border-radius: 6px;
  padding: 5px 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  font-size: 10px;
  line-height: 1.25;
  overflow: hidden;
  word-break: break-word;
  hyphens: auto;
  /* cells fill their grid area exactly */
  box-sizing: border-box;
}

.pan-cell:hover {
  border-color: var(--wonder-green);
  box-shadow: 0 0 0 3px rgba(28,79,42,0.15);
}

.pan-cell.filled {
  background: #f0f7eb;
  border-color: var(--wonder-green-light);
}

.pan-cell.empty {
  background: #fafafa;
  border-color: #ddd;
  border-style: dashed;
  color: #999;
}

.pan-cell.selected {
  border-color: var(--wonder-green);
  box-shadow: 0 0 0 3px rgba(28,79,42,0.3);
}

.pan-cell .pan-item-name {
  font-weight: 700;
  font-size: 9.5px;
  color: #1a1a1a;
  margin-bottom: 2px;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  max-width: 100%;
  width: 100%;
  line-height: 1.2;
}

.pan-cell .pan-item-id {
  font-size: 8.5px;
  color: #444;
  margin-bottom: 2px;
}

.pan-cell .pan-utensil {
  font-size: 8.5px;
  color: var(--wonder-green);
  font-weight: 600;
  margin-top: 2px;
  word-break: break-word;
  max-width: 100%;
}

.pan-cell .pan-size-badge {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 9px;
  color: #999;
  font-weight: 500;
}

.pan-cell .allergen-badge {
  font-size: 9px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
  border-radius: 3px;
  padding: 1px 4px;
  margin-top: 2px;
}

/* ── ALLERGEN COLORS ──────────────────────────────────────── */
.pan-cell[data-allergens*="Gluten"] { border-left: 3px solid #f59e0b; }
.pan-cell[data-allergens*="Dairy"] { border-left: 3px solid #3b82f6; }
.pan-cell[data-allergens*="Nut"] { border-left: 3px solid #8b5cf6; }
.pan-cell[data-allergens*="Soy"] { border-left: 3px solid #ec4899; }
.pan-cell[data-allergens*="Egg"] { border-left: 3px solid #f97316; }
.pan-cell[data-allergens*="Shellfish"] { border-left: 3px solid #ef4444; }

/* ── DRAG AND DROP ──────────────────────────────────────── */
.pan-cell[draggable="true"] { cursor: grab; }
.pan-cell[draggable="true"]:active { cursor: grabbing; }
.pan-cell.dragging { opacity: 0.4; transform: scale(0.97); }
.pan-cell.drag-over {
  border-color: var(--wonder-green) !important;
  box-shadow: 0 0 0 3px rgba(28,79,42,0.35);
  background: #e8f4e8 !important;
}

/* ── DUPLICATE ITEM GLOW ────────────────────────────────── */
@keyframes panGlow {
  0%,100% { box-shadow: 0 0 0 3px rgba(234,179,8,0.3), 0 0 12px 3px rgba(234,179,8,0.2); }
  50%      { box-shadow: 0 0 0 5px rgba(234,179,8,0.6), 0 0 20px 6px rgba(234,179,8,0.4); }
}
.pan-glow {
  animation: panGlow 0.9s ease-in-out infinite;
  border-color: #eab308 !important;
  z-index: 10;
}

/* ── SECTION DIVIDER ZONES ──────────────────────────────── */
/* Wide dark-green gap acting as a visible section break */
.divider-zone {
  background: var(--wonder-green-dark);
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: background 0.15s;
}
.divider-zone:hover { background: #0f2a15; }
/* Subtle "×" indicator on hover so user knows they can click to remove */
.divider-zone::before {
  content: '×';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  color: rgba(255,255,255,0.25);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  line-height: 1;
}
.divider-zone:hover::before { opacity: 1; }

/* Thin invisible hot-spot between pan slots — only active in Divider Mode */
.divider-toggle {
  cursor: default;
  position: relative;
  z-index: 3;
  opacity: 0;
  pointer-events: none; /* disabled by default — only enabled in dividerMode */
}
/* When divider mode is active, toggles become clickable */
.divider-toggle-active {
  cursor: pointer !important;
  pointer-events: auto !important;
  opacity: 1 !important;
}
.divider-toggle-active:hover {
  background: rgba(255,255,255,0.18);
  border-radius: 2px;
}
.divider-toggle-active:hover::after {
  content: '+';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  pointer-events: none;
}

/* ── COLUMN ADD / REMOVE BUTTONS ────────────────────────── */
.col-adj-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-width: 28px;
  border-radius: 8px;
  background: var(--wonder-green-dark);
  color: rgba(255,255,255,0.7);
  border: none;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.col-adj-btn:hover { background: var(--wonder-green); color: white; }
.col-adj-add { background: #1C4F2A; }

/* ── HOLDING TRAY ───────────────────────────────────────── */
.holding-tray {
  margin-top: 16px;
  background: #fff8e7;
  border: 2px dashed #f59e0b;
  border-radius: 10px;
  padding: 12px;
}
.holding-tray-header {
  font-size: 13px;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 10px;
}
.holding-tray-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tray-item {
  background: white;
  border: 2px solid #f59e0b;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: grab;
  min-width: 90px;
  max-width: 140px;
  text-align: center;
  transition: all 0.15s;
}
.tray-item:hover {
  border-color: var(--wonder-green);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.tray-item:active { cursor: grabbing; }

/* ── PRINT — hide interactive elements ──────────────────── */
.no-screen { display: none; }
@media print { .no-screen { display: block; } }

/* ── NAV ────────────────────────────────────────────────── */
.nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  color: rgba(255,255,255,0.75);
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
  font-size: 14px;
}
.nav-link:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-link.active { background: rgba(255,255,255,0.15); color: white; }

/* ── BUTTONS ──────────────────────────────────────────── */
.btn-primary {
  background: var(--wonder-green);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 14px;
}
.btn-primary:hover { background: var(--wonder-green-light); }

.btn-secondary {
  background: var(--wonder-sage);
  color: var(--wonder-green);
  border: 2px solid var(--wonder-sage-mid);
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
}
.btn-secondary:hover { background: var(--wonder-sage-dark); }

.btn-danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
}
.btn-danger:hover { background: #fecaca; }

/* ── FORM INPUTS ──────────────────────────────────────── */
.form-input {
  width: 100%;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  transition: border-color 0.15s;
  outline: none;
  font-family: inherit;
}
.form-input:focus { border-color: var(--wonder-green); }

/* ── CARDS ────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ── TOAST ────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: 10px;
  color: white;
  font-weight: 500;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideIn 0.2s ease;
  max-width: 320px;
}
.toast.success { background: var(--wonder-green); }
.toast.error { background: #dc2626; }
.toast.info { background: #2563eb; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── PRINT STYLES ─────────────────────────────────────── */
@media print {
  body { background: white !important; }
  .no-print { display: none !important; }
  .cold-rail-grid {
    gap: 2px;
    background: #333;
    border-color: #333;
    padding: 2px;
  }
  .pan-cell {
    min-height: 70px;
    font-size: 10px;
    break-inside: avoid;
  }
  #sidebar, #top-nav { display: none !important; }
  #print-area { padding: 0 !important; }
}

/* ── SCROLLBAR ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--wonder-sage-mid); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--wonder-green-light); }

/* ── TRANSITIONS ──────────────────────────────────────── */
.fade-in { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ── SIDEBAR ──────────────────────────────────────────── */
#sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--wonder-green);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
}

#main-content {
  margin-left: 240px;
  min-height: 100vh;
  padding: 32px;
}

/* ── ITEM CHIP ─────────────────────────────────────────── */
.item-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--wonder-sage);
  border: 1px solid var(--wonder-sage-mid);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
}

/* ── ALLERGEN CHECKBOX GRID ──────────────────────────── */
.allergen-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.allergen-checkbox {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #444;
  transition: all 0.15s;
  background: white;
  user-select: none;
}

.allergen-checkbox:hover {
  border-color: #9ca3af;
  background: #f9fafb;
}

.allergen-checkbox.checked {
  border-color: var(--wonder-green);
  background: var(--wonder-sage);
  color: var(--wonder-green);
  font-weight: 600;
}

.allergen-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── UTENSIL TAG (checkbox-style, used in Add Item modal) ─── */
.utensil-tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: #555;
  background: white;
  transition: all 0.12s;
  user-select: none;
  white-space: nowrap;
}
.utensil-tag:hover {
  border-color: var(--wonder-green);
  color: var(--wonder-green);
}
.utensil-tag.selected {
  background: var(--wonder-green);
  border-color: var(--wonder-green);
  color: white;
  font-weight: 600;
}

/* ── UTENSIL OPTION BTN ───────────────────────────────── */
.utensil-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
  background: white;
  font-size: 14px;
  font-weight: 500;
}
.utensil-option:hover {
  border-color: var(--wonder-green);
  background: var(--wonder-sage);
  color: var(--wonder-green);
}
