/* styles.css — Terugverdientijd Thuisbatterij
   Responsief dashboard, kaarten, tabellen, grafieken. */

:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #0ea5e9;
  --primary-d: #0369a1;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --doubtful: #d97706;
  --doubtful-bg: #fef3c7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

/* ---------- Header ---------- */
.app-header {
  background: linear-gradient(135deg, #0369a1, #0ea5e9);
  color: #fff;
  padding: 18px 20px;
}
.app-header__inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}
.app-header h1 { margin: 0; font-size: 22px; }
.subtitle { margin: 4px 0 0; font-size: 13px; opacity: .9; max-width: 60ch; }
.app-header__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1400px;
  margin: 20px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
}

.column-inputs { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }
@media (max-width: 1000px) { .column-inputs { position: static; } }
.column-results { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.panel h2 {
  margin: 0 0 14px;
  font-size: 15px;
  color: #334155;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
}
.sub-head { font-size: 13px; color: var(--muted); margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Form ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .grid-2 { grid-template-columns: 1fr; } }

.field { margin-bottom: 12px; display: flex; flex-direction: column; }
.field label { font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.field input {
  padding: 9px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  width: 100%;
  background: #fff;
}
.field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,165,233,.15); }
.field.disabled { opacity: .45; }
.field.disabled input { background: #f1f5f9; pointer-events: none; }
.field.has-error input { border-color: var(--bad); background: var(--bad-bg); }
.field-error { color: var(--bad); font-size: 12px; margin-top: 4px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.check {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; margin: 8px 0 12px; cursor: pointer;
}
.check input { width: 16px; height: 16px; }
.check--highlight {
  background: #e0f2fe; border: 1px solid #7dd3fc;
  padding: 10px 12px; border-radius: 8px; margin: 4px 0 14px;
}

.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  border: 0; border-radius: 8px; padding: 9px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: #fff; color: var(--primary-d); }
.btn-primary:hover { background: #e0f2fe; }
.btn-ghost { background: rgba(255,255,255,.18); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.3); }
.column-results .btn-ghost { background: #f1f5f9; color: var(--primary-d); }
.column-results .btn-ghost:hover { background: #e2e8f0; }
.btn-help { background: #fbbf24; color: #422006; }
.btn-help:hover { background: #f59e0b; }

/* ---------- Verdict ---------- */
.verdict {
  display: flex; gap: 14px; align-items: center;
  border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow);
  border-left: 6px solid var(--muted); background: #fff;
}
.verdict__icon {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 40px;
  display: grid; place-items: center; font-size: 20px; font-weight: 700; color: #fff;
}
.verdict__title { font-size: 18px; font-weight: 700; }
.verdict__sub { font-size: 13px; color: var(--muted); }
.verdict--good { border-color: var(--good); background: var(--good-bg); }
.verdict--good .verdict__icon { background: var(--good); }
.verdict--doubtful { border-color: var(--doubtful); background: var(--doubtful-bg); }
.verdict--doubtful .verdict__icon { background: var(--doubtful); }
.verdict--bad { border-color: var(--bad); background: var(--bad-bg); }
.verdict--bad .verdict__icon { background: var(--bad); }

/* ---------- Metric cards ---------- */
.metrics-grid, .sizing-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px;
}
.card-metric {
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
  border-top: 3px solid var(--primary);
}
.card-metric__label { font-size: 12px; color: var(--muted); font-weight: 600; }
.card-metric__value { font-size: 20px; font-weight: 700; margin-top: 4px; }
.card-metric__sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-metric--good { border-top-color: var(--good); }
.card-metric--good .card-metric__value { color: var(--good); }
.card-metric--doubtful { border-top-color: var(--doubtful); }
.card-metric--doubtful .card-metric__value { color: var(--doubtful); }
.card-metric--bad { border-top-color: var(--bad); }
.card-metric--bad .card-metric__value { color: var(--bad); }

/* ---------- Tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 600; background: #f8fafc; }
.data-table td:not(:first-child), .data-table th:not(:first-child) { text-align: right; }
.data-table--compact th, .data-table--compact td { padding: 5px 8px; font-size: 12px; }
.data-table .pos { color: var(--good); font-weight: 600; }
.data-table .neg { color: var(--bad); font-weight: 600; }
.table-scroll { overflow-x: auto; }

/* ---------- Advice ---------- */
.advice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 8px;
}
.advice--warning { background: var(--doubtful-bg); color: #92400e; }
.advice--info { background: #e0f2fe; color: #075985; }
.advice__icon { flex: 0 0 auto; }

/* ---------- Charts ---------- */
.chart { margin-top: 12px; width: 100%; }
.chart svg { display: block; }

/* ---------- Detail ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-head h2 { border: 0; margin: 0; padding: 0; }
.detail-wrap { max-height: 0; overflow: hidden; transition: max-height .3s ease; }
.detail-wrap.open { max-height: 4000px; margin-top: 12px; }
.detail-list { font-size: 13px; padding-left: 18px; }
.detail-list li { margin-bottom: 6px; }
.detail-wrap h3 { font-size: 14px; margin: 16px 0 8px; }

.muted { color: var(--muted); font-size: 13px; }
.result-footer { font-size: 12px; color: var(--muted); text-align: center; padding: 8px 0 24px; }

/* ---------- Uitleg-modal ---------- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%; height: 100%;
  z-index: 1000;
  background: rgba(15,23,42,.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 16px; overflow-y: auto;
}
.modal-overlay.hidden { display: none !important; }
.modal {
  background: #fff; border-radius: 14px; max-width: 760px; width: 100%;
  box-shadow: 0 20px 50px rgba(15,23,42,.35);
  margin: auto;
}
.modal__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: #fff; border-radius: 14px 14px 0 0; z-index: 1;
}
.modal__head h2 { margin: 0; font-size: 19px; color: var(--ink); }
.modal__close {
  border: 0; background: #f1f5f9; color: var(--ink); cursor: pointer;
  width: 34px; height: 34px; border-radius: 8px; font-size: 16px; flex: 0 0 auto;
}
.modal__close:hover { background: #e2e8f0; }
.modal__body { padding: 20px 22px 26px; font-size: 14px; line-height: 1.6; }
.modal__body h3 { font-size: 16px; margin: 22px 0 8px; color: #334155; }
.modal__body p { margin: 8px 0; }
.modal__body ul, .modal__body ol { margin: 8px 0; padding-left: 22px; }
.modal__body li { margin-bottom: 6px; }

.callout {
  border-radius: 10px; padding: 14px 16px; margin: 14px 0;
  border-left: 5px solid var(--muted); background: #f8fafc;
}
.callout > strong:first-child { display: block; margin-bottom: 6px; font-size: 15px; }
.callout--warning { background: var(--doubtful-bg); border-color: var(--doubtful); }
.callout--info { background: #e0f2fe; border-color: var(--primary); }
.callout--neutral { background: #f1f5f9; border-color: #94a3b8; }
.formula {
  font-family: 'Consolas', monospace; background: rgba(255,255,255,.7);
  border: 1px solid rgba(15,23,42,.12); border-radius: 6px;
  padding: 8px 12px; font-weight: 600; display: inline-block;
}

.explain-steps > li { margin-bottom: 10px; }
.explain-table { border-collapse: collapse; margin: 6px 0; }
.explain-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 4px; }
.dot--good { background: var(--good); }
.dot--doubtful { background: var(--doubtful); }
.dot--bad { background: var(--bad); }

/* ---------- Print ---------- */
@media print {
  .no-print, .modal-overlay { display: none !important; }
  body { background: #fff; }
  .layout { display: block; max-width: none; margin: 0; padding: 0; }
  .column-results { gap: 12px; }
  .panel { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .detail-wrap { max-height: none !important; overflow: visible !important; }
  .app-header { background: #0369a1 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .card-metric, .verdict, .advice { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
