/* ========================================
   Chat View — v2 Wide Layout
   ======================================== */

/* ---- Mode Tabs ---- */
#mode-tabs {
  display: flex;
  gap: 6px;
  padding: 16px 32px;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}

#mode-tabs::-webkit-scrollbar {
  display: none;
}

.mode-tab {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.mode-tab:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.mode-tab.active {
  background: var(--core-accent);
  color: #fff;
}

.mode-tab[data-mode="deep-lore"].active {
  background: linear-gradient(135deg, var(--gold), #C49530);
  color: #1a1200;
}

.mode-tab[data-mode="companion"].active {
  background: linear-gradient(135deg, var(--companion-accent), #7C4DFF);
}

.mode-tab[data-mode="watch-along"].active {
  background: linear-gradient(135deg, var(--core-magenta), var(--core-accent));
  color: #fff;
}

/* Sony Exclusive badge on Deep Lore tab */
.exclusive-star {
  color: var(--gold);
  margin-left: 2px;
}

.mode-tab.active .exclusive-star {
  color: #1a1200;
}

/* ---- Messages Container ---- */
#messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 32px;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Message Row */
.message {
  display: flex;
  gap: 10px;
  max-width: 100%;
  animation: messagePop 350ms var(--ease-out) both;
}

.message.user {
  flex-direction: row-reverse;
}

/* Avatar */
.message .msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 14px;
  background: linear-gradient(135deg, var(--core-accent), var(--sony-purple));
  margin-top: 2px;
}

.message .msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message.user .msg-avatar {
  display: none;
}

/* Bubble */
.message-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
}

.message.assistant .message-bubble {
  background: var(--bubble-assistant);
  border-top-left-radius: 4px;
}

.message.user .message-bubble {
  background: var(--bubble-user);
  border-top-right-radius: 4px;
  color: var(--text-primary);
}

.message.system .message-bubble {
  background: var(--bubble-system);
  color: var(--text-secondary);
  font-size: 13px;
  max-width: 100%;
  text-align: center;
  border-radius: 10px;
  padding: 10px 16px;
}

.message.system {
  justify-content: center;
}

.message.system .msg-avatar {
  display: none;
}

/* ---- Markdown inside bubbles ---- */
.message-bubble p {
  margin-bottom: 10px;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble strong {
  font-weight: 700;
  color: var(--text-primary);
}

.message-bubble em {
  font-style: italic;
  color: var(--text-secondary);
}

.message-bubble h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 10px 0 6px;
}

.message-bubble h4 {
  font-size: 14px;
  font-weight: 700;
  margin: 8px 0 4px;
}

.message-bubble ul, .message-bubble ol {
  margin: 8px 0;
  padding-left: 20px;
}

.message-bubble li {
  margin-bottom: 4px;
}

.message-bubble code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
}

.message-bubble hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 10px 0;
}

/* ---- Typing Indicator ---- */
.typing-indicator {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  animation: messagePop 300ms var(--ease-out) both;
}

.typing-indicator .msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: linear-gradient(135deg, var(--core-accent), var(--sony-purple));
}

.typing-dots {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
  background: var(--bubble-assistant);
  border-radius: 16px;
  border-top-left-radius: 4px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typingDot 1.4s ease-in-out infinite;
}

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

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

/* ---- Prompt Chips ---- */
#prompt-chips {
  display: flex;
  gap: 8px;
  padding: 14px 32px;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
  overflow-x: visible;
  flex-wrap: wrap;
  border-top: 1px solid rgba(255,255,255,0.04);
  min-height: auto;
  flex-shrink: 0;
}

.prompt-chip {
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.06);
  transition: all var(--transition-fast);
  white-space: normal;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

#prompt-chips.hidden {
  display: none;
}

.prompt-chip:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.12);
}

/* ======== Watch Along — Fact Cards ======== */
.fact-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 14px 16px;
  animation: messagePop 350ms var(--ease-out) both;
  flex-shrink: 0;
}

.fact-timestamp {
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--core-magenta), var(--core-accent));
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 10px;
  letter-spacing: 0.5px;
  min-width: 48px;
  text-align: center;
}

.fact-text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-primary);
}

.fact-text strong {
  font-weight: 700;
  color: var(--core-accent);
}

/* ======== Deep Lore — Deleted Scene Cards ======== */
.deleted-scene-card {
  background: var(--bg-card);
  border: 1px solid rgba(212, 168, 67, 0.2);
  border-radius: 14px;
  overflow: hidden;
  animation: messagePop 400ms var(--ease-out) both;
  flex-shrink: 0;
}

.scene-preview {
  width: 100%;
  height: 140px;
  background: linear-gradient(135deg, #0d0d18, #1a1a28);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.scene-preview .play-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.scene-preview .play-icon::after {
  content: '';
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 0 8px 14px;
  border-color: transparent transparent transparent rgba(255,255,255,0.6);
  margin-left: 3px;
}

.scene-preview .film-strip-icon {
  position: absolute;
  bottom: 10px;
  right: 12px;
  font-size: 18px;
  opacity: 0.2;
}

.scene-card-body {
  padding: 14px 16px;
}

.vault-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gold);
  background: var(--gold-dim);
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.scene-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.scene-near-time {
  font-size: 11px;
  color: var(--gold);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.scene-desc {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
}

/* ======== Deep Lore — Vault Secret Cards ======== */
.vault-secret-card {
  display: flex;
  gap: 0;
  background: linear-gradient(135deg, rgba(212, 168, 67, 0.06), rgba(212, 168, 67, 0.02));
  border: 1px solid rgba(212, 168, 67, 0.2);
  border-radius: 14px;
  overflow: hidden;
  animation: messagePop 400ms var(--ease-out) both;
  flex-shrink: 0;
}

.secret-icon-area {
  width: 64px;
  min-height: 100%;
  background: linear-gradient(180deg, rgba(212, 168, 67, 0.12), rgba(212, 168, 67, 0.04));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-right: 1px solid rgba(212, 168, 67, 0.1);
}

.secret-lock {
  font-size: 22px;
  opacity: 0.7;
}

.secret-body {
  padding: 14px 16px;
  flex: 1;
}

.vault-secret-card .vault-badge {
  color: var(--gold);
  background: rgba(212, 168, 67, 0.12);
}

.vault-secret-card .scene-title {
  margin-bottom: 6px;
}

.vault-secret-card .scene-desc {
  font-size: 13px;
  line-height: 1.6;
}

/* ---- Controls Bar (Slider + Spoiler Toggle) ---- */
#controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 32px;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  user-select: none;
}

/* Range Slider */
#response-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--core-accent) 0%,
    var(--core-accent) var(--slider-pct, 72%),
    rgba(255,255,255,0.1) var(--slider-pct, 72%),
    rgba(255,255,255,0.1) 100%
  );
  outline: none;
  cursor: pointer;
}

#response-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--core-accent);
  box-shadow: 0 0 6px var(--core-accent-glow);
  cursor: pointer;
}

#response-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--core-accent);
  box-shadow: 0 0 6px var(--core-accent-glow);
  border: none;
  cursor: pointer;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
  transition: background var(--transition-fast);
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition-fast);
}

.toggle-switch input:checked + .toggle-track {
  background: var(--core-accent);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(16px);
}

/* ---- Chat Input Bar ---- */
#chat-input-bar {
  display: flex;
  align-items: center;
  padding: 12px 32px;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
  border-top: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  height: 44px;
  padding: 0 16px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.06);
  border-right: none;
  border-radius: 12px 0 0 12px;
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color var(--transition-fast);
}

#chat-input::placeholder {
  color: var(--text-tertiary);
}

#chat-input:focus {
  border-color: var(--core-accent);
}

#chat-send-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--core-accent), var(--sony-purple));
  border: none;
  border-radius: 0 12px 12px 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity var(--transition-fast);
}

#chat-send-btn svg {
  fill: #fff;
}

#chat-send-btn:hover {
  opacity: 0.85;
}
