/* ===================== BOT VIEWER / CHAT PAGE ===================== */

.chat-app {
  display: flex;
  height: calc(100vh - 57px);
  overflow: hidden;
}

/* When there is no media, chat takes full width */
.chat-app.no-media .chat-panel { flex: 1; }
.chat-app.no-media .media-panel { display: none; }

/* Left: Chat Panel */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.header-avatar img,
.header-avatar video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-bot-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

/* Voice selector */
.voice-select {
  padding: 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.8rem;
  font-family: var(--font);
  color: var(--text-light);
  background: var(--surface);
  cursor: pointer;
  outline: none;
  max-width: 160px;
  transition: border-color 0.2s;
}

.voice-select:hover,
.voice-select:focus {
  border-color: var(--primary-light);
}

/* Messages area */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Message bubbles */
.message {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}

.message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.message.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble {
  padding: 11px 16px;
  border-radius: 18px;
  font-size: 0.93rem;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message.user .bubble {
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  border-bottom-right-radius: 6px;
}

.message.assistant .bubble {
  background: var(--bot-bubble);
  color: var(--bot-bubble-text);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow);
}

.message.error .bubble {
  background: #FFF0ED;
  color: var(--error);
  border: 1px solid rgba(225, 112, 85, 0.2);
  border-bottom-left-radius: 6px;
}

/* Play button for TTS */
.play-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  padding: 3px 10px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  font-size: 0.76rem;
  color: var(--text-light);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  font-family: var(--font);
}

.play-btn:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}

.play-btn.playing {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(14, 165, 233, 0.08);
}

.play-btn.paused {
  border-color: var(--primary-light);
  color: var(--primary);
}

.play-btn svg {
  width: 13px;
  height: 13px;
}

/* Loading dots */
.loading-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-light);
  animation: dotPulse 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Input area */
.input-area {
  display: flex;
  gap: 8px;
  padding: 14px 24px 4px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  align-items: center;
  flex-wrap: wrap;
}

.input-area .ai-disclaimer {
  width: 100%;
  padding: 0;
}

.input-area input {
  flex: 1;
  padding: 11px 16px;
  border: 2px solid var(--border);
  border-radius: 24px;
  font-size: 0.93rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}

.input-area input:focus {
  border-color: var(--primary-light);
}

.btn-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.btn-send:hover { background: var(--primary-dark); }
.btn-send:active { transform: scale(0.93); }
.btn-send:disabled { background: var(--border); cursor: not-allowed; }

/* Left Media Panel */
.media-panel {
  width: 40%;
  max-width: 480px;
  min-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.media-panel-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.media-display {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg);
  margin: 20px;
}

.media-display img,
.media-display video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-light);
  text-align: center;
  padding: 40px;
}

.placeholder-icon { font-size: 3rem; }
.placeholder-text { font-size: 0.9rem; line-height: 1.5; }

/* View Prompt button */
.view-prompt-btn {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.view-prompt-btn:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}

.view-prompt-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

/* Prompt Info panel (replaces media display) */
.prompt-info {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px 24px;
}

.prompt-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.prompt-info-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.prompt-info-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text-light);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.prompt-info-close:hover {
  background: var(--border);
  color: var(--text);
}

.prompt-info-body {
  flex: 1;
  overflow-y: auto;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.prompt-section label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.prompt-text {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 14px;
}

/* Error state for bot not found */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 57px);
  text-align: center;
  padding: 24px;
}

.error-page h2 {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 8px;
}

.error-page p {
  color: var(--text-light);
  margin-bottom: 24px;
}

/* Responsive */
@media (max-width: 768px) {
  .chat-app {
    flex-direction: column;
  }

  .media-panel {
    width: 100%;
    max-width: none;
    min-width: 0;
    max-height: 35vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .media-display {
    margin: 12px;
  }

  .chat-app.no-media .media-panel { display: none; }

  .chat-panel {
    flex: 1;
    min-height: 0;
  }

  .messages { padding: 16px; }
  .input-area { padding: 12px 16px; }
}
