/* ============================================================
   Owner Zone Dashboard — overview of all 6 zones + mushroom tent
   Owner sees: zone state, crew assignments, alerts, tomorrow's prep
   Uses admin.css variables — standalone dark/gold luxury theme
   ============================================================ */

:root {
  --gold:       #c8933f;
  --gold-light: #e8b96a;
  --gold-dim:   #9a6e2e;
  --dark:       #0e1a0f;
  --dark-2:     #162016;
  --dark-3:     #1e2e1c;
  --green:      #2d5743;
  --green-lt:   #3a7058;
  --cream:      #f5f0e8;
  --muted:      #8a9e89;
  --border:     rgba(200,147,63,0.18);
  --c-alert:    #c83a3a;
  --c-warn:     #c8933f;
  --c-ok:       #2d8a5e;
  --card-bg:    #121c12;
  --card-border: rgba(200,147,63,0.12);
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--dark);
  color: var(--cream);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: 'Playfair Display', serif; }
a { color: var(--gold); text-decoration: none; }
.gold { color: var(--gold); }
.muted { color: var(--muted); }

/* ---- Header ---- */
.owner-header {
  background: var(--dark-2);
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-left .brand {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  color: var(--gold);
}
.header-left .subtitle { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.72rem; color: #6bc98a;
  background: rgba(107,201,138,0.12);
  border: 1px solid rgba(107,201,138,0.25);
  padding: 3px 10px; border-radius: 12px;
}
.live-dot-sm {
  width: 6px; height: 6px; border-radius: 50%;
  background: #6bc98a; animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:0.4 } }

.btn-ghost {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--dark-3);
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn-primary {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: var(--green);
  color: var(--cream);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}
.btn-primary:hover { background: var(--green-lt); }

/* ---- Page layout ---- */
.owner-page { padding: 20px 24px; max-width: 1200px; margin: 0 auto; }

/* ---- Alert feed ---- */
.alert-banner {
  background: rgba(200,58,58,0.1);
  border: 1px solid rgba(200,58,58,0.3);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
  display: none;
}
.alert-banner.has-alerts { display: block; }
.alert-banner-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.alert-banner-header strong { font-size: 0.88rem; color: #f08080; }
.alert-feed { display: flex; flex-direction: column; gap: 8px; }
.alert-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: rgba(200,58,58,0.08);
  border-radius: 8px;
  border-left: 3px solid var(--c-alert);
}
.alert-icon { font-size: 1rem; }
.alert-body { flex: 1; }
.alert-title { font-size: 0.85rem; font-weight: 500; }
.alert-meta { font-size: 0.72rem; color: var(--muted); }
.alert-time { font-size: 0.7rem; color: var(--muted); white-space: nowrap; }
.alert-dismiss-btn {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.85rem;
}
.alert-dismiss-btn:hover { color: #f08080; }

/* ---- Stats strip ---- */
.owner-stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}
.owner-stat {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
}
.owner-stat-val {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--gold);
  line-height: 1;
}
.owner-stat-lbl { font-size: 0.68rem; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ---- Zone grid ---- */
.zones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.zone-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 18px;
  transition: border-color 0.2s;
}
.zone-card:hover { border-color: rgba(200,147,63,0.3); }
.zone-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.zone-id-lg {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: var(--gold);
}
.zone-type-badge {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--dark-3);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.zone-next-harvest {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.zone-next-harvest span { color: var(--gold-light); font-weight: 500; }

/* Occupancy bar */
.occ-bar-wrap { margin-bottom: 12px; }
.occ-bar-label { font-size: 0.72rem; color: var(--muted); margin-bottom: 4px; display: flex; justify-content: space-between; }
.occ-bar { height: 8px; background: var(--dark-3); border-radius: 4px; overflow: hidden; }
.occ-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.occ-fill.idle  { background: var(--muted); }
.occ-fill.planted { background: #4a8f5c; }
.occ-fill.growing { background: var(--green); }
.occ-fill.ready  { background: var(--gold); }

/* Stage breakdown */
.zone-stages { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.stage-chip {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 500;
}
.stage-chip.germ { background: rgba(74,143,92,0.3); color: #6bc98a; }
.stage-chip.grow { background: rgba(45,87,67,0.35); color: #7fd4a0; }
.stage-chip.ready { background: rgba(200,147,63,0.3); color: var(--gold-light); }
.stage-chip.idle-chip { background: rgba(138,158,137,0.15); color: var(--muted); }

/* Zone tasks mini */
.zone-task-mini {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 6px 10px;
  background: var(--dark-3);
  border-radius: 6px;
  border-left: 2px solid var(--gold);
  margin-top: 8px;
}
.zone-task-mini strong { color: var(--gold-light); }

/* ---- Tasks section ---- */
.section-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.section-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 20px;
}
.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  color: var(--gold);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title span.count {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: normal;
}

/* Today tasks */
.owner-task-list { display: flex; flex-direction: column; gap: 8px; }
.owner-task-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--dark-3);
  border-radius: 8px;
  border-left: 3px solid var(--gold);
}
.owner-task-item.urgent { border-left-color: var(--c-alert); }
.task-type-icon { font-size: 1rem; }
.task-info { flex: 1; }
.task-info-desc { font-size: 0.88rem; font-weight: 500; }
.task-info-meta { font-size: 0.72rem; color: var(--muted); }
.task-crew-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(200,147,63,0.15);
  color: var(--gold-light);
}
.task-time-badge { font-size: 0.7rem; color: var(--muted); }

/* Tomorrow preview */
.tomorrow-list { display: flex; flex-direction: column; gap: 8px; }
.tomorrow-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--dark-3);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.tomorrow-item strong { color: var(--cream); margin-right: 4px; }
.tomorrow-empty { text-align: center; padding: 24px; color: var(--muted); font-size: 0.88rem; }

/* ---- Completed log ---- */
.completed-log { display: flex; flex-direction: column; gap: 6px; }
.log-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  border-left: 2px solid var(--green);
}
.log-item strong { color: var(--cream); }
.log-time { margin-left: auto; font-size: 0.72rem; }

/* ---- Generate AI tasks button ---- */
.ai-generate-section {
  margin-bottom: 24px;
}
.ai-generate-card {
  background: rgba(200,147,63,0.06);
  border: 1px solid rgba(200,147,63,0.25);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.ai-icon { font-size: 1.5rem; }
.ai-text { flex: 1; }
.ai-text strong { font-size: 0.9rem; color: var(--gold); display: block; margin-bottom: 2px; }
.ai-text span { font-size: 0.78rem; color: var(--muted); }
.btn-generate {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: var(--dark);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
}
.btn-generate:hover { background: linear-gradient(135deg, var(--gold-light), var(--gold)); }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Run history ---- */
.run-history { margin-top: 16px; }
.run-history-title { font-size: 0.78rem; color: var(--muted); margin-bottom: 8px; }
.run-list { display: flex; flex-direction: column; gap: 6px; }
.run-item {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 6px 10px;
  background: var(--dark-3);
  border-radius: 6px;
}
.run-date { color: var(--cream); font-weight: 500; min-width: 80px; }
.run-counts { color: var(--gold-light); }
.run-status { margin-left: auto; }
.run-status.ok { color: #6bc98a; }
.run-status.fail { color: #f08080; }

/* ---- Loading spinner ---- */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(200,147,63,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .owner-stats { grid-template-columns: repeat(3, 1fr); }
  .section-row { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .owner-stats { grid-template-columns: repeat(2, 1fr); }
  .owner-page { padding: 12px; }
  .zones-grid { grid-template-columns: 1fr; }
}

/* ---- Staple crops section ---- */
.section-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 12px 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.section-title-bar .section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  color: var(--gold);
  margin-bottom: 0;
}
.staple-task { border-left-color: var(--c-primary) !important; }

/* Status badge colors */
.status-badge.pending { background: rgba(200,147,63,0.2); color: var(--gold-light); }
.status-badge.completed { background: rgba(107,201,138,0.2); color: #6bc98a; }
.status-badge.skipped { background: rgba(138,158,137,0.15); color: var(--muted); }

/* --- c-primary color for staple (green) --- */
:root { --c-primary: #2d8a5e; --c-success: #6bc98a; }