/**
 * Chat-Seite von Tobi, Werte nach tc-support-chat/design/design-system.md und tokens.css.
 */

@font-face {
  font-family: "Inter";
  font-weight: 400;
  font-display: swap;
  src: url("/theme/assets/fonts/Inter/Inter-Regular.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-weight: 500;
  font-display: swap;
  src: url("/theme/assets/fonts/Inter/Inter-Medium.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-weight: 600;
  font-display: swap;
  src: url("/theme/assets/fonts/Inter/Inter-SemiBold.woff2") format("woff2");
}

:root {
  --font-family: "Inter", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --letter-spacing: -0.02em;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --line-height-xs: 1rem;
  --line-height-sm: 1.25rem;
  --line-height-message: 1.3125rem;
  --paragraph-gap: 1.25em;

  --color-accent: #0d5a93;
  --color-on-accent: #ffffff;
  --color-surface: #ffffff;
  --color-bubble: #f4f4f5;
  --color-text: #27272a;
  --color-text-strong: #09090b;
  --color-link: #18181b;
  --color-black: #000000;
  --color-muted: #71717a;
  --color-line: #e4e4e7;
  --color-disabled: #a1a1aa;
  --color-danger: #b91c1c;

  --radius-notice: 0.75rem;
  --radius-comment: 1rem;
  --radius-bubble: 1.25rem;
  --radius-input: 1.5rem;

  --header-height: 4rem;
  --avatar-size: 2rem;
  --icon-button-size: 2rem;
  --icon-size: 1.25rem;
  --icon-size-sm: 1rem;
  --target-size-min: 1.5rem;
  --comment-height: 2rem;

  --header-gradient: linear-gradient(0deg, rgba(0, 0, 0, 0.02) 0.44%, rgba(0, 0, 0, 0) 49.5%);
  --input-shadow: 0 4px 16px rgba(0, 0, 0, 0.04), 0 2px 2px rgba(0, 0, 0, 0.02);
  --menu-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --focus-ring: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-accent);
  --transition-fast: 150ms ease-out;
  --typing-dot-duration: 1.2s;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 0ms;
    --typing-dot-duration: 0s;
  }
}

html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  letter-spacing: var(--letter-spacing);
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
}

.tobi-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.tobi {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Kopf */
.tobi-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 0 0 var(--header-height);
  padding: 0 1.25rem;
  background: var(--color-surface) var(--header-gradient);
}

.tobi-avatar {
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 50%;
  flex: none;
}

.tobi-title {
  flex: 1;
  margin: 0;
  color: var(--color-black);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-sm);
  font-weight: 600;
}

.tobi-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--icon-button-size);
  height: var(--icon-button-size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--color-black);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.tobi-icon-button:hover {
  background: var(--color-bubble);
}

.tobi-icon-button svg {
  width: var(--icon-size);
  height: var(--icon-size);
  opacity: 0.64;
  fill: currentColor;
}

.tobi-close-button svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.tobi-menu-wrap {
  position: relative;
}

.tobi-menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  min-width: 13rem;
  padding: 0.25rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-notice);
  background: var(--color-surface);
  box-shadow: var(--menu-shadow);
}

.tobi-menu-item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--color-text-strong);
  text-align: left;
  line-height: var(--line-height-sm);
  cursor: pointer;
}

.tobi-menu-item:hover {
  background: var(--color-bubble);
}

/* Nachrichtenliste */
.tobi-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
  padding: 1.25rem 1.25rem 1rem;
}

.tobi-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.tobi-message.is-user {
  align-items: flex-end;
}

.tobi-bubble {
  max-width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-bubble);
  background: var(--color-bubble);
  color: var(--color-text);
  line-height: var(--line-height-message);
  overflow-wrap: anywhere;
}

.is-user .tobi-bubble {
  max-width: 85%;
  background: var(--color-accent);
  color: var(--color-on-accent);
  white-space: pre-wrap;
}

.tobi-bubble > :first-child {
  margin-top: 0;
}

.tobi-bubble > :last-child {
  margin-bottom: 0;
}

.tobi-bubble p,
.tobi-bubble ul,
.tobi-bubble ol,
.tobi-bubble pre,
.tobi-bubble table,
.tobi-bubble blockquote {
  margin: 0 0 var(--paragraph-gap);
}

.tobi-bubble ul,
.tobi-bubble ol {
  padding-left: 1.25rem;
}

.tobi-bubble li + li {
  margin-top: 0.25rem;
}

.tobi-bubble h1,
.tobi-bubble h2,
.tobi-bubble h3,
.tobi-bubble h4 {
  margin: 0 0 0.5rem;
  font-size: inherit;
  font-weight: 600;
}

.tobi-bubble a {
  color: var(--color-link);
  font-weight: 500;
  text-decoration: underline;
}

.is-user .tobi-bubble a {
  color: inherit;
}

.tobi-bubble code {
  padding: 0.0625rem 0.25rem;
  border-radius: 0.25rem;
  background: var(--color-surface);
  font-size: 0.8125rem;
}

.tobi-bubble pre {
  overflow-x: auto;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: var(--color-surface);
}

.tobi-bubble pre code {
  padding: 0;
}

.tobi-bubble table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
}

.tobi-bubble th,
.tobi-bubble td {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--color-line);
  text-align: left;
}

/* Tipp-Anzeige */
.tobi-typing {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem 0;
}

.tobi-typing span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--color-muted);
  animation: tobi-dot var(--typing-dot-duration) infinite ease-in-out;
}

.tobi-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.tobi-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes tobi-dot {
  0%,
  80%,
  100% {
    opacity: 0.3;
  }

  40% {
    opacity: 1;
  }
}

/* Metazeile und Bewertung */
.tobi-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding-left: 1rem;
  color: var(--color-muted);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-xs);
}

.tobi-meta-divider {
  width: 1px;
  height: 0.75rem;
  background: var(--color-line);
}

.tobi-rate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--target-size-min);
  height: var(--target-size-min);
  margin: -0.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
}

.tobi-rate svg {
  width: var(--icon-size-sm);
  height: var(--icon-size-sm);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tobi-rate:hover,
.tobi-rate[aria-pressed="true"] {
  color: var(--color-text-strong);
}

.tobi-rate[aria-pressed="true"] svg {
  fill: currentColor;
}

.tobi-comment {
  display: flex;
  width: 100%;
  margin-top: 0.5rem;
  padding-left: 1rem;
}

.tobi-comment input {
  width: 100%;
  height: var(--comment-height);
  padding: 0 0.75rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-comment);
  background: var(--color-surface);
  font-size: var(--font-size-xs);
  outline: none;
}

.tobi-thanks {
  margin: 0.5rem 0 0;
  padding-left: 1rem;
  color: var(--color-muted);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-xs);
}

/* Hinweise in der Liste */
.tobi-notice {
  align-self: center;
  max-width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-notice);
  background: var(--color-bubble);
  color: var(--color-text);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-xs);
  text-align: center;
}

.tobi-notice a,
.tobi-notice button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text-strong);
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
}

/* Eingabe */
.tobi-input {
  flex: none;
  padding: 0 1rem;
}

.tobi-field {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  border: 1px solid var(--color-muted);
  border-radius: var(--radius-input);
  background: var(--color-surface);
  box-shadow: var(--input-shadow);
}

.tobi-field textarea {
  flex: 1;
  min-height: 2rem;
  max-height: 7.5rem;
  padding: 0.375rem 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--color-text-strong);
  line-height: var(--line-height-sm);
}

.tobi-field textarea::placeholder {
  color: var(--color-muted);
}

.tobi-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--icon-button-size);
  height: var(--icon-button-size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--color-text-strong);
  color: var(--color-on-accent);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.tobi-send svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tobi-send:disabled {
  background: var(--color-bubble);
  color: var(--color-disabled);
  cursor: default;
}

.tobi-counter {
  margin: 0.375rem 1rem 0;
  color: var(--color-muted);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-xs);
  text-align: right;
}

.tobi-counter.is-over {
  color: var(--color-danger);
}

/* Fußzeile */
.tobi-foot {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex: none;
  padding: 0.75rem 1rem 1rem;
  font-size: var(--font-size-xs);
  line-height: var(--line-height-xs);
}

.tobi-foot a {
  color: var(--color-text-strong);
  font-weight: 500;
  text-decoration: underline;
}

/* Breite Fenster: Lesebreite wie im Chatfenster der Blase, mittig */
@media (min-width: 56rem) {
  .tobi-log {
    padding-left: calc((100% - 48rem) / 2);
    padding-right: calc((100% - 48rem) / 2);
  }

  .tobi-input,
  .tobi-head {
    padding-left: calc((100% - 50rem) / 2);
    padding-right: calc((100% - 50rem) / 2);
  }
}

/* Fokus nur bei Tastatur */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.tobi-field:focus-within {
  border-color: var(--color-text-strong);
}

.tobi-field textarea:focus-visible,
.tobi-comment input:focus-visible {
  box-shadow: none;
}

.tobi-comment input:focus-visible {
  border-color: var(--color-accent);
}
