/* TerraTransfer KI-Assistent — Floating Chat Widget
   Bezieht sich auf die Brand-Variablen aus assets/css/style.css */

#tt-chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9990;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;
  background: var(--brand-700, #1B3A5C);
  color: #fff;
  border: none;
  border-radius: 999px;
  box-shadow: 0 12px 28px -8px rgba(14, 31, 54, 0.35),
              0 4px 8px -4px rgba(14, 31, 54, 0.18);
  font: 600 15px/1.2 var(--font-sans, system-ui, sans-serif);
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
#tt-chat-launcher:hover {
  background: var(--brand-600, #25548A);
  transform: translateY(-2px);
}
#tt-chat-launcher:focus-visible {
  outline: 3px solid var(--brand-300, #A6C8E8);
  outline-offset: 2px;
}
#tt-chat-launcher svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
#tt-chat-launcher .tt-launcher-label { white-space: nowrap; }

#tt-chat-launcher.tt-hidden { display: none; }

/* Panel */
#tt-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9991;
  width: min(420px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 100px));
  background: var(--white, #fff);
  border: 1px solid var(--ink-200, #DFE4EC);
  border-radius: var(--radius-lg, 20px);
  box-shadow: 0 24px 48px -12px rgba(14, 31, 54, 0.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-sans, system-ui, sans-serif);
}
#tt-chat-panel.tt-open { display: flex; }

#tt-chat-header {
  background: var(--brand-700, #1B3A5C);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
#tt-chat-header .tt-avatar {
  width: 36px;
  height: 36px;
  background: var(--brand-500, #3B7BBD);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#tt-chat-header .tt-avatar svg { width: 20px; height: 20px; color: #fff; }
#tt-chat-header .tt-title { font-weight: 600; font-size: 15px; line-height: 1.2; }
#tt-chat-header .tt-sub   { font-size: 12px; opacity: 0.85; margin-top: 2px; }
#tt-chat-header .tt-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  opacity: 0.85;
}
#tt-chat-header .tt-close:hover { background: rgba(255,255,255,0.1); opacity: 1; }
#tt-chat-header .tt-close svg { width: 18px; height: 18px; display: block; }

#tt-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--brand-50, #F2F5F8);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tt-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.tt-msg.tt-bot {
  background: #fff;
  color: var(--ink-900, #0E1A2B);
  align-self: flex-start;
  border: 1px solid var(--ink-200, #DFE4EC);
  border-bottom-left-radius: 4px;
}
.tt-msg.tt-user {
  background: var(--brand-700, #1B3A5C);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.tt-msg.tt-system {
  background: transparent;
  color: var(--ink-500, #5A6678);
  font-size: 12px;
  align-self: center;
  text-align: center;
  max-width: 100%;
  padding: 4px 8px;
}

.tt-msg a {
  color: var(--brand-600, #25548A);
  text-decoration: underline;
}
.tt-msg.tt-user a { color: #fff; }

.tt-typing {
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
}
.tt-typing span {
  width: 6px;
  height: 6px;
  background: var(--ink-400, #8392A4);
  border-radius: 50%;
  animation: tt-bounce 1.2s infinite;
}
.tt-typing span:nth-child(2) { animation-delay: 0.15s; }
.tt-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tt-bounce {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

#tt-chat-suggestions {
  padding: 10px 16px 0;
  background: var(--brand-50, #F2F5F8);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tt-chip {
  background: #fff;
  border: 1px solid var(--ink-200, #DFE4EC);
  color: var(--brand-700, #1B3A5C);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.tt-chip:hover {
  background: var(--brand-100, #EAF1F8);
  border-color: var(--brand-400, #6BA4DB);
}

#tt-chat-form {
  border-top: 1px solid var(--ink-200, #DFE4EC);
  background: #fff;
  padding: 10px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
#tt-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--ink-200, #DFE4EC);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  min-height: 40px;
  max-height: 120px;
  background: var(--brand-50, #F2F5F8);
  color: var(--ink-900, #0E1A2B);
}
#tt-chat-input:focus {
  outline: none;
  border-color: var(--brand-500, #3B7BBD);
  background: #fff;
}
#tt-chat-send {
  background: var(--brand-700, #1B3A5C);
  color: #fff;
  border: none;
  border-radius: 12px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
#tt-chat-send:hover:not(:disabled) { background: var(--brand-600, #25548A); }
#tt-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
#tt-chat-send svg { width: 18px; height: 18px; }

#tt-chat-footer {
  font-size: 11px;
  color: var(--ink-500, #5A6678);
  padding: 6px 14px 10px;
  background: #fff;
  text-align: center;
  border-top: 1px solid var(--ink-100, #EAF1F8);
}
#tt-chat-footer a { color: var(--brand-600, #25548A); }

/* Honeypot — versteckt, fuer Menschen unsichtbar */
.tt-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}

/* Mobile */
@media (max-width: 540px) {
  #tt-chat-launcher .tt-launcher-label { display: none; }
  #tt-chat-launcher { padding: 14px; }
  #tt-chat-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
}

/* ============================================================
   Dark-Mode-Overrides
   Site setzt [data-theme="dark"] auf <html>; chat-widget zieht nach.
   ============================================================ */
[data-theme="dark"] #tt-chat-launcher {
  background: var(--brand-700, #1B3A5C);
  color: #fff;
  box-shadow: 0 12px 28px -8px rgba(0,0,0,.55), 0 4px 8px -4px rgba(0,0,0,.4);
}

[data-theme="dark"] #tt-chat-panel {
  background: #0E1626;
  border-color: #2A3344;
  box-shadow: 0 24px 48px -12px rgba(0,0,0,.65);
}

[data-theme="dark"] #tt-chat-body {
  background: #0A1120;
}

[data-theme="dark"] .tt-msg.tt-bot {
  background: #14213B;
  color: #ECEFF4;
  border-color: #2A3344;
}
[data-theme="dark"] .tt-msg.tt-bot a {
  color: #6BA4DB;
}
[data-theme="dark"] .tt-msg.tt-system {
  color: #8C97AB;
}
[data-theme="dark"] .tt-msg.tt-user {
  background: var(--brand-600, #25548A);
  color: #fff;
}

[data-theme="dark"] .tt-typing span {
  background: #6F7A8E;
}

[data-theme="dark"] #tt-chat-suggestions {
  background: #0A1120;
}
[data-theme="dark"] .tt-chip {
  background: #14213B;
  color: #C5CCD9;
  border-color: #2A3344;
}
[data-theme="dark"] .tt-chip:hover {
  background: #1B2A45;
  border-color: #3B7BBD;
  color: #ECEFF4;
}

[data-theme="dark"] #tt-chat-form {
  background: #0E1626;
  border-top-color: #2A3344;
}
[data-theme="dark"] #tt-chat-input {
  background: #14213B;
  color: #ECEFF4;
  border-color: #2A3344;
}
[data-theme="dark"] #tt-chat-input:focus {
  background: #182A48;
  border-color: var(--brand-500, #3B7BBD);
}
[data-theme="dark"] #tt-chat-input::placeholder {
  color: #8C97AB;
}

[data-theme="dark"] #tt-chat-send {
  background: var(--brand-600, #25548A);
  color: #fff;
}
[data-theme="dark"] #tt-chat-send:hover:not(:disabled) {
  background: var(--brand-500, #3B7BBD);
}

[data-theme="dark"] #tt-chat-footer {
  background: #0E1626;
  color: #8C97AB;
  border-top-color: #1B2233;
}
[data-theme="dark"] #tt-chat-footer a {
  color: #6BA4DB;
}
