/* =========================================
   NF Foam Mix Calc — styles.css
   National Foam: #E8003D / black / white
   V1
   ========================================= */

:root {
  --bg:          #0a0a0a;
  --card:        #111111;
  --card2:       #1a1a1a;
  --border:      #2a2a2a;
  --border2:     #3a3a3a;
  --text:        #f0f0f0;
  --muted:       #888888;
  --accent:      #E8003D;
  --accent2:     #c4002f;
  --accent-glow: rgba(232,0,61,.18);
  --green:       #22c55e;
  --green-bg:    rgba(34,197,94,.12);
  --yellow:      #f59e0b;
  --yellow-bg:   rgba(245,158,11,.12);
  --red:         #E8003D;
  --red-bg:      rgba(232,0,61,.12);
  --blue:        #3b82f6;
  --blue-bg:     rgba(59,130,246,.12);
  --shadow:      0 8px 32px rgba(0,0,0,.7);
  --radius:      12px;
  font-family: 'SF Pro Display',-apple-system,'Helvetica Neue',Arial,sans-serif;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(232,0,61,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232,0,61,.03) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(900px, calc(100vw - 24px));
  margin: 14px auto;
  padding-bottom: 40px;
}

/* ── Header ── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.headerLeft  { display: flex; flex-direction: column; gap: 4px; }
.headerRight { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header h1   { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.3px; color: #fff; }
.nf          { color: var(--accent); font-weight: 900; }

.meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* ── Pills ── */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border2);
  border-radius: 999px;
  background: var(--card);
  font-size: 11px;
  color: var(--muted);
}
.pill.ok    { border-color: rgba(34,197,94,.4);  color: var(--green);  background: var(--green-bg); }
.pill.warn  { border-color: rgba(245,158,11,.4); color: var(--yellow); background: var(--yellow-bg); }
.pill.empty { border-color: rgba(232,0,61,.4);   color: #ff4d72;       background: var(--red-bg); }

/* ── Status bar ── */
.statusBar {
  position: sticky;
  bottom: 0;
  margin: 10px 0;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(17,17,17,.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 20;
}
.statusBarInner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.statusLeft, .statusRight { display: flex; align-items: center; gap: 8px; }
.statusDot {
  width: 7px; height: 7px;
  border-radius: 999px;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 7px var(--accent);
}
.statusBar[data-error="1"] .statusDot  { background: #ff4d72; box-shadow: 0 0 7px #ff4d72; }
.statusBar[data-error="1"] .statusText { color: #ff4d72; }

/* ── Card ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* ── Section header ── */
.sectionHeader {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 0 2px;
}
.sectionName {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  white-space: nowrap;
}
.sectionName.accent { color: var(--accent); }
.sectionLine { flex: 1; height: 1px; background: var(--border); }

/* ── Entry form ── */
.entryGrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}
.field  { display: grid; gap: 4px; min-width: 0; }
.lbl {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

input, select {
  width: 100%;
  font-size: 16px; /* iOS Safari: prevents auto-zoom */
  padding: 9px 10px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  outline: none;
  background: var(--card2);
  color: var(--text);
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(.5);
}

/* ── Buttons ── */
.btn {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--card2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn.primary          { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active   { background: var(--accent2); }
.btn.ghost            { background: transparent; }
.btn.ghost:hover      { background: rgba(255,255,255,.05); }
.btn:disabled         { opacity: .35; cursor: not-allowed; }
.saveBtn              { width: 100%; padding: 11px; font-size: 14px; font-weight: 600; letter-spacing: .3px; }

.iconBtn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.iconBtn:hover { color: var(--text); }

/* ── Results grid ── */
.resultsGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }

.resultCard {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  border-left: 3px solid var(--accent);
}
.resultCard.water { border-left-color: var(--blue); }
.resultCard.foam  { border-left-color: var(--accent); }

.resultTitle {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin-bottom: 8px;
}
.resultMain  { font-size: 28px; font-weight: 800; color: #fff; line-height: 1; }
.resultUnit  { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.resultAlts  { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.resultAlt {
  font-size: 12px;
  color: var(--muted);
  background: var(--card);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ── Subtract trigger row ── */
.subtractTrigger {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.subBtn {
  padding: 5px 12px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: border-color .15s, color .15s;
}
.subBtn:hover { border-color: var(--accent); color: var(--accent); }

.remainBox {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 10px;
  min-width: 0;
}
.remainLabel { font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 1px; }
.remainVal   { font-size: 14px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.remainBox.zero  { border-color: rgba(232,0,61,.5);  background: var(--red-bg); }
.remainBox.zero  .remainVal { color: #ff4d72; }
.remainBox.low   { border-color: rgba(245,158,11,.5); background: var(--yellow-bg); }
.remainBox.low   .remainVal { color: var(--yellow); }

/* ── Calc note ── */
.calcNote { font-size: 11px; color: var(--muted); line-height: 1.7; padding-top: 8px; }

/* ── Entries section ── */
.tableWrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

table.fuelTable { width: 100%; border-collapse: collapse; }
table.fuelTable thead tr { background: var(--card2); border-bottom: 1px solid var(--border); }
table.fuelTable th {
  padding: 8px 10px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}
table.fuelTable th.right  { text-align: right; }
table.fuelTable th.center { text-align: center; }
table.fuelTable tbody tr  { border-bottom: 1px solid var(--border); transition: background .12s; }
table.fuelTable tbody tr:last-child { border-bottom: none; }
table.fuelTable tbody tr:hover { background: rgba(255,255,255,.025); }
table.fuelTable td { padding: 10px; font-size: 13px; vertical-align: middle; }
table.fuelTable td.right  { text-align: right; }
table.fuelTable td.center { text-align: center; }

.deleteRowBtn {
  border: none;
  background: transparent;
  color: var(--border2);
  cursor: pointer;
  font-size: 15px;
  padding: 4px 6px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  transition: color .15s;
}
.deleteRowBtn:hover { color: var(--accent); }

.emptyState {
  text-align: center;
  padding: 40px 24px;
  color: var(--muted);
  font-size: 13px;
}

/* ── Subtraction sub-log (inside entry row) ── */
.subLogWrap { padding: 6px 10px 10px; }
.subLogHeading {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin-bottom: 6px;
}
.subLogZeroTag { color: #ff4d72; font-weight: 700; }

table.subLogTable { width: 100%; border-collapse: collapse; }
table.subLogTable td {
  padding: 5px 8px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  vertical-align: middle;
}
table.subLogTable tr:last-child td { border-bottom: none; }
.subLogDate { font-size: 10px; }
.subLogVal  { font-size: 13px; font-weight: 700; color: var(--text); }
.subLogRem  { font-size: 11px; color: var(--muted); }
.subLogZero { color: #ff4d72; font-weight: 700; font-size: 11px; }

/* ── Dialogs ── */
.dialog {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 100%;
  width: 100%;
}
.dialog::backdrop {
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.dialogCard {
  width: min(380px, calc(100vw - 24px));
  border-radius: 16px;
  border: 1px solid var(--border2);
  background: var(--card);
  box-shadow: var(--shadow), 0 0 0 1px rgba(232,0,61,.08);
  padding: 18px;
  display: grid;
  gap: 14px;
  margin: auto;
}
.dialogHeader {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.dialogFuelName { font-size: 18px; font-weight: 700; color: #fff; }
.dialogSub      { font-size: 11px; color: var(--muted); margin-top: 3px; text-transform: uppercase; letter-spacing: .6px; }

.useStats {
  display: flex;
  align-items: center;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.useStat        { flex: 1; padding: 12px 10px; text-align: center; }
.useStatVal     { font-size: 22px; font-weight: 800; color: #fff; line-height: 1; }
.useStatLbl     { font-size: 9px; color: var(--muted); margin-top: 3px; text-transform: uppercase; letter-spacing: .5px; }
.useStatDivider { width: 1px; height: 40px; background: var(--border); flex-shrink: 0; }

.usePreview        { font-size: 12px; color: var(--muted); min-height: 16px; line-height: 1.5; }
.usePreview.warn   { color: var(--yellow); }
.usePreview.danger { color: #ff4d72; }
.usePreview.ok     { color: var(--green); }

.dialogBtns      { display: flex; gap: 8px; }
.dialogBtns .btn { flex: 1; text-align: center; padding: 11px; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .wrap          { width: calc(100vw - 16px); margin: 8px auto; }
  .entryGrid     { grid-template-columns: 1fr 1fr; }
  .resultsGrid   { grid-template-columns: 1fr; }
  .header h1     { font-size: 18px; }
  table.fuelTable th { font-size: 8px; padding: 6px 7px; }
  table.fuelTable td { font-size: 12px; padding: 8px 7px; }
  .resultMain    { font-size: 22px; }
}
@media (max-width: 380px) {
  .entryGrid { grid-template-columns: 1fr; }
}
