/* innoChat Mitarbeiterkonsole – Farben nach innoflex Corporate Design (Anthrazit, Gold, Schiefergrau, Signalrot) */
:root {
  --brand: #1c1e22;
  --brand-2: #52657f;
  --accent: #d8c456;
  --ink: #1c1e22;
  --muted: #7a808a;
  --line: #e0e2e6;
  --surface: #f1f2f4;
  --panel: #ffffff;
  --bg: #f4f5f6;
  --ok: #16a34a;
  --danger: #d62e28;
  --ring: color-mix(in srgb, var(--brand) 16%, transparent);
  --shadow: 0 1px 2px rgba(28, 30, 34, .06), 0 8px 24px -12px rgba(28, 30, 34, .18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #34383f;
    --ink: #f6fafc;
    --muted: #8c929c;
    --line: #33373e;
    --surface: #2b2e34;
    --panel: #24272c;
    --bg: #1c1e22;
    --brand-2: #9fb1c9;
    --ring: rgba(216, 196, 86, .25);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 20px; height: 20px; flex: none; display: block; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 20px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.small { font-size: 12.5px; }
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* Formulare */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.input {
  font: inherit; font-size: 15px; color: var(--ink);
  padding: 11px 13px; border-radius: 11px; border: 1.5px solid var(--line); background: var(--panel);
  outline: none; transition: border-color .15s, box-shadow .15s; width: 100%;
}
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 4px var(--ring); }
.input.sm { padding: 8px 12px; font-size: 14px; }
.input.code { font-size: 26px; letter-spacing: .3em; text-align: center; font-weight: 800; }
select.input { appearance: auto; }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.form-error { color: var(--danger); font-size: 13.5px; margin: 0; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 11px; font-weight: 800; font-size: 14px;
  background: var(--surface); color: var(--ink); transition: filter .15s, transform .1s; white-space: nowrap;
}
.btn:hover { filter: brightness(.96); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.accent { background: var(--accent); color: #1c1e22; }
.btn.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.lg { padding: 13px 18px; font-size: 15px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible, .send:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); transition: background .15s; }
.icon-btn:hover { background: var(--surface); color: var(--ink); }

.av {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: #fff; font-weight: 800; font-size: 14px; background: #64748b; text-transform: uppercase; position: relative;
}
.av.sm { width: 30px; height: 30px; font-size: 12px; }
.av img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; background: #fff; }
.av .presence { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--panel); background: #94a3b8; }
.av .presence.on { background: var(--ok); }
.av .presence.st-anwesend { background: #16a34a; }
.av .presence.st-beschaeftigt { background: #dc2626; }
.av .presence.st-pause { background: #f59e0b; }
.av .presence.st-abwesend { background: #94a3b8; }
.av .presence.st-offline { background: transparent; border-color: #94a3b8; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, rgba(216, 196, 86, .18) 0, transparent 60%), linear-gradient(160deg, #131417, #1c1e22 60%, #2b2e34); }
.login-card { width: min(420px, 100%); background: var(--panel); border-radius: 22px; padding: 30px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5); display: flex; flex-direction: column; gap: 24px; }
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand img { border-radius: 14px; }
.login-brand h1 { font-size: 24px; font-weight: 800; }
.login-brand p { margin: 2px 0 0; color: var(--muted); }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.qr { display: grid; place-items: center; padding: 10px; background: #fff; border-radius: 14px; border: 1px solid var(--line); }
.secret { display: block; margin-top: 6px; padding: 10px; border-radius: 8px; background: var(--surface); font-size: 14px; letter-spacing: .08em; word-break: break-all; user-select: all; }

/* Layout */
.app { display: grid; grid-template-columns: 330px minmax(0, 1fr) 270px; height: 100vh; height: 100dvh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.chat { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.info { background: var(--panel); border-left: 1px solid var(--line); padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 26px; }

.me { position: relative; display: flex; align-items: center; gap: 12px; padding: 16px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.me::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--accent); }
.me .av { box-shadow: 0 0 0 2px rgba(255, 255, 255, .6); }
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.me-text .muted { color: rgba(255, 255, 255, .75); }
.me .icon-btn { color: #fff; }
.me .icon-btn:hover { background: rgba(255, 255, 255, .14); }
.menu { position: absolute; right: 12px; top: 60px; z-index: 20; min-width: 240px; background: var(--panel); color: var(--ink); border-radius: 14px; padding: 6px; box-shadow: 0 20px 50px -12px rgba(0, 0, 0, .35); border: 1px solid var(--line); }
.menu button { display: flex; width: 100%; padding: 10px 12px; border-radius: 9px; font-size: 14px; text-align: left; }
.menu button:hover { background: var(--surface); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.menu .danger { color: var(--danger); }

.availability { display: flex; align-items: center; gap: 12px; margin: 14px 14px 6px; padding: 12px 14px; border-radius: 14px; background: var(--surface); cursor: pointer; transition: background .2s; }
.availability.on { background: color-mix(in srgb, var(--ok) 14%, var(--panel)); }
.availability input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; width: 46px; height: 26px; border-radius: 13px; background: #cbd5e1; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.availability.on .switch { background: var(--ok); }
.availability.on .switch::after { transform: translateX(20px); }
.availability input:focus-visible + .switch { outline: 3px solid var(--accent); outline-offset: 2px; }
.availability-text { display: flex; flex-direction: column; }
.availability-text .small { color: var(--muted); }

.tabs { display: flex; gap: 4px; padding: 10px 14px 6px; }
.tab { flex: 1; padding: 8px 6px; border-radius: 10px; font-weight: 700; font-size: 13.5px; color: var(--muted); display: flex; gap: 6px; justify-content: center; align-items: center; }
.tab.on { background: var(--surface); color: var(--ink); }
.count { min-width: 20px; padding: 0 6px; height: 20px; border-radius: 10px; background: var(--line); font-size: 12px; display: grid; place-items: center; }
.tab.on .count { background: var(--brand); color: #fff; }
.search { padding: 4px 14px 10px; }

.conv-list { list-style: none; margin: 0; padding: 0 8px 16px; overflow-y: auto; flex: 1; }
.conv-item { display: flex; gap: 11px; align-items: center; padding: 11px 10px; border-radius: 13px; cursor: pointer; position: relative; transition: background .12s; }
.conv-item:hover { background: var(--surface); }
.conv-item.active { background: color-mix(in srgb, var(--brand) 10%, var(--panel)); }
.conv-item.ringing { animation: ring 1.4s ease-in-out infinite; }
.conv-item.ringing::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px; border-radius: 2px; background: var(--accent); }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; gap: 6px; align-items: baseline; }
.conv-top strong { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-top time { font-size: 12px; color: var(--muted); flex: none; }
.conv-preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-tags { display: flex; gap: 5px; margin-top: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--surface); color: var(--muted); }
.tag.new { background: var(--accent); color: #1c1e22; }
.tag.offline { background: transparent; border: 1px solid var(--line); }
.unread { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.list-empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 14px; }

/* Chat */
.empty { margin: auto; text-align: center; max-width: 380px; padding: 30px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty img { border-radius: 18px; opacity: .9; }
.conv { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.conv-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.conv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.conv-title strong { font-size: 16px; }
.conv-actions { display: flex; gap: 8px; }
.back { display: none; }
.page-bar { padding: 8px 18px; font-size: 13px; background: var(--surface); border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.page-bar a { color: var(--brand-2); font-weight: 700; text-decoration: none; }
.messages { flex: 1; overflow-y: auto; padding: 18px 22px; }
.day { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-size: 12px; color: var(--muted); font-weight: 700; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.row { display: flex; gap: 10px; margin-top: 14px; align-items: flex-end; }
.row.cont { margin-top: 3px; }
.row.out { flex-direction: row-reverse; }
.row .av { visibility: hidden; }
.row.first .av { visibility: visible; align-self: flex-start; }
.col { display: flex; flex-direction: column; max-width: min(640px, 72%); min-width: 0; }
.row.out .col { align-items: flex-end; }
.meta { font-size: 12px; color: var(--muted); margin: 0 6px 3px; }
.meta b { color: var(--ink); }
.bubble { padding: 9px 14px; border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); white-space: pre-wrap; overflow-wrap: anywhere; }
.row.in .bubble { border-top-left-radius: 6px; }
.row.out .bubble { background: var(--brand); color: #fff; border-top-right-radius: 6px; }
.row.out.colleague .bubble { background: color-mix(in srgb, var(--brand) 55%, var(--panel)); }
.bubble a { color: inherit; }
.bubble.img { padding: 4px; }
.bubble.img img { display: block; max-width: 100%; max-height: 320px; border-radius: 12px; cursor: zoom-in; background: var(--surface); }
.bubble.img .cap { padding: 6px 10px 4px; }
.sys { margin: 14px auto 4px; width: fit-content; max-width: 90%; text-align: center; font-size: 12.5px; color: var(--muted); background: var(--surface); padding: 4px 12px; border-radius: 999px; }
.typing { padding: 0 22px 8px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.dots { display: inline-flex; gap: 3px; padding: 7px 9px; border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
.tray { display: flex; gap: 12px; align-items: center; margin: 0 18px 8px; padding: 8px; border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.tray img { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; }
.tray-text { flex: 1; display: flex; flex-direction: column; }
.composer { display: flex; gap: 6px; align-items: flex-end; margin: 0 18px 18px; padding: 8px 8px 8px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--line); box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--brand-2); box-shadow: 0 0 0 4px var(--ring); }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; font: inherit; color: var(--ink); background: transparent; padding: 8px 0; max-height: 180px; }
.send { width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; }
.send[disabled] { opacity: .35; cursor: default; }
.readonly-note { margin: 0 18px 18px; padding: 12px 16px; border-radius: 12px; background: var(--surface); color: var(--muted); font-size: 14px; text-align: center; }

/* Info-Spalte */
.people, .stats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.people li { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.people .small { font-weight: 400; }
.stats li { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; background: var(--surface); }
.stats img { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; background: #fff; }
.stats .num { margin-left: auto; text-align: right; font-size: 20px; font-weight: 800; line-height: 1; }
.stats .num span { display: block; white-space: nowrap; font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 3px; }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(8, 15, 30, .55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; animation: fade .15s ease; }
.modal-card { width: min(520px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--panel); border-radius: 20px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5); overflow: hidden; }
.modal-card.wide { width: min(1080px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal-foot .form-error { margin-right: auto; }
.table-wrap { overflow: auto; }
table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
.users th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.users td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.users tr.inactive td { opacity: .5; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell span { display: flex; flex-direction: column; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--surface); margin: 1px 2px 1px 0; }
.pill.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, #f59e0b 18%, transparent); color: #b45309; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.perm-grid { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; font-size: 14px; }
.perm-grid select { padding: 6px 10px; font-size: 13px; width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--line); font-size: 13.5px; cursor: pointer; }
.chip:has(input:checked) { border-color: var(--brand-2); background: color-mix(in srgb, var(--brand) 10%, var(--panel)); }
.chip input { accent-color: var(--brand); }
.devices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.devices li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface); font-size: 13.5px; }
.devices li span { flex: 1; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 0; }
legend { font-size: 13px; font-weight: 800; color: var(--muted); padding: 0 6px; }

/* Toasts, Lightbox, Banner */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; padding: 11px 18px; border-radius: 12px; background: #0f1b2d; color: #fff; font-size: 14px; box-shadow: 0 16px 40px -10px rgba(0, 0, 0, .5); animation: drop .25s ease; display: flex; gap: 12px; align-items: center; }
.toast button { color: var(--accent); font-weight: 800; }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(8, 15, 30, .85); display: grid; place-items: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; }

@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
@keyframes ring { 0%, 100% { background: transparent; } 50% { background: color-mix(in srgb, var(--accent) 22%, transparent); } }
@keyframes fade { from { opacity: 0; } }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 1180px) {
  .app { grid-template-columns: 310px minmax(0, 1fr); }
  .info { display: none; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .app.in-chat .sidebar { display: none; }
  .app:not(.in-chat) .chat { display: none; }
  .back { display: grid; }
  .conv-actions .btn { padding: 8px 10px; }
  .col { max-width: 85%; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
