/* Soft Minimalist Design System */
:root {
  /* Palette - Warm & Organic */
  --primary-dark: #1f2937;
  --primary-main: #10b981;
  --primary-soft: #d1fae5;

  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;

  --text-main: #334155;
  --text-light: #64748b;
  --text-lighter: #94a3b8;

  --border-light: #f1f5f9;
  --border-focus: #10b981;

  --accent-error: #ef4444;
  --accent-error-bg: #fef2f2;
  --accent-blue: #3b82f6;

  /* Scanner Specific */
  --scanner-overlay: rgba(0, 0, 0, 0.85);

  /* Shadows - Soft & Diffused */
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
  --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.01);
  --shadow-button: 0 4px 6px -1px rgba(16, 185, 129, 0.2);

  /* Radius */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  /* Fonts */
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
}

/* Layout */
.app-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
  max-width: 1800px;
  margin: 0 auto;
}

/* Sidebar */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  padding: 64px 32px;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 40px;
  z-index: 50;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-soft) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background-color: var(--primary-soft);
  border-radius: var(--radius-full);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-icon {
  font-size: 2rem;
  background: linear-gradient(135deg, #10b981, #059669);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.03em;
  line-height: 1;
}

.brand-subtitle {
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--text-lighter);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
  transition: all 0.2s;
}

.brand-subtitle:hover {
  opacity: 1;
  color: var(--primary-main);
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-lighter);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}



/* Form Elements */
.input-field,
.select-field {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-page);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.input-field:hover,
.select-field:hover {
  background: #f1f5f9;
}

.input-field:focus,
.select-field:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--primary-main);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-button);
}

.btn-primary:hover {
  background: #059669;
  transform: translateY(-1px);
  box-shadow: 0 6px 12px -2px rgba(16, 185, 129, 0.3);
}

.btn-secondary {
  width: 100%;
  padding: 12px;
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-light);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  border-color: var(--text-lighter);
  color: var(--text-main);
}

/* Main Content */
.main-content {
  padding: 64px 48px;
}

.page-header {
  margin-bottom: 48px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.page-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.04em;
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 1.05rem;
  color: var(--text-light);
}

.garden-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 32px;
}

/* --- Refined Card Design --- */
.plant-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid white;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  height: 100%;
  /* Ensure card fills grid row height */
}

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

.plant-card.overdue {
  border-color: #fee2e2;
  background: #fff;
  /* Keep white bg, just accent frame */
}

.plant-card.overdue::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-error);
}

/* Header */
.card-header {
  display: flex;
  gap: 16px;
  align-items: center;
  height: 96px;
  /* Fixed height to align stat lines */
}

.card-img-box {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f1f5f9;
  flex-shrink: 0;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.plant-card:hover .card-img {
  transform: scale(1.1);
}

.card-title-group {
  flex: 1;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 4px;

  /* Clamp Title */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-status {
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #ECFDF3;
  color: #027A48;
  /* Dark Green Text */
  border-radius: 8px;
}

.card-status.alert {
  background: var(--accent-error-bg);
  color: var(--accent-error);
}

/* Stats Grid */
/* Stats Grid */
.card-stats {
  display: grid;
  /* Balanced columns but giving Light slightly more room */
  grid-template-columns: 1fr 1.5fr 1fr;
  gap: 12px;
  padding: 16px 8px;
  /* Added side padding */
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  /* Force fixed height so alignment matches across row */
  height: 74px;
  align-items: start;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  /* Context for absolute hover */
  min-width: 0;
  /* critical for grid truncation */
}

.stat-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-lighter);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.stat-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;

  /* Single Line Truncation by default */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: help;
  /* Hint that interaction is possible */

  /* UX: Subtle visual cue it can expand */
  border-bottom: 1px dotted transparent;
  transition: all 0.2s;
}

/* Hover Effect: Show full text over other content */
.stat-item:hover .stat-value {
  position: absolute;
  top: 16px;
  /* Offset to cover original text */
  left: 0;
  z-index: 10;
  background: var(--primary-dark);
  color: white;
  white-space: normal;
  /* Allow wrapping */
  overflow: visible;
  padding: 4px 8px;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  width: max-content;
  max-width: 200px;
  /* Cap width */
}

/* Ensure block behavior for overflow */


/* Actions */
.card-actions {
  display: flex;
  gap: 12px;
  margin-top: auto;
  /* Push to bottom */
}

.btn-action-primary {
  flex: 1;
  height: 44px;
  padding: 0 16px;
  background: var(--primary-dark);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-action-primary:hover {
  background: black;
  transform: translateY(-2px);
}

.btn-action-icon {
  width: 44px;
  height: 44px;
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-action-icon:hover {
  border-color: var(--accent-error);
  color: var(--accent-error);
  background: var(--accent-error-bg);
}

/* Helper Components */
.suggestions-list {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-top: 8px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.suggestion-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--bg-page);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 12px;
}

.suggestion-item:hover {
  background: var(--bg-page);
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal img {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hover);
  max-width: 90vw;
  max-height: 90vh;
}

/* Scanner UI */
.scanner-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--scanner-overlay);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.scanner-video-container {
  width: 90%;
  max-width: 500px;
  height: 60vh;
  background: black;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.scanner-video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-controls {
  margin-top: 24px;
  display: flex;
  gap: 16px;
}

.scanner-result-card {
  display: none;
  position: absolute;
  bottom: 20px;
  left: 20px;
  right: 20px;
  background: white;
  padding: 20px;
  border-radius: var(--radius-sm);
  animation: slideUp 0.3s ease-out;
}

.scan-status {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 8px;
}

.scan-status.healthy {
  background: #dcfce7;
  color: #166534;
}

.scan-status.sick {
  background: #fee2e2;
  color: #991b1b;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Responsive Design */

/* Tablet & Smaller Desktop (Below 1024px) */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .sidebar {
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    padding: 32px 24px;
    gap: 24px;
  }

  /* Make sidebar sections distinct on mobile/tablet */
  .sidebar-section {
    background: white;
    padding: 20px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
  }

  .main-content {
    padding: 32px 24px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 32px;
  }
}

/* Mobile (Below 640px) */
@media (max-width: 640px) {
  .garden-grid {
    grid-template-columns: 1fr;
    /* Single column cards */
    gap: 20px;
  }

  .page-title {
    font-size: 2rem;
  }

  .plant-card {
    padding: 20px;
  }

  /* Stack stats if needed, or keep grid but reduce gap */
  .card-stats {
    gap: 8px;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  .stat-value {
    font-size: 0.85rem;
  }

  /* Ensure buttons are easy to tap */
  /* Ensure buttons are easy to tap */
  .btn-action-primary {
    height: 52px;
    padding: 0 16px;
  }

  .btn-action-icon {
    padding: 0;
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
  }

  /* Modal adjustments */
  .modal-content {
    padding: 20px;
  }
}

/* --- Bulk Add Feature Styles --- */
.bulk-modal-content {
  background: white;
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.bulk-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
}

.bulk-header h2 {
  font-family: var(--font-display);
  color: var(--primary-dark);
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-light);
  cursor: pointer;
}

.bulk-body {
  padding: 32px;
  overflow-y: auto;
  background: var(--bg-page);
  flex: 1;
}

.bulk-instruction {
  margin-bottom: 16px;
  color: var(--text-light);
  font-weight: 500;
}

.bulk-textarea {
  width: 100%;
  height: 300px;
  padding: 20px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1rem;
  resize: none;
  background: white;
}

.bulk-textarea:focus {
  outline: none;
  border-color: var(--primary-main);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.bulk-footer {
  padding: 24px 32px;
  background: white;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  /* Align buttons to the right */
  gap: 16px;
}

.bulk-lists-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  height: 100%;
}

.bulk-section {
  background: white;
  border-radius: var(--radius-sm);
  padding: 20px;
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
}

.bulk-section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.bulk-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  /* simple scroll limit */
}

/* Review Cards */
.bulk-card {
  background: var(--bg-page);
  border-radius: var(--radius-xs);
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  border: 1px solid transparent;
}

.bulk-card.found {
  border-left: 3px solid var(--primary-main);
}

.bulk-card.unknown {
  border-left: 3px solid #f59e0b;
  /* Amber for warning/attention */
  flex-direction: column;
  align-items: stretch;
}

.bulk-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
}

.bulk-info {
  flex: 1;
}

.bulk-info .name {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.95rem;
}

.bulk-info .meta {
  font-size: 0.8rem;
  color: var(--text-light);
}

.btn-remove {
  background: transparent;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
}

.btn-remove:hover {
  color: var(--accent-error);
}

.bulk-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.bulk-form-row label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
}

.input-field.small {
  padding: 8px 12px;
  font-size: 0.9rem;
}

.btn-remove-row {
  align-self: flex-end;
  font-size: 0.8rem;
  color: var(--accent-error);
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

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

/* --- Plant Detail UI --- */
.detail-modal {
  /* Inherits .modal base styles but specific alignment */
  align-items: center;
  padding: 20px;
}

.detail-card {
  background: white;
  width: 100%;
  max-width: 600px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.btn-close-detail {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.3);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s;
}

.btn-close-detail:hover {
  background: rgba(0, 0, 0, 0.5);
}

.detail-header {
  position: relative;
}

.detail-hero-img {
  width: 100%;
  height: 240px;
  object-fit: cover;
}

.detail-header-text {
  padding: 24px 32px 0 32px;
}

.detail-scientific {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  font-weight: 600;
  margin-bottom: 4px;
}

.detail-title {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--primary-dark);
  line-height: 1.1;
  margin-bottom: 12px;
}

.detail-desc {
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.6;
  opacity: 0.9;
  /* Limit lines if description is huge */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-grid {
  padding: 24px 32px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  overflow-y: auto;
}

.detail-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.icon-box {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-box.water {
  background: #e0f2fe;
  color: #0284c7;
}

.icon-box.sun {
  background: #fef3c7;
  color: #d97706;
}

.icon-box.maintenance {
  background: #f3e8ff;
  color: #9333ea;
}

.icon-box.growth {
  background: #dcfce7;
  color: #166534;
}

.icon-box.map {
  background: #f1f5f9;
  color: #475569;
}

.detail-item .label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.detail-item .value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary-dark);
}

.detail-actions {
  padding: 24px 32px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: white;
}

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

  .detail-hero-img {
    height: 180px;
  }
}