/* HarvestHub — design tokens
   bg:        #F6F7F1  (pale sprout-tray white)
   surface:   #FFFFFF
   ink:       #1E2A1F  (deep growing-green, near-black)
   leaf:      #2C5B3F  (primary)
   leaf-dark: #1E4029
   sprout:    #9ACB5A  (accent / positive)
   soil:      #7A5A3A  (secondary / inventory)
   rust:      #B4482E  (overdue / danger)
   sand:      #EDE7D8  (subtle panel bg)
*/

* { box-sizing: border-box; }

:root {
  --bg: #F6F7F1;
  --surface: #FFFFFF;
  --ink: #1E2A1F;
  --ink-soft: #55604F;
  --leaf: #2C5B3F;
  --leaf-dark: #1E4029;
  --sprout: #9ACB5A;
  --soil: #7A5A3A;
  --rust: #B4482E;
  --sand: #EDE7D8;
  --border: #DDE1D2;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Public Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
}

h1, h2, h3 {
  font-family: "Fraunces", Georgia, serif;
  color: var(--leaf-dark);
  margin: 0 0 4px 0;
  font-weight: 600;
}

a { color: var(--leaf); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--leaf-dark);
  color: #EFF3EA;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 20px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 16px;
}
.brand-mark {
  color: var(--sprout);
  font-size: 22px;
  transform: rotate(90deg);
  display: inline-block;
}
.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  flex-shrink: 0;
}
.brand-name {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 17px;
  color: #fff;
}
.sidebar nav { display: flex; flex-direction: column; }
.sidebar nav a {
  color: #C9D4C0;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 2px;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.08); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--sprout); color: var(--leaf-dark); font-weight: 600; }
.nav-group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8CA080;
  margin: 16px 0 4px 10px;
}

/* Reports hover submenu */
.nav-item-has-submenu {
  position: relative;
}
.nav-submenu-trigger {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  color: #C9D4C0;
  cursor: default;
}
.nav-item-has-submenu:hover .nav-submenu-trigger,
.nav-item-has-submenu.active .nav-submenu-trigger {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.nav-submenu {
  display: none;
  position: fixed;
  min-width: 200px;
  max-width: 260px;
  background: var(--leaf-dark);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 6px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.nav-submenu a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  color: #C9D4C0;
}
.nav-submenu a:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}
.nav-submenu a.active {
  background: var(--sprout);
  color: var(--leaf-dark);
  font-weight: 600;
}

/* Content */
.content {
  flex: 1;
  padding: 32px 40px;
  max-width: 1200px;
}

/* Mobile top bar — hidden on desktop; shown at <=900px (see media query
   below), replacing the sidebar so navigation is always reachable. */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  background: var(--leaf-dark);
  color: #fff;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 120;
}
.mobile-topbar .brand-name { color: #fff; font-family: "Fraunces", serif; font-weight: 600; font-size: 16px; }
.hamburger-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.12); }
.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  position: absolute;
  top: 20px;
  right: 14px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header p.subtitle { color: var(--ink-soft); margin: 4px 0 0 0; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 7px;
  background: var(--leaf);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--leaf-dark); text-decoration: none; }
.btn-secondary { background: var(--sand); color: var(--ink); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: #fff; color: var(--rust); border: 1px solid var(--rust); }
.btn-danger:hover { background: var(--rust); color: #fff; }
.btn-small { padding: 5px 10px; font-size: 12.5px; }

/* Cards / panels */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  overflow-x: auto;
}
.grid {
  display: grid;
  gap: 16px;
}
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .mobile-topbar { display: flex; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close-btn { display: block; }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 150;
  }
  .sidebar-backdrop.open { display: block; }

  .content { padding: 20px 16px 40px 16px; }
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.stat .stat-label { font-size: 12.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
.stat .stat-value { font-family: "Fraunces", serif; font-size: 28px; color: var(--leaf-dark); margin-top: 4px; }
.stat.warn .stat-value { color: var(--rust); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
th { color: var(--ink-soft); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: var(--sand); }

/* Forms */
.form-row { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--sprout);
  outline-offset: 1px;
  border-color: var(--leaf);
}
textarea { min-height: 70px; resize: vertical; }
.search-box { width: 220px; max-width: 100%; }

/* Flash */
.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  animation: toast-in 0.2s ease;
}
.toast.toast-hide { animation: toast-out 0.18s ease forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(24px); }
}
.toast-success { background: #E4F1DD; color: var(--leaf-dark); }
.toast-danger { background: #F6DAD2; color: var(--rust); }
.toast-body { flex: 1; }
.toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0;
}
.toast-close:hover { opacity: 1; }
@media (max-width: 900px) {
  .toast-stack { left: 16px; right: 16px; max-width: none; top: 70px; }
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-seeded { background: #EAE3D4; color: var(--soil); }
.badge-germinating { background: #F3EDCB; color: #8A7A1E; }
.badge-growing { background: #DCEFCB; color: var(--leaf-dark); }
.badge-ready { background: var(--sprout); color: var(--leaf-dark); }
.badge-harvested { background: #DDE1D2; color: var(--ink-soft); }
.badge-overdue { background: #F6DAD2; color: var(--rust); }
.badge-blackout { background: var(--soil); color: #fff; }
.badge-pending { background: #F3EDCB; color: #8A7A1E; }
.badge-fulfilled { background: var(--sprout); color: var(--leaf-dark); }
.badge-cancelled { background: #DDE1D2; color: var(--ink-soft); }
.badge-type { background: var(--sand); color: var(--soil); }
.badge-type-microgreen { background: #DCEFCB; color: var(--leaf-dark); }
.badge-type-market-garden { background: #F3EDCB; color: #8A7A1E; }
.badge-type-hydroponic { background: #D6E8F0; color: #285C77; }
.badge-type-other { background: var(--sand); color: var(--soil); }
.badge-type-packaging { background: #EFE0F7; color: #6B3FA0; }
.badge-type-growing-medium { background: #E4D4BE; color: #6B4A2A; }
.badge-tracked { background: #E4F1DD; color: var(--leaf-dark); }
.badge-not-tracked { background: var(--sand); color: var(--ink-soft); }

.type-section-row td { padding: 14px 12px 6px 12px; border-bottom: 2px solid var(--border, #ddd6c8); }
.type-section-heading { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft, #6b6558); }
.variety-sub-row { display: none; background: var(--sand, #f7f4ee); }
.variety-toggle-btn {
  background: none; border: none; cursor: pointer; padding: 2px 0;
  font-size: 12.5px; color: var(--ink-soft, #6b6558);
}
.variety-toggle-btn:hover { text-decoration: underline; }
/* Small leading icon on status badges — color alone isn't enough to scan
   quickly (or accessible), so these carry a shape too. */
.badge::before { margin-right: 4px; }
.badge-seeded::before { content: "●"; }
.badge-germinating::before { content: "◐"; }
.badge-growing::before { content: "↑"; }
.badge-ready::before { content: "✓"; }
.badge-harvested::before { content: "✂"; }
.badge-overdue::before { content: "⚠"; }
.badge-pending::before { content: "◐"; }
.badge-fulfilled::before { content: "✓"; }
.badge-cancelled::before { content: "✕"; }

/* Stage tracker (signature element) */
.stage-track {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 10px 0;
}
.stage-seg {
  flex: 1;
  height: 6px;
  background: var(--border);
  position: relative;
}
.stage-seg:first-child { border-radius: 4px 0 0 4px; }
.stage-seg:last-child { border-radius: 0 4px 4px 0; }
.stage-seg.done { background: var(--leaf); }
.stage-seg.current { background: var(--sprout); }
.stage-seg.overdue { background: var(--rust); }
.stage-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-soft);
}
.empty-state-icon {
  font-size: 32px;
  margin-bottom: 10px;
  opacity: 0.6;
}

.tray-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 12px;
}
.tray-card.overdue { border-color: var(--rust); background: #FDF4F1; }
.tray-card-head { display: flex; justify-content: space-between; align-items: center; }

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--soil);
  margin: 28px 0 10px 0;
  font-weight: 700;
}
.section-title:first-child { margin-top: 0; }

.actions-row { display: flex; gap: 8px; align-items: center; }
.text-muted { color: var(--ink-soft); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.item-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1.4fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 10px; }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(30, 42, 31, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px 28px;
  width: 90%;
  max-width: 440px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.modal-box h3 {
  margin-bottom: 16px;
}

/* Margin % pills */
.margin-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 12.5px;
}
.margin-great { background: #DCEFCB; color: #1E4029; }
.margin-good { background: #F3EDCB; color: #8A7A1E; }
.margin-ok { background: #F6DAD2; color: #B4482E; }
.margin-bad { background: #B4482E; color: #fff; }

/* Floating assistant widget */
#assistant-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
}
#assistant-toggle {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--leaf-dark);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}
#assistant-toggle:hover {
  background: var(--leaf);
}
#assistant-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--rust);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
#assistant-panel {
  display: none;
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 320px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.25);
}
#assistant-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--leaf-dark);
  font-family: "Fraunces", Georgia, serif;
}
#assistant-close {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-soft);
}
#assistant-panel-body {
  padding: 8px;
}
.assistant-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13.5px;
  margin-bottom: 4px;
}
.assistant-tip:hover {
  background: var(--sand);
  text-decoration: none;
}
.assistant-tip-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.assistant-tip-warn {
  background: #F6DAD2;
}
.assistant-tip-warn:hover {
  background: #F0C8BC;
}
.assistant-tip-ok {
  color: var(--ink-soft);
}
