/* ═══════════════════════════════════════════════
   Garden Watering Tracker — Styles
   Mobile-first, earthy garden palette
   ═══════════════════════════════════════════════ */

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --green-900: #1b4332;
  --green-700: #2d6a4f;
  --green-500: #40916c;
  --green-300: #52b788;
  --green-100: #95d5b2;
  --green-50:  #d8f3dc;
  --brown:     #d4a373;
  --brown-dark:#a67c52;
  --bg:        #f0f7f4;
  --surface:   #ffffff;
  --text:      #1a1a2e;
  --text-muted:#6b7280;
  --danger:    #dc2626;
  --success:   #16a34a;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  min-height: 100dvh;
  position: relative;
}

/* ── Pages ── */
.page {
  display: none;
  min-height: 100dvh;
  padding-bottom: 80px; /* room for FAB */
}
.page.active {
  display: flex;
  flex-direction: column;
}

/* ── App Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--green-50);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  background: rgba(255,255,255,0.95);
}
.app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green-700);
}

/* ── Buttons ── */
.btn {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--green-700);
  color: white;
}
.btn-primary:hover { background: var(--green-500); }
.btn-primary:disabled {
  background: var(--green-100);
  cursor: not-allowed;
  transform: none;
}
.btn-ghost {
  background: transparent;
  color: var(--green-700);
  padding: 8px 12px;
}
.btn-ghost:hover { background: var(--green-50); }
.btn-full {
  width: 100%;
  justify-content: center;
}

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--green-700);
  color: white;
  font-size: 1.5rem;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 20;
}
.fab:active {
  transform: scale(0.9);
}

/* ── Login ── */
#page-login.active {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green-700) 0%, var(--green-500) 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}
.login-card h1 {
  font-size: 1.5rem;
  color: var(--green-700);
  margin-bottom: 4px;
}
.login-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}
.field {
  text-align: left;
  margin-bottom: 20px;
}
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.password-wrap {
  position: relative;
}
.password-wrap input {
  width: 100%;
  padding: 12px 44px 12px 16px;
  border: 2px solid var(--green-50);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--bg);
  transition: border-color 0.15s;
}
.password-wrap input:focus {
  outline: none;
  border-color: var(--green-500);
  background: white;
}
.toggle-vis {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  opacity: 0.6;
}
.toggle-vis:hover { opacity: 1; }

/* ── Dashboard ── */
#dashboard-content {
  padding: 16px;
  flex: 1;
}
.session-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.15s;
}
.session-card:active {
  transform: scale(0.99);
  box-shadow: none;
}
.session-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.session-date {
  font-weight: 700;
  color: var(--green-700);
  font-size: 1rem;
}
.session-time {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.session-stats {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.session-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}
.session-weather {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.session-thumbs {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.session-thumbs img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}
.session-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.session-empty .emoji { font-size: 3rem; margin-bottom: 12px; }
.load-more {
  text-align: center;
  padding: 16px;
  color: var(--green-500);
  cursor: pointer;
  font-weight: 600;
}
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* ── Upload ── */
.upload-main {
  padding: 16px;
  flex: 1;
}
.upload-zone {
  border: 2px dashed var(--green-100);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface);
  margin-bottom: 16px;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--green-500);
  background: var(--green-50);
}
.upload-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 8px;
}
.upload-zone p {
  color: var(--text-muted);
  font-size: 0.95rem;
}
.upload-zone small {
  color: var(--text-muted);
  opacity: 0.7;
}
.photo-preview-item {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.photo-preview-item img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.preview-meta {
  flex: 1;
  min-width: 0;
}
.preview-meta .time {
  font-weight: 600;
  font-size: 0.9rem;
}
.preview-meta .location {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.preview-meta .note {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}
.preview-meta .no-exif {
  font-size: 0.8rem;
  color: var(--danger);
}
.upload-notes-field {
  margin-bottom: 16px;
}
.upload-notes-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.upload-notes-field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--green-50);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  resize: vertical;
  background: var(--surface);
}
.upload-notes-field textarea:focus {
  outline: none;
  border-color: var(--green-500);
}
.progress-bar-wrap {
  margin-top: 12px;
  background: var(--green-50);
  border-radius: 999px;
  height: 24px;
  position: relative;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--green-500);
  border-radius: 999px;
  transition: width 0.3s ease;
  width: 0%;
}
.progress-bar-wrap span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--green-900);
}

/* ── Session Detail ── */
#session-content {
  padding: 16px;
  flex: 1;
}
.session-detail-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.session-detail-card h2 {
  font-size: 1.2rem;
  color: var(--green-700);
  margin-bottom: 4px;
}
.session-detail-card .subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--green-50);
  font-size: 0.9rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); }
.detail-value { font-weight: 600; }

.weather-section {
  margin-top: 12px;
}
.weather-section h3 {
  font-size: 0.95rem;
  color: var(--green-700);
  margin-bottom: 8px;
}
.weather-current {
  background: var(--green-50);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.weather-current .w-icon {
  font-size: 2rem;
}
.weather-current .w-temp {
  font-size: 1.5rem;
  font-weight: 700;
}
.weather-current .w-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.weather-daily {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.weather-daily span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.session-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 16px;
}
.photo-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.photo-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.15s;
  display: block;
}
.photo-item img:active {
  transform: scale(0.97);
}
.photo-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(220, 38, 38, 0.85);
  color: white;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.photo-item:hover .photo-delete-btn,
.photo-delete-btn:focus-visible {
  opacity: 1;
}
.photo-delete-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Photo Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
  padding: 20px;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius);
}

/* ── Messages ── */
.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 8px;
  display: none;
}
.error-msg.visible { display: block; }
.success-msg {
  color: var(--success);
  font-size: 0.85rem;
  margin-top: 8px;
  display: none;
}
.success-msg.visible { display: block; }
