/* Digital Twin chatbot — matches ebada.de dark/gold theme */

.ebada-chatbot {
  --chatbot-panel-bg: #0d0d0d;
  --chatbot-surface: #1a1a1a;
  --chatbot-border: rgba(201, 168, 76, 0.22);
  --chatbot-shadow: 0 12px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(201, 168, 76, 0.08);
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: calc(24px + env(safe-area-inset-right, 0px));
  z-index: 9999;
  font-family: var(--font-body, 'Inter', system-ui, sans-serif);
}

.ebada-chatbot--rtl {
  right: auto;
  left: calc(24px + env(safe-area-inset-left, 0px));
}

.ebada-chatbot--rtl .ebada-chatbot-launcher-label {
  margin-left: 0;
  margin-right: 10px;
}

/* Launcher bubble */
.ebada-chatbot-launcher {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 10px 18px 10px 10px;
  border: 1px solid var(--chatbot-border);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--chatbot-panel-bg) 0%, var(--chatbot-surface) 100%);
  color: var(--text-primary, #f0ede8);
  cursor: pointer;
  box-shadow: var(--chatbot-shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  min-height: 44px;
  min-width: 44px;
  -webkit-tap-highlight-color: transparent;
}

.ebada-chatbot-launcher:hover {
  transform: translateY(-2px);
  border-color: var(--gold, #c9a84c);
  box-shadow: 0 16px 56px rgba(0, 0, 0, 0.6), 0 0 24px rgba(201, 168, 76, 0.12);
}

.ebada-chatbot-launcher[aria-expanded="true"] {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

.ebada-chatbot-launcher-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold, #c9a84c);
}

.ebada-chatbot-launcher-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold-dim, rgba(201, 168, 76, 0.15));
  color: var(--gold, #c9a84c);
  font-size: 16px;
}

.ebada-chatbot-launcher-label {
  margin-left: 10px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--gold, #c9a84c);
  white-space: nowrap;
}

/* Panel */
.ebada-chatbot-panel {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: min(620px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  background: var(--chatbot-panel-bg);
  border: 1px solid var(--chatbot-border);
  border-radius: 16px;
  box-shadow: var(--chatbot-shadow);
  overflow: hidden;
  min-width: 0;
  animation: ebadaChatSlideUp 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.ebada-chatbot--rtl .ebada-chatbot-panel {
  right: auto;
  left: 0;
}

.ebada-chatbot-panel[hidden] {
  display: none !important;
}

@keyframes ebadaChatSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header */
.ebada-chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--chatbot-surface);
  border-bottom: 1px solid var(--chatbot-border);
}

.ebada-chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ebada-chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold, #c9a84c);
  flex-shrink: 0;
}

.ebada-chatbot-avatar--initials {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-dim, rgba(201, 168, 76, 0.15));
  color: var(--gold, #c9a84c);
  font-weight: 700;
  font-size: 14px;
}

.ebada-chatbot-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #f0ede8);
  line-height: 1.3;
}

.ebada-chatbot-subtitle {
  display: block;
  font-size: 12px;
  color: var(--text-muted, #9a9690);
  line-height: 1.3;
}

.ebada-chatbot-close {
  background: transparent;
  border: none;
  color: var(--text-muted, #9a9690);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.ebada-chatbot-close:hover {
  color: var(--gold, #c9a84c);
  background: var(--gold-dim, rgba(201, 168, 76, 0.15));
}

.ebada-chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ebada-chatbot-voice-mode,
.ebada-chatbot-speaker {
  background: transparent;
  border: none;
  color: var(--text-muted, #9a9690);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.ebada-chatbot-voice-mode:hover,
.ebada-chatbot-speaker:hover {
  color: var(--gold, #c9a84c);
  background: var(--gold-dim, rgba(201, 168, 76, 0.15));
}

.ebada-chatbot-voice-mode--on,
.ebada-chatbot-speaker--on {
  color: var(--gold, #c9a84c);
  background: var(--gold-dim, rgba(201, 168, 76, 0.2));
  box-shadow: 0 0 0 1px rgba(201, 168, 76, 0.35);
}

.ebada-chatbot-voice-mode:disabled,
.ebada-chatbot-speaker:disabled,
.ebada-chatbot-mic:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Voice status badge */
.ebada-chatbot-voice-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gold, #c9a84c);
  background: rgba(201, 168, 76, 0.08);
  border-bottom: 1px solid rgba(201, 168, 76, 0.15);
}

.ebada-chatbot-voice-status[hidden] {
  display: none !important;
}

.ebada-chatbot-voice-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold, #c9a84c);
  flex-shrink: 0;
}

.ebada-chatbot-voice-status--listening .ebada-chatbot-voice-status-dot {
  animation: ebadaChatMicPulse 1.2s ease-in-out infinite;
}

.ebada-chatbot-voice-status--speaking .ebada-chatbot-voice-status-dot {
  animation: ebadaChatSpeakPulse 0.8s ease-in-out infinite;
}

.ebada-chatbot-voice-status-text {
  flex: 1;
}

.ebada-chatbot-voice-stop {
  background: transparent;
  border: 1px solid rgba(201, 168, 76, 0.4);
  color: var(--gold, #c9a84c);
  border-radius: 8px;
  min-width: 32px;
  min-height: 32px;
  padding: 4px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ebada-chatbot-voice-stop:hover {
  background: var(--gold-dim, rgba(201, 168, 76, 0.15));
}

.ebada-chatbot-voice-stop[hidden] {
  display: none !important;
}

@keyframes ebadaChatMicPulse {
  0%, 100% { opacity: 0.45; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

@keyframes ebadaChatSpeakPulse {
  0%, 100% { opacity: 0.6; transform: scaleY(0.7); }
  50% { opacity: 1; transform: scaleY(1.2); }
}

/* Messages */
.ebada-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 360px;
  scroll-behavior: smooth;
}

.ebada-chatbot-msg {
  display: flex;
  max-width: 92%;
}

.ebada-chatbot-msg--user {
  align-self: flex-end;
}

.ebada-chatbot-msg--bot {
  align-self: flex-start;
}

.ebada-chatbot-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
}

.ebada-chatbot-msg--user .ebada-chatbot-msg-bubble {
  background: var(--gold, #c9a84c);
  color: #0d0d0d;
  border-bottom-right-radius: 4px;
}

.ebada-chatbot--rtl .ebada-chatbot-msg--user .ebada-chatbot-msg-bubble {
  border-bottom-right-radius: 14px;
  border-bottom-left-radius: 4px;
}

.ebada-chatbot-msg--bot .ebada-chatbot-msg-bubble {
  background: var(--chatbot-surface);
  color: var(--text-primary, #f0ede8);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: 4px;
  position: relative;
  padding-right: 36px;
}

.ebada-chatbot--rtl .ebada-chatbot-msg--bot .ebada-chatbot-msg-bubble {
  padding-right: 14px;
  padding-left: 36px;
}

.ebada-chatbot-msg-speak {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(201, 168, 76, 0.12);
  color: var(--gold, #c9a84c);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: background 0.2s, color 0.2s;
}

.ebada-chatbot--rtl .ebada-chatbot-msg-speak {
  right: auto;
  left: 8px;
}

.ebada-chatbot-msg-speak:hover {
  background: rgba(201, 168, 76, 0.25);
  color: var(--gold-hover, #e8c76a);
}

.ebada-chatbot--rtl .ebada-chatbot-msg--bot .ebada-chatbot-msg-bubble {
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 4px;
}

.ebada-chatbot-msg-bubble a {
  color: var(--gold-hover, #e8c76a);
  text-decoration: underline;
}

.ebada-chatbot-msg--user .ebada-chatbot-msg-bubble a {
  color: #0d0d0d;
  font-weight: 600;
}

/* Typing indicator */
.ebada-chatbot-typing .ebada-chatbot-msg-bubble {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
}

.ebada-chatbot-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold, #c9a84c);
  opacity: 0.4;
  animation: ebadaChatDot 1.2s infinite ease-in-out;
}

.ebada-chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.ebada-chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ebadaChatDot {
  0%, 80%, 100% { opacity: 0.35; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* Action chips in messages */
.ebada-chatbot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ebada-chatbot-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--gold, #c9a84c);
  background: var(--gold-dim, rgba(201, 168, 76, 0.15));
  color: var(--gold, #c9a84c);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.ebada-chatbot-action:hover {
  background: var(--gold, #c9a84c);
  color: #0d0d0d;
}

.ebada-chatbot-action--book {
  background: var(--gold, #c9a84c);
  color: #0d0d0d;
}

.ebada-chatbot-action--book:hover {
  background: var(--gold-hover, #e8c76a);
}

/* Quick action chips */
.ebada-chatbot-chips[hidden] {
  display: none !important;
}

.ebada-chatbot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}

.ebada-chatbot-chip {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid rgba(201, 168, 76, 0.35);
  background: transparent;
  color: var(--text-muted, #9a9690);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.ebada-chatbot-chip:hover {
  border-color: var(--gold, #c9a84c);
  color: var(--gold, #c9a84c);
  background: var(--gold-dim, rgba(201, 168, 76, 0.1));
}

/* Input */
.ebada-chatbot-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--chatbot-border);
  background: var(--chatbot-surface);
}

.ebada-chatbot-input-row textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: var(--chatbot-panel-bg);
  color: var(--text-primary, #f0ede8);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
}

.ebada-chatbot-input-row textarea:focus {
  outline: none;
  border-color: var(--gold, #c9a84c);
}

.ebada-chatbot-input-row textarea::placeholder {
  color: var(--text-faint, #5a5957);
}

.ebada-chatbot-send {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: var(--gold, #c9a84c);
  color: #0d0d0d;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.ebada-chatbot-send:hover:not(:disabled) {
  background: var(--gold-hover, #e8c76a);
}

.ebada-chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ebada-chatbot-mic {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: var(--chatbot-panel-bg);
  color: var(--text-muted, #9a9690);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.ebada-chatbot-mic:hover:not(:disabled) {
  color: var(--gold, #c9a84c);
  border-color: rgba(201, 168, 76, 0.4);
}

.ebada-chatbot-mic--listening {
  color: #0d0d0d;
  background: var(--gold, #c9a84c);
  border-color: var(--gold, #c9a84c);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.25);
}

.ebada-chatbot-mic-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 14px;
  border: 2px solid var(--gold, #c9a84c);
  opacity: 0;
  pointer-events: none;
}

.ebada-chatbot-mic--listening .ebada-chatbot-mic-pulse {
  animation: ebadaChatMicRing 1.4s ease-out infinite;
}

@keyframes ebadaChatMicRing {
  0% { opacity: 0.7; transform: scale(0.92); }
  100% { opacity: 0; transform: scale(1.25); }
}

.ebada-chatbot-voice-notice {
  margin: 0;
  padding: 0 16px 8px;
  font-size: 11px;
  color: var(--text-muted, #9a9690);
  text-align: center;
  line-height: 1.4;
}

.ebada-chatbot-voice-notice[hidden] {
  display: none !important;
}

.ebada-chatbot-disclaimer {
  margin: 0;
  padding: 8px 16px 12px;
  font-size: 10px;
  color: var(--text-faint, #5a5957);
  text-align: center;
  line-height: 1.4;
}

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

/* Mobile */
@media (max-width: 768px) {
  .ebada-chatbot-panel {
    width: min(380px, calc(100vw - 24px));
    max-height: min(620px, calc(100dvh - 96px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  }

  .ebada-chatbot-messages {
    max-height: min(360px, calc(100dvh - 320px));
  }
}

@media (max-width: 480px) {
  .ebada-chatbot {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
  }

  .ebada-chatbot--rtl {
    left: calc(16px + env(safe-area-inset-left, 0px));
  }

  .ebada-chatbot-panel {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 72px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  .ebada-chatbot-launcher-label {
    display: none;
  }

  .ebada-chatbot-launcher {
    padding: 12px;
    border-radius: 50%;
  }

  .ebada-chatbot-messages {
    max-height: calc(100dvh - 280px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  .ebada-chatbot-input-row textarea {
    font-size: 16px;
  }
}

/* Web search indicator & source pills */
.ebada-chatbot-web-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--gold, #c9a84c);
  background: rgba(201, 168, 76, 0.12);
  border: 1px solid rgba(201, 168, 76, 0.25);
}

.ebada-chatbot-web-badge i {
  font-size: 10px;
  opacity: 0.9;
}

.ebada-chatbot-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.ebada-chatbot-source {
  display: inline-block;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-secondary, #b8b5b0);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.2s, color 0.2s;
}

.ebada-chatbot-source:hover {
  color: var(--gold, #c9a84c);
  border-color: rgba(201, 168, 76, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  .ebada-chatbot-panel,
  .ebada-chatbot-launcher,
  .ebada-chatbot-typing span,
  .ebada-chatbot-mic--listening .ebada-chatbot-mic-pulse,
  .ebada-chatbot-voice-status--listening .ebada-chatbot-voice-status-dot,
  .ebada-chatbot-voice-status--speaking .ebada-chatbot-voice-status-dot {
    animation: none;
    transition: none;
  }
}
