/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --green-dark:   #2E7D32;
  --green-mid:    #388E3C;
  --green-light:  #4CAF50;
  --green-bg:     #F1F8E9;
  --text-dark:    #1a1a1a;
  --text-mid:     #444;
  --text-muted:   #777;
  --border:       #C8E6C9;
  --white:        #ffffff;
  --shadow:       0 2px 8px rgba(0,0,0,.10);
  --radius:       12px;
  --touch-min:    44px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  color: var(--text-dark);
  background: var(--green-bg);
  -webkit-text-size-adjust: 100%;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--green-dark);
  color: var(--white);
  padding: 16px 24px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.app-title   { font-size: 1.5rem; font-weight: 700; letter-spacing: .5px; }
.app-subtitle{ font-size: .875rem; opacity: .85; margin-top: 2px; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app-main { padding: 20px; max-width: 1200px; margin: 0 auto; }

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

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

/* ── Panels ──────────────────────────────────────────────────────────────── */
.panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ── Input Section ───────────────────────────────────────────────────────── */
.input-label {
  display: block;
  font-weight: 600;
  color: var(--green-dark);
  margin-bottom: 8px;
  font-size: .9rem;
}

.input-row {
  display: flex;
  gap: 10px;
}

.barcode-input {
  flex: 1;
  height: var(--touch-min);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  font-size: 1rem;
  transition: border-color .2s;
  -webkit-appearance: none;
}
.barcode-input:focus {
  outline: none;
  border-color: var(--green-light);
}

.input-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  padding: 0 18px;
  border: none;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }

.btn-primary   { background: var(--green-dark);  color: var(--white); }
.btn-primary:hover { background: var(--green-mid); }

.btn-secondary { background: var(--green-light); color: var(--white); }
.btn-secondary:hover { background: var(--green-mid); }

.btn-outline {
  background: transparent;
  color: var(--green-dark);
  border: 2px solid var(--green-dark);
}
.btn-outline:hover { background: var(--green-bg); }

/* ── Status Bar ──────────────────────────────────────────────────────────── */
.status-bar {
  min-height: 24px;
  margin: 12px 0;
  font-size: .85rem;
  border-radius: 6px;
  padding: 0 8px;
  transition: all .3s;
}
.status-bar.info    { background: #E3F2FD; color: #1565C0; padding: 8px; }
.status-bar.success { background: #E8F5E9; color: var(--green-dark); padding: 8px; }
.status-bar.error   { background: #FFEBEE; color: #C62828; padding: 8px; }

/* ── History / Searchable Dropdown ───────────────────────────────────────── */
.section-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 10px;
}

.plant-dropdown-container { position: relative; }

.plant-search-input {
  width: 100%;
  height: var(--touch-min);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  font-size: 1rem;
  transition: border-color .2s;
  -webkit-appearance: none;
  cursor: pointer;
}
.plant-search-input:focus {
  outline: none;
  border-color: var(--green-light);
}

.plant-dropdown-list {
  display: none;
  flex-direction: column;
  gap: 4px;
  max-height: 360px;
  overflow-y: auto;
  margin-top: 4px;
  padding: 6px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
  position: absolute;
  left: 0;
  right: 0;
  z-index: 100;
}
.plant-dropdown-list.open {
  display: flex;
}

.plant-dropdown-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  min-height: var(--touch-min);
  font-size: .9rem;
  color: var(--text-dark);
}
.plant-dropdown-item:hover, .plant-dropdown-item.active {
  background: var(--green-bg);
  border-color: var(--green-light);
}

.empty-state { color: var(--text-muted); font-size: .875rem; text-align: center; padding: 20px 0; }

/* ── Care Card ───────────────────────────────────────────────────────────── */
.card-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}
.placeholder-icon { font-size: 3rem; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-names { flex: 1; }
.scientific-name { font-style: italic; font-size: 1.25rem; font-weight: 600; color: var(--text-dark); }
.common-name     { font-weight: 700; font-size: 1rem; color: var(--green-dark); margin-top: 2px; }

.card-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card-description {
  font-style: italic;
  color: var(--text-mid);
  font-size: .9rem;
  line-height: 1.5;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.care-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.care-item { display: flex; flex-direction: column; gap: 3px; }
.care-item-full { grid-column: 1 / -1; }

.care-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--green-dark);
  text-transform: uppercase;
  letter-spacing: .6px;
}
.care-value { font-size: .875rem; color: var(--text-dark); line-height: 1.4; }

/* ── Verification Badge ──────────────────────────────────────────────────── */
.verification-badge {
  margin-top: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
}
.verification-badge.verified    { background: #E8F5E9; color: #2E7D32; }
.verification-badge.conflicting { background: #FFF8E1; color: #F57F17; }

/* ── Gemini Notes ────────────────────────────────────────────────────────── */
.gemini-notes {
  margin-top: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: .8rem;
  color: #7B3F00;
  background: #FFF3E0;
  line-height: 1.4;
}

/* ── Loading Overlay ─────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 1000;
}
.loading-spinner {
  width: 52px; height: 52px;
  border: 5px solid rgba(255,255,255,.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.loading-text { color: var(--white); font-size: 1rem; font-weight: 600; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scan Label — responsive wrap on narrow screens ─────────────────────── */
@media (max-width: 420px) {
  .input-row { flex-wrap: wrap; }
  #scan-label-btn { flex: 1 1 100%; }
}
