/* CSS Variables for theming */
:root {
  --color-primary: #2d7a3e;
  --color-primary-light: #4a9d5a;
  --color-secondary: #7fbc8c;
  --color-accent: #f4a261;
  --color-bg: #f8f9f5;
  --color-card: #ffffff;
  --color-text: #2c3e2f;
  --color-text-muted: #6b7c6e;
  --color-border: #d4e3d7;
  --color-success: #52b788;
  --color-warning: #f4a261;
  --color-danger: #e63946;
  --color-info: #457b9d;
  --shadow: 0 2px 8px rgba(45, 122, 62, 0.1);
  --shadow-lg: 0 4px 16px rgba(45, 122, 62, 0.15);
  --header-height: 60px;
  --bottom-nav-height: 70px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --color-primary: #4a9d5a;
    --color-primary-light: #5fb06f;
    --color-secondary: #6aa876;
    --color-accent: #f4a261;
    --color-bg: #1a2321;
    --color-card: #243330;
    --color-text: #e8f2ea;
    --color-text-muted: #9fb5a3;
    --color-border: #3a4a47;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* =========================
   Login Page
   ========================= */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: var(--color-card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header h1 {
  font-size: 2rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.login-header p {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--color-text);
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.error-message {
  background: var(--color-danger);
  color: white;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.btn-primary {
  width: 100%;
  padding: 0.875rem;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  min-height: 48px;
}

.btn-primary:hover {
  background: var(--color-primary-light);
}

.btn-primary:active {
  transform: scale(0.98);
}

/* =========================
   App Container & Layout
   ========================= */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--color-card);
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
  z-index: 100;
}

.app-header h1 {
  font-size: 1.25rem;
  color: var(--color-primary);
  font-weight: 700;
}

.btn-icon {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--color-bg);
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-icon:active {
  background: var(--color-border);
  transform: scale(0.95);
}

/* =========================
   Tab Content
   ========================= */
.tab-content-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: var(--header-height);
  margin-bottom: var(--bottom-nav-height);
  -webkit-overflow-scrolling: touch;
}

.tab-content {
  display: none;
  padding: 1rem;
  padding-bottom: 2rem;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease-in, transform 0.3s ease-in;
}

.tab-content.active {
  display: block;
  animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideIn {
  0% {
    opacity: 0;
    transform: translateX(20px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

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

/* =========================
   Bottom Navigation
   ========================= */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--color-card);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  padding: 0 0.25rem;
  overflow-x: auto;
  overflow-y: hidden;
}

.nav-btn {
  flex: 1;
  min-width: 60px;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  transition: color 0.2s, transform 0.1s;
  padding: 0.5rem 0.25rem;
}

.nav-btn.active {
  color: var(--color-primary);
}

.nav-btn:active {
  transform: scale(0.95);
}

.nav-icon {
  font-size: 1.5rem;
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 500;
  text-align: center;
}

/* =========================
   Dashboard Sections
   ========================= */
.dashboard-section {
  margin-bottom: 1.5rem;
}

.dashboard-section h2 {
  font-size: 1.25rem;
  color: var(--color-primary);
  margin-bottom: 1rem;
  font-weight: 700;
}

.section-intro {
  color: var(--color-text-muted);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

/* =========================
   Alerts Section
   ========================= */
.alerts-preview, .alerts-section {
  margin-bottom: 1rem;
}

.alert {
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  box-shadow: var(--shadow);
}

.alert-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.alert-content {
  flex: 1;
}

.alert-message {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.alert-time {
  font-size: 0.85rem;
  opacity: 0.8;
}

.alert-warning {
  background: var(--color-warning);
  color: white;
}

.alert-info {
  background: var(--color-info);
  color: white;
}

.alert-danger {
  background: var(--color-danger);
  color: white;
}

.alert-success {
  background: var(--color-success);
  color: white;
}

/* =========================
   Cards
   ========================= */
.card {
  background: var(--color-card);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.card h3 {
  font-size: 1rem;
  color: var(--color-text);
  margin-bottom: 1rem;
  font-weight: 600;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.card-icon {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.card-content h3 {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.reading-large {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.reading-small {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

/* =========================
   Soil Moisture
   ========================= */
.moisture-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .moisture-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.moisture-zone {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.zone-label {
  font-weight: 500;
  min-width: 60px;
  color: var(--color-text);
  font-size: 0.9rem;
}

.moisture-bar {
  flex: 1;
  height: 32px;
  background: var(--color-border);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
}

.moisture-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
  border-radius: 16px;
  transition: width 0.3s ease;
}

.moisture-value {
  font-weight: 600;
  min-width: 45px;
  text-align: right;
  color: var(--color-primary);
  font-size: 0.9rem;
}

/* =========================
   Weather
   ========================= */
.weather-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.weather-day {
  background: var(--color-card);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.weather-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.weather-label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.weather-temp {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 0.25rem;
}

.weather-condition {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* =========================
   Camera Grid
   ========================= */
.camera-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .camera-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.camera-card {
  background: var(--color-card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.camera-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--color-border);
}

.camera-label {
  padding: 0.75rem;
  font-weight: 500;
  color: var(--color-text);
  text-align: center;
  font-size: 0.9rem;
}

/* =========================
   Controls
   ========================= */
.controls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .controls-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.control-card {
  background: var(--color-card);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.control-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.control-header span {
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text);
}

.control-buttons {
  display: flex;
  gap: 0.5rem;
}

.control-btn {
  flex: 1;
  padding: 0.625rem;
  border: 2px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}

.control-btn:hover {
  border-color: var(--color-primary);
}

.control-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.control-btn:active {
  transform: scale(0.95);
}

/* =========================
   Plant List
   ========================= */
.plant-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.plant-item {
  background: var(--color-card);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.plant-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.plant-image {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.plant-details {
  flex: 1;
}

.plant-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.plant-info {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* =========================
   Timelapse
   ========================= */
.timelapse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.75rem;
}

.timelapse-item {
  background: var(--color-card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s;
}

.timelapse-item:active {
  transform: scale(0.95);
}

.timelapse-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--color-border);
}

.timelapse-date {
  padding: 0.5rem;
  font-size: 0.75rem;
  text-align: center;
  color: var(--color-text-muted);
}

/* =========================
   Shopping List
   ========================= */
.shopping-items {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.shopping-item {
  background: var(--color-card);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  gap: 0.75rem;
  align-items: start;
}

.item-emoji {
  font-size: 2.5rem;
  grid-row: 1 / 4;
}

.item-details {
  grid-column: 2;
}

.item-details h3 {
  font-size: 1rem;
  color: var(--color-text);
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.item-desc {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.badge-rec, .badge-opt {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-rec {
  background: var(--color-success);
  color: white;
}

.badge-opt {
  background: var(--color-info);
  color: white;
}

.item-price {
  grid-column: 2;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
}

.buy-btn {
  grid-column: 1 / 3;
  display: block;
  text-align: center;
  padding: 0.75rem;
  background: linear-gradient(135deg, #ff9900, #e88b00);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.2s, box-shadow 0.2s;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.buy-btn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(255, 153, 0, 0.4);
}

/* =========================
   Proposal
   ========================= */
.proposal-embed {
  background: var(--color-card);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.proposal-embed h2 {
  font-size: 1.5rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.proposal-intro {
  color: var(--color-text-muted);
  margin-bottom: 2rem;
  font-size: 1rem;
}

.proposal-section {
  margin-bottom: 2rem;
}

.proposal-section h3 {
  font-size: 1.1rem;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.proposal-section p {
  color: var(--color-text-muted);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.feature-list, .timeline-list {
  list-style: none;
  padding: 0;
}

.feature-list li, .timeline-list li {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--color-bg);
  border-radius: 8px;
  line-height: 1.6;
}

.feature-list strong {
  color: var(--color-primary);
}

.total-box {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: white;
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  margin-top: 2rem;
}

.total-box .label {
  font-size: 1rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

.total-box .amount {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.total-box .sublabel {
  font-size: 0.85rem;
  opacity: 0.85;
}

/* =========================
   Setup Guide
   ========================= */
.setup-step {
  background: var(--color-card);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.setup-step.success {
  background: linear-gradient(135deg, var(--color-success), #6fcf97);
  color: white;
}

.setup-step.success .step-content h3 {
  color: white;
}

.setup-step.success .step-content p,
.setup-step.success .step-content li {
  color: rgba(255, 255, 255, 0.9);
}

.step-number, .step-icon {
  width: 40px;
  height: 40px;
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.step-icon {
  font-size: 1.5rem;
  background: white;
}

.step-content {
  flex: 1;
}

.step-content h3 {
  font-size: 1.1rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.step-content p {
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.step-content ul {
  list-style: none;
  padding: 0;
}

.step-content li {
  padding: 0.5rem 0;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* =========================
   Charts
   ========================= */
canvas {
  max-width: 100%;
  height: auto !important;
}

/* =========================
   Footer
   ========================= */
.app-footer {
  text-align: center;
  padding: 1rem 0;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* =========================
   Loading & Utilities
   ========================= */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

/* =========================
   Responsive Overrides
   ========================= */
@media (min-width: 768px) {
  .app-header h1 {
    font-size: 1.5rem;
  }
  
  .tab-content {
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
  }
  
  .nav-label {
    font-size: 0.75rem;
  }
}

/* Prevent overscroll bounce on iOS */
.tab-content-wrapper {
  overscroll-behavior: contain;
}
