/* =============================================================================
   NEONNACHT — Chat-Panel der Startseite
   =============================================================================
   Gilt nur fuer index.html. NICHT in Admin- oder andere Seiten einbinden
   (Regression 17.09.2026: geteilte Stildateien).

   Hintergrund: Die Chat-Regeln standen in styles.css, die index.html seit dem
   Neonnacht-Umbau (18.09.2026) nicht mehr laedt. Ohne sie lag .chat-container
   als Zeile statt Spalte: Nachrichten als schmaler Streifen links, Eingabe
   daneben, Knoepfe als graue Browser-Kaesten. chat-background.css (Papier-
   Textur, weisse Blasen) ist aus index.html entfernt — hier ersetzt.

   Den DOM baut js/chat.js per innerHTML (renderChat, renderEventChat,
   getMessageHTML, renderImageMessage). Klassennamen sind Funktionsvertrag.
   Wo chat.js oder event-status.js Inline-Stile fuer hellen Grund setzen,
   wird hier gezielt mit !important ueberschrieben.

   Emoji-Auswahl (js/emoji-picker.js), Bild-Menue (js/chat-image-upload.js)
   und Reaktionsauswahl (js/chat.js) haengen am <body>, nicht im Panel. Ihre
   eingebetteten Stile kommen nach diesem Blatt — daher "html body ..." fuer
   die hoehere Spezifitaet. Sie lagen mit z-index 9999/10000 HINTER dem
   Panel (--z-panel 100300) und waren im offenen Chat unsichtbar.
   ============================================================================= */

/* -- Rahmen ----------------------------------------------------------------- */

/* atelier-panel.css setzt unter 640px .a-panel__body { padding-inline } und
   ueberstimmt damit --flush (steht spaeter in der Datei). Der Chat braucht
   die volle Breite, Verlauf und Eingabe bringen ihren Innenabstand selbst mit. */
#panel-chat .s-chatpanel__koerper { padding: 0; }

#panel-chat .chat-container {
  display: flex;
  flex-direction: column;
  min-block-size: 0;
  block-size: 100%;
  background: var(--c-bg);
}

#panel-chat .chat-messages {
  flex: 1 1 auto;
  min-block-size: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-4) var(--s-4) !important;
  background: var(--c-bg);
  scrollbar-width: thin;
  scrollbar-color: var(--c-line-strong) transparent;
}

/* -- Nachricht ---------------------------------------------------------------- */

#panel-chat .message-wrapper { display: flex; position: relative; }
#panel-chat .message-wrapper.own    { justify-content: flex-end; }
#panel-chat .message-wrapper.other  { justify-content: flex-start; }
#panel-chat .message-wrapper.system { justify-content: center; }

/* Flex mit Umbruch: Kopf, Zitat, Bild und Text belegen je eine volle Zeile,
   die Fusszeile teilen sich Reaktionen, (Touch-)Aktionen und Uhrzeit. So
   kostet die Uhrzeit keine eigene Zeile, sobald Reaktionen da sind.        */
#panel-chat .message {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: var(--s-2);
  position: relative;
  max-inline-size: 82%;
  min-inline-size: 5.5rem;
  padding: var(--s-2) var(--s-4) var(--s-2);
  border-radius: 18px 18px 18px 6px;
  background: var(--c-surface-up);
  border: 1px solid var(--c-line);
  color: var(--c-text-body);
}

#panel-chat .message.own {
  border-radius: 18px 18px 6px 18px;
  border-color: transparent;
  background: var(--c-verlauf);
  /* Sonst kachelt der Verlauf unter den transparenten Rand: Farbstreifen. */
  background-origin: border-box;
  color: var(--c-text-on-accent);
}

#panel-chat .message.system {
  max-inline-size: 100%;
  text-align: center;
  border-radius: var(--r-lg);
  background: rgb(251 205 10 / .08);
  border-color: rgb(251 205 10 / .35);
  color: var(--c-text);
}

#panel-chat .message-user {
  margin-block-end: 2px;
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--n-cyan);
}

#panel-chat .message-text {
  font-size: var(--t-base);
  line-height: 1.45;
  color: inherit;
  overflow-wrap: anywhere;
}
#panel-chat .message.own .message-text { font-weight: 600; }

#panel-chat .message > * { flex: 0 0 100%; min-inline-size: 0; }
#panel-chat .message > .message-reactions { order: 1; flex: 0 1 auto; }
#panel-chat .message > .message-actions   { order: 2; flex: 0 0 auto; }
#panel-chat .message > .message-time      { order: 3; flex: 0 0 auto; margin-inline-start: auto; }

#panel-chat .message-time {
  margin-block-start: 4px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: end;
  color: var(--c-text-muted);
}
#panel-chat .message.own .message-time { color: rgb(8 7 10 / .66); }

/* Suchtreffer: chat.js setzt einen hellgelben Inline-Grund. */
#panel-chat .message mark { color: var(--c-text-on-accent) !important; }

/* -- Zitat (Antwort auf ...) -------------------------------------------------- */

#panel-chat .message-reply {
  margin-block: 2px var(--s-2);
  padding: 6px 10px;
  border-inline-start: 3px solid var(--n-violett-hell);
  border-radius: var(--r-md);
  background: rgb(255 255 255 / .05);
  font-size: var(--t-xs);
}
#panel-chat .message-reply-author { font-weight: 700; margin-block-end: 2px; color: var(--n-violett-hell); }
#panel-chat .message-reply-text   { color: var(--c-text-muted); }

#panel-chat .message.own .message-reply { background: rgb(8 7 10 / .14); border-inline-start-color: rgb(8 7 10 / .55); }
#panel-chat .message.own .message-reply-author { color: var(--c-text-on-accent); }
#panel-chat .message.own .message-reply-text   { color: rgb(8 7 10 / .75); }

/* -- Reaktionen --------------------------------------------------------------- */

#panel-chat .message-reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-block-start: 6px; }

#panel-chat .message-reaction {
  display: inline-flex; align-items: center; gap: 4px;
  min-block-size: 26px;
  padding: 2px 9px;
  font: inherit; font-size: var(--t-xs); line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--c-text-body);
  background: rgb(255 255 255 / .06);
  border: 1px solid var(--c-line);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
#panel-chat .message-reaction:hover { background: rgb(255 255 255 / .1); border-color: var(--c-line-strong); }
#panel-chat .message-reaction.active { border-color: var(--n-violett-hell); background: rgb(139 92 246 / .18); }

#panel-chat .message.own .message-reaction { color: var(--c-text-on-accent); background: rgb(8 7 10 / .16); border-color: rgb(8 7 10 / .18); }
#panel-chat .message.own .message-reaction:hover  { background: rgb(8 7 10 / .26); }
#panel-chat .message.own .message-reaction.active { border-color: rgb(8 7 10 / .6); }

/* -- Aktionen: Antworten, Reagieren, Loeschen ----------------------------------
   Maus: schwebende Leiste oben an der Blase, beim Ueberfahren oder Tastatur-
   fokus. Touch: es gibt kein Ueberfahren — dort steht die Leiste dezent und
   immer sichtbar unter dem Text (wie frueher in mobile-styles.css).          */

#panel-chat .message-actions { display: flex; gap: 2px; }

#panel-chat .message-action-btn {
  display: grid; place-items: center;
  inline-size: 30px; block-size: 30px;
  padding: 0;
  color: var(--c-text-muted);
  background: none;
  border: 0;
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
#panel-chat .message-action-btn svg { inline-size: 16px; block-size: 16px; }
#panel-chat .message-action-btn:hover { color: var(--c-text); background: rgb(255 255 255 / .08); }
#panel-chat .message-action-btn.delete:hover { color: var(--c-bad); background: rgb(255 71 87 / .12); }
#panel-chat .message-action-btn:focus-visible { outline: 2px solid var(--n-cyan); outline-offset: 1px; }

@media (hover: hover) and (pointer: fine) {
  #panel-chat .message-actions {
    position: absolute;
    inset-block-start: -14px;
    inset-inline-end: 8px;
    z-index: 2;
    padding: 2px;
    background: var(--c-surface);
    border: 1px solid var(--c-line-strong);
    border-radius: var(--r-full);
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
  }
  #panel-chat .message.own .message-actions { inset-inline-end: auto; inset-inline-start: 8px; }
  #panel-chat .message-wrapper:hover .message-actions,
  #panel-chat .message:focus-within .message-actions { opacity: 1; pointer-events: auto; }
}

@media (hover: none), (pointer: coarse) {
  #panel-chat .message-actions { margin: 2px 0 -4px -8px; }
  #panel-chat .message-action-btn { inline-size: 34px; block-size: 34px; }
  #panel-chat .message.own .message-action-btn { color: rgb(8 7 10 / .6); }
  #panel-chat .message.own .message-action-btn:hover { color: var(--c-text-on-accent); background: rgb(8 7 10 / .12); }
}

/* -- Bilder ------------------------------------------------------------------- */

#panel-chat .message-image-wrapper { margin: 6px 0 4px; border-radius: var(--r-lg); overflow: hidden; max-inline-size: 100%; }
#panel-chat .message-image { box-shadow: none; border-radius: var(--r-lg); }
#panel-chat .message-image[src=""] { background: var(--c-surface); animation: none; }

/* -- Eingabe ------------------------------------------------------------------ */

#panel-chat .chat-input {
  flex: 0 0 auto;
  padding: var(--s-3) var(--s-3) calc(var(--s-3) + env(safe-area-inset-bottom));
  border-block-start: 1px solid var(--c-line);
  background: var(--c-bg-tief);
}

#panel-chat .chat-input-wrapper { display: flex; align-items: center; gap: var(--s-2); }

#panel-chat .chat-input-btn,
#panel-chat .chat-send-btn {
  flex: 0 0 auto;
  display: grid; place-items: center;
  inline-size: 44px; block-size: 44px;
  padding: 0;
  color: var(--c-text-body);
  background: rgb(255 255 255 / .06);
  border: 1px solid var(--c-line);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, transform .15s var(--ease-paper);
}
#panel-chat .chat-input-btn .icon,
#panel-chat .chat-send-btn .icon { inline-size: 20px; block-size: 20px; }
#panel-chat .chat-input-btn:hover { color: var(--c-text); background: rgb(255 255 255 / .1); border-color: var(--c-line-strong); }
#panel-chat .chat-input-btn:active,
#panel-chat .chat-send-btn:active { transform: scale(.94); }

#panel-chat .chat-send-btn { color: var(--c-text-on-accent); background: var(--c-verlauf); background-origin: border-box; border-color: transparent; }
#panel-chat .chat-send-btn:hover { box-shadow: var(--glow-accent); }

#panel-chat .chat-input-field {
  flex: 1 1 auto;
  min-inline-size: 0;
  block-size: 44px;
  padding: 0 var(--s-4);
  /* 16px: darunter zoomt iOS Safari beim Antippen in die Seite. */
  font: inherit; font-size: 1rem;
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-full);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#panel-chat .chat-input-field::placeholder { color: var(--c-text-muted); opacity: 1; }
#panel-chat .chat-input-field:focus { border-color: var(--n-violett-hell); box-shadow: 0 0 0 3px rgb(139 92 246 / .25); }

#panel-chat .chat-input-btn:focus-visible,
#panel-chat .chat-send-btn:focus-visible { outline: 2px solid var(--n-cyan); outline-offset: 2px; }

@media (max-width: 400px) {
  #panel-chat .chat-input-wrapper { gap: 6px; }
  #panel-chat .chat-input-btn { inline-size: 40px; block-size: 40px; }
}

/* Antwort-Vorschau ueber der Eingabe (Inline-Stile fuer hellen Grund). */
#panel-chat #reply-preview {
  margin: 0 0 var(--s-2) !important;
  padding: var(--s-2) var(--s-3) !important;
  background: var(--c-surface) !important;
  border-inline-start: 3px solid var(--n-violett-hell) !important;
  border-radius: var(--r-md) !important;
}
#panel-chat #reply-preview div[style*="color: #8b5cf6"] { color: var(--n-violett-hell) !important; }
#panel-chat #reply-preview #reply-text { color: var(--c-text-muted) !important; max-inline-size: 100% !important; }
#panel-chat #reply-preview button { color: var(--c-text-muted); }
#panel-chat #reply-preview button:hover { color: var(--c-text); }

/* -- Hinweise im Verlauf (Inline-Stile aus chat.js) --------------------------- */

#panel-chat .chat-messages button[onclick^="loadMoreMessages"] {
  min-inline-size: 0 !important;
  padding: 10px 18px !important;
  font: inherit !important; font-size: var(--t-sm) !important; font-weight: 700 !important;
  color: var(--c-text) !important;
  background: rgb(255 255 255 / .06) !important;
  border: 1px solid var(--c-line-strong) !important;
  border-radius: var(--r-full) !important;
  box-shadow: none !important;
}
#panel-chat .chat-messages button[onclick^="clearChatSearch"] {
  font: inherit !important; font-weight: 700 !important;
  color: var(--c-text-on-accent) !important;
  background: var(--c-verlauf) !important;
  border-radius: var(--r-full) !important;
}

/* -- Kein Event / Chat geschlossen ------------------------------------------- */

#panel-chat .chat-header {
  flex: 0 0 auto;
  padding: var(--s-4);
  border-block-end: 1px solid var(--c-line);
  background: var(--c-bg-tief);
}
#panel-chat .chat-header-content { display: flex; align-items: center; gap: var(--s-4); }
#panel-chat .chat-header-content > div[style*="#f3f4f6"] {
  inline-size: 48px !important; block-size: 48px !important;
  background: var(--c-surface) !important;
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg) !important;
}
#panel-chat .chat-header-content > div[style*="#f3f4f6"] > div { font-size: 24px !important; }
#panel-chat .chat-product-info { flex: 1 1 auto; min-inline-size: 0; }
#panel-chat .chat-product-name {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: var(--t-lg);
  font-weight: 400;
  letter-spacing: var(--track-display);
  text-transform: uppercase;
  color: var(--c-text);
}
#panel-chat .chat-product-description { font-size: var(--t-sm); color: var(--c-text-muted) !important; }

#panel-chat .no-event-container {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-3);
  min-block-size: 100%;
  padding: var(--s-6) var(--s-4);
  text-align: center;
  background: none !important;
  border: 0 !important;
}
#panel-chat .no-event-icon { font-size: 40px !important; line-height: 1; }
#panel-chat .no-event-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--t-xl);
  font-weight: 400;
  letter-spacing: var(--track-display);
  text-transform: uppercase;
  color: var(--c-text) !important;
}
#panel-chat .no-event-text { margin: 0; font-size: var(--t-base); line-height: var(--lh-body); color: var(--c-text-body); }
#panel-chat .no-event-text strong { color: var(--c-text); }

/* "Bestellschluss in" — chat.js/event-status.js setzen einen weissen Kasten. */
#panel-chat .no-event-container > div[style*="background: white"] {
  margin-block-start: var(--s-3) !important;
  padding: var(--s-4) var(--s-5) !important;
  background: var(--c-surface) !important;
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg) !important;
  box-shadow: none !important;
}
#panel-chat .no-event-container > div[style*="background: white"] > div:first-child { color: var(--c-text-muted) !important; }
#panel-chat .no-event-container > div[style*="background: white"] > div:last-child {
  font-family: var(--font-display); font-weight: 400 !important; color: var(--c-text) !important;
  font-variant-numeric: tabular-nums;
}

/* Countdown bis zum naechsten Event (event-status.js renderEventCountdown). */
#panel-chat .event-countdown-widget { margin-block-start: var(--s-3); }
#panel-chat .event-countdown-widget h3 {
  margin: 0 0 var(--s-2);
  font-size: var(--t-2xs); font-weight: 700;
  letter-spacing: var(--track-label); text-transform: uppercase;
  color: var(--c-text-muted);
}
#panel-chat .countdown-display { display: flex; align-items: flex-start; justify-content: center; gap: var(--s-2); }
#panel-chat .countdown-unit { display: flex; flex-direction: column; align-items: center; min-inline-size: 3rem; }
#panel-chat .countdown-number,
#panel-chat .countdown-separator {
  font-family: var(--font-display); font-size: 2.25rem; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--c-text);
}
#panel-chat .countdown-separator { color: var(--c-text-faint); }
#panel-chat .countdown-label { margin-block-start: 4px; font-size: var(--t-2xs); color: var(--c-text-muted); }

/* =============================================================================
   UEBERLAGERUNGEN AM <body>
   ============================================================================= */

/* -- Reaktionsauswahl (js/chat.js showEventChatReactionPicker) -------------- */

html body .reaction-picker-overlay {
  position: fixed; inset: 0;
  z-index: var(--z-popover);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-4);
  background: rgb(5 4 8 / .6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
html body .reaction-picker {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px;
  max-inline-size: 22rem;
  padding: var(--s-2);
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgb(0 0 0 / .5);
}
html body .reaction-emoji-btn {
  display: grid; place-items: center;
  inline-size: 48px; block-size: 48px;
  padding: 0;
  font-size: 26px; line-height: 1;
  background: none; border: 0; border-radius: 14px;
  cursor: pointer;
  transition: background-color .15s, transform .15s var(--ease-paper);
}
html body .reaction-emoji-btn:hover { background: rgb(255 255 255 / .08); transform: scale(1.12); }
html body .reaction-emoji-btn:active { transform: scale(.94); }

/* -- Emoji-Auswahl (js/emoji-picker.js) -------------------------------------- */

html body .rene-emoji-picker {
  z-index: var(--z-popover);
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong);
  box-shadow: 0 20px 50px rgb(0 0 0 / .5);
  backdrop-filter: none;
  color: var(--c-text);
  overflow: hidden; /* Kopfzeile sonst eckig ueber den runden Ecken */
}
html body .rene-emoji-picker-header { background: var(--c-surface); border-block-end: 1px solid var(--c-line); }
html body .rene-emoji-category-btn:hover,
html body .rene-emoji-btn:hover { background: rgb(255 255 255 / .08); }
html body .rene-emoji-category-title { color: var(--c-text-muted); font-size: var(--t-2xs); letter-spacing: var(--track-label); }
html body .rene-emoji-picker-content { scrollbar-width: thin; scrollbar-color: var(--c-line-strong) transparent; }

/* -- Bild-Menue (js/chat-image-upload.js) ------------------------------------ */

html body .image-upload-menu { z-index: var(--z-popover); }
html body .upload-menu-overlay { background: rgb(5 4 8 / .6); }
html body .upload-menu-content {
  padding-block-end: calc(var(--s-5) + env(safe-area-inset-bottom));
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong);
  border-block-end: 0;
  box-shadow: 0 -20px 50px rgb(0 0 0 / .5);
}
html body .upload-menu-header h3 {
  font-family: var(--font-display); font-size: var(--t-xl); font-weight: 400;
  text-transform: uppercase; color: var(--c-text);
}
html body .upload-menu-header button { color: var(--c-text-body); background: rgb(255 255 255 / .06); border: 1px solid var(--c-line); }
html body .upload-menu-header button:hover { background: rgb(255 255 255 / .1); }
html body .upload-option-btn {
  font: inherit; font-weight: 700;
  color: var(--c-text);
  background: rgb(255 255 255 / .04);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-lg);
}
html body .upload-option-btn:hover {
  color: var(--c-text-on-accent);
  background: var(--c-verlauf);
  background-origin: border-box;
  border-color: transparent;
  box-shadow: var(--glow-accent);
}

@media (prefers-reduced-motion: reduce) {
  #panel-chat .message-actions,
  #panel-chat .chat-input-btn,
  #panel-chat .chat-send-btn,
  html body .reaction-emoji-btn { transition: none; }
  html body .reaction-emoji-btn:hover { transform: none; }
}
