/* chat-widget.css - Version 3.19 (Avatars & Sending Feedback) */

/* Modernes Farbschema */
:root {
  --primary: #4A90E2;
  --primary-hover: #357ABD;
  --background: #FFFFFF;
  --text: #2C3E50;
  --text-own: #FFFFFF;
  --border: #E0E7ED;
  --bubble-bg: #F0F4F8;
  --shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  --z-base: 1;
  --z-dropdown: 10;
  --z-sticky: 100;
  --z-modal: 1000;
  --z-emoji-picker: 1010;
  --avatar-size: 32px; /* Avatar Größe zentral definieren */
}

/* Hauptcontainer - Standardmäßig versteckt! */
.modern-chat-container {
  background: var(--background);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1rem;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  position: relative;
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  display: none;
  overflow: hidden;
}

/* Ladeanzeige */
.chat-loading {
  display: none;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--primary);
}

/* Nachrichtenbereich */
.modern-chat-messages {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  max-height: 350px;
  overflow-y: auto;
  overflow-x: hidden;
  flex-grow: 1;
  min-height: 100px;
  padding-right: 5px;
}
.no-messages {
  text-align: center;
  color: #999;
  padding: 2rem 0;
  font-style: italic;
}

/* --- NEU: Layout für Nachricht mit Avatar --- */
.modern-chat-message {
  display: flex; /* Flexbox für Avatar + Inhalt */
  gap: 8px;      /* Abstand zwischen Avatar und Inhalt */
  margin-bottom: 1rem;
  animation: fadeIn 0.3s ease-out;
  position: relative;
}
.modern-chat-message.own-message {
  flex-direction: row-reverse; /* Avatar rechts für eigene Nachrichten */
}

/* --- NEU: Avatar Styling --- */
.modern-chat-avatar {
  flex-shrink: 0; /* Verhindert, dass Avatar schrumpft */
  width: var(--avatar-size);
  height: var(--avatar-size);
  margin-top: 2px; /* Kleine Anpassung zur Ausrichtung am Namen */
}
.modern-chat-avatar img {
  display: block; /* Verhindert extra Platz unter dem Bild */
  width: 100%;
  height: 100%;
  border-radius: 50%; /* Macht Avatare rund */
  background-color: #eee; /* Hintergrund für Standard-Avatare */
  object-fit: cover; /* Stellt sicher, dass das Bild den Kreis füllt */
}

/* Nachricht Inhalt (rechte Seite neben Avatar oder linke Seite bei own-message) */
.modern-chat-message .message-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1; /* Nimmt restlichen Platz ein */
  min-width: 0; /* Wichtig für Flexbox-Umbruch */
  align-items: flex-start; /* Standardmäßig linksbündig */
}
.modern-chat-message.own-message .message-content {
  align-items: flex-end; /* Eigene Nachrichten rechtsbündig */
}
/* --- Ende NEU: Layout & Avatar --- */


.modern-chat-message.optimistic {
  opacity: 0.7;
}

/* Username */
.modern-chat-username {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.8rem;
  margin-bottom: 4px;
  padding: 0 10px; /* Beibehalten für Innenabstand des Namens */
}

/* Nachrichtentext-Bubble */
.modern-chat-text {
  background: var(--bubble-bg);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 18px;
  width: fit-content; /* Passt sich der Textbreite an */
  max-width: 100%; /* Bubble kann volle Breite des Containers einnehmen */
  line-height: 1.45;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  position: relative;
  box-sizing: border-box;
  text-align: left; /* Text in Bubble linksbündig */
}
.own-message .modern-chat-text {
  background: var(--primary);
  color: var(--text-own);
}

/* Zeitangabe */
.modern-chat-time {
  font-size: 0.7rem;
  color: #94A3B8;
  margin-top: 4px;
  display: block;
  padding: 0 10px; /* Beibehalten für Innenabstand */
  /* align-self wird jetzt vom message-content übernommen */
}
/* .own-message .modern-chat-time wird durch align-items: flex-end auf .message-content gesteuert */


/* Container für Steuerbuttons */
.message-controls {
  font-size: 0.7rem;
  margin-top: 4px;
  padding: 0 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 18px;
  /* align-self wird jetzt vom message-content übernommen */
}
/* .own-message .message-controls wird durch align-items: flex-end auf .message-content gesteuert */


/* Steuerbuttons */
.message-controls button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  opacity: 0.6;
  transition: opacity 0.2s;
  line-height: 1;
}
.message-controls button:hover {
  opacity: 1;
}
.message-controls .delete-btn {
  color: #e74c3c;
}
.message-controls .edit-btn {
  color: #3498db;
  font-size: 0.8rem;
}
.message-controls .report-btn {
  color: #f39c12;
}
.message-controls .block-btn {
  color: #c0392b;
}
.message-controls .reply-btn {
  color: #555;
  font-size: 1rem;
}


/* Bearbeiten Input */
.modern-chat-text .edit-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--primary);
  border-radius: 4px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: inherit;
  resize: vertical;
  min-height: 50px;
}
.message-controls .save-edit-btn,
.message-controls .cancel-edit-btn {
  opacity: 1;
  font-size: 0.7rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 2px 5px;
}
.message-controls .save-edit-btn {
  background-color: #d4edda;
  border-color: #c3e6cb;
}
.message-controls .cancel-edit-btn {
  background-color: #f8d7da;
  border-color: #f5c6cb;
}

/* Eingabebereich */
.modern-chat-form {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 0;
  flex-shrink: 0;
}
.modern-chat-guest-name {
  display: block;
  width: calc(100% - 24px);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.modern-chat-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
  position: relative;
}

/* Emoji Picker (Desktop only) */
.emoji-picker-container {
  position: relative;
  flex-shrink: 0;
}
.emoji-btn {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  padding: 0 5px;
  cursor: pointer;
  color: #777;
  line-height: 40px;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.emoji-btn:hover {
  opacity: 1;
}
emoji-picker {
  display: none;
  position: absolute;
  bottom: calc(100% + 5px);
  right: 0;
  z-index: var(--z-emoji-picker);
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  border-radius: 8px;
  border: 1px solid var(--border);
  width: 320px;
}
.modern-chat-input-group .emoji-picker-container:first-child emoji-picker {
  right: auto;
  left: 0;
}

/* Hide Emoji Picker on Mobile (Smartphones, Tablets) */
@media screen and (max-width: 767px) {
  .emoji-picker-container {
    display: none;
  }
}

/* Textfeld */
.modern-chat-message-input {
  flex-grow: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 1rem;
  transition: border-color 0.2s;
  resize: none;
  min-height: 42px;
  box-sizing: border-box;
}
.modern-chat-message-input:focus {
  border-color: var(--primary);
  outline: none;
}
/* Senden-Button */
.modern-chat-submit-btn {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s;
  background: var(--primary);
  color: white;
  flex-shrink: 0;
}
.modern-chat-submit-btn:hover {
  background: var(--primary-hover);
}
.modern-chat-submit-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Sound Toggle */
.sound-toggle-container {
  margin-top: 0.75rem !important;
  padding-right: 5px;
  justify-content: flex-end;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sound-toggle-container .switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
}
.sound-toggle-container input {
  opacity: 0;
  width: 0;
  height: 0;
}
.sound-toggle-container .slider {
  position: absolute;
  cursor: pointer;
  border-radius: 20px;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
}
.sound-toggle-container .slider span {
  position: absolute;
  content: '';
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: .4s;
}
.sound-toggle-container label[for="sound-toggle"] {
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 0;
}

/* Badge */
.mobile-chat-toggle .badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: red;
  color: white;
  border-radius: 50%;
  padding: 0;
  font-size: 0.75rem;
  font-weight: bold;
  z-index: calc(var(--z-sticky) + 1);
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-sizing: border-box;
  text-align: center;
  border: none;
  display: none;
}
.mobile-chat-toggle .badge.show {
  display: flex !important;
}

/* Mobile Chat Modal */
.mobile-chat-modal {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 85vh;
  max-height: 600px;
  background: white;
  z-index: var(--z-modal);
  box-shadow: 0 -4px 10px rgba(0,0,0,0.15);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease-out;
  overflow: hidden;
}
.modal-chat-content {
  flex-grow: 1;
  overflow: hidden;
  display: flex;
}
.modal-chat-content > .modern-chat-container {
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: 1rem;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
}
@media screen and (min-width: 576px) {
  .mobile-chat-modal {
    width: 450px;
    max-height: 70vh;
    left: auto;
    right: 20px;
    bottom: 80px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    transform: none;
  }
  .modal-chat-content > .modern-chat-container {
      border-radius: 0;
  }
}
.mobile-chat-modal .close-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  background: #eee;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 1.1rem;
  line-height: 28px;
  text-align: center;
  cursor: pointer;
  z-index: calc(var(--z-modal) + 1);
  color: #555;
  transition: background-color 0.2s, color 0.2s;
}
.mobile-chat-modal .close-btn:hover {
  background-color: #ddd;
  color: #000;
}

/* Responsive Anpassungen */
@media screen and (max-width: 575px) {
  .modern-chat-messages { padding-right: 2px; }
  .mobile-chat-modal { height: 90vh; }
}

/* Admin-spezifische Styles */
.modern-chat-admin-delete-link {
  color: #a00;
  text-decoration: none;
}
.modern-chat-admin-delete-link:hover {
  color: #f00;
  text-decoration: underline;
}
.wp-list-table th.check-column {
  padding-left: 8px !important;
}

/* Ripple-Effekt */
@keyframes ripple-effect {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(2.0); opacity: 0; }
}
.mobile-chat-toggle::before,
.mobile-chat-toggle::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(74, 144, 226, 0.3);
  border-radius: 50%;
  z-index: -1;
  opacity: 0;
  animation: ripple-effect 2s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
}
.mobile-chat-toggle::after {
  animation-delay: 0.7s;
}

/* Mobile Toggle Button */
.mobile-chat-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  border: none;
  z-index: var(--z-sticky);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s;
}
.mobile-chat-toggle:hover {
  background: var(--primary-hover);
}
.mobile-chat-toggle::before,
.mobile-chat-toggle::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(74, 144, 226, 0.3);
  border-radius: 50%;
  z-index: -1;
  opacity: 0;
  animation: ripple-effect 2s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
}
.mobile-chat-toggle::after {
  animation-delay: 0.7s;
}

/* Desktop Always-Open Styles */
.modern-chat-container.always-open {
  display: flex !important;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 380px;
  height: 70vh;
  max-height: 600px;
  z-index: 999;
  border: 1px solid var(--border);
  animation: none;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  overflow: hidden;
}
body.desktop-chat-view #mobile-chat-toggle {
  display: none;
}
body.desktop-chat-view #mobile-chat-modal {
  display: none !important;
}
.modern-chat-container.always-open .modern-chat-messages {
  /* Anpassungen bei Bedarf */
}
.modern-chat-container.always-open .desktop-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #eee;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 1.1rem;
  line-height: 28px;
  text-align: center;
  cursor: pointer;
  z-index: 10;
  color: #555;
  transition: background-color 0.2s, color 0.2s;
}
.modern-chat-container.always-open .desktop-close-btn:hover {
  background-color: #ddd;
  color: #000;
}
@media screen and (max-width: 991px) {
  .modern-chat-container.always-open {
    display: none !important;
  }
  body.desktop-chat-view #mobile-chat-toggle {
    display: flex;
  }
}

/* Online Indicator */
.online-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: #4CAF50;
  border-radius: 50%;
  margin-left: 5px;
}

/* --- NEU: Sending Feedback Animation --- */
@keyframes sending-flash {
  0% { background-color: transparent; }
  50% { background-color: rgba(74, 144, 226, 0.1); } /* Subtiler Flash */
  100% { background-color: transparent; }
}

.modern-chat-message.sending-feedback .message-content {
  /* Wendet die Animation auf den Inhaltscontainer an */
  animation: sending-flash 0.8s ease-out; /* Dauer sollte JS Timeout entsprechen */
  border-radius: 18px; /* Damit der Flash die Bubble-Form hat */
}
/* --- Ende NEU --- */
