/* =====================================================================
 *  Field Intelligence page.
 *
 *  Written against the app's LIGHT theme (index.css: --bg #f0f2ee, white
 *  cards, --text-dark #111). An earlier version of this file assumed a dark
 *  theme and set white text on white cards, which made every value invisible.
 * ===================================================================== */

.geo-input-card { margin-bottom: 18px; }

/* ---- method tabs ---- */
.geo-method-tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0 16px;
  flex-wrap: wrap;
}

.geo-method {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-mid);
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.geo-method:hover { color: var(--green-primary); border-color: var(--green-primary); }
.geo-method.active {
  color: #fff;
  background: var(--green-primary);
  border-color: var(--green-primary);
}

.geo-method-panel { display: none; }
.geo-method-panel.active { display: block; }

/* ---- inputs ---- */
.geo-hint {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.geo-search-row { display: flex; gap: 10px; flex-wrap: wrap; }
.geo-search-row .custom-input { flex: 1; min-width: 220px; }

.geo-coord-row,
.geo-details-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.geo-details-row {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.geo-field { display: flex; flex-direction: column; gap: 5px; min-width: 190px; flex: 1; }
.geo-field label {
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-geo-primary,
.btn-analyze {
  padding: 10px 20px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: var(--green-primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
}
.btn-geo-primary:hover,
.btn-analyze:hover:not(:disabled) { background: var(--green-bright); }

.btn-analyze {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  font-size: 13px;
}
.btn-analyze:disabled {
  background: #c8d4c4;
  color: #f4f7f2;
  cursor: not-allowed;
}

/* ---- status lines ---- */
.geo-status {
  font-size: 12px;
  line-height: 1.5;
  margin: 10px 0 0;
  color: var(--text-mid);
}
.geo-status.ok { color: var(--green-primary); font-weight: 600; }
.geo-status.warn { color: #b45309; font-weight: 600; }

/* Recovery steps shown when the browser has location blocked for this site
   and will therefore never show a permission popup. */
.geo-status.warn.has-steps,
.geo-status.warn:has(.gps-fix-steps) {
  padding: 12px 14px;
  background: #fff7ed;
  border-left: 3px solid #d97706;
  border-radius: 6px;
}

.gps-fix-steps {
  margin: 8px 0 0;
  padding-left: 20px;
  font-weight: 400;
  color: var(--text-mid);
}
.gps-fix-steps li { margin-bottom: 5px; line-height: 1.6; }

.gps-fix-alt {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px dashed #e7d3b5;
  font-weight: 400;
  color: var(--text-mid);
}

/* Inline "do this instead" actions, styled as links rather than buttons so
   they do not compete with the primary action. */
.link-btn {
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--green-primary);
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--green-bright); }

/* ---- search results ---- */
.geo-results { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }

.geo-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  text-align: left;
  font-family: inherit;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.geo-result:hover { border-color: var(--green-primary); background: var(--green-pale); }
.geo-result.chosen { border-color: var(--green-primary); background: var(--green-pale); }

.geo-result-name { font-size: 12px; color: var(--text-dark); line-height: 1.4; }
.geo-result-coords {
  font-size: 10px;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---- selected banner ---- */
.geo-selected {
  margin-top: 16px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dark);
  background: var(--green-pale);
  border-left: 3px solid var(--green-primary);
  border-radius: 6px;
}
.geo-coords-mono {
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  color: var(--text-mid);
  font-size: 11px;
}

/* ---- KPI row ---- */
.geo-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.kpi-geo { padding: 16px 18px; }
.kpi-geo-label {
  font-size: 9px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}
.kpi-geo-val {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-dark);
  margin: 6px 0 2px;
  text-transform: capitalize;
  line-height: 1.15;
}
.kpi-geo-sub { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

/* ---- two column ---- */
.geo-two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

/* ---- map ---- */
.map-wrap { position: relative; margin-top: 12px; }

.field-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  background: #e8ede6;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: grab;
}
.field-canvas:active { cursor: grabbing; }

.map-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.map-btn {
  width: 30px;
  height: 30px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-dark);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
}
.map-btn:hover { background: #fff; border-color: var(--green-primary); }

.map-attribution {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 9px;
  color: #555;
  background: rgba(255, 255, 255, 0.8);
  padding: 1px 5px;
  border-radius: 3px;
}
.map-attribution a { color: #555; }

.field-legend {
  margin-top: 10px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-mid);
}
.field-legend a { color: var(--green-primary); font-weight: 600; }

/* ---- tables ---- */
.geo-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.geo-table tr { border-bottom: 1px solid var(--border); }
.geo-table tr:last-child { border-bottom: none; }
.geo-table td { padding: 9px 6px; font-size: 12px; vertical-align: top; }
.geo-label { color: var(--text-muted); width: 34%; }
.geo-value { color: var(--text-dark); font-weight: 600; }
.geo-source {
  color: var(--text-muted);
  font-size: 9.5px;
  text-align: right;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  white-space: nowrap;
}

/* ---- soil bars ---- */
.soil-bars { margin: 14px 0 4px; display: flex; flex-direction: column; gap: 9px; }
.soil-bar-row { display: flex; align-items: center; gap: 10px; }
.soil-bar-label { font-size: 11px; color: var(--text-mid); width: 42px; font-weight: 600; }
.soil-bar {
  flex: 1;
  height: 10px;
  background: #e4e9e1;
  border-radius: 5px;
  overflow: hidden;
}
.soil-bar-fill { height: 100%; border-radius: 5px; transition: width 0.5s ease; }
.soil-bar-val {
  font-size: 11px;
  color: var(--text-dark);
  font-weight: 600;
  width: 48px;
  text-align: right;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
}

/* ---- crops ---- */
.crop-list { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.crop-row { display: flex; flex-direction: column; gap: 5px; }
.crop-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.crop-name { font-size: 13px; font-weight: 700; color: var(--text-dark); }
.crop-score {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
}
.crop-score.good { color: #10793f; }
.crop-score.ok   { color: #b45309; }
.crop-score.poor { color: #b91c1c; }

.crop-bar { height: 7px; background: #e4e9e1; border-radius: 4px; overflow: hidden; }
.crop-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.crop-bar-fill.good { background: #10793f; }
.crop-bar-fill.ok   { background: #d97706; }
.crop-bar-fill.poor { background: #b91c1c; }

.crop-reason { font-size: 11px; color: var(--text-muted); line-height: 1.5; }

/* ---- suggestions ---- */
.suggestion {
  margin-top: 12px;
  padding: 11px 13px;
  background: var(--green-pale);
  border-left: 3px solid var(--green-primary);
  border-radius: 6px;
}
.suggestion-action { font-size: 12.5px; font-weight: 700; color: var(--text-dark); }
.suggestion-reason { font-size: 11.5px; color: var(--text-mid); margin-top: 3px; line-height: 1.5; }

/* ---- evidence ---- */
.evidence-list { margin: 12px 0 0; padding-left: 20px; }
.evidence-list li { font-size: 12px; color: var(--text-mid); line-height: 1.75; }

.geo-disclaimer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-muted);
  font-style: italic;
}

/* =====================================================================
 *  Shared location bar (farm-location.js) — used on every page that
 *  needs a field position.
 * ===================================================================== */

.floc-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 13px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.floc-icon { font-size: 14px; }
.floc-text {
  flex: 1;
  min-width: 150px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dark);
}
.floc-btn {
  padding: 5px 11px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  color: var(--green-primary);
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.floc-btn:hover { border-color: var(--green-primary); background: var(--green-pale); }

.floc-note {
  margin-top: 7px;
  padding: 8px 12px;
  font-size: 11.5px;
  line-height: 1.55;
  border-radius: 6px;
  color: var(--text-mid);
  background: #f4f6f2;
}
.floc-note.ok { color: #10793f; background: var(--green-pale); }
.floc-note.warn { color: #92400e; background: #fff7ed; }

@media (max-width: 720px) {
  .geo-coord-row, .geo-details-row { flex-direction: column; align-items: stretch; }
  .btn-geo-primary { width: 100%; }
  .geo-source { display: none; }
}


/* =====================================================================
 *  Dashboard field panel (index.html, inside the Agent 1 card).
 *  Replaces inline dark-theme styles that rendered white text and black
 *  boxes on a white card — the values were there but unreadable.
 * ===================================================================== */

.gis-col {
  flex: 1;
  min-width: 280px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding-left: 20px;
  border-left: 1px dashed var(--border);
}

.gis-info { flex: 1; min-width: 0; }

.gis-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 3px;
}
.gis-change {
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  color: var(--green-primary);
}

.gis-coords {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  color: var(--text-dark);
}

.gis-source { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

/* Readable at a normal size — the old box was 8px light-grey on near-black. */
.gis-detail {
  margin-top: 6px;
  padding: 7px 9px;
  font-size: 11px;
  line-height: 1.65;
  color: var(--text-mid);
  background: #f6f8f4;
  border: 1px solid var(--border);
  border-radius: 5px;
  max-height: 78px;
  overflow-y: auto;
}
.gis-detail b { color: var(--text-dark); }
.gis-detail a { color: var(--green-primary); font-weight: 600; }

.gis-map-col { text-align: center; }

.gis-canvas {
  display: block;
  margin: 0 auto;
  background: #e8ede6;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.gis-map-label {
  margin-top: 3px;
  font-size: 8px;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
}

@media (max-width: 900px) {
  .gis-col { border-left: none; padding-left: 0; padding-top: 16px; border-top: 1px dashed var(--border); }
}
