/* ============================================================
   GISIT Dashboard — Dark Utilitarian Theme
   Mobile-first. Built for morning field-check on a phone.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=IBM+Plex+Sans:wght@300;400;500;600;700&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg-primary:     #0d0f0e;
  --bg-card:        #141716;
  --bg-card-hover:  #1a1e1c;
  --bg-section:     #111310;
  --border:         #2a2e2b;
  --border-light:   #1e2220;

  --text-primary:   #e8ece9;
  --text-secondary: #8a9289;
  --text-muted:     #555e57;
  --text-label:     #6b7a6e;

  /* Status colors */
  --go:             #4caf6e;
  --go-bg:          #0d2618;
  --go-border:      #1a4a2a;

  --caution:        #e8a020;
  --caution-bg:     #2a1e06;
  --caution-border: #4a3410;

  --nogo:           #e05252;
  --nogo-bg:        #2a0e0e;
  --nogo-border:    #4a1a1a;

  --info:           #5b9bd5;
  --info-bg:        #0d1e2e;
  --info-border:    #1a3350;

  /* Confidence */
  --conf-high:      #4caf6e;
  --conf-med:       #e8a020;
  --conf-low:       #e05252;

  --accent:         #c8a84b;   /* warm gold — harvest reference */
  --accent-dim:     #7a6530;

  --font-main:      'IBM Plex Sans', sans-serif;
  --font-mono:      'IBM Plex Mono', monospace;

  --radius:         6px;
  --radius-lg:      10px;
  --max-width:      520px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-weight: 400;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* ── Header ────────────────────────────────────────────── */
.dash-header {
  background: var(--bg-section);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.dash-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.dash-logo img {
  height: 36px;
  width: auto;
}

.dash-logo-text .brand {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1;
}

.dash-logo-text .sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
  margin-top: 3px;
}

.dash-meta {
  text-align: right;
}

.dash-meta .season-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.dash-meta .update-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Main Layout ───────────────────────────────────────── */
.dash-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 12px 24px;
}

/* ── Section Labels ────────────────────────────────────── */
.section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-label);
  padding: 16px 4px 8px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 10px;
}

/* ── Crop Season Snapshot ──────────────────────────────── */
.snapshot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 4px;
}

.snapshot-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.snapshot-tile .tile-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}

.snapshot-tile .tile-unit {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
}

.snapshot-tile .tile-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 5px;
}

.snapshot-tile.wide {
  grid-column: 1 / -1;
}

.snapshot-tile .tile-accent {
  color: var(--accent);
}

.snapshot-tile .tile-go { color: var(--go); }
.snapshot-tile .tile-caution { color: var(--caution); }
.snapshot-tile .tile-nogo { color: var(--nogo); }

/* Growing condition banner */
.condition-banner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  grid-column: 1 / -1;
}

.condition-banner .cond-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.condition-banner .cond-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--go);
}

/* ── Decision Cards ────────────────────────────────────── */
.decision-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.decision-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s;
}

.decision-card:active {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

/* Status-specific left border accent */
.decision-card.status-go    { border-left: 3px solid var(--go); }
.decision-card.status-caution { border-left: 3px solid var(--caution); }
.decision-card.status-nogo  { border-left: 3px solid var(--nogo); }
.decision-card.status-info  { border-left: 3px solid var(--info); }

.card-main {
  padding: 14px 16px 12px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.card-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}

.card-body {
  flex: 1;
  min-width: 0;
}

.card-question {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.card-reason {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}

.card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

.status-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 3px;
}

.status-go .status-badge    { background: var(--go-bg);     color: var(--go);     border: 1px solid var(--go-border); }
.status-caution .status-badge { background: var(--caution-bg); color: var(--caution); border: 1px solid var(--caution-border); }
.status-nogo .status-badge  { background: var(--nogo-bg);   color: var(--nogo);   border: 1px solid var(--nogo-border); }
.status-info .status-badge  { background: var(--info-bg);   color: var(--info);   border: 1px solid var(--info-border); }

.conf-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.conf-high { color: var(--conf-high); }
.conf-med  { color: var(--conf-med); }
.conf-low  { color: var(--conf-low); }

.card-expand-indicator {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Card drill-down details (hidden by default) */
.card-details {
  display: none;
  background: var(--bg-section);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}

.card-details.open {
  display: block;
}

.card-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}

.detail-item .detail-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.detail-item .detail-value {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.detail-item .detail-value.good  { color: var(--go); }
.detail-item .detail-value.warn  { color: var(--caution); }
.detail-item .detail-value.bad   { color: var(--nogo); }

.detail-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  line-height: 1.5;
}

/* ── 10-Day Forecast Strip ─────────────────────────────── */
.forecast-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 -12px;
  padding: 0 12px;
}

.forecast-scroll::-webkit-scrollbar { display: none; }

.forecast-strip {
  display: flex;
  gap: 6px;
  padding-bottom: 4px;
  width: max-content;
}

.forecast-day {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 10px 8px;
  min-width: 62px;
  text-align: center;
  flex-shrink: 0;
}

.forecast-day.today {
  border-color: var(--accent-dim);
  background: #1a160a;
}

.forecast-day .fc-dow {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.forecast-day.today .fc-dow {
  color: var(--accent);
}

.forecast-day .fc-icon {
  font-size: 20px;
  line-height: 1;
  margin: 5px 0 4px;
}

.forecast-day .fc-hi {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.forecast-day .fc-lo {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.forecast-day .fc-rain {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--info);
  margin-top: 4px;
}

.forecast-day .fc-rain.no-rain {
  color: var(--text-muted);
}

/* ── Current Conditions Bar ────────────────────────────── */
.current-conditions {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
}

.cond-item .cond-val {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}

.cond-item .cond-lbl {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Notes Section ─────────────────────────────────────── */
.notes-area {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.notes-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notes-header .notes-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.notes-header .notes-date {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.notes-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  padding: 12px 14px;
  resize: none;
  min-height: 80px;
  outline: none;
  line-height: 1.5;
}

.notes-input::placeholder { color: var(--text-muted); }

.notes-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
}

.btn-save-note {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: var(--font-main);
}

.btn-save-note:active {
  background: var(--accent);
  color: #0d0f0e;
}

.saved-notes-list {
  padding: 0 14px 4px;
}

.saved-note {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  color: var(--text-secondary);
}

.saved-note:last-child { border-bottom: none; }

.saved-note .note-ts {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

/* ── Placeholder Card (Yield Prediction) ───────────────── */
.placeholder-card {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.placeholder-card .ph-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.placeholder-card .ph-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 4px;
}

.placeholder-card .ph-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Loading State ─────────────────────────────────────── */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  flex-direction: column;
  gap: 12px;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Error State ───────────────────────────────────────── */
.error-banner {
  background: var(--nogo-bg);
  border: 1px solid var(--nogo-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--nogo);
  display: none;
}

.error-banner.visible { display: block; }

/* ── Login Screen ──────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-primary);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.login-logo {
  height: 48px;
  margin-bottom: 20px;
}

.login-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.login-input {
  width: 100%;
  background: var(--bg-section);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 15px;
  padding: 12px 14px;
  margin-bottom: 10px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.login-input:focus { border-color: var(--accent-dim); }

.login-btn {
  width: 100%;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 13px;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s, color 0.15s;
}

.login-btn:active {
  background: var(--accent);
  color: #0d0f0e;
}

.login-error {
  font-size: 12px;
  color: var(--nogo);
  margin-top: 10px;
  min-height: 18px;
}

/* ── Utility ───────────────────────────────────────────── */
.hidden { display: none !important; }

.data-stale {
  font-size: 10px;
  color: var(--caution);
  font-family: var(--font-mono);
}

/* ── Desktop Comfort (min-width: 560px) ────────────────── */
@media (min-width: 560px) {
  .dash-main { padding: 0 16px 32px; }
  .snapshot-grid { grid-template-columns: repeat(4, 1fr); }
  .snapshot-tile.wide { grid-column: auto; }
  .decision-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .decision-card.status-go,
  .decision-card.status-caution,
  .decision-card.status-nogo,
  .decision-card.status-info { grid-column: auto; }
}
