/* ============================================================
 * Felix Chat-Widget — Hero Blueprint System
 * Michael Höner Solutions · ruhige Premium-Intelligenz
 *
 * Farben:
 *   Deep Graphite   #1C1F24  — Headlines, Primärflächen
 *   Warm White      #F7F6F3  — Hauptfläche, Hintergrund
 *   Stone Grey      #8A8F98  — Sekundärtext, Linien, Labels
 *   Soft Titanium   #D9DDE2  — UI-Card-Flächen, Layer
 *   Muted Copper    #B07A4F  — Akzent, sparsam
 *
 * Prinzip: Architektur statt Aktionismus.
 * Keine Gradienten. Keine Schatten-Wolken. Keine Animationen
 * außer ruhigem Ein-/Ausblenden.
 * ============================================================ */

.mh-scope-chat,
.mh-chat-toggle,
.mh-chat-panel,
.mh-chat-panel * {
  font-family: "Inter", "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
 * Launcher — Label + Toggle-Button
 * Vertikal gestapelt, rechts unten verankert, ruhig im Blueprint
 * ============================================================ */
.mh-chat-launcher {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.mh-chat-label {
  background: #FFFFFF;
  color: #1C1F24;
  border: 1px solid #D9DDE2;
  border-radius: 3px;
  padding: 8px 14px;
  font-family: "Inter", "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
  white-space: nowrap;
  line-height: 1;
}
.mh-chat-label:hover {
  border-color: #1C1F24;
  color: #B07A4F;
}
.mh-chat-label:focus-visible {
  outline: 2px solid #B07A4F;
  outline-offset: 2px;
}

.mh-chat-toggle {
  align-self: flex-end;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(28, 31, 36, 0.08);
  cursor: pointer;
  background: #1C1F24;
  color: #F7F6F3;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 180ms ease, border-color 180ms ease;
  padding: 0;
}
.mh-chat-toggle:hover {
  background: #2A2D33;
  border-color: rgba(176, 122, 79, 0.5);
}
.mh-chat-toggle:focus-visible {
  outline: 2px solid #B07A4F;
  outline-offset: 3px;
}
.mh-chat-toggle svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.4;
}

/* ============================================================
 * Panel — Hauptcontainer
 * Warm White, dünne Stone-Grey-Linie statt Schatten
 * ============================================================ */
.mh-chat-panel {
  position: fixed;
  right: 28px;
  bottom: 96px;
  z-index: 9999;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 130px);
  background: #F7F6F3;
  color: #1C1F24;
  border: 1px solid rgba(138, 143, 152, 0.25);
  border-radius: 4px;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.mh-chat-panel[data-open="true"] {
  display: flex;
  animation: mhChatIn 240ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes mhChatIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
 * Header — Deep Graphite, asymmetrisch
 * ============================================================ */
.mh-chat-header {
  padding: 22px 22px 18px;
  background: #1C1F24;
  color: #F7F6F3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(217, 221, 226, 0.10);
}
.mh-chat-header__title-wrap {
  flex: 1;
  min-width: 0;
}
.mh-chat-header__title {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.2;
  color: #F7F6F3;
}
.mh-chat-header__sub {
  font-size: 10.5px;
  margin: 4px 0 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #8A8F98;
  font-weight: 400;
}

/* ============================================================
 * Header-Icon-Buttons
 * ============================================================ */
.mh-chat-header__actions {
  display: flex;
  gap: 2px;
  align-items: center;
  flex-shrink: 0;
}
.mh-chat-icon-btn {
  background: transparent;
  border: none;
  color: #D9DDE2;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms ease, color 160ms ease;
  padding: 0;
}
.mh-chat-icon-btn:hover {
  background: rgba(247, 246, 243, 0.08);
  color: #F7F6F3;
}
.mh-chat-icon-btn:focus-visible {
  outline: 1px solid #B07A4F;
  outline-offset: 2px;
}
.mh-chat-icon-btn svg {
  width: 15px;
  height: 15px;
  stroke-width: 1.5;
}
.mh-chat-close svg { width: 16px; height: 16px; }

/* ============================================================
 * Disclaimer — Stone-Grey-Ton
 * ============================================================ */
.mh-chat-disclaimer {
  background: #F7F6F3;
  border-bottom: 1px solid rgba(138, 143, 152, 0.18);
  padding: 12px 22px;
  font-size: 11px;
  line-height: 1.55;
  color: #8A8F98;
  letter-spacing: 0.01em;
}
.mh-chat-disclaimer a {
  color: #1C1F24;
  text-decoration: underline;
  text-decoration-color: rgba(28, 31, 36, 0.3);
  text-underline-offset: 2px;
}
.mh-chat-disclaimer a:hover {
  text-decoration-color: #B07A4F;
  color: #B07A4F;
}

/* ============================================================
 * Messages — ruhige Bubbles, scharfe Kanten
 * ============================================================ */
.mh-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: #D9DDE2 transparent;
}
.mh-chat-messages::-webkit-scrollbar {
  width: 6px;
}
.mh-chat-messages::-webkit-scrollbar-thumb {
  background: #D9DDE2;
  border-radius: 3px;
}
.mh-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.mh-chat-msg {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 3px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  letter-spacing: -0.005em;
}
.mh-chat-msg--bot {
  background: #FFFFFF;
  border: 1px solid rgba(138, 143, 152, 0.22);
  color: #1C1F24;
  align-self: flex-start;
}
.mh-chat-msg--user {
  background: #1C1F24;
  color: #F7F6F3;
  border: 1px solid #1C1F24;
  align-self: flex-end;
}
.mh-chat-msg a {
  color: #B07A4F;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.mh-chat-msg--user a {
  color: #D9DDE2;
}
.mh-chat-msg--user a:hover {
  color: #B07A4F;
}
.mh-chat-msg p { margin: 0 0 8px; }
.mh-chat-msg p:last-child { margin-bottom: 0; }
.mh-chat-msg ul, .mh-chat-msg ol {
  margin: 6px 0 0;
  padding-left: 18px;
}
.mh-chat-msg li { margin: 3px 0; }
.mh-chat-msg strong { font-weight: 600; }

/* Typing indicator — drei ruhige Punkte */
.mh-chat-typing {
  display: inline-flex;
  gap: 5px;
  padding: 4px 0;
  align-items: center;
}
.mh-chat-typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #8A8F98;
  animation: mhDot 1.4s infinite ease-in-out;
}
.mh-chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.mh-chat-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes mhDot {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* ============================================================
 * Input — ruhig, präzise, kein Glitzern
 * ============================================================ */
.mh-chat-form {
  border-top: 1px solid rgba(138, 143, 152, 0.20);
  padding: 14px 18px;
  display: flex;
  gap: 10px;
  background: #FFFFFF;
  align-items: flex-end;
}
.mh-chat-input {
  flex: 1;
  border: 1px solid #D9DDE2;
  background: #F7F6F3;
  color: #1C1F24;
  border-radius: 3px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 160ms ease, background 160ms ease;
}
.mh-chat-input::placeholder {
  color: #8A8F98;
  opacity: 1;
}
.mh-chat-input:focus {
  outline: none;
  border-color: #1C1F24;
  background: #FFFFFF;
}
.mh-chat-send {
  background: #1C1F24;
  color: #F7F6F3;
  border: 1px solid #1C1F24;
  border-radius: 3px;
  padding: 0 14px;
  min-width: 42px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms ease, border-color 160ms ease;
}
.mh-chat-send:hover:not(:disabled) {
  background: #2A2D33;
  border-color: #2A2D33;
}
.mh-chat-send:focus-visible {
  outline: 2px solid #B07A4F;
  outline-offset: 2px;
}
.mh-chat-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.mh-chat-send svg {
  width: 15px;
  height: 15px;
  stroke-width: 1.5;
}

/* ============================================================
 * Consent-View — vor erster Interaktion
 * ============================================================ */
.mh-chat-consent {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  background: #F7F6F3;
  overflow-y: auto;
}
.mh-chat-consent[hidden] { display: none; }
.mh-chat-consent__inner {
  max-width: 100%;
  text-align: left;
}
.mh-chat-consent__eyebrow {
  margin: 0 0 12px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #8A8F98;
  font-weight: 500;
}
.mh-chat-consent__headline {
  margin: 0 0 16px;
  font-size: 19px;
  font-weight: 500;
  line-height: 1.25;
  color: #1C1F24;
  letter-spacing: -0.015em;
}
.mh-chat-consent__text {
  margin: 0 0 14px;
  font-size: 13.5px;
  line-height: 1.6;
  color: #1C1F24;
  letter-spacing: -0.005em;
}
.mh-chat-consent__text strong {
  font-weight: 600;
}
.mh-chat-consent__text a {
  color: #B07A4F;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.mh-chat-consent__text a:hover {
  color: #1C1F24;
}
.mh-chat-consent__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
}
.mh-chat-consent__accept,
.mh-chat-consent__secondary {
  display: block;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 12px 18px;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  letter-spacing: 0.01em;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.mh-chat-consent__accept {
  background: #1C1F24;
  color: #F7F6F3;
  border-color: #1C1F24;
  order: 1;
}
.mh-chat-consent__accept:hover {
  background: #2A2D33;
  border-color: #2A2D33;
}
.mh-chat-consent__accept:focus-visible {
  outline: 2px solid #B07A4F;
  outline-offset: 2px;
}
.mh-chat-consent__secondary {
  background: transparent;
  color: #8A8F98;
  border-color: #D9DDE2;
  order: 2;
}
.mh-chat-consent__secondary:hover {
  color: #1C1F24;
  border-color: #1C1F24;
  background: #FFFFFF;
}

/* Wenn Consent-View aktiv: Messages-Bereich verbergen */
.mh-chat-panel[data-state="consent"] .mh-chat-messages,
.mh-chat-panel[data-state="consent"] .mh-chat-form,
.mh-chat-panel[data-state="consent"] .mh-chat-mail-form { display: none; }
.mh-chat-panel[data-state="consent"] .mh-chat-restart,
.mh-chat-panel[data-state="consent"] .mh-chat-mail { display: none; }

/* Widerrufs-Link im Disclaimer */
.mh-chat-revoke {
  cursor: pointer;
}

/* ============================================================
 * Mail-Form — Soft Titanium als Card-Fläche
 * ============================================================ */
.mh-chat-mail-form {
  border-top: 1px solid rgba(138, 143, 152, 0.20);
  padding: 20px 22px;
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mh-chat-mail-form[hidden] { display: none; }
.mh-chat-mail-form__intro {
  margin: 0 0 4px;
  font-size: 12.5px;
  line-height: 1.55;
  color: #1C1F24;
  letter-spacing: -0.005em;
}
.mh-chat-mail-form__field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.mh-chat-mail-form__field > span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #8A8F98;
  font-weight: 500;
}
.mh-chat-mail-form__field input {
  border: 1px solid #D9DDE2;
  background: #F7F6F3;
  color: #1C1F24;
  border-radius: 3px;
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color 160ms ease, background 160ms ease;
}
.mh-chat-mail-form__field input::placeholder {
  color: #8A8F98;
}
.mh-chat-mail-form__field input:focus {
  outline: none;
  border-color: #1C1F24;
  background: #FFFFFF;
}
.mh-chat-mail-form__actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}
.mh-chat-mail-cancel,
.mh-chat-mail-submit {
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 9px 16px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.mh-chat-mail-cancel {
  background: transparent;
  color: #8A8F98;
  border-color: transparent;
}
.mh-chat-mail-cancel:hover {
  color: #1C1F24;
  background: #F7F6F3;
}
.mh-chat-mail-submit {
  background: #1C1F24;
  color: #F7F6F3;
  border-color: #1C1F24;
}
.mh-chat-mail-submit:hover:not(:disabled) {
  background: #2A2D33;
  border-color: #2A2D33;
}
.mh-chat-mail-submit:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ============================================================
 * Mobile — fullscreen, kein Border-Radius
 * ============================================================ */
@media (max-width: 480px) {
  .mh-chat-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
  .mh-chat-launcher {
    right: 18px;
    bottom: 18px;
    gap: 8px;
  }
  .mh-chat-label {
    font-size: 12px;
    padding: 7px 12px;
  }
  .mh-chat-header {
    padding: 18px 20px 14px;
  }
  .mh-chat-messages {
    padding: 18px 20px 14px;
  }
}

/* ============================================================
 * Reduced Motion
 * ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .mh-chat-panel[data-open="true"] { animation: none; }
  .mh-chat-typing span { animation: none; opacity: 0.5; }
  .mh-chat-toggle,
  .mh-chat-icon-btn,
  .mh-chat-input,
  .mh-chat-send,
  .mh-chat-mail-cancel,
  .mh-chat-mail-submit { transition: none; }
}
