/* PlantPulse — Complete Styles */

:root {
  --green-dark: #2D5A27;
  --green-mid: #4A7C59;
  --green-light: #7FB069;
  --cream: #F7F5F0;
  --brown: #8B6914;
  --white: #FFFFFF;
  --gray-100: #F0EDE8;
  --gray-200: #E0DDD6;
  --gray-300: #B8B4AC;
  --gray-400: #8A8680;
  --gray-600: #5A5750;
  --gray-800: #2E2C28;
  --red: #D64545;
  --red-light: #FDEAEA;
  --yellow: #E8A317;
  --yellow-light: #FFF8E1;
  --green-status: #4CAF50;
  --green-status-light: #E8F5E9;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--cream);
  color: var(--gray-800);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ─── Header ─────────────────────────────────────── */

#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--green-dark);
  color: var(--white);
  box-shadow: var(--shadow-md);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.icon-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: rgba(255,255,255,0.15);
}

/* ─── Screens ────────────────────────────────────── */

.screen {
  display: none;
  padding: 16px;
  padding-bottom: 100px;
  max-width: 800px;
  margin: 0 auto;
  animation: fadeIn 0.2s ease;
}

.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Today's Care ───────────────────────────────── */

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--green-dark);
}

#today-care-section {
  margin-bottom: 20px;
}

.today-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s;
}

.today-card:active { transform: scale(0.98); }

.today-card.overdue {
  border-left: 4px solid var(--red);
}

.today-card.due-today {
  border-left: 4px solid var(--yellow);
}

.today-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.today-thumb-placeholder {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.today-info { flex: 1; min-width: 0; }

.today-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.today-status {
  font-size: 13px;
  margin-top: 2px;
}

.today-status.overdue { color: var(--red); font-weight: 600; }
.today-status.due { color: var(--yellow); font-weight: 600; }

.btn-water {
  background: var(--green-mid);
  color: var(--white);
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-water:hover { background: var(--green-dark); }

.all-caught-up {
  text-align: center;
  padding: 20px;
  color: var(--green-mid);
  font-size: 16px;
  font-weight: 500;
}

/* ─── Sort Bar ───────────────────────────────────── */

#sort-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

#sort-bar label {
  font-size: 14px;
  color: var(--gray-400);
  font-weight: 500;
}

#sort-select {
  padding: 6px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 14px;
  color: var(--gray-800);
  cursor: pointer;
}

/* ─── Garden Grid ────────────────────────────────── */

#garden-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 600px) {
  #garden-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 900px) {
  #garden-grid { grid-template-columns: repeat(4, 1fr); }
}

.plant-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}

.plant-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.plant-card:active { transform: scale(0.97); }

.card-photo {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--gray-100);
}

.card-photo-placeholder {
  width: 100%;
  aspect-ratio: 1;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}

.card-body {
  padding: 10px;
}

.card-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-scientific {
  font-size: 12px;
  color: var(--gray-400);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
  color: var(--gray-400);
}

.card-sun { font-size: 11px; }

.status-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(4px);
}

.status-badge.on-track {
  background: rgba(76, 175, 80, 0.9);
  color: var(--white);
}

.status-badge.due-today {
  background: rgba(232, 163, 23, 0.9);
  color: var(--white);
}

.status-badge.overdue {
  background: rgba(214, 69, 69, 0.9);
  color: var(--white);
}

/* ─── Empty State ────────────────────────────────── */

#empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

#empty-state h2 {
  font-size: 22px;
  color: var(--green-dark);
  margin-bottom: 8px;
}

#empty-state p {
  color: var(--gray-400);
  margin-bottom: 24px;
}

/* ─── FAB ────────────────────────────────────────── */

.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--green-mid);
  color: var(--white);
  font-size: 32px;
  font-weight: 300;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
  z-index: 50;
  line-height: 1;
}

.fab:hover {
  background: var(--green-dark);
  transform: scale(1.08);
}

.fab:active { transform: scale(0.95); }

/* ─── Buttons ────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }

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

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

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-800);
}

.btn-secondary:hover { background: var(--gray-200); }

.btn-danger {
  background: var(--red-light);
  color: var(--red);
}

.btn-danger:hover { background: #f5d0d0; }

.btn-text {
  background: none;
  color: var(--green-mid);
  padding: 8px;
  font-weight: 500;
}

.btn-text:hover { text-decoration: underline; }

.btn-large {
  padding: 14px 28px;
  font-size: 16px;
  border-radius: var(--radius);
}

.btn-full { width: 100%; }

/* ─── Add Plant Flow ─────────────────────────────── */

.add-plant-flow {
  max-width: 480px;
  margin: 0 auto;
}

.add-step { display: none; }
.add-step.active { display: block; }

.add-step h2 {
  font-size: 22px;
  color: var(--green-dark);
  margin-bottom: 4px;
}

.subtitle {
  color: var(--gray-400);
  margin-bottom: 24px;
}

.capture-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 32px;
}

.photo-preview-wrap {
  width: 100%;
  max-width: 400px;
  margin: 0 auto 20px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.photo-preview-wrap.small {
  max-width: 200px;
}

.photo-preview-wrap img {
  width: 100%;
  display: block;
}

#identify-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#identify-loading {
  text-align: center;
  padding: 24px;
}

#identify-loading p {
  margin-top: 12px;
  color: var(--gray-400);
  font-size: 15px;
}

#identify-error {
  text-align: center;
  padding: 16px;
}

.error-text {
  color: var(--red);
  margin-bottom: 12px;
  font-size: 14px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--green-mid);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

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

#ai-result-banner {
  background: var(--green-status-light);
  border: 1px solid var(--green-status);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  text-align: center;
}

#ai-result-banner p {
  font-size: 15px;
}

.confidence-note {
  font-size: 13px !important;
  color: var(--yellow) !important;
  margin-top: 4px;
}

/* ─── Forms ──────────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.1);
}

/* ─── Plant Detail ───────────────────────────────── */

.detail-photo-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto 20px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.detail-photo-wrap img {
  width: 100%;
  display: block;
}

.detail-info {
  max-width: 480px;
  margin: 0 auto;
}

.detail-info h2 {
  font-size: 24px;
  color: var(--green-dark);
}

.scientific {
  font-style: italic;
  color: var(--gray-400);
  font-size: 15px;
  margin-top: 2px;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.meta-item {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.meta-label {
  display: block;
  font-size: 12px;
  color: var(--gray-400);
  margin-bottom: 4px;
}

.meta-value {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--green-dark);
}

.care-tips-box {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-600);
  box-shadow: var(--shadow-sm);
}

.care-tips-box:empty { display: none; }

.detail-actions {
  margin-bottom: 24px;
}

.detail-action-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.detail-action-row .btn { flex: 1; }

.watering-history {
  margin-top: 8px;
}

.watering-history h3 {
  font-size: 16px;
  color: var(--green-dark);
  margin-bottom: 10px;
}

.watering-history ul {
  list-style: none;
}

.watering-history li {
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  gap: 8px;
}

.watering-history li::before {
  content: '💧';
  font-size: 16px;
}

.muted {
  color: var(--gray-300);
  font-size: 14px;
}

/* ─── Settings ───────────────────────────────────── */

#screen-settings h2 {
  font-size: 22px;
  color: var(--green-dark);
  margin-bottom: 20px;
}

.settings-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.settings-section h3 {
  font-size: 16px;
  margin-bottom: 6px;
}

.settings-desc {
  font-size: 14px;
  color: var(--gray-400);
  margin-bottom: 14px;
}

.settings-desc a {
  color: var(--green-mid);
}

.api-key-input-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.api-key-input-wrap input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: monospace;
}

.api-key-input-wrap input:focus {
  outline: none;
  border-color: var(--green-mid);
}

.eye-btn {
  color: var(--gray-400);
  flex-shrink: 0;
}

.api-key-actions {
  display: flex;
  gap: 8px;
}

.api-status {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 500;
}

.api-status.success { color: var(--green-status); }
.api-status.error { color: var(--red); }
.api-status.warning { color: var(--yellow); }

/* ─── Confirm Dialog ─────────────────────────────── */

.confirm-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.15s ease;
}

.confirm-dialog {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 320px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.confirm-dialog h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.confirm-dialog p {
  color: var(--gray-400);
  font-size: 14px;
  margin-bottom: 20px;
}

.confirm-dialog .btn-row {
  display: flex;
  gap: 8px;
}

.confirm-dialog .btn-row .btn { flex: 1; }

/* ─── Toast ──────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-800);
  color: var(--white);
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.2s forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
