/**
 * @file web/src/components/playground/PlaygroundView.module.css
 * @description Styles for the Playground chat modal — multi-turn chat, model
 * selector, streaming response, and routed-via metadata.
 */

.overlay {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 24px;
}

.modal {
  background: var(--color-bg-card, #080908);
  border: 1px solid var(--color-border, #161a16);
  border-radius: 12px;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  min-height: 0;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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

.headerLeft {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.headerTitle {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.headerSubtitle {
  font-size: 12px;
  color: var(--text-muted, #888);
  font-weight: 400;
}

.headerActions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.iconBtn {
  background: transparent;
  border: 1px solid var(--border, #1e1e2e);
  border-radius: 6px;
  color: var(--text-muted, #888);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, border-color 0.12s;
}

.iconBtn:hover {
  color: var(--text, #eee);
  border-color: var(--accent, #22c55e);
}

.modelBar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border, #1e1e2e);
  background: var(--bg-secondary, #16161e);
  font-size: 12px;
  flex-shrink: 0;
}

.modelLabel {
  color: var(--text-muted, #888);
  font-weight: 500;
}

.modelSelect {
  flex: 1;
  background: var(--bg-primary, #0f0f17);
  border: 1px solid var(--border, #1e1e2e);
  border-radius: 6px;
  color: var(--text, #eee);
  padding: 6px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  max-width: 360px;
}

.modelSelect:focus {
  outline: none;
  border-color: var(--accent, #22c55e);
}

.presetChip {
  background: var(--bg-primary, #0f0f17);
  border: 1px solid var(--border, #1e1e2e);
  border-radius: 6px;
  color: var(--text, #eee);
  padding: 4px 8px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}

.presetChip:hover {
  border-color: var(--accent, #22c55e);
  color: var(--accent, #22c55e);
}

.prePromptToggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted, #888);
  cursor: pointer;
  user-select: none;
}

.prePromptToggle input {
  cursor: pointer;
}

.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 320px;
}

/* 📖 Flex container that fills the modal body and hosts either the router
   daemon start/starting panels or the shared <PlaygroundChat> (which itself is
   a column flex that scrolls internally and pins the input at the bottom). */
.chatBody {
  flex: 1;
  min-height: 320px;
  display: flex;
  flex-direction: column;
}

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #888);
  text-align: center;
  padding: 40px 20px;
  gap: 8px;
}

.emptyTitle {
  font-size: 16px;
  color: var(--text, #eee);
  font-weight: 600;
}

.emptyHint {
  font-size: 12px;
  max-width: 380px;
  line-height: 1.5;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 88%;
  animation: msgIn 0.15s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

.message.system {
  align-self: center;
  max-width: 100%;
}

.messageRole {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #888);
  font-weight: 600;
  padding: 0 4px;
}

.bubble {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.user .bubble {
  background: var(--accent, #22c55e);
  color: #061a08;
}

.message.assistant .bubble {
  background: var(--bg-secondary, #16161e);
  border: 1px solid var(--border, #1e1e2e);
  color: var(--text, #eee);
}

.message.system .bubble {
  background: transparent;
  border: 1px dashed var(--border, #1e1e2e);
  color: var(--text-muted, #888);
  font-size: 12px;
  font-style: italic;
  text-align: center;
  max-width: 100%;
}

.codeBlock {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border, #1e1e2e);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 12px;
  overflow-x: auto;
  margin: 6px 0;
  white-space: pre;
}

.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted, #888);
  padding: 0 4px;
}

.metaChip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-secondary, #16161e);
  border: 1px solid var(--border, #1e1e2e);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'Menlo', 'Monaco', monospace;
}

.metaChip.provider {
  color: var(--accent, #22c55e);
  border-color: rgba(34, 197, 94, 0.3);
}

.metaChip.error {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.3);
}

.cursor {
  display: inline-block;
  width: 7px;
  height: 14px;
  background: var(--accent, #22c55e);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.9s infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.inputBar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border, #1e1e2e);
  flex-shrink: 0;
  align-items: flex-end;
  background: var(--bg-secondary, #16161e);
}

.textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 180px;
  background: var(--bg-primary, #0f0f17);
  border: 1px solid var(--border, #1e1e2e);
  border-radius: 8px;
  color: var(--text, #eee);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
}

.textarea:focus {
  outline: none;
  border-color: var(--accent, #22c55e);
}

.textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sendBtn {
  background: var(--accent, #22c55e);
  color: #061a08;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  font-family: inherit;
}

.sendBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sendBtn:hover:not(:disabled) {
  filter: brightness(1.1);
}

.errorBar {
  padding: 8px 16px;
  background: rgba(248, 113, 113, 0.12);
  border-top: 1px solid rgba(248, 113, 113, 0.3);
  color: #f87171;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.stopBar {
  padding: 6px 16px;
  background: var(--bg-secondary, #16161e);
  border-top: 1px solid var(--border, #1e1e2e);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted, #888);
  flex-shrink: 0;
}

.stopBtn {
  background: transparent;
  border: 1px solid #f87171;
  color: #f87171;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.stopBtn:hover {
  background: rgba(248, 113, 113, 0.1);
}

/* ── Daemon start panel ─────────────────────────────────────────────── */

.daemonStartPanel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #888);
  text-align: center;
  padding: 40px 24px;
  gap: 12px;
}

.daemonStartTitle {
  font-size: 16px;
  color: var(--text, #eee);
  font-weight: 600;
}

.daemonStartHint {
  font-size: 12px;
  max-width: 400px;
  line-height: 1.5;
  opacity: 0.7;
}

.daemonStartBtn {
  margin-top: 4px;
  background: var(--accent, #22c55e);
  color: #061a08;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  transition: opacity 0.2s, transform 0.15s, filter 0.12s;
}

.daemonStartBtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.daemonStartBtn:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: scale(1.02);
}

.daemonStartBtn:active:not(:disabled) {
  transform: scale(0.98);
}

.daemonStartAlt {
  font-size: 11px;
  opacity: 0.5;
  margin-top: 4px;
}

.daemonStartAlt code {
  background: var(--bg-secondary, #16161e);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 11px;
}

.spin {
  animation: spinAnim 1s linear infinite;
}

@keyframes spinAnim {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
