/* Audapt Sales Tool - webversie. Kleuren en maten volgen het ontwerp in GUI\. */

:root {
  --accent: #1D4ED8;
  --accent-dark: #1E3A8A;
  --bg: #F4F6F8;
  --panel: #FFFFFF;
  --line: #E5E7EB;
  --line-soft: #F3F4F6;
  --head: #F9FAFB;
  --text: #111827;
  --muted: #4B5563;
  --sel: #EFF6FF;
  --dark: #0F172A;
  --dark-2: #1E293B;
  --dark-line: #334155;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; }
h2 { font-size: 14px; font-weight: 600; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
a:not([href]) { color: inherit; text-decoration: none; }
button, input { font-family: inherit; }
input:focus-visible, button:focus-visible, .scroll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.sr-only { position: absolute; left: -9999px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---- Opbouw ---- */

.app { height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  padding: 12px 24px; background: var(--dark); color: #F8FAFC;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #FFFFFF;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.brand-name { font-weight: 600; font-size: 16px; }
.brand.dark { color: var(--text); }
.topbar-search { flex: 1 1 320px; display: flex; justify-content: center; }
.topbar-search input {
  width: 100%; max-width: 520px; height: 40px; border-radius: 8px;
  border: 1px solid var(--dark-line); background: var(--dark-2); color: #F8FAFC;
  padding: 0 14px; font-size: 14px;
}
.topbar-search input::placeholder { color: #94A3B8; }
.topbar-meta { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #CBD5E1; }
.chip { padding: 4px 10px; border-radius: 999px; background: var(--dark-2); }

.banner { padding: 10px 24px; background: #FEF2F2; color: #991B1B; border-bottom: 1px solid #FECACA; }

.layout {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 16px; padding: 16px 24px;
}
.right { display: flex; flex-direction: column; gap: 16px; min-width: 0; min-height: 0; }
.cols {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(190px, 240px) minmax(0, 1fr) minmax(260px, 300px);
  gap: 16px;
}

.footer {
  padding: 0 24px 10px; font-size: 12px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between;
}

/* ---- Panelen ---- */

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.panel-head.stacked { display: block; }
.panel-head.stacked h2 + * { margin-top: 10px; }
.panel-head.stacked h2 + .small { margin-top: 4px; }
.panel-head.wrap { flex-wrap: wrap; }
.head-title { display: flex; align-items: baseline; gap: 10px; }
.head-tools { display: flex; align-items: center; gap: 8px; flex: 1 1 260px; justify-content: flex-end; }
.head-tools input { flex: 1 1 180px; max-width: 320px; }
.panel-head input {
  width: 100%; height: 36px; border: 1px solid #D1D5DB; border-radius: 8px;
  padding: 0 10px; font-size: 13px; background: #FFFFFF; color: var(--text);
}
.checks { display: flex; align-items: center; gap: 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; user-select: none; }
.panel-head .check input { width: 16px; height: 16px; padding: 0; margin: 0; accent-color: var(--accent); cursor: pointer; }
.scroll { flex: 1; min-height: 0; overflow: auto; }
.note { margin-top: 8px; font-size: 12px; color: #92400E; background: #FFFBEB; border-radius: 6px; padding: 6px 8px; }
.empty { padding: 24px 16px; color: var(--muted); font-size: 13px; }

/* ---- Lijsten (relaties, verkochte artikelen) ---- */

.row {
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft); cursor: pointer;
  background: #FFFFFF;
}
.row:hover { background: #F9FAFB; }
.row.sel { background: var(--sel); box-shadow: inset 3px 0 0 var(--accent); }
.row-top { display: flex; justify-content: space-between; gap: 8px; }
.row-name { font-weight: 600; overflow-wrap: anywhere; }
.row-code { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.sold-panel .row { font-size: 13px; padding: 10px 16px; }
.sold-panel .row-name { font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---- Geselecteerde relatie ---- */

.detail { flex-direction: row; flex-wrap: wrap; gap: 24px; align-items: center; padding: 16px 20px; overflow: visible; }
.detail-main { flex: 1 1 240px; min-width: 0; }
.detail-name { font-size: 20px; font-weight: 700; margin-top: 2px; overflow-wrap: anywhere; }
.detail-fields { display: flex; flex-wrap: wrap; gap: 24px; font-size: 13px; }

/* ---- Tabellen ---- */

.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid th {
  position: sticky; top: 0; z-index: 1;
  padding: 10px 8px; text-align: left; font-size: 12px; font-weight: 600;
  color: var(--muted); background: var(--head); white-space: nowrap;
}
.grid td { padding: 9px 8px; border-top: 1px solid var(--line-soft); overflow-wrap: anywhere; }
.grid th:first-child, .grid td:first-child { padding-left: 16px; }
.grid th:last-child, .grid td:last-child { padding-right: 16px; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid .code { font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid .strong { font-weight: 600; }
.tabular { font-variant-numeric: tabular-nums; }
#itemBody tr { cursor: pointer; }
#itemBody tr:hover { background: #F9FAFB; }
#itemBody tr.sel { background: var(--sel); box-shadow: inset 3px 0 0 var(--accent); }
.pill {
  display: inline-block; min-width: 28px; text-align: center; padding: 2px 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line-soft); color: var(--muted);
}
.pill.ok { background: #DCFCE7; color: #14532D; }

/* ---- Knoppen ---- */

.btn {
  height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid #D1D5DB;
  background: #FFFFFF; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #F9FAFB; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { height: 40px; padding: 0 16px; border: none; background: var(--accent); color: #FFFFFF; font-size: 14px; }
.btn.primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn.icon { width: 36px; padding: 0; border: none; font-size: 16px; }

/* ---- Vensters (registratie, voorraad) ---- */

.overlay {
  position: fixed; inset: 0; z-index: 10; background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.card {
  width: 100%; max-width: 420px; max-height: 100%; overflow: auto;
  background: #FFFFFF; border-radius: 12px; padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .3);
}
.card.wide { max-width: 680px; }
.card h1 { font-size: 18px; font-weight: 700; }
.card p { margin: 0; }
.card input {
  height: 40px; border: 1px solid #D1D5DB; border-radius: 8px; padding: 0 12px; font-size: 14px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-foot { display: flex; justify-content: flex-end; }
.error { color: #991B1B; background: #FEF2F2; border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.facts dd.big { font-size: 18px; }
#stockStatus { margin-top: 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  max-width: min(560px, calc(100vw - 32px));
  background: var(--dark); color: #F8FAFC; padding: 10px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .3);
}

/* ---- Smallere schermen ---- */

@media (max-width: 1400px) {
  .cols { grid-template-columns: minmax(190px, 240px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .prices-panel { grid-column: 1 / -1; max-height: 240px; }
}
@media (max-width: 900px) {
  .app { height: auto; min-height: 100vh; }
  .topbar, .layout { padding-left: 16px; padding-right: 16px; }
  .layout, .cols { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .rel-panel .scroll { max-height: 40vh; }
  .sold-panel .scroll { max-height: 40vh; }
  .items-panel .scroll { max-height: 70vh; }
  .prices-panel { grid-column: auto; max-height: none; }
  .footer { padding: 0 16px 10px; }
}
