/* =============================================================
   GrowDiary – Stylesheet
   Green / dark botanical theme
============================================================= */

:root {
  --gd-green:      #4caf50;
  --gd-green-dark: #388e3c;
  --gd-green-soft: #e8f5e9;
  --gd-amber:      #ff9800;
  --gd-red:        #e53935;
  --gd-surface:    #ffffff;
  --gd-surface-2:  #f5f8f5;
  --gd-border:     #d0e4d0;
  --gd-text:       #1e2b1e;
  --gd-muted:      #6a7f6a;
  --gd-radius:     12px;
  --gd-shadow:     0 4px 20px rgba(0,0,0,.10);
  --gd-font:       'Segoe UI', system-ui, sans-serif;
}

/* ---- Reset ---- */
#gd-app, #gd-view-app, #gd-community-app {
  font-family: var(--gd-font);
  color: var(--gd-text);
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ---- Header ---- */
.gd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}
.gd-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gd-green-dark);
}

/* ---- Buttons ---- */
.gd-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
  text-decoration: none;
}
.gd-btn:active { transform: scale(.97); }
.gd-btn-primary {
  background: var(--gd-green);
  color: #fff;
}
.gd-btn-primary:hover { background: var(--gd-green-dark); }
.gd-btn-danger {
  background: var(--gd-red);
  color: #fff;
}
.gd-btn-danger:hover { background: #b71c1c; }
.gd-btn-ghost {
  background: transparent;
  color: var(--gd-muted);
  border: 1px solid var(--gd-border);
}
.gd-btn-ghost:hover { background: var(--gd-surface-2); }
.gd-btn-sm {
  padding: 6px 12px;
  font-size: .82rem;
}

/* ---- Card grid ---- */
.gd-diary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 20px;
}
.gd-card {
  background: var(--gd-surface);
  border: 1px solid var(--gd-border);
  border-radius: var(--gd-radius);
  overflow: hidden;
  box-shadow: var(--gd-shadow);
  transition: transform .2s;
}
.gd-card:hover { transform: translateY(-3px); }

.gd-card-img {
  height: 160px;
  background-size: cover;
  background-position: center;
}
.gd-card-img--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  background: var(--gd-green-soft);
}

.gd-card-body { padding: 16px; }
.gd-card-title {
  margin: 8px 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
}
.gd-card-strain { color: var(--gd-muted); font-size: .88rem; margin: 0 0 8px; }
.gd-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: .82rem;
  color: var(--gd-muted);
  margin-bottom: 12px;
}
.gd-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---- Tags / badges ---- */
.gd-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.gd-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--gd-green-soft);
  color: var(--gd-green-dark);
}
.gd-tag--public  { background: #e3f2fd; color: #1565c0; }
.gd-tag--private { background: #fafafa; color: #757575; }
.gd-tag--status  { background: #fff8e1; color: #e65100; }

/* ---- Empty / notice ---- */
.gd-empty, .gd-loading, .gd-notice {
  grid-column: 1/-1;
  padding: 48px;
  text-align: center;
  color: var(--gd-muted);
  font-size: 1.1rem;
}
.gd-notice--error { color: var(--gd-red); }

/* ====================================================================
   MODALS
==================================================================== */
.gd-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gd-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
}
.gd-modal-box {
  position: relative;
  background: var(--gd-surface);
  border-radius: var(--gd-radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
  width: 90vw;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.gd-modal-box--wide { max-width: 900px; }
.gd-modal-box--sm   { max-width: 420px; }

.gd-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gd-border);
}
.gd-modal-header h2 { margin: 0; font-size: 1.2rem; }
.gd-modal-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--gd-muted);
  line-height: 1;
}
.gd-modal-body {
  padding: 20px 24px 24px;
  overflow-y: auto;
}

/* ====================================================================
   FORMS
==================================================================== */
.gd-form { display: flex; flex-direction: column; gap: 16px; }
.gd-form-row {
  display: grid;
  gap: 12px;
}
.gd-form-row--2 { grid-template-columns: repeat(2, 1fr); }
.gd-form-row--3 { grid-template-columns: repeat(3, 1fr); }
.gd-form-row--4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 600px) {
  .gd-form-row--2,
  .gd-form-row--3,
  .gd-form-row--4 { grid-template-columns: 1fr; }
}

.gd-field { display: flex; flex-direction: column; gap: 4px; }
.gd-field label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--gd-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.gd-field input,
.gd-field select,
.gd-field textarea {
  padding: 10px 12px;
  border: 1.5px solid var(--gd-border);
  border-radius: 8px;
  font-size: .95rem;
  font-family: inherit;
  background: var(--gd-surface-2);
  transition: border-color .15s;
}
.gd-field input:focus,
.gd-field select:focus,
.gd-field textarea:focus {
  outline: none;
  border-color: var(--gd-green);
  background: #fff;
}
.gd-form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 8px;
}
.gd-form-msg {
  font-size: .9rem;
  padding: 4px 0;
  display: none;
}

.gd-section-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gd-green-dark);
  border-bottom: 2px solid var(--gd-green-soft);
  padding-bottom: 4px;
  margin-top: 4px;
}

/* Image upload */
.gd-image-upload-row { display: flex; gap: 8px; }
.gd-image-upload-row input { flex: 1; }
.gd-img-preview { margin-top: 8px; }
.gd-img-preview img {
  max-height: 120px;
  border-radius: 8px;
  border: 1px solid var(--gd-border);
}

/* Week gallery */
.gd-image-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.gd-gallery-thumb {
  position: relative;
  width: 80px;
  height: 80px;
}
.gd-gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--gd-border);
}
.gd-remove-photo {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--gd-red);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: .85rem;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gd-no-photos { font-size: .85rem; color: var(--gd-muted); margin: 0; }

/* Star rating */
#gd-star-rating { display: flex; gap: 4px; cursor: pointer; font-size: 1.6rem; }
#gd-star-rating span { color: var(--gd-border); transition: color .1s; }
#gd-star-rating span.active { color: var(--gd-amber); }
.gd-stars { color: var(--gd-amber); font-size: .9rem; }

/* ====================================================================
   WEEK TABS
==================================================================== */
.gd-week-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--gd-green-soft);
}
.gd-week-tab {
  padding: 6px 10px;
  border: 1.5px solid var(--gd-border);
  border-radius: 6px;
  background: var(--gd-surface-2);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.gd-week-tab--filled {
  background: var(--gd-green-soft);
  border-color: var(--gd-green);
  color: var(--gd-green-dark);
}
.gd-week-tab--active {
  background: var(--gd-green) !important;
  border-color: var(--gd-green) !important;
  color: #fff !important;
}
.gd-week-tab:hover:not(.gd-week-tab--active) {
  background: var(--gd-green-soft);
  border-color: var(--gd-green);
}

/* ====================================================================
   VIEW DIARY – HERO
==================================================================== */
.gd-diary-hero {
  height: 320px;
  background: var(--gd-green-soft);
  background-size: cover;
  background-position: center;
  border-radius: var(--gd-radius);
  margin-bottom: 40px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.gd-diary-hero-overlay {
  width: 100%;
  padding: 24px 28px;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
}
.gd-diary-hero-info h1 { color: #fff; margin: 0 0 6px; font-size: 2rem; }
.gd-diary-hero-info p  { color: rgba(255,255,255,.8); margin: 0 0 8px; font-size: .95rem; }
.gd-diary-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ====================================================================
   TIMELINE
==================================================================== */
.gd-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}
.gd-timeline::before {
  content: '';
  position: absolute;
  left: 28px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--gd-green-soft);
  border-radius: 3px;
}

.gd-timeline-item {
  display: flex;
  gap: 20px;
  padding-bottom: 32px;
  position: relative;
}
.gd-timeline-badge {
  width: 56px;
  height: 56px;
  min-width: 56px;
  background: var(--gd-surface);
  border: 3px solid var(--gd-green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  z-index: 1;
  box-shadow: 0 2px 8px rgba(76,175,80,.2);
}

.gd-timeline-card {
  flex: 1;
  background: var(--gd-surface);
  border: 1px solid var(--gd-border);
  border-radius: var(--gd-radius);
  padding: 20px;
  box-shadow: var(--gd-shadow);
}

.gd-timeline-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.gd-timeline-week {
  font-weight: 700;
  font-size: 1rem;
  color: var(--gd-green-dark);
}

.gd-timeline-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.gd-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--gd-surface-2);
  border: 1px solid var(--gd-border);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 64px;
}
.gd-stat span { font-size: 1rem; margin-bottom: 2px; }
.gd-stat strong { font-size: .9rem; font-weight: 700; }
.gd-stat small { font-size: .7rem; color: var(--gd-muted); text-transform: uppercase; }

.gd-timeline-text { margin-bottom: 12px; }
.gd-timeline-text strong { display: block; font-size: .85rem; margin-bottom: 4px; }
.gd-timeline-text p { margin: 0; font-size: .93rem; line-height: 1.6; }
.gd-timeline-text--warn {
  background: #fff8e1;
  border-left: 3px solid var(--gd-amber);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
}

.gd-timeline-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.gd-timeline-img {
  height: 120px;
  width: 160px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--gd-border);
}

/* ====================================================================
   PAGINATION
==================================================================== */
.gd-pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 28px;
}

/* ====================================================================
   TEMPERATURE / HEIGHT UNIT TOGGLE BUTTONS
==================================================================== */
.gd-unit-toggle {
  background: #fff8e1;
  color: #e65100;
  border: 1.5px solid #ffcc80;
  font-weight: 700;
  letter-spacing: .02em;
}
.gd-unit-toggle:hover {
  background: #ffe0b2;
  border-color: #ff9800;
}
.gd-view-toggles {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ====================================================================
   LIGHTBOX
==================================================================== */
#gd-lightbox {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
}
#gd-lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.92);
  cursor: zoom-out;
}
#gd-lightbox-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
  max-height: 90vh;
}
#gd-lightbox-img {
  max-width: 88vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 48px rgba(0,0,0,.6);
  display: block;
}
#gd-lightbox-counter {
  color: rgba(255,255,255,.7);
  font-size: .85rem;
  margin-top: 10px;
  letter-spacing: .06em;
}
#gd-lightbox-prev,
#gd-lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  background: rgba(255,255,255,.12);
  border: none;
  color: #fff;
  font-size: 2.8rem;
  line-height: 1;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  cursor: pointer;
  transition: background .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
#gd-lightbox-prev { left: 16px; }
#gd-lightbox-next { right: 16px; }
#gd-lightbox-prev:hover,
#gd-lightbox-next:hover { background: rgba(255,255,255,.28); }

#gd-lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 2;
  background: rgba(255,255,255,.14);
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  transition: background .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
#gd-lightbox-close:hover { background: rgba(255,255,255,.3); }

/* Make lightbox-triggerable images show a zoom cursor */
.gd-lb-trigger,
.gd-timeline-img { cursor: zoom-in; }

/* Lock body scroll when lightbox is open */
body.gd-lb-open { overflow: hidden; }

/* ====================================================================
   VIEW DIARY – RECAP SETUP CARDS
==================================================================== */
.gd-hero-breadcrumb { margin-bottom: 10px; }
.gd-hero-breadcrumb a {
  color: rgba(255,255,255,.8);
  text-decoration: none;
  font-size: .9rem;
}
.gd-hero-breadcrumb a:hover { color: #fff; }

.gd-section-heading {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gd-green-dark);
  margin: 32px 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gd-green-soft);
}

.gd-recap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 20px 0 0;
}
.gd-recap-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--gd-surface);
  border: 1px solid var(--gd-border);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.gd-recap-icon { font-size: 1.6rem; flex-shrink: 0; }
.gd-recap-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gd-recap-body small { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gd-muted); }
.gd-recap-body strong { font-size: .95rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gd-recap-notes {
  grid-column: 1 / -1;
  background: var(--gd-surface-2);
  border: 1px solid var(--gd-border);
  border-radius: 10px;
  padding: 16px 18px;
}
.gd-recap-notes strong { display: block; margin-bottom: 6px; font-size: .9rem; }
.gd-recap-notes p { margin: 0; font-size: .93rem; line-height: 1.65; color: var(--gd-text); }

/* ====================================================================
   VIEW DIARY – PROGRESS BAR & WEEK PIPS
==================================================================== */
.gd-progress-wrap {
  margin: 28px 0 0;
  background: var(--gd-surface);
  border: 1px solid var(--gd-border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.gd-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--gd-muted);
}
.gd-progress-track {
  height: 10px;
  background: var(--gd-green-soft);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
}
.gd-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gd-green), var(--gd-green-dark));
  border-radius: 10px;
  transition: width .6s ease;
}
.gd-week-pip-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.gd-week-pip {
  width: calc( (100% - 76px) / 20 );
  min-width: 16px;
  height: 20px;
  border-radius: 4px;
  background: var(--gd-border);
  transition: transform .15s;
  position: relative;
}
.gd-week-pip--filled { cursor: pointer; }
.gd-week-pip--filled:hover { transform: scaleY(1.3); }

/* ====================================================================
   VIEW DIARY – SUMMARY STATS
==================================================================== */
.gd-summary-stats { margin-top: 28px; }
.gd-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.gd-summary-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--gd-surface);
  border: 1px solid var(--gd-border);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
}
.gd-summary-card--wide { grid-column: 1 / -1; }
.gd-summary-icon { font-size: 1.4rem; flex-shrink: 0; }
.gd-summary-card small {
  display: block;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gd-muted);
  margin-bottom: 2px;
}
.gd-summary-card strong { font-size: .95rem; font-weight: 700; }

/* ====================================================================
   VIEW DIARY – UNIT TOGGLE ROW (view page)
==================================================================== */
.gd-view-toggles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 20px 0 0;
}

/* ====================================================================
   TIMELINE – additional tags
==================================================================== */
.gd-tag--stage { background: #f3e5f5; color: #6a1b9a; }
.gd-tag--ph    { background: #e3f2fd; color: #0d47a1; font-size: .72rem; }

/* ====================================================================
   Responsive
==================================================================== */
@media (max-width: 500px) {
  .gd-timeline::before { display: none; }
  .gd-timeline-item { flex-direction: column; }
  .gd-diary-hero { height: 220px; }
  .gd-title { font-size: 1.4rem; }
}

/* ====================================================================
   MARS HYDRO CSV IMPORT
==================================================================== */
.gd-csv-upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.gd-btn-sensor {
  background: linear-gradient(135deg, #1a237e, #283593);
  color: #fff;
  border: none;
}
.gd-btn-sensor:hover {
  background: linear-gradient(135deg, #283593, #1a237e);
  color: #fff;
}
#gd-csv-status {
  font-size: .82rem;
  line-height: 1.4;
}
.gd-label-hint {
  font-size: .75rem;
  font-weight: 400;
  color: var(--gd-text-light);
  margin-left: 6px;
}
#gd-csv-preview-chart {
  margin-top: 14px;
  background: var(--gd-surface);
  border: 1px solid var(--gd-border);
  border-radius: 10px;
  padding: 12px;
}
#gd-csv-canvas {
  max-height: 220px;
}

/* ====================================================================
   SENSOR CHARTS on View Diary timeline
==================================================================== */
.gd-sensor-chart-wrap {
  margin: 18px 0 4px;
  background: var(--gd-surface);
  border: 1px solid var(--gd-border);
  border-radius: 12px;
  padding: 16px;
}
.gd-sensor-chart-title {
  font-size: .82rem;
  font-weight: 600;
  color: var(--gd-text-light);
  margin-bottom: 14px;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.gd-sensor-charts {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.gd-chart-block {
  background: #fff;
  border: 1px solid var(--gd-border);
  border-radius: 8px;
  padding: 12px 14px;
}
.gd-chart-subtitle {
  font-size: .78rem;
  font-weight: 600;
  color: var(--gd-text-light);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.gd-chart-block canvas {
  width: 100% !important;
}
#gd-csv-preview-chart .gd-chart-block {
  background: var(--gd-surface);
}
#gd-csv-preview-chart canvas {
  max-height: 180px;
}
