/* Tradaly · Support-Tickets als Chat (Kundenbereich und Developer)
   Rechner: Liste links, Unterhaltung rechts. Handy: Liste als Seite, Unterhaltung als Vollbild darüber. */

.chat-seite { padding-top: 24px; padding-bottom: 24px; }
.postfach {
  display: grid; grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  height: calc(100dvh - 68px - var(--oben) - 48px); min-height: 520px;
  border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; background: var(--surface); box-shadow: var(--e1);
}

/* Liste */
.pf-liste { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--line); background: var(--surface); }
.pf-liste-kopf { padding: 18px 18px 12px; display: grid; gap: 12px; border-bottom: 1px solid var(--line); }
.pf-liste-titel { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pf-liste-titel .label { display: block; margin-bottom: 4px; }
.pf-liste-titel h1 { font-size: 24px; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; }
.pf-neu { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; transition: background-color .15s var(--ease), transform .15s var(--ease); }
.pf-neu:hover { background: #7A6DE3; }
.pf-neu:active { transform: scale(.94); }
.pf-neu .ic { width: 20px; height: 20px; }
.pf-suche { position: relative; }
.pf-suche .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-dim); pointer-events: none; }
.pf-suche input { width: 100%; min-height: 42px; padding: 0 14px 0 40px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); font-size: 16px; outline: none; transition: border-color .15s var(--ease); }
.pf-suche input:focus { border-color: var(--accent-hi); }
.pf-suche input::placeholder { color: #5A5F6D; }
.pf-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.pf-filter::-webkit-scrollbar { display: none; }
.pf-filter button { flex: none; min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: none; color: var(--ink-soft); font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease); }
.pf-filter button:hover { color: var(--ink); border-color: var(--ink-soft); }
.pf-filter button[aria-pressed="true"] { background: rgba(107,93,216,.2); border-color: var(--accent); color: var(--ink); }
.pf-filter b { font: 600 11px/1 var(--f-mono); color: var(--ink-dim); }
.pf-filter button[aria-pressed="true"] b { color: var(--accent-hi); }

.pf-zeilen { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.pf-zeile { width: 100%; display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 12px; align-items: center; padding: 12px 18px; border: 0; background: none; text-align: left; cursor: pointer; color: inherit; position: relative; font: inherit; transition: background-color .12s var(--ease); }
.pf-zeile::after { content: ""; position: absolute; left: 76px; right: 0; bottom: 0; border-bottom: 1px solid var(--line); }
.pf-zeile:last-child::after { display: none; }
.pf-zeile:hover { background: rgba(255,255,255,.03); }
.pf-zeile[aria-current="true"] { background: rgba(107,93,216,.13); }
.pf-zeile:focus-visible { outline-offset: -3px; }
.pf-zeile-text { display: grid; gap: 3px; min-width: 0; }
.pf-oben, .pf-unten { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pf-titel { flex: 1; min-width: 0; font-weight: 600; font-size: 15.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-zeit { flex: none; font: 500 12px/1 var(--f-mono); color: var(--ink-dim); }
.pf-wer { font: 500 12px/1.35 var(--f-mono); color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-vorschau { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-vorschau .ic { width: 15px; height: 15px; vertical-align: -3px; margin-right: 3px; color: var(--ink-dim); }
.pf-zeile.ungelesen .pf-titel, .pf-zeile.ungelesen .pf-vorschau { color: var(--ink); }
.pf-zeile.ungelesen .pf-zeit { color: var(--teal); }
.pf-punkt { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--teal); color: #07120F; font: 700 11px/20px var(--f-mono); text-align: center; }
.pf-punkt.leer { min-width: 12px; width: 12px; height: 12px; padding: 0; }
.pf-mk { flex: none; font: 600 10.5px/1 var(--f-mono); letter-spacing: .05em; text-transform: uppercase; padding: 4px 7px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-dim); }
.pf-mk.gruen { color: var(--teal); border-color: rgba(99,204,185,.35); }
.pf-mk.gelb { color: var(--amber); border-color: rgba(230,184,77,.35); }
.pf-mk.rot { color: var(--danger); border-color: rgba(232,131,131,.35); }
.pf-mk.lila { color: var(--accent-hi); border-color: rgba(140,128,240,.4); }
.pf-liste-leer { padding: 44px 24px; text-align: center; color: var(--ink-soft); display: grid; justify-items: center; gap: 10px; font-size: 14.5px; }
.pf-liste-leer .ic { width: 32px; height: 32px; color: var(--ink-dim); }
.pf-liste-leer h3 { font-size: 17px; color: var(--ink); }
.pf-liste-fuss { border-top: 1px solid var(--line); padding: 12px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pf-liste-fuss p { font-size: 13.5px; line-height: 1.4; color: var(--ink-soft); }
.pf-liste-fuss p b { display: block; color: var(--ink); font-weight: 600; font-size: 14px; }

/* Bild für Personen und Tickets */
.pf-avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font: 600 18px/1 var(--f-display); color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--line-2); flex: none; text-transform: uppercase; }
.pf-avatar .ic { width: 20px; height: 20px; }
.pf-avatar.f-lila { background: rgba(107,93,216,.22); border-color: rgba(140,128,240,.42); color: #DAD5FB; }
.pf-avatar.f-teal { background: rgba(99,204,185,.15); border-color: rgba(99,204,185,.42); color: #C9F0E8; }
.pf-avatar.f-gelb { background: rgba(230,184,77,.13); border-color: rgba(230,184,77,.42); color: #F3E2B8; }
.pf-avatar.f-rot { background: rgba(232,131,131,.12); border-color: rgba(232,131,131,.4); color: #F6CDCD; }
.pf-avatar.f-blau { background: rgba(110,160,240,.13); border-color: rgba(110,160,240,.4); color: #D2E2FB; }
.pf-avatar.f-grau { color: var(--ink-dim); }

/* Unterhaltung */
.pf-chat { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; min-width: 0; position: relative; background: radial-gradient(70% 45% at 100% 0%, rgba(107,93,216,.07), transparent 70%), var(--bg-2); }
.pf-leer-chat { grid-row: 1 / -1; place-self: center; display: grid; justify-items: center; gap: 12px; text-align: center; padding: 32px; color: var(--ink-soft); max-width: 380px; }
.pf-leer-chat .ic-rund { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: rgba(107,93,216,.16); color: var(--accent-hi); }
.pf-leer-chat .ic-rund .ic { width: 28px; height: 28px; }
.pf-leer-chat h2 { font-size: 20px; color: var(--ink); }
.pf-chat-kopf { display: flex; align-items: center; gap: 12px; padding: 10px 18px; min-height: 68px; border-bottom: 1px solid var(--line); background: var(--surface); }
.pf-chat-kopf .pf-avatar { width: 42px; height: 42px; font-size: 16px; }
.pf-zurueck { display: none; width: 44px; height: 44px; margin-right: -6px; border: 0; border-radius: 50%; background: none; color: var(--ink); place-items: center; cursor: pointer; flex: none; }
.pf-zurueck .ic { width: 24px; height: 24px; }
.pf-chat-titel { flex: 1; min-width: 0; display: grid; gap: 2px; }
.pf-chat-titel strong { font: 600 16px/1.3 var(--f-display); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-chat-titel span { font-size: 13px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-chat-titel .pf-st-mobil { display: none; }
.pf-aktionen { display: flex; align-items: center; gap: 8px; flex: none; }

.pf-mitte { position: relative; min-height: 0; display: grid; }
.pf-verlauf { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px clamp(12px, 3vw, 36px) 14px; display: flex; flex-direction: column; }
.pf-verlauf > :first-child { margin-top: auto; }
.pf-tag { align-self: center; margin: 14px 0 8px; padding: 5px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; line-height: 1.3; color: var(--ink-soft); }
.pf-msg { display: flex; margin-top: 10px; }
.pf-msg.folge { margin-top: 3px; }
.pf-msg.mir { justify-content: flex-end; }
.pf-blase { max-width: min(76%, 640px); padding: 7px 11px 6px 12px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line-2); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; line-height: 1.45; box-shadow: 0 1px 1px rgba(0,0,0,.25); }
.pf-msg.dir:not(.folge) .pf-blase { border-top-left-radius: 6px; }
.pf-msg.mir .pf-blase { background: #4A3FB0; border-color: #5D51CC; color: #fff; }
.pf-msg.mir:not(.folge) .pf-blase { border-top-right-radius: 6px; }
.pf-name { display: block; font: 600 12.5px/1.4 var(--f-text); color: var(--accent-hi); margin-bottom: 1px; }
.pf-uhr { float: right; position: relative; top: 5px; margin: 0 0 0 12px; display: inline-flex; align-items: center; gap: 4px; font: 500 11px/1.6 var(--f-mono); color: var(--ink-dim); white-space: nowrap; }
.pf-uhr .ic { width: 13px; height: 13px; }
.pf-msg.mir .pf-uhr { color: rgba(255,255,255,.68); }
.pf-blase a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.pf-msg.wartet .pf-blase { opacity: .72; }
.pf-anhaenge { display: grid; gap: 6px; margin: 4px 0 4px; white-space: normal; }
.pf-anhaenge + .pf-text { display: block; margin-top: 2px; }
.pf-datei { display: flex; align-items: center; gap: 10px; min-width: 0; width: 100%; padding: 9px 12px; border-radius: 12px; background: rgba(0,0,0,.2); border: 1px solid rgba(255,255,255,.08); color: inherit; font: inherit; font-size: 14px; line-height: 1.3; text-align: left; cursor: pointer; }
.pf-datei:hover { border-color: rgba(255,255,255,.22); }
.pf-datei span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-datei small { flex: none; margin-left: auto; font: 500 11px/1 var(--f-mono); opacity: .7; }
.pf-bild { display: block; width: 260px; max-width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: rgba(0,0,0,.28); cursor: zoom-in; }
.pf-bild img { width: 100%; height: 100%; object-fit: cover; }
.pf-hinweis-mitte { align-self: center; max-width: 440px; text-align: center; color: var(--ink-dim); font-size: 13.5px; line-height: 1.5; margin: 12px 0 4px; }
.pf-runter { position: absolute; right: 16px; bottom: 14px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); display: grid; place-items: center; cursor: pointer; box-shadow: 0 8px 22px rgba(0,0,0,.5); }
.pf-runter.neu::after { content: ""; position: absolute; top: 2px; right: 2px; width: 11px; height: 11px; border-radius: 50%; background: var(--teal); border: 2px solid var(--surface); }

/* Neues Ticket: Betreff über dem Verlauf */
.pf-betreff { display: grid; gap: 8px; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); margin-top: 6px; }
.pf-verlauf > .pf-betreff:first-child { margin-top: 6px; }
.pf-betreff label { font-weight: 600; font-size: 14px; }
.pf-betreff .eingabe { min-height: 46px; }

/* Schreiben */
.pf-fuss { border-top: 1px solid var(--line); background: var(--surface); }
.pf-schreiben { padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); }
.pf-hinweis { font-size: 12.5px; color: var(--ink-dim); margin: 0 4px 8px; }
.pf-fehler { font-size: 13.5px; color: var(--danger); margin: 0 4px 8px; }
.pf-gewaehlt { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pf-gewaehlt span { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 4px 5px 10px; border-radius: 10px; background: rgba(107,93,216,.14); border: 1px solid rgba(107,93,216,.35); font-size: 13px; }
.pf-gewaehlt span > i { font-style: normal; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-gewaehlt small { font: 500 11px var(--f-mono); color: var(--ink-dim); white-space: nowrap; }
.pf-gewaehlt button { width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: var(--ink-dim); cursor: pointer; display: grid; place-items: center; flex: none; }
.pf-gewaehlt button:hover { color: var(--danger); }
.pf-gewaehlt .ic { width: 14px; height: 14px; }
.pf-eingabe { display: flex; align-items: flex-end; gap: 8px; }
.pf-rund { position: relative; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-2); background: none; color: var(--ink-soft); display: grid; place-items: center; cursor: pointer; flex: none; transition: color .15s var(--ease), border-color .15s var(--ease); }
.pf-rund:hover { color: var(--ink); border-color: var(--ink-soft); }
.pf-rund:focus-within { outline: 3px solid var(--teal); outline-offset: 3px; }
.pf-rund input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pf-eingabe textarea { flex: 1; min-width: 0; height: 44px; min-height: 44px; max-height: 168px; resize: none; padding: 10px 16px; border-radius: 22px; background: var(--bg); border: 1px solid var(--line-2); font-size: 16px; line-height: 1.5; outline: none; transition: border-color .15s var(--ease); }
.pf-eingabe textarea:focus { border-color: var(--accent-hi); }
.pf-eingabe textarea::placeholder { color: #5A5F6D; }
.pf-senden { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; transition: background-color .15s var(--ease), transform .15s var(--ease), opacity .15s var(--ease); }
.pf-senden:hover:not([disabled]) { background: #7A6DE3; }
.pf-senden:active:not([disabled]) { transform: scale(.93); }
.pf-senden[disabled] { opacity: .4; cursor: default; }
.pf-senden .ic { width: 19px; height: 19px; margin-left: -2px; }
.pf-zu { padding: 14px 18px calc(14px + env(safe-area-inset-bottom, 0px)); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px; text-align: center; color: var(--ink-soft); font-size: 14px; }

/* Bildansicht */
dialog.pf-ansicht { border: 0; padding: 0; margin: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; background: rgba(3,4,10,.94); color: var(--ink); }
dialog.pf-ansicht::backdrop { background: rgba(3,4,10,.94); }
.pf-ansicht-in { width: 100%; height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.pf-ansicht-kopf { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--oben)) 14px 10px; }
.pf-ansicht-kopf span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--ink-soft); }
.pf-ansicht img { width: 100%; height: 100%; object-fit: contain; padding: 0 12px calc(12px + env(safe-area-inset-bottom, 0px)); }

html.pf-gesperrt, html.pf-gesperrt body { overflow: hidden; }
/* Nach dem Einblenden des Vollbild-Chats: Seite dahinter ausblenden, Grund in der Farbe des Eingabebereichs */
html.pf-ruhig, html.pf-ruhig body { background: var(--surface); }
html.pf-ruhig .app-kopf, html.pf-ruhig .fuss-app, html.pf-ruhig .pf-liste { visibility: hidden; }
/* Im Vollbild-Chat liegt unten das Eingabefeld, Meldungen erscheinen deshalb oben */
html.pf-gesperrt .toast { top: calc(70px + var(--oben)); bottom: auto; }

@media (max-width: 899px) {
  .seite.chat-seite { width: 100%; padding: 0 0 24px; }
  .postfach { display: block; height: auto; min-height: 0; border: 0; border-radius: 0; background: none; box-shadow: none; overflow: visible; }
  .pf-liste { border-right: 0; background: none; }
  .pf-liste-kopf { padding: 22px var(--gutter) 12px; border-bottom: 0; }
  .pf-filter { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 2px; }
  .pf-zeilen { overflow: visible; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .pf-zeile { padding: 12px var(--gutter); }
  .pf-zeile::after { left: calc(var(--gutter) + 58px); }
  .pf-liste-fuss { margin: 18px var(--gutter) 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
  .pf-chat { display: none; position: fixed; left: 0; right: 0; top: 0; height: 100dvh; z-index: 120; background: var(--bg-2); transform: translateX(100%); transition: transform .28s var(--ease); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
  .postfach.chat-offen .pf-chat { display: grid; }
  .postfach.chat-ein .pf-chat { transform: none; }
  .pf-leer-chat { display: none; }
  .pf-chat-kopf { padding: calc(8px + var(--oben)) 12px 8px 6px; min-height: calc(62px + var(--oben)); gap: 10px; }
  .pf-zurueck { display: grid; }
  .pf-verlauf { padding: 10px 10px 12px; }
  .pf-blase { max-width: 84%; }
  .pf-schreiben { padding: 8px 8px calc(8px + max(env(safe-area-inset-bottom, 0px), var(--unter-tastatur, 0px))); }
  .pf-zu { padding-bottom: calc(14px + max(env(safe-area-inset-bottom, 0px), var(--unter-tastatur, 0px))); }
  .pf-eingabe { gap: 6px; }
  .postfach.tastatur .pf-schreiben { padding-bottom: calc(8px + var(--unter-tastatur, 0px)); }
  .postfach.tastatur .pf-zu { padding-bottom: calc(14px + var(--unter-tastatur, 0px)); }
}
@media (max-width: 559px) {
  .pf-aktionen .pf-status { display: none; }
  .pf-chat-titel .pf-st-mobil { display: inline; }
}
