/* app/app/static/css/main.css  (FULL REPLACEMENT)
   Agrinomy UI (dark) + IBM Plex typography + Fertigation helpers
*/

/* =========================
   Theme + Tokens
   ========================= */

:root{
  /* Surfaces */
  --bg: #0b1220;
  --bg-top: #070b14;
  --surface: rgba(255,255,255,0.06);
  --surface-2: rgba(255,255,255,0.09);
  --border: rgba(255,255,255,0.12);

  /* Text */
  --text-color: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.70);
  --muted-2: rgba(255,255,255,0.55);

  /* Accent / status */
  --accent: #79c0ff;
  --accent-2: #67e8f9;
  --danger: #fb7185;
  --warn: #fbbf24;
  --ok: #34d399;

  /* Layout */
  --shadow: 0 12px 30px rgba(0,0,0,0.35);
  --radius: 18px;
  --maxw: 1100px;

  /* Typography — IBM Plex */
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --base-font-size: 15px;
  --line: 1.55;

  --h1: 32px;
  --h2: 24px;
  --h3: 18px;
  --h4: 16px;
}

/* =========================
   Base + layout
   ========================= */

*{ box-sizing: border-box; }

html, body{ height:100%; width:100%; max-width:100%; overflow-x:hidden; }

body{
  margin:0;
  font-family: var(--font-sans);
  font-size: var(--base-font-size);
  line-height: var(--line);
  font-weight: 400;
  color: var(--text-color);

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;

  background:
    radial-gradient(1200px 600px at 10% 0%, rgba(121,192,255,0.18), transparent 60%),
    radial-gradient(900px 500px at 90% 20%, rgba(103,232,249,0.12), transparent 55%),
    linear-gradient(180deg, var(--bg-top), var(--bg) 35%, var(--bg-top));

  /* Sticky footer layout */
  display:flex;
  flex-direction:column;
}

.container{
  width: 100%;
  max-width: var(--maxw, 1200px);
  margin: 0 auto;
  padding: 20px 16px 40px;
  flex: 1;
}

a{ color: var(--accent); text-decoration:none; }
a:hover{ text-decoration: underline; }

/* UI inputs inherit typography cleanly */
button, input, select, textarea{
  font-family: var(--font-sans);
}

/* Headings */
h1, h2, h3, h4, h5, h6{
  font-family: var(--font-sans);
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0 0 0.6em;
  color: var(--text-color);
}
h1{ font-size: var(--h1); letter-spacing: -0.02em; }
h2{ font-size: var(--h2); }
h3{ font-size: var(--h3); letter-spacing: -0.01em; }
h4{ font-size: var(--h4); letter-spacing: -0.01em; }

/* Labels + helper text */
label, .small, .help, .sub, .caption{
  font-weight: 450;
  letter-spacing: 0.002em;
}

.muted{ color: var(--muted); }

/* Numeric readability */
table{ font-variant-numeric: tabular-nums; }

/* Code / mono */
code, pre, kbd, samp, .mono{
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
pre{
  font-size: 13px;
  line-height: 1.5;
}

/* Optional: “report” areas */
.prose, .article, .longform{
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-color);
}
.prose h1, .prose h2, .prose h3,
.article h1, .article h2, .article h3,
.longform h1, .longform h2, .longform h3{
  font-family: var(--font-sans);
}

/* Placeholders */
input::placeholder, textarea::placeholder{ opacity: 0.75; }

/* =========================
   Encyclopaedia typography
   ========================= */

.encyclopedia,
.encyclopedia *,
.markdown,
.markdown * {
  font-family: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
               "Helvetica Neue", Arial, sans-serif;
}


/* =========================
   Top bar / nav
   ========================= */

.topbar{
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
  background: rgba(7,11,20,0.6);
  border-bottom: 1px solid var(--border);
}

.topbar-inner{
  max-width: var(--maxw);
  margin:0 auto;
  padding: 14px 16px;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight: 750;
  letter-spacing: 0.2px;
}

.brand-badge{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(121,192,255,0.9), rgba(103,232,249,0.85));
  box-shadow: var(--shadow);
}

.nav{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content:flex-end;
}

.nav-btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--text-color);
  text-decoration:none;
  font-weight: 600;
  font-size: 14px;
}
.nav-btn:hover{
  background: rgba(255,255,255,0.08);
  border-color: rgba(121,192,255,0.35);
  text-decoration:none;
}
.nav-btn.active{
  background: rgba(121,192,255,0.14);
  border-color: rgba(121,192,255,0.50);
}
/* =========================
   Nav "More" dropdown
   ========================= */
.nav-more{
  position: relative;
  display: inline-flex;
}

.nav-more-btn{
  cursor: pointer;
}

/* dropdown */
.nav-dropdown{
  position: absolute;
  top: calc(100% + 8px);
  right: 0;

  display: none;
  min-width: 200px;
  padding: 8px;

  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 1000;
}

.nav-more:hover .nav-dropdown{
  display: block;
}

.nav-dd-item{
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}

.nav-dd-item:hover{
  background: var(--surface-2);
}
.nav-dropdown.is-open{
  display: block;
}

/* =========================
   Page header
   ========================= */

.page-head{
  margin: 18px 0 16px;
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 16px;
}

.h1{
  font-size: 28px;
  line-height: 1.2;
  margin:0;
  letter-spacing: -0.2px;
  color: var(--text-color);
}

.sub{
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* =========================
   Cards / layout helpers
   ========================= */

.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text-color);
}

.card.pad{ padding: 16px; }

.card-head{
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}

.card-title{
  margin:0;
  font-size: 16px;
  font-weight: 750;
  color: var(--text-color);
}

.card-body{ padding: 16px; }

.card-foot{
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content:flex-end;
}

.grid{
  display:grid;
  gap: 14px;
  width:100%;
  max-width:100%;
  min-width:0;
}
.grid > *{ min-width:0; }

.grid.cols-2{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3{ grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 900px){
  .grid.cols-3{ grid-template-columns: 1fr; }
  .grid.cols-2{ grid-template-columns: 1fr; }
}

.row{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* =========================
   Buttons / chips / badges
   ========================= */

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--text-color);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
  cursor:pointer;
  text-decoration:none;
}
.btn:hover{ background: rgba(255,255,255,0.08); border-color: rgba(121,192,255,0.35); text-decoration:none; }
.btn:disabled{ opacity: 0.5; cursor:not-allowed; }
.btn.primary{ background: rgba(121,192,255,0.16); border-color: rgba(121,192,255,0.55); }
.btn.danger{ background: rgba(251,113,133,0.14); border-color: rgba(251,113,133,0.55); }

.btn.btn-small{
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 10px;
  font-weight: 800;
}

.chip{
  display:inline-flex;
  gap:8px;
  align-items:center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.badge{
  display:inline-flex;
  align-items:center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.75);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.badge.badge-alt{
  border-color: rgba(121,192,255,0.40);
  background: rgba(121,192,255,0.12);
  color: rgba(121,192,255,0.95);
}

/* =========================
   Forms
   ========================= */

.form{ display:grid; gap: 12px; }
.field{ display:grid; gap: 6px; }

.label{
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  display:block;
  margin-bottom: 6px;
}

.input, select, textarea{
  width:100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.22);
  color: var(--text-color);
  outline: none;
}

.input:focus, select:focus, textarea:focus{
  border-color: rgba(121,192,255,0.6);
  box-shadow: 0 0 0 4px rgba(121,192,255,0.12);
}

.help{ font-size: 12px; color: var(--muted-2); }
input[type="date"].input{ padding: 9px 12px; }
button.btn{ appearance: none; }

/* =========================
   Tables
   ========================= */

.table, .tbl{
  width:100%;
  border-collapse: collapse;
  overflow:hidden;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
}

.table th, .table td,
.tbl th, .tbl td{
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align:left;
  font-size: 14px;
  color: var(--text-color);
}

.table th, .tbl th{
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.01em;
  background: rgba(255,255,255,0.04);
}

.table tr:hover td, .tbl tr:hover td{
  background: rgba(255,255,255,0.03);
}

/* Prevent tables from breaking page width */
.table-wrap{
  width: 100%;
  overflow-x: auto;
}

/* =========================
   Flash + alerts (unified)
   ========================= */

.flash-wrap{ display:grid; gap:10px; margin: 14px 0; }

.flash, .alert{
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text-color);
}

.flash.info, .alert.info{
  border-color: rgba(121,192,255,0.45);
  background: rgba(121,192,255,0.10);
}

.flash.ok, .alert.ok{
  border-color: rgba(52,211,153,0.45);
  background: rgba(52,211,153,0.10);
}

.flash.warn, .alert.warn{
  border-color: rgba(251,191,36,0.55);
  background: rgba(251,191,36,0.10);
}

.flash.danger, .alert.danger{
  border-color: rgba(251,113,133,0.65);
  background: rgba(251,113,133,0.10);
}

/* =========================
   Key-value blocks
   ========================= */

.kv{ display:grid; gap: 10px; }

.kv > div{
  display:flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
}

.k{
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.2px;
}

.v{
  color: var(--text-color);
  font-weight: 700;
  font-size: 13px;
  text-align: right;
}

/* =========================
   Utilities
   ========================= */

.truncate{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  max-width: 100%;
}

/* details marker cleanup */
details summary::-webkit-details-marker { display:none; }
details summary { list-style: none; }

/* =========================
   Horizontal scroller (canonical)
   ========================= */

.hscroll{
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: block;

  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
}

.hscroll::-webkit-scrollbar{ height: 10px; }

.hscroll::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
}

/* =========================
   Fertigation helpers
   ========================= */

/* Nutrient grid (spreadsheet-like) */
.nutrient-grid{
  display: grid;
  gap: 10px;
  align-items: end;
  padding: 12px;
  min-width: 920px;
}

.nutrient-grid .ng-label{
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
  align-self: center;
}

.nutrient-grid .ng-head{
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding-bottom: 4px;
}

.ng-cell .input{
  text-align: center;
  padding: 10px 10px;
}

/* Let nutrient grids overflow inside the scroller (not the page) */
.hscroll .nutrient-grid{
  width: max-content;
}

/* Explicit column maps (prevents stretching/misalignment) */
.nutrient-grid.ng-wide-15{
  grid-template-columns: 160px repeat(15, minmax(90px, 1fr));
}
.nutrient-grid.ng-wide-13{
  grid-template-columns: 160px repeat(13, minmax(90px, 1fr));
}
.nutrient-grid.ng-wide-3{
  grid-template-columns: 160px repeat(3, minmax(90px, 1fr));
  max-width: 700px;
}

/* Make the small “More” row not look stretched */
.nutrient-grid.ng-wide-3 .ng-cell .input{ max-width: 220px; }

/* Compact numeric boxes inside the horizontal grids */
.input.input-compact{
  padding: 9px 10px;
  min-width: 80px;
}

/* Mobile: make the nutrient grid stack into 2 columns */
@media (max-width: 900px){
  .nutrient-grid{
    min-width: 0 !important;
    grid-template-columns: 1fr 1fr !important;
  }
  .nutrient-grid .ng-head{ text-align:left; }
  .ng-cell .input{ text-align:left; }

  .nutrient-grid.ng-wide-15,
  .nutrient-grid.ng-wide-13,
  .nutrient-grid.ng-wide-3{
    grid-template-columns: 1fr 1fr !important;
    min-width: 0 !important;
    max-width: none !important;
  }
  .nutrient-grid.ng-wide-3 .ng-cell .input{ max-width: none; }
}

/* Results toggles */
.toggles{
  display:flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items:center;
}
.toggles label{
  display:flex;
  align-items:center;
  gap:8px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}
.toggles input[type="checkbox"]{
  width: 16px;
  height: 16px;
}

/* Status badges + row highlighting */
.status{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width: 86px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  font-weight: 800;
  font-size: 12px;
  color: var(--text-color);
}
.status.ok{ border-color: rgba(52,211,153,0.60); background: rgba(52,211,153,0.12); }
.status.warn{ border-color: rgba(251,191,36,0.70); background: rgba(251,191,36,0.12); }
.status.bad{ border-color: rgba(251,113,133,0.75); background: rgba(251,113,133,0.12); }

.row-warn td{ background: rgba(251,191,36,0.08); }
.row-bad td{ background: rgba(251,113,133,0.08); }

/* =========================
   Charts (canonical)
   ========================= */

.chart-wrap{
  position: relative;
  width: 100%;
  height: 260px;
}
@media (max-width: 640px){
  .chart-wrap{
    height: 220px;
  }
}
.chart-wrap canvas{
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* =========================
   Footer
   ========================= */

.site-footer{
  margin-top: 28px;
  padding: 18px 16px;
  text-align: center;

  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.10);
  backdrop-filter: blur(6px);

  color: var(--muted);
  font-size: 13px;
}

.site-footer a{
  color: var(--text-color);
  font-weight: 700;
  text-decoration: none;
}

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

.site-footer .support-link{
  margin: 0;
}

/* =========================
   Auth pages (login/register)
   ========================= */

.auth-wrap{
  max-width: 980px;
  margin: 28px auto;
  padding: 0 14px;
}

.auth-grid{
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.auth-aside{
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  overflow: hidden;
}

.auth-aside-inner{
  padding: 22px;
}

.brand-mark{
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg,
    rgba(255,255,255,0.10),
    rgba(255,255,255,0.02)
  );
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  margin-bottom: 14px;
}

.auth-h1{
  font-size: 26px;
  line-height: 1.15;
  margin: 0 0 8px;
}

.auth-sub{
  margin: 0 0 14px;
  color: var(--muted);
}

.auth-bullets{
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.auth-bullets li{ margin: 6px 0; }

.auth-footnote{
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.auth-card .card-head{
  padding-bottom: 0;
}

.auth-form{
  display: grid;
  gap: 14px;
}

.field .label-row{
  display:flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.small-link{
  font-size: 12.5px;
  opacity: 0.9;
}

.field-error{
  margin-top: 7px;
  font-size: 12.5px;
  color: var(--danger);
}

.input-with-btn{
  display:flex;
  gap: 10px;
  align-items: center;
}

.btn-block{
  width: 100%;
  justify-content: center;
}

.btn-ghost{
  background: transparent;
  border: 1px solid var(--border);
}

.btn-icon{
  width: 44px;
  height: 42px;
  padding: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius: 12px;
}

.pw-eye{
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 12px;
  position: relative;
  opacity: 0.85;
}
.pw-eye:after{
  content:"";
  position:absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  border: 2px solid currentColor;
  transform: translate(-50%, -50%);
}
#togglePw.is-on .pw-eye{ opacity: 1; }

.row-between{
  display:flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.check{
  display:flex;
  align-items:center;
  gap: 10px;
  user-select: none;
}

.checkbox{
  width: 16px;
  height: 16px;
}

.dot{ opacity: 0.6; padding: 0 6px; }

/* Mobile */
@media (max-width: 860px){
  .auth-grid{ grid-template-columns: 1fr; }
  .auth-aside{ order: 2; }
}

/* =========================
   Printing
   ========================= */

@media print{
  .topbar, .toggles, .btn{ display:none !important; }
  body{ background: #fff !important; color:#000 !important; }
  .card{ box-shadow:none !important; background:#fff !important; border: 1px solid #ddd !important; }
  .tbl, .table{ border: 1px solid #ddd !important; }
  .tbl th, .tbl td, .table th, .table td{ color:#000 !important; border-bottom: 1px solid #ddd !important; }
  .print-newpage{ page-break-before: always; }
}
/* =========================
   Fertigation input rows
   Mobile: label + input paired
   Desktop: tighter, not miles apart
   ========================= */

.kv-list{
  display: grid;
  gap: 8px;
}

/* Desktop / tablet default: tighter pairing */
.kv-row{
  display: flex;
  align-items: center;
  gap: 12px;
}

.kv-row .kv-label{
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  flex: 0 0 140px;   /* label width */
  max-width: 140px;
}

.kv-row .kv-input{
  width: 180px;      /* input width */
  max-width: 100%;
}

/* Mobile: switch to grid so label + input stay readable */
@media (max-width: 720px){
  .kv-row{
    display: grid;
    grid-template-columns: 1fr 140px;
    gap: 10px;
    align-items: center;
  }

  .kv-row .kv-label{
    flex: initial;
    max-width: none;
  }

  .kv-row .kv-input{
    width: 100%;
  }
}

/* Very small phones */
@media (max-width: 420px){
  .kv-row{ grid-template-columns: 1fr 160px; }
}
/* =========================
   Scouting photo grid
   Keeps images contained and uniform
   ========================= */

.photo-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

figure.photo{
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255,255,255,0.03);
}

figure.photo a{
  display: block;
}

figure.photo img{
  display: block;
  width: 100%;
  height: 220px;          /* standard tile height */
  object-fit: cover;      /* crop to tile, keep aspect */
}

figure.photo figcaption{
  padding: 10px 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}

/* Keep the delete button from stretching the tile */
figure.photo form{
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
