/* Kundenhilfe-Portal – Basis-Styles. Akzentfarbe kommt aus config.js (BRAND_COLOR). */
:root {
  --brand: #0b5cad;
  --brand-ink: #fff;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e2e5ea;
  --line-strong: #cdd2da;
  --ink: #1b2330;
  --ink-2: #4a5566;
  --ink-3: #7a8494;
  --ok: #1d7a46;
  --ok-bg: #e5f4ea;
  --warn: #9a5b00;
  --warn-bg: #fff3dc;
  --err: #b42318;
  --err-bg: #fdeceb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.18);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
.muted { color: var(--ink-3); }
.small { font-size: .86rem; }
.hidden { display: none !important; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.stack > * + * { margin-top: .8rem; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 650; color: var(--ink); text-decoration: none; }
.brand img { height: 30px; }
.brand .dot { width: 12px; height: 12px; border-radius: 3px; background: var(--brand); }
.topbar .who { color: var(--ink-2); font-size: .9rem; text-align: right; }

/* ---------- Buttons & Inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: .5rem .9rem; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); border-color: #f1b8b3; }
.btn.danger:hover { background: var(--err-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: .3rem .6rem; font-size: .86rem; }
label { display: block; font-size: .86rem; font-weight: 600; color: var(--ink-2); margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=search], input[type=date], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: .5rem .65rem;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: .45rem; font-weight: 500; color: var(--ink); margin: 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.field + .field { margin-top: .75rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

/* ---------- Cards, Tabs, Badges ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; }
.card + .card { margin-top: 1rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tab { border: 0; background: none; font: inherit; font-weight: 600; color: var(--ink-3); padding: .65rem .9rem; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.badge { display: inline-block; font-size: .76rem; font-weight: 650; padding: .12rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.err { background: var(--err-bg); color: var(--err); border-color: transparent; }
.empty { text-align: center; color: var(--ink-3); padding: 2rem 1rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); font-weight: 650; }
tr:hover td { background: var(--surface-2); }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 270px 1fr; gap: 1.25rem; max-width: 1400px; margin: 0 auto; padding: 1.25rem; }
.sidebar { position: sticky; top: 72px; align-self: start; max-height: calc(100vh - 90px); overflow: auto; }
.nav-group { margin-bottom: 1rem; }
.nav-group h4 { margin: 0 0 .3rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.nav-item { display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit; color: var(--ink); padding: .45rem .6rem; border-radius: 7px; cursor: pointer; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: color-mix(in srgb, var(--brand) 12%, white); color: var(--brand); font-weight: 600; }
.nav-item small { display: block; color: var(--ink-3); font-weight: 400; }
.device-select-mobile { display: none; margin-bottom: 1rem; }
.page { max-width: 1100px; margin: 0 auto; padding: 1.25rem; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: .9rem; }
  .sidebar { display: none; }
  .device-select-mobile { display: block; }
  .grid2 { grid-template-columns: 1fr; }
  .topbar .who .hide-sm, .topbar .hide-sm { display: none; }
  .topbar { padding: .6rem .9rem; gap: .5rem; }
}

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; min-height: calc(100vh - 220px); }
.messages { flex: 1; display: flex; flex-direction: column; gap: 1rem; padding-bottom: 1rem; }
.msg { max-width: 860px; }
.msg.user { align-self: flex-end; background: var(--brand); color: var(--brand-ink); padding: .65rem .9rem; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); padding: .8rem 1rem; border-radius: 14px 14px 14px 4px; box-shadow: var(--shadow); width: 100%; }
.msg.bot .answer > :first-child { margin-top: 0; }
.msg.bot .answer > :last-child { margin-bottom: 0; }
.msg.bot .answer table { font-size: .9rem; }
.cite { display: inline-block; background: color-mix(in srgb, var(--brand) 14%, white); color: var(--brand); font-size: .72rem; font-weight: 700; padding: 0 .35rem; border-radius: 5px; margin-left: 1px; cursor: pointer; vertical-align: super; line-height: 1.4; }
.msg.error { border-color: #f1b8b3; background: var(--err-bg); color: var(--err); }
.typing { display: inline-flex; gap: 4px; padding: .4rem 0; }
.typing i { width: 7px; height: 7px; background: var(--ink-3); border-radius: 50%; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.sources { margin-top: .9rem; padding-top: .8rem; border-top: 1px dashed var(--line); }
.sources h5 { margin: 0 0 .5rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.source-grid { align-items: start; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; }
.source { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-2); cursor: pointer; text-align: left; padding: 0; font: inherit; color: inherit; }
.source:hover { border-color: var(--brand); }
.source .thumb { aspect-ratio: 4/3; background: #e9ecf1 center/contain no-repeat; display: block; width: 100%; }
.source .meta { padding: .45rem .55rem; font-size: .82rem; }
.source .meta b { color: var(--brand); margin-right: .25rem; }
.source.textonly .meta { padding: .6rem; }
.composer { position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0 .25rem; }
.composer form { display: flex; gap: .5rem; align-items: flex-end; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; padding: .4rem; box-shadow: var(--shadow); }
.composer textarea { border: 0; min-height: 44px; max-height: 200px; resize: none; padding: .55rem; }
.composer textarea:focus { outline: none; }
.suggestions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 1rem; }
.suggestions button { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: .35rem .8rem; font: inherit; font-size: .88rem; cursor: pointer; color: var(--ink-2); }
.suggestions button:hover { border-color: var(--brand); color: var(--brand); }
.disclaimer { font-size: .78rem; color: var(--ink-3); margin-top: .35rem; text-align: center; }

/* ---------- Dokumente / FAQ ---------- */
.doc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.doc { display: flex; gap: .75rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.doc:hover { border-color: var(--brand); }
.doc .ico { width: 40px; height: 48px; flex: none; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: var(--ink-3); }
.faq { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: .8rem 1rem; }
.faq + .faq { margin-top: .6rem; }
.faq .code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; color: var(--brand); margin-right: .4rem; }
.faq p { margin: .35rem 0 0; white-space: pre-wrap; }

/* ---------- Modal / Viewer / Lightbox ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(15,20,30,.55); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { color: var(--ink); background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: min(720px, 100%); max-height: calc(100vh - 2rem); overflow: auto; padding: 1.25rem; }
.modal.wide { width: min(1000px, 100%); }
.modal-head { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.modal-head h2 { margin: 0; flex: 1; }
.viewer { position: fixed; inset: 0; z-index: 110; background: #11151c; color: #fff; display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem; background: #1b212b; flex-wrap: wrap; }
.viewer-bar .title { flex: 1; font-weight: 600; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar .btn { background: #2a3240; border-color: #3a4352; color: #fff; }
.viewer-bar .btn:hover { background: #343d4d; }
.viewer-bar .btn.on { background: var(--brand); border-color: var(--brand); }
.viewer-stage { flex: 1; overflow: hidden; position: relative; touch-action: none; cursor: grab; }
.viewer-stage.cropping { cursor: crosshair; }
.viewer-stage img { position: absolute; left: 0; top: 0; transform-origin: 0 0; user-select: none; -webkit-user-drag: none; max-width: none; background: #fff; }
.viewer-text { flex: 1; overflow: auto; padding: 1.5rem; background: #fff; color: var(--ink); white-space: pre-wrap; max-width: 900px; width: 100%; margin: 0 auto; }
.crop-box { position: absolute; border: 2px dashed #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); pointer-events: none; }
.viewer-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: rgba(0,0,0,.65); padding: .35rem .75rem; border-radius: 999px; font-size: .85rem; pointer-events: none; }
.viewer .pageinfo { font-size: .9rem; color: #c9d1dc; min-width: 80px; text-align: center; }

/* ---------- Upload ---------- */
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 1.6rem; text-align: center; color: var(--ink-2); background: var(--surface-2); cursor: pointer; }
.dropzone.over { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, white); }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.queue-item { padding: .55rem 0; border-bottom: 1px solid var(--line); }
.queue-item:last-child { border-bottom: 0; }

/* ---------- Toast ---------- */
#toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast { background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: .92rem; }
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 1.5rem; }
.login { width: min(400px, 100%); }
.login .brand { justify-content: center; font-size: 1.15rem; margin-bottom: 1.25rem; }
.pw-box { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05rem; background: var(--surface-2); border: 1px solid var(--line); padding: .6rem .8rem; border-radius: 8px; user-select: all; }

/* ---------- Tickets ---------- */
.ticket-btn { border-color: var(--brand); color: var(--brand); }
.ticket-cta { margin-top: .9rem; padding: .75rem .9rem; border-radius: 8px; background: var(--warn-bg); display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.ticket-cta.subtle { background: transparent; padding: .5rem 0 0; border-top: 1px dashed var(--line); border-radius: 0; }
.ticket-cta p { margin: 0; flex: 1; min-width: 200px; }
.seg { display: flex; gap: .5rem; flex-wrap: wrap; }
.seg label { flex: 1; min-width: 150px; margin: 0; display: flex; gap: .5rem; align-items: flex-start; border: 1px solid var(--line-strong); border-radius: 8px; padding: .6rem .7rem; cursor: pointer; color: var(--ink); font-weight: 500; }
.seg label:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, white); }
.seg input { margin-top: .2rem; accent-color: var(--brand); }
.seg small { display: block; color: var(--ink-3); font-weight: 400; }
.req::after { content: ' *'; color: var(--err); }
.ticket-done { text-align: center; padding: 1rem 0; }
.ticket-done .no { font-size: 1.6rem; font-weight: 700; color: var(--brand); letter-spacing: .02em; }
.transcript-msg { padding: .5rem .7rem; border-radius: 8px; margin: .4rem 0; white-space: pre-wrap; font-size: .92rem; }
.transcript-msg.user { background: color-mix(in srgb, var(--brand) 9%, white); }
.transcript-msg.assistant { background: var(--surface-2); }
.transcript-msg small { display: block; color: var(--ink-3); font-size: .78rem; }
.tab .count { display: inline-block; min-width: 1.3em; padding: 0 .35em; margin-left: .3rem; border-radius: 99px; background: var(--err); color: #fff; font-size: .72rem; line-height: 1.5; }

.events { margin-top: .6rem; border-left: 2px solid var(--line-strong); padding-left: .8rem; }
.event { padding: .4rem 0; border-bottom: 1px dashed var(--line); }
.event:last-child { border-bottom: 0; }
