/* ============================================================
   PLANT DOCTOR — The Balcony Project
   Clean light theme — consistent contrast throughout
   ============================================================ */

:root {
  /* Backgrounds */
  --bg:            #f2f7ec;
  --bg-soft:       #e6f0db;
  --surface:       #ffffff;
  --surface-soft:  #f8faf5;
  --surface-hover: #eef5e6;

  /* Borders */
  --line:          rgba(45, 80, 22, 0.14);
  --line-strong:   rgba(45, 80, 22, 0.22);

  /* Text */
  --text:          #1a2e10;
  --text-secondary:#3b5428;
  --muted:         #5a7245;
  --muted-light:   #7a9460;
  --placeholder:   #9aae85;

  /* Brand */
  --green:         #3a7020;
  --green-dark:    #2D5016;
  --green-mid:     #4A7C23;
  --green-pale:    #d4e8c0;
  --gold:          #b8913a;
  --gold-light:    #d4a84b;
  --gold-bg:       #fdf5e4;
  --gold-border:   #e8c87a;

  /* Semantic */
  --warning-bg:    #fdf5e4;
  --warning-border:#d4a84b;
  --warning-text:  #7a5a10;
  --success-bg:    #e8f5e0;
  --success-border:#66aa44;
  --success-text:  #2a5a18;

  /* Topbar (dark — intentional brand anchor) */
  --topbar-bg:     #1e3a10;
  --topbar-text:   #e8f5e0;
  --topbar-muted:  rgba(232,245,224,0.65);
  --topbar-border: rgba(255,255,255,0.10);

  /* Shadows */
  --shadow-sm:     0 2px 8px rgba(45,80,22,0.08);
  --shadow-md:     0 6px 24px rgba(45,80,22,0.10);
  --shadow-lg:     0 16px 48px rgba(45,80,22,0.12);

  /* Radii */
  --radius-lg:     24px;
  --radius-md:     18px;
  --radius-sm:     12px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }

body {
  font-family: 'Poppins', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 10% 20%, rgba(74,124,35,0.06) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(197,162,83,0.05) 0%, transparent 35%);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-mid); }
img { max-width: 100%; display: block; }
button, input { font: inherit; }
ul { list-style: none; padding: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.hidden { display: none !important; }

/* ── Shell ──────────────────────────────────────────────────── */
.pd-shell {
  width: min(1400px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 40px;
}

/* ── Top Bar ────────────────────────────────────────────────── */
.pd-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 20px;
  margin-bottom: 20px;
  border-radius: 20px;
  background: var(--topbar-bg);
  border: 1px solid var(--topbar-border);
  box-shadow: var(--shadow-lg);
}

.pd-brand-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.pd-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--topbar-text);
}

.pd-brand img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 16px;
  background: rgba(255,255,255,0.08);
  padding: 8px;
  /* Logo is dark green — invert to white on the dark topbar */
  filter: brightness(0) invert(1);
  opacity: 0.9;
}

.pd-brand strong {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  line-height: 1.1;
  color: var(--topbar-text);
}

.pd-brand-eyebrow,
.eyebrow {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--topbar-muted);
}

/* Eyebrow inside light content panels */
.pd-panel-head .eyebrow,
.card .eyebrow {
  color: var(--muted);
}

.pd-site-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--topbar-text);
  background: rgba(255,255,255,0.06);
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s;
}

.pd-site-link:hover {
  background: rgba(255,255,255,0.14);
  color: var(--topbar-text);
  transform: translateY(-1px);
}

/* ── Search ─────────────────────────────────────────────────── */
.pd-search-wrap {
  min-width: min(420px, 100%);
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.pd-search-wrap input {
  width: min(100%, 460px);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  padding: 0.75rem 1.2rem;
  color: var(--topbar-text);
  background: rgba(255,255,255,0.08);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.pd-search-wrap input::placeholder { color: var(--topbar-muted); }
.pd-search-wrap input:focus {
  border-color: var(--green-pale);
  box-shadow: 0 0 0 3px rgba(74,124,35,0.22);
}

/* ── Layout ─────────────────────────────────────────────────── */
.pd-layout {
  display: grid;
  grid-template-columns: minmax(270px, 310px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

/* ── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ── Sidebar ────────────────────────────────────────────────── */
.pd-sidebar {
  padding: 18px;
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 116px);
  overflow: hidden;
}

.pd-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.pd-panel-head h2,
.pd-panel-head h1,
.card h1,
.card h2,
.card h3 {
  font-family: 'Playfair Display', serif;
  color: var(--text);
}

.pd-panel-head h2 {
  margin: 0.1rem 0 0;
  font-size: clamp(1.3rem, 2vw, 1.7rem);
}

/* ── Pills ──────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--surface-soft);
  color: var(--text-secondary);
}

.pill.subtle { color: var(--muted); }

.pill.active {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
  font-weight: 600;
}

.pill.warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
  font-weight: 600;
}

/* ── Plant List ─────────────────────────────────────────────── */
.plant-list {
  display: grid;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  max-height: calc(100vh - 200px);
  scrollbar-width: thin;
  scrollbar-color: var(--green-pale) transparent;
}

.plant-list::-webkit-scrollbar { width: 4px; }
.plant-list::-webkit-scrollbar-thumb {
  background: var(--green-pale);
  border-radius: 4px;
}

.plant-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.plant-card:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.plant-card.is-active {
  background: var(--success-bg);
  border-color: var(--success-border);
  box-shadow: 0 2px 12px rgba(74,124,35,0.14);
}

.plant-card img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--bg-soft);
}

.plant-card strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.plant-card span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 2px;
}

/* ── Main Panel ─────────────────────────────────────────────── */
.pd-main { display: grid; gap: 18px; }

/* ── Status / Loading Card ──────────────────────────────────── */
.status-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 28px 24px;
}

.status-card h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: var(--text);
  margin-bottom: 4px;
}

.status-card p { color: var(--muted); margin: 0; }

.spinner {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 3px solid var(--bg-soft);
  border-top-color: var(--green);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Plant Overview ─────────────────────────────────────────── */
.plant-overview { padding: 24px; }

.plant-hero {
  display: grid;
  grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
}

.plant-hero-media {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: var(--bg-soft);
  min-height: 220px;
}

.plant-hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.plant-hero-body {
  display: grid;
  gap: 14px;
  align-content: start;
}

.plant-hero-body h1,
.plant-hero-body h2 {
  font-family: 'Playfair Display', serif;
  color: var(--text);
  margin-bottom: 2px;
}

.plant-hero-body p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.72;
}

/* ── Meta Grid ──────────────────────────────────────────────── */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.meta-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.meta-card h3 {
  font-family: 'Playfair Display', serif;
  font-size: 0.97rem;
  color: var(--text);
  margin: 0 0 0.5rem;
}

.meta-card p,
.meta-card li {
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.6;
  font-size: 0.9rem;
}

.meta-card ul { padding-left: 1rem; list-style: disc; }

/* ── Symptom Selector ───────────────────────────────────────── */
.symptom-wrap,
.results-wrap {
  padding: 22px 24px;
}

.symptom-wrap h2,
.results-wrap h2 {
  font-family: 'Playfair Display', serif;
  color: var(--text);
  margin-bottom: 4px;
}

.symptom-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.symptom-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.symptom-chip {
  border: 1.5px solid var(--line-strong);
  background: var(--surface-soft);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.15s;
}

.symptom-chip:hover {
  background: var(--surface-hover);
  border-color: var(--green-mid);
  color: var(--text);
  transform: translateY(-1px);
}

.symptom-chip.active {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
  font-weight: 600;
}

/* ── Problem Cards ──────────────────────────────────────────── */
.problem-grid { display: grid; gap: 16px; }

.problem-card {
  padding: 20px;
  border-radius: 20px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  transition: box-shadow 0.2s;
}

.problem-card:hover { box-shadow: var(--shadow-sm); }

.problem-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.problem-head h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  color: var(--text);
  margin: 0;
}

.problem-meta,
.inline-pills,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.problem-card p,
.problem-card li,
.empty-state p {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 0.92rem;
}

.problem-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.problem-section {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
}

.problem-section h4 {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
}

.problem-section ul {
  padding-left: 1.1rem;
  list-style: disc;
}

.problem-section li {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.6;
  margin-bottom: 0.25rem;
}

/* ── Empty State ────────────────────────────────────────────── */
.empty-state { padding: 8px 4px; }
.empty-state p { color: var(--muted); }

/* ── Notice ─────────────────────────────────────────────────── */
.notice {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 0.9rem;
  line-height: 1.65;
}

/* ── Buttons ────────────────────────────────────────────────── */
.primary-button,
.ghost-button,
.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
  border: none;
}

.primary-button {
  background: linear-gradient(160deg, var(--green-mid) 0%, var(--green-dark) 100%);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(45,80,22,0.25);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 18px rgba(45,80,22,0.32);
  color: #ffffff;
}

.ghost-button {
  background: var(--surface-soft);
  border: 1.5px solid var(--line-strong) !important;
  color: var(--text-secondary);
}

.ghost-button:hover {
  background: var(--surface-hover);
  border-color: var(--green-mid) !important;
  color: var(--text);
  transform: translateY(-1px);
}

.action-link {
  background: transparent;
  border: 1.5px solid var(--line-strong) !important;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.action-link:hover {
  background: var(--surface-hover);
  border-color: var(--green) !important;
  color: var(--green-dark);
  transform: translateY(-1px);
}

/* ── Selected Plant Bar (collapsed sidebar state) ──────────── */
.selected-plant-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  margin-bottom: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.18s, box-shadow 0.18s;
}
.selected-plant-bar:hover {
  background: #d6efca;
  box-shadow: var(--shadow-sm);
}
.selected-plant-bar img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
  background: var(--bg-soft);
}
.selected-plant-text {
  flex: 1;
  min-width: 0;
}
.selected-plant-text strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.selected-plant-text span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
}
.selected-plant-bar svg {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.2s;
}
.selected-plant-bar:hover svg {
  transform: translateY(2px);
}

/* When a plant is selected: hide the full list and search, show compact bar */
.plant-selected .plant-list,
.plant-selected .pd-panel-head .pill,
.plant-selected .pd-search-wrap {
  display: none;
}

/* On desktop (sidebar visible as column), keep list accessible */
@media (min-width: 1081px) {
  .plant-selected .plant-list {
    display: grid;
  }
  .plant-selected .pd-search-wrap {
    display: flex;
  }
  .plant-selected .pd-panel-head .pill {
    display: inline-flex;
  }
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .pd-layout { grid-template-columns: 1fr; }
  .pd-sidebar { position: static; max-height: none; overflow: visible; }
  .plant-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 820px) {
  .pd-shell { width: calc(100% - 16px); padding-top: 8px; }
  .pd-topbar {
    position: static;
    padding: 14px 16px;
    border-radius: 18px;
    flex-direction: column;
    align-items: stretch;
  }
  .pd-brand-wrap { flex-direction: column; align-items: stretch; }
  .pd-search-wrap { min-width: 0; justify-content: stretch; }
  .pd-search-wrap input { width: 100%; }
  .plant-hero { grid-template-columns: 1fr; }
  .plant-hero-media { min-height: 200px; max-height: 280px; }
  .problem-columns,
  .meta-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .plant-list { grid-template-columns: 1fr; }
  .card, .pd-topbar { border-radius: 18px; }
  .problem-card, .problem-section, .meta-card, .plant-card { border-radius: 14px; }
  .pd-brand strong { font-size: 1.15rem; }
  .primary-button, .ghost-button { width: 100%; }
  .symptom-wrap, .results-wrap, .plant-overview { padding: 18px 16px; }
}
