/* ── Empty State ── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  pointer-events: none;
  user-select: none;
  padding-bottom: 60px;
}

.empty-state svg {
  width: 200px;
  height: 200px;
  color: rgba(59, 130, 246, 0.18);
  flex-shrink: 0;
}

.empty-state-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 420px;
  text-align: center;
}

.empty-state-title {
  font-size: 14px;
  font-weight: 600;
  color: rgba(96, 165, 250, 0.6);
  letter-spacing: 0.01em;
}

.empty-state-sub {
  font-size: 12px;
  font-weight: 400;
  color: rgba(59, 130, 246, 0.35);
  line-height: 1.6;
}

.empty-state.hidden { display: none; }

.chat-page {
  display: flex;
  flex-direction: row;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* ── Chat Panel (left) ── */
.chat-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--border);
}

/* ── Preview Panel (right) ── */
.preview-panel {
  width: 46%;
  min-width: 360px;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: var(--bg);
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.preview-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.preview-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: rgba(37, 99, 235, 0.45);
  font-family: 'AppFont', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: -1px;
}

.preview-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.preview-tab:not(.active):hover {
  color: var(--accent);
}

/* ── Preview Content Area ── */
.preview-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* ── Preview Empty State ── */
.preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  pointer-events: none;
  user-select: none;
}

.preview-empty svg {
  width: 72px;
  height: 72px;
  color: rgba(59, 130, 246, 0.15);
}

.preview-empty-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  text-align: center;
}

.preview-empty-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(59, 130, 246, 0.45);
}

.preview-empty-sub {
  font-size: 12px;
  color: rgba(59, 130, 246, 0.18);
  line-height: 1.6;
}

/* ── iframe ── */
.preview-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* ── Code View ── */
.preview-code-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0a0a0a;
}

.code-lang-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #1a1a1a;
  flex-shrink: 0;
  background: #0a0a0a;
}

.code-lang-tab {
  padding: 9px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #6b7280;
  font-family: 'AppFont', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.03em;
}

.code-lang-tab.active {
  color: #d4d4d4;
  border-bottom-color: var(--accent);
}

.code-lang-tab:not(.active):hover {
  color: #d4d4d4;
}

.code-panel-copy-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #6b7280;
  font-size: 11px;
  cursor: pointer;
  padding: 4px 16px;
  border-radius: 4px;
  font-family: 'AppFont', sans-serif;
  transition: all 0.2s;
  flex-shrink: 0;
}

.code-panel-copy-btn:hover {
  background: rgba(59, 130, 246, 0.12);
  color: #d4d4d4;
}

.monaco-editors-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.editor-instance {
  position: absolute;
  inset: 0;
  visibility: hidden;
}

.editor-instance.active {
  visibility: visible;
}

/* ── Visibility helper ── */
.pv-hidden { display: none !important; }

/* ── Chat Header ── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ── Messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Message ── */
.chat-msg {
  display: flex;
  max-width: 90%;
  min-width: 0;
  animation: msgFadeIn 200ms ease;
}

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

.chat-msg--agent {
  align-self: flex-start;
}

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

.chat-bubble {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: none;
  min-width: 0;
  overflow: hidden;
}

.chat-msg--agent .chat-bubble {
  background: rgba(18, 18, 18, 0.7);
  color: var(--text);
}

.chat-msg--user .chat-bubble {
  background: rgba(25, 25, 25, 0.75);
  color: var(--text);
}

.chat-bubble p {
  margin: 0;
}

/* ── Code blocks ── */
.code-block-wrap {
  margin: 10px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(59, 130, 246, 0.15);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: rgba(8, 8, 8, 0.95);
  border-bottom: 1px solid rgba(59, 130, 246, 0.06);
}

.code-block-lang {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.code-copy-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 3px 10px;
  border-radius: 4px;
  transition: all 0.2s;
  font-family: 'AppFont', sans-serif;
}

.code-copy-btn:hover {
  background: rgba(59, 130, 246, 0.12);
  color: var(--text);
}

.code-block {
  margin: 0;
  padding: 16px;
  background: rgba(4, 4, 4, 0.98);
  overflow-x: auto;
}

.code-block code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  line-height: 1.65;
  color: #c9d1e0;
  white-space: pre;
}

/* ── Inline code ── */
.inline-code {
  background: rgba(59, 130, 246, 0.08);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.875em;
}

/* ── Typing indicator ── */
.chat-msg--typing .chat-bubble {
  padding: 14px 18px;
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s ease infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ── Input Bar ── */
.chat-input-bar {
  padding: 0 0 28px;
  flex-shrink: 0;
}

.chat-input-bar .flow-prompt-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 3.5rem;
  padding: 0.5rem;
  background: rgba(13, 13, 13, 0.9);
  backdrop-filter: blur(20px);
  border-radius: 0;
  box-shadow: rgba(0, 0, 0, 0.5) 0px 16px 32px -8px;
}

.chat-input-bar .flow-input-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-input-bar .flow-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'AppFont', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  min-height: 2rem;
  max-height: 160px;
  padding: 6px 8px;
  overflow-y: auto;
}

.chat-textarea::placeholder {
  color: var(--text-muted);
}

.chat-input-bar .flow-create-btn {
  width: 2rem;
  height: 2rem;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity var(--transition);
}

.chat-input-bar .flow-create-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
