/* ============================================================
   Variables
   ============================================================ */
:root {
  --bg: #f0f4ec;
  --card: #ffffff;
  --text: #1f2a1f;
  --muted: #6b7d6b;
  --accent: #2d6a35;
  --accent-hover: #235429;
  --border: #d4dfd0;
  --danger: #c0392b;
  --danger-hover: #962d22;
  --radius: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}

/* ============================================================
   Header & Tabs
   ============================================================ */
.app-header {
  background: var(--accent);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.header-inner {
  max-width: 1020px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.header-inner h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab-btn {
  background: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.88);
  border: none;
  padding: 7px 18px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  color: white;
}

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

.btn-logout {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.88);
  border: 1px solid rgba(255,255,255,0.28);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  transition: all 0.15s;
}
.btn-logout:hover { background: rgba(255,255,255,0.25); color: white; }

/* ============================================================
   Layout
   ============================================================ */
.container {
  max-width: 1020px;
  margin: 0 auto;
  padding: 22px 16px 60px;
}

.tab-panel { display: block; }
.tab-panel.hidden { display: none; }
.hidden { display: none !important; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: border-color 0.15s;
}
.btn-secondary:hover { border-color: #999; }

.btn-sm {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.btn-sm:hover { border-color: #aaa; background: #fafafa; }

.btn-sm.btn-card-water { border-color: #90c4dc; color: #1a6d96; }
.btn-sm.btn-card-water:hover { background: #eaf5fb; }
.btn-sm.btn-card-note { border-color: #b8a8d8; color: #5a3fa0; }
.btn-sm.btn-card-note:hover { background: #f3f0fa; }
.btn-sm.btn-card-view { border-color: #98c898; color: var(--accent); }
.btn-sm.btn-card-view:hover { background: #eef6ee; }
.btn-sm.btn-danger { border-color: #e8b0a8; color: var(--danger); }
.btn-sm.btn-danger:hover { background: #fdf0ee; }

.log-entry-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.btn-edit-log {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 7px;
  font-size: 0.78rem;
  font-family: inherit;
  border-radius: 4px;
  line-height: 1;
}
.btn-edit-log:hover { color: var(--accent); background: #eef6ee; }

.btn-del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.78rem;
  border-radius: 4px;
  font-family: inherit;
  line-height: 1;
  margin-left: auto;
}
.btn-del:hover { color: var(--danger); background: #fdf0ee; }

/* ============================================================
   Quick action buttons (top of dashboard)
   ============================================================ */
.quick-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.btn-quick {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-quick:hover { opacity: 0.88; }
.btn-quick:active { transform: scale(0.97); }
.btn-quick.btn-rain { background: #3680b8; color: white; }
.btn-quick.btn-water-all { background: #2d9e6e; color: white; }

/* ============================================================
   Stats bar
   ============================================================ */
.stats-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.stat {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  flex: 1;
  min-width: 130px;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================================
   Dashboard filter bar
   ============================================================ */
.dashboard-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: white;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s;
}
.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.filter-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 600;
}

/* ============================================================
   Plant card grid
   ============================================================ */
.plants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.plant-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow 0.15s;
}
.plant-card:hover { box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08); }

.plant-card.plant-dead {
  background: #f5f5f4;
  border-color: #d1d5db;
  opacity: 0.82;
}
.plant-card.plant-dead .plant-card-name { color: var(--muted); }
.plant-card.plant-dead .plant-card-sub  { color: #9ca3af; }

.plant-died-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: #e5e7eb;
  color: #6b7280;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.plant-row.plant-dead .plant-row-head { color: var(--muted); }
.plant-row.plant-dead .plant-row-head:hover { background: #f9fafb; }

.btn-sm.btn-died   { border-color: #e8b0a8; color: var(--danger); }
.btn-sm.btn-died:hover { background: #fdf0ee; }
.btn-sm.btn-restore { border-color: #90c4dc; color: #1a6d96; }
.btn-sm.btn-restore:hover { background: #eaf5fb; }

.modal-plant-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   Date prompt dialog
   ============================================================ */
.date-prompt-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.date-prompt {
  background: white;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.date-prompt p {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text);
}

.date-prompt input[type="date"] {
  font: inherit;
  font-size: 0.92rem;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
  margin-bottom: 14px;
}

.date-prompt input[type="date"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.date-prompt-actions {
  display: flex;
  gap: 8px;
}

/* ============================================================
   Share / view-only mode — hide all edit controls
   ============================================================ */
.share-mode .quick-actions,
.share-mode #add-plant-btn,
.share-mode .row-actions,
.share-mode .btn-card-water,
.share-mode .btn-card-note,
.share-mode .btn-restore,
.share-mode .section-header,
.share-mode .log-entry-actions,
.share-mode .modal-plant-actions,
.share-mode .btn-logout { display: none !important; }

/* Category color accents — left border per plant type */
.card-cat-tomato   { border-left: 4px solid #d94f4f; }
.card-cat-pepper   { border-left: 4px solid #c0392b; }
.card-cat-cucumber { border-left: 4px solid #27ae60; }
.card-cat-herb     { border-left: 4px solid #7ec850; }
.card-cat-squash   { border-left: 4px solid #e0b831; }
.card-cat-beans    { border-left: 4px solid #e07840; }
.card-cat-lettuce  { border-left: 4px solid #2fb08a; }
.card-cat-root     { border-left: 4px solid #c4975a; }
.card-cat-corn     { border-left: 4px solid #e8c94a; }
.card-cat-eggplant { border-left: 4px solid #8b4ec2; }
.card-cat-melon    { border-left: 4px solid #e8834a; }
.card-cat-berries  { border-left: 4px solid #a84ec2; }
.card-cat-flowers  { border-left: 4px solid #e06fa0; }
.card-cat-other    { border-left: 4px solid #8c9e8c; }

.plant-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.plant-card-name {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}
.plant-card-name .variety {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.95rem;
}

.plant-card-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.plant-loc {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.water-status {
  font-size: 0.82rem;
  color: var(--muted);
}
.water-status.overdue {
  color: var(--danger);
  font-weight: 500;
}

.plant-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

/* ============================================================
   Status badges
   ============================================================ */
.status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.s-seedling  { background: #e0f2fe; color: #0369a1; }
.s-growing   { background: #dcfce7; color: #166534; }
.s-producing { background: #fef9c3; color: #854d0e; }
.s-struggling{ background: #fee2e2; color: #991b1b; }
.s-harvested { background: #f5f0e8; color: #78492a; }
.s-dormant   { background: #f4f4f5; color: #52525b; }

/* ============================================================
   Type badges (log event types)
   ============================================================ */
.type-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.t-water         { background: #dbeafe; color: #1d4ed8; }
.t-rain          { background: #e0f2fe; color: #0369a1; }
.t-fertilize     { background: #fef3c7; color: #92400e; }
.t-observation   { background: #ede9fe; color: #5b21b6; }
.t-harvest       { background: #dcfce7; color: #166534; }
.t-treatment     { background: #fee2e2; color: #991b1b; }
.t-first_flowers { background: #fdf4ff; color: #7e22ce; }
.t-first_fruit   { background: #fff7ed; color: #c2410c; }
.t-harvest_start { background: #f0fdf4; color: #15803d; }
.t-height        { background: #f8fafc; color: #475569; }
.t-died          { background: #374151; color: #f9fafb; }

/* ============================================================
   Category details
   ============================================================ */
.cat-details {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 8px;
}
.cat-item {
  font-size: 0.86rem;
  white-space: nowrap;
}
.plant-card-sub {
  font-size: 1.05rem;
  color: var(--accent);
  font-weight: 600;
  line-height: 1.3;
}
.plant-row-sub {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 500;
}

/* ============================================================
   Growth milestones
   ============================================================ */
.milestones {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.milestone-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  flex-wrap: wrap;
}
.milestone-row.achieved { background: #f4fbf4; }
.milestone-row.pending  { background: #fafafa; }
.milestone-row.height-row { background: #f8fafc; }

.milestone-dot {
  font-size: 0.8rem;
  width: 16px;
  flex-shrink: 0;
  color: var(--muted);
}
.milestone-row.achieved .milestone-dot { color: var(--accent); }

.milestone-label {
  font-weight: 600;
  min-width: 120px;
  flex-shrink: 0;
}

.milestone-date { color: var(--text); }

.milestone-days {
  color: var(--muted);
  font-size: 0.8rem;
  font-style: italic;
}

.milestone-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.milestone-pending {
  color: var(--muted);
  font-style: italic;
}

.height-history {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  font-size: 0.84rem;
}

.height-entry {
  white-space: nowrap;
}

.plant-milestones {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-bottom: 14px;
}
.plant-milestones > strong {
  font-size: 0.88rem;
  display: block;
  margin-bottom: 8px;
}

.card-height {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ============================================================
   Section header
   ============================================================ */
.section-header {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

/* ============================================================
   Form card
   ============================================================ */
.form-card { margin-bottom: 20px; }
.form-card h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text);
}
.form-grid label.full { grid-column: 1 / -1; }

.form-grid input,
.form-grid textarea,
.form-grid select {
  font: inherit;
  font-size: 0.92rem;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  width: 100%;
  transition: border-color 0.15s, outline 0.15s;
}
.form-grid input:focus,
.form-grid textarea:focus,
.form-grid select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ============================================================
   Plant rows (Plants tab)
   ============================================================ */
.plant-row {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
}

.plant-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}
.plant-row-head:hover { background: #f7faf5; }

.plant-row-name { flex: 1; }
.plant-row-name .muted { font-size: 0.88rem; }

.expand-arrow {
  color: var(--muted);
  font-size: 0.72rem;
  flex-shrink: 0;
}

.plant-row-body {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--border);
}

.row-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 14px 0;
}
@media (max-width: 620px) {
  .row-detail-grid { grid-template-columns: 1fr; }
}
.row-detail-grid p {
  font-size: 0.88rem;
  margin-bottom: 6px;
}

.care-box {
  background: #f7faf5;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.84rem;
  line-height: 1.65;
  max-height: 220px;
  overflow-y: auto;
}

.plant-history {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.plant-history > strong {
  font-size: 0.88rem;
  display: block;
  margin-bottom: 8px;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.history-list li {
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.log-date-sm { color: var(--muted); min-width: 108px; font-size: 0.82rem; }
.log-amt { color: var(--muted); font-size: 0.8rem; }
.log-note-sm { color: var(--text); font-size: 0.84rem; }

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ============================================================
   Journal filters
   ============================================================ */
.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.filters select {
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  min-width: 120px;
}

/* ============================================================
   Plant picker (pill buttons)
   ============================================================ */
.plant-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.pick-pill {
  padding: 5px 13px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: white;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s;
  white-space: nowrap;
}
.pick-pill:hover { border-color: var(--accent); color: var(--accent); }
.pick-pill.selected { background: var(--accent); color: white; border-color: var(--accent); font-weight: 500; }
.pick-pill[data-id="all"] { font-weight: 600; }

/* ============================================================
   Log entries
   ============================================================ */
.log-entry {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 8px;
}

.log-entry-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.log-date {
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 110px;
}

.log-plants {
  color: var(--muted);
  font-size: 0.84rem;
  flex: 1;
}

.log-amount {
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 5px;
}

.log-notes {
  font-size: 0.9rem;
  margin-top: 6px;
  line-height: 1.55;
}

/* ============================================================
   Empty states
   ============================================================ */
.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 48px 24px;
  font-size: 0.95rem;
  line-height: 1.7;
}

.muted { color: var(--muted); font-size: 0.88rem; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 660px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.modal-header h2 {
  font-size: 1.25rem;
  margin-bottom: 6px;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
  line-height: 1;
  flex-shrink: 0;
}
.modal-close-btn:hover { color: var(--text); background: #f0f0f0; }

.modal-body {
  padding: 20px 24px 24px;
}

.modal-section {
  margin-bottom: 22px;
}
.modal-section:last-child { margin-bottom: 0; }

.modal-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.modal-section-header h3 {
  margin-bottom: 0;
}

.modal-section h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 600;
}

.modal-section p {
  font-size: 0.9rem;
  margin-bottom: 5px;
}
