/* ==========================================================================
 * styles.css — SHL Feedback / NPS Dashboard
 * Calm, professional, SHL/LEITWOLF brand palette. Progressive disclosure.
 * ======================================================================== */

:root {
  /* SHL brand (from 00-kontext/shl_strategy_brand.md) */
  --burgund:   #6b223d;   /* main */
  --akzent:    #9e0f4f;   /* accent */
  --altrosa:   #bf796b;
  --greige:    #cbbfb9;
  --bg:        #f5f5f5;
  --text:      #3a3a3a;

  /* semantic NPS colors (calm, brand-tuned) */
  --prom: #4f7d5e;   /* muted green */
  --pass: #c9a24b;   /* muted amber */
  --detr: #b0485a;   /* muted red, leans burgund */

  --surface: #ffffff;
  --border:  #e4ddd9;
  --muted:   #8a8079;
  --radius:  14px;
  --shadow:  0 1px 3px rgba(58,58,58,.06), 0 6px 20px rgba(58,58,58,.05);
  --maxw: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--text);
  background: var(--bg); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit; cursor: pointer; border: 1px solid transparent;
  border-radius: 10px; padding: .55rem 1rem; transition: background .15s, border-color .15s;
}
.btn:focus-visible { outline: 3px solid var(--altrosa); outline-offset: 2px; }
.btn-primary { background: var(--burgund); color: #fff; }
.btn-primary:hover { background: var(--akzent); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--altrosa); }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }

/* ---------- Password gate ---------- */
.gate {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--burgund), #4a1729);
  padding: 1.5rem; z-index: 100;
}
[hidden] { display: none !important; }
.gate-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 2.25rem 2rem; width: 100%; max-width: 360px; text-align: center;
}
.gate-title { color: var(--burgund); font-size: 1.35rem; }
.gate-sub { color: var(--muted); margin: .4rem 0 1.3rem; font-size: .95rem; }
.gate-input {
  width: 100%; font: inherit; padding: .7rem .85rem; border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: .9rem;
}
.gate-input:focus-visible { outline: 3px solid var(--altrosa); outline-offset: 1px; border-color: var(--altrosa); }
.gate-btn { width: 100%; }
.gate-error { color: var(--detr); margin: .8rem 0 0; font-size: .9rem; }

/* ---------- Layout ---------- */
.dashboard { max-width: var(--maxw); margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.banner {
  border-radius: 10px; padding: .75rem 1rem; margin-bottom: 1.25rem;
  font-size: .9rem; border: 1px solid;
}
.banner.sample { background: #fdf6e9; border-color: #e8d3a0; color: #7a5b16; }
.banner.error  { background: #fbeaec; border-color: #e3b3bb; color: #8a2230; }

.app-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem;
}
.app-title { color: var(--burgund); font-size: 1.7rem; letter-spacing: -.01em; }
.app-subtitle { color: var(--muted); font-size: .9rem; margin-top: .15rem; }
.app-header-actions { display: flex; gap: .5rem; }

.controls {
  display: flex; align-items: end; gap: 1rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin-bottom: 1.5rem; box-shadow: var(--shadow);
}
.control-group { display: flex; flex-direction: column; gap: .25rem; }
.control-group label { font-size: .78rem; color: var(--muted); }
.controls input[type=date] {
  font: inherit; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 8px;
}
.total-count { margin-left: auto; text-align: right; }
.total-num { display: block; font-size: 1.6rem; font-weight: 700; color: var(--burgund); line-height: 1; }
.total-label { font-size: .78rem; color: var(--muted); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem 1.5rem; box-shadow: var(--shadow);
}
.card-title { font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 1rem; }

.default-view {
  display: grid; gap: 1.25rem; margin-bottom: 1.5rem;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1.2fr);
  grid-template-areas: "nps breakdown" "trend trend";
}
.nps-card { grid-area: nps; text-align: center; }
.breakdown-card { grid-area: breakdown; }
.trend-card { grid-area: trend; }

/* ---------- NPS gauge ---------- */
.nps-gauge-wrap { position: relative; width: 100%; max-width: 280px; margin: 0 auto; }
.nps-gauge { width: 100%; height: auto; display: block; }
.gauge-bg { fill: none; stroke: var(--greige); stroke-width: 14; stroke-linecap: round; opacity: .5; }
.gauge-fill {
  fill: none; stroke: var(--burgund); stroke-width: 14; stroke-linecap: round;
  stroke-dasharray: 283; stroke-dashoffset: 283; transition: stroke-dashoffset .7s ease, stroke .4s;
}
.nps-number-wrap { position: absolute; left: 0; right: 0; bottom: 6%; }
.nps-number { display: block; font-size: 2.6rem; font-weight: 800; color: var(--burgund); line-height: 1; }
.nps-sublabel { font-size: .8rem; color: var(--muted); letter-spacing: .08em; }
.nps-hint { font-size: .78rem; color: var(--muted); margin: .9rem 0 0; }

/* ---------- Stacked bar ---------- */
.stacked-bar {
  display: flex; height: 30px; border-radius: 8px; overflow: hidden; background: var(--bg);
  border: 1px solid var(--border); margin-bottom: 1.1rem;
}
.seg { height: 100%; transition: width .5s ease; }
.seg-prom { background: var(--prom); }
.seg-pass { background: var(--pass); }
.seg-detr { background: var(--detr); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.legend li { display: flex; align-items: center; gap: .5rem; font-size: .92rem; }
.legend strong { margin-left: auto; }
.legend .muted { margin-left: .4rem; min-width: 46px; text-align: right; }
.dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.dot-prom { background: var(--prom); }
.dot-pass { background: var(--pass); }
.dot-detr { background: var(--detr); }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 220px; }
.chart-box-tall { height: 300px; }
.chart-box-sm { height: 200px; max-width: 280px; }

/* ---------- Disclosure ---------- */
.disclosure {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 1rem; box-shadow: var(--shadow); overflow: hidden;
}
.disclosure-head {
  cursor: pointer; padding: 1.1rem 1.4rem; font-weight: 600; color: var(--burgund);
  list-style: none; display: flex; align-items: center; gap: .6rem; user-select: none;
}
.disclosure-head::-webkit-details-marker { display: none; }
.disclosure-head:focus-visible { outline: 3px solid var(--altrosa); outline-offset: -3px; }
.chev { transition: transform .2s; color: var(--altrosa); }
.disclosure[open] .chev { transform: rotate(90deg); }
.disclosure-body { padding: 0 1.4rem 1.5rem; }
.two-col { display: grid; gap: 1.5rem; grid-template-columns: 1fr 1fr; align-items: start; }
.sub-h { font-size: .9rem; margin-bottom: .8rem; color: var(--text); }

/* ---------- Facet filters ---------- */
.facet-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 1rem; }
.facet h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .5rem; }
.facet-options { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
  border: 1px solid var(--border); border-radius: 20px; padding: .3rem .75rem; font-size: .85rem;
  background: var(--bg); transition: background .15s, border-color .15s, color .15s;
}
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip:has(input:checked) { background: var(--burgund); color: #fff; border-color: var(--burgund); }
.chip:focus-within { outline: 2px solid var(--altrosa); outline-offset: 1px; }

/* ---------- Theme cloud ---------- */
.theme-cloud { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.theme-tag {
  background: var(--bg); border: 1px solid var(--border); border-radius: 20px;
  padding: .25rem .7rem; color: var(--burgund);
}
.theme-tag .cnt { color: var(--muted); font-size: .8em; margin-left: .3rem; }

/* ---------- Table ---------- */
.table-search {
  width: 100%; max-width: 360px; font: inherit; padding: .55rem .8rem;
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 1rem;
}
.table-wrap { overflow-x: auto; }
.resp-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.resp-table th, .resp-table td {
  text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.resp-table th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
.resp-table td:nth-child(5), .resp-table td:nth-child(6), .resp-table td:nth-child(7) {
  max-width: 220px; font-size: .84rem; color: #555;
}
.score-pill { display: inline-block; min-width: 26px; text-align: center; padding: .15rem .4rem; border-radius: 6px; font-weight: 600; color: #fff; font-size: .82rem; }
.s-prom { background: var(--prom); }
.s-pass { background: var(--pass); }
.s-detr { background: var(--detr); }
.sent { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.sent-pos { color: var(--prom); }
.sent-neu { color: var(--pass); }
.sent-neg { color: var(--detr); }

.app-footer { margin-top: 1.5rem; text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .default-view { grid-template-columns: 1fr; grid-template-areas: "nps" "breakdown" "trend"; }
  .two-col { grid-template-columns: 1fr; }
  .total-count { margin-left: 0; text-align: left; }
}

/* ---------- Print / PDF ---------- */
@media print {
  body { background: #fff; }
  .gate, .app-header-actions, .controls .btn, #date-reset,
  .table-search, #facet-reset { display: none !important; }
  .dashboard { max-width: 100%; padding: 0; }
  .card, .disclosure { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  /* Expand all disclosure sections when printing so PDF captures everything. */
  .disclosure[open] .disclosure-body { display: block; }
  .chev { display: none; }
  a[href]::after { content: ""; }
}

/* ── Einzelantworten: Aufklapp-Detail pro Submit ── */
.resp-row { cursor: pointer; }
.resp-row:hover { background: #fbf7f4; }
.resp-caret { display: inline-block; transition: transform .15s ease; color: var(--burg, #6b223d); font-size: .8em; }
.resp-row.open .resp-caret { transform: rotate(90deg); }
.resp-detail > td { background: #faf7f5; padding: 14px 18px; border-top: none; }
.qa-grid { display: grid; gap: 4px; margin-bottom: 10px; }
/* section header within a self-describing (answers_json) detail, grouped by key prefix */
.qa-section { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted, #8a8079); font-weight: 600; margin: 8px 0 4px; }
.qa-section:first-child { margin-top: 0; }
.qa { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 5px 10px; background: #fff; border: 1px solid #ece6e1; border-radius: 7px; font-size: 13px; }
.qa-q { color: #3a3a3a; line-height: 1.35; }
.qa-v { flex-shrink: 0; min-width: 30px; text-align: center; padding: 2px 9px; font-weight: 700; color: #fff; background: var(--burgund, #6b223d); border-radius: 5px; }
.detail-open { font-size: 13px; color: #3a3a3a; margin-top: 4px; line-height: 1.5; }
