/* styles.css - Clean, high-contrast, modern agricultural dashboard */
:root {
  --primary: #1b4332;
  --primary-light: #2d6a4f;
  --accent: #52b788;
  --accent-soft: #d8f3dc;
  --bg-app: #f4f6f5;
  --bg-card: #ffffff;
  --text-main: #19201d;
  --text-muted: #5a6660;
  --border-color: #e2e8e5;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 14px rgba(27, 67, 50, 0.08);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 540px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}

/* Header */
.app-header {
  background: var(--primary);
  color: white;
  padding: 16px 18px 0 18px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.branding {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 26px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 6px;
  display: inline-flex;
}

.app-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.station-meta {
  font-size: 11px;
  color: var(--accent-soft);
  font-weight: 500;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.25);
}

.spinning {
  animation: spin 1s linear infinite;
}

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

/* Status Bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 500;
  margin-bottom: 12px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: #52b788;
  border-radius: 50%;
  box-shadow: 0 0 6px #52b788;
}

.bat-icon {
  font-size: 13px;
}

.bat-label {
  opacity: 0.85;
  font-size: 11px;
}

/* Install Banner */
.install-banner {
  background: linear-gradient(135deg, #2d6a4f, #1b4332);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-size: 12px;
}

.install-banner.hidden {
  display: none;
}

.install-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.install-text strong {
  font-size: 13px;
}

.install-btn {
  background: white;
  color: var(--primary);
  border: none;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
}

.dismiss-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.nav-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  padding: 10px 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.nav-tab.active {
  color: white;
}

.nav-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  right: 10%;
  height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
}

/* Main Content */
.main-content {
  padding: 16px;
  flex: 1;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  gap: 12px;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(27, 67, 50, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Hero Temperature Card */
.hero-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hero-temp-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--primary-light);
  margin-bottom: 2px;
}

.temp-display {
  display: flex;
  align-items: baseline;
}

.temp-val {
  font-size: 58px;
  font-weight: 800;
  line-height: 1;
  color: var(--text-main);
  letter-spacing: -2px;
}

.temp-unit {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 2px;
}

.temp-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.temp-sub .sep {
  color: #c0c7c3;
}

.hero-highlow {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hl-badge {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  text-align: right;
  min-width: 90px;
}

.hl-badge.high {
  background: #fdf2e9;
  border-left: 3px solid #e67e22;
}

.hl-badge.low {
  background: #ebf5fb;
  border-left: 3px solid #3498db;
}

.hl-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.hl-val {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
}

.hl-time {
  font-size: 9px;
  color: var(--text-muted);
}

/* Metric Cards Grid */
.cards-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.metric-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.card-icon {
  font-size: 18px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

.card-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.primary-metric {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.primary-metric .val {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text-main);
}

.primary-metric .unit {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
}

.secondary-info {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: right;
}

.secondary-info strong {
  color: var(--text-main);
}

/* Wind & Spraying Card Enhancements */
.wind-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.wind-card .card-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.wind-main-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.spray-badge {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 9px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.spray-badge.optimal {
  background: #e8f5e9;
  color: #1b4332;
  border-color: #a5d6a7;
}

.spray-badge.caution {
  background: #fff8e1;
  color: #92400e;
  border-color: #fde68a;
}

.spray-badge.unfavorable {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

/* Spray Diagnostics (Delta T, Drift Risk, Wet Bulb) */
.spray-diagnostics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.spray-diag-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.diag-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.diag-val {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
}

.diag-sub {
  font-size: 9.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Actionable Advisory Box */
.spray-advisory-box {
  background: #f8faf9;
  border-left: 3px solid var(--primary-light);
  border-radius: 4px;
  padding: 9px 11px;
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--text-main);
  line-height: 1.4;
}

.spray-advisory-box.optimal {
  background: #f0fdf4;
  border-left-color: #22c55e;
  color: #166534;
}

.spray-advisory-box.caution {
  background: #fffbeb;
  border-left-color: #f59e0b;
  color: #92400e;
}

.spray-advisory-box.unfavorable {
  background: #fef2f2;
  border-left-color: #ef4444;
  color: #991b1b;
}

.spray-adv-icon {
  font-size: 15px;
  flex-shrink: 0;
}

/* Hourly Spray Window */
.spray-forecast-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spray-fc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}

.spray-fc-title {
  font-weight: 700;
  color: var(--primary);
}

.spray-fc-legend {
  display: flex;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.dot.dot-opt {
  background: #22c55e;
}

.dot.dot-ctn {
  background: #f59e0b;
}

.dot.dot-unf {
  background: #ef4444;
}

.spray-timeline {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.spray-timeline::-webkit-scrollbar {
  height: 4px;
}

.spray-timeline::-webkit-scrollbar-thumb {
  background: #d4ded9;
  border-radius: 4px;
}

.spray-hour-pill {
  flex: 0 0 auto;
  min-width: 50px;
  padding: 6px 4px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}

.spray-hour-pill .pill-time {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

.spray-hour-pill .pill-wind {
  font-size: 11px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
}

.spray-hour-pill.optimal {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.spray-hour-pill.optimal .pill-wind {
  color: #166534;
}

.spray-hour-pill.caution {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.spray-hour-pill.caution .pill-wind {
  color: #92400e;
}

.spray-hour-pill.unfavorable {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.spray-hour-pill.unfavorable .pill-wind {
  color: #991b1b;
}

/* Agronomy Card Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
}

.stat-box {
  background: var(--bg-app);
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-num {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
}

/* Comparison Section */
.section-intro-card {
  background: #e8f5e9;
  border: 1px solid #c8e6c9;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.intro-icon {
  font-size: 24px;
}

.section-intro-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.section-intro-card p {
  font-size: 12px;
  color: #2e7d32;
  line-height: 1.4;
}

.comparison-card, .forecast-outlook-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.comparison-header, .outlook-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.comparison-header h4, .outlook-header h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

.badge {
  background: var(--accent-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
}

/* Comparison Table */
.comp-table-wrap {
  overflow-x: auto;
}

.comp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.comp-table th, .comp-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.comp-table th {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.diff-cell {
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.diff-positive {
  color: #d9534f;
}

.diff-negative {
  color: #0275d8;
}

.diff-neutral {
  color: var(--text-muted);
}

.comp-summary-box {
  background: #fdfaf2;
  border-left: 3px solid #f0ad4e;
  border-radius: 4px;
  padding: 10px 12px;
  margin-top: 14px;
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: #8a6d3b;
  line-height: 1.4;
}

/* Historical Microclimate Comparison Enhancements */
.export-btn {
  background: var(--accent-soft);
  color: var(--primary);
  border: 1px solid rgba(27, 67, 50, 0.2);
  border-radius: 16px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.bias-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

@media (min-width: 500px) {
  .bias-stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.bias-stat-box {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}

.bias-stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.bias-stat-num {
  font-size: 16px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-main);
  margin: 3px 0 1px 0;
}

.bias-stat-sub {
  font-size: 9.5px;
  color: var(--text-muted);
}

.bias-box {
  background: #f0fdfa;
  border-left-color: #0d9488;
  color: #115e59;
}

.hist-chart-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.hist-chart-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 6px;
}

.hist-chart-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

.hist-btn-group {
  display: flex;
  gap: 4px;
}

.hist-tab-btn {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

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

.hist-table-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.hist-table-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.hist-table th, .hist-table td {
  padding: 8px 6px;
  font-size: 12px;
}

.hist-day-cell {
  font-weight: 600;
  white-space: nowrap;
}

.hist-note-cell {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 140px;
}

/* 7-Day Forecast Cards */
.forecast-days-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fc-day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}

.fc-day-row:last-child {
  border-bottom: none;
}

.fc-day-title {
  font-weight: 600;
  width: 80px;
}

.fc-weather-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.fc-temps {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}

.fc-high {
  color: var(--text-main);
}

.fc-low {
  color: var(--text-muted);
  margin-left: 6px;
}

/* Charts Section */
.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.chart-header {
  margin-bottom: 12px;
}

.chart-header h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

.chart-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.chart-canvas-container {
  width: 100%;
  height: 180px;
  position: relative;
}

.chart-canvas-container canvas {
  width: 100% !important;
  height: 180px !important;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

.app-footer a {
  color: var(--primary-light);
  font-weight: 600;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}
