/* Multi-Agent Research Pipeline - Sequence Diagram Style */

/* Page Layout */
body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: var(--demo-space-10) 0;
}

/* Input Section */
.input-row {
  display: flex;
  gap: var(--demo-space-3);
  margin-top: var(--demo-space-4);
}

.topic-input {
  flex: 1;
}

.start-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--demo-space-2);
}

.start-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--demo-bg-elevated);
  color: var(--demo-text-muted);
}

/* API Status */
.api-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--demo-space-2);
  padding: var(--demo-space-2) var(--demo-space-4);
  background: var(--demo-bg-elevated);
  border: 1px solid var(--demo-border-default);
  border-radius: var(--demo-radius-md);
  font-size: var(--demo-text-xs);
  color: var(--demo-text-secondary);
}

.api-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--demo-text-muted);
}

.api-status.ready .status-dot {
  background: var(--demo-success);
}

.api-status.warning .status-dot {
  background: var(--demo-warning);
}

.api-status.error .status-dot {
  background: var(--demo-error);
}

/* Requirements */
.requirements {
  padding: var(--demo-space-4);
  font-size: var(--demo-text-sm);
  color: var(--demo-text-secondary);
}

.requirements p {
  margin-bottom: var(--demo-space-2);
}

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

/* Sequence Diagram Card */
.sequence-card {
  overflow: hidden;
}

.sequence-header {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--demo-border-default);
  background: var(--demo-bg-elevated);
  margin: calc(-1 * var(--demo-space-4));
  margin-bottom: var(--demo-space-4);
}

.agent-column {
  display: flex;
  justify-content: center;
  padding: var(--demo-space-4);
}

.agent-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--demo-space-2);
}

.agent-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--demo-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: all var(--demo-transition-normal);
}

.agent-icon.orchestrator {
  background: linear-gradient(135deg, var(--demo-accent-primary), #e66000);
}

.agent-icon.searcher {
  background: linear-gradient(135deg, #00ddff, #0090ed);
}

.agent-icon.reader {
  background: linear-gradient(135deg, #30e60b, #00b347);
}

.agent-icon.writer {
  background: linear-gradient(135deg, #ffbd4f, #ff9400);
}

.agent-icon.active {
  box-shadow: 0 0 20px currentColor;
  transform: scale(1.1);
}

.agent-label {
  font-size: var(--demo-text-sm);
  font-weight: var(--demo-weight-semibold);
  color: var(--demo-text-primary);
}

/* Sequence Body */
.sequence-body {
  position: relative;
  min-height: 300px;
  overflow-y: auto;
  padding: var(--demo-space-4) 0;
}

.lifelines {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  pointer-events: none;
}

.lifeline {
  display: flex;
  justify-content: center;
}

.lifeline::after {
  content: '';
  width: 2px;
  background: var(--demo-border-default);
  height: 100%;
}

/* Messages */
.messages {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--demo-space-3);
  padding: 0 var(--demo-space-4);
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--demo-text-muted);
  font-size: var(--demo-text-sm);
  text-align: center;
  padding: var(--demo-space-4);
}

.empty-state strong {
  color: var(--demo-text-primary);
}

/* Message Item */
.message-row {
  animation: fadeSlideIn 0.3s ease;
}

.message-row.status-row {
  min-height: 40px;
}

.message-row.arrow-row {
  min-height: 50px;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Grid layout for messages */
.message-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  min-height: inherit;
}

.message-cell {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 40px;
}

/* Arrow styling */
.arrow-cell {
  padding: 0 20px;
}

.arrow-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 0;
}

.arrow-line-left,
.arrow-line-right {
  height: 2px;
  flex: 1;
  min-width: 20px;
}

.arrow-line-right {
  position: relative;
}

.arrow-head {
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid;
}

.arrow-wrapper.leftward .arrow-head {
  right: auto;
  left: -1px;
  border-left: none;
  border-right: 8px solid;
}

.arrow-wrapper.leftward .arrow-line-left {
  order: 3;
}

.arrow-wrapper.leftward .arrow-label {
  order: 2;
}

.arrow-wrapper.leftward .arrow-line-right {
  order: 1;
}

/* Arrow label */
.arrow-label {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 20px;
  border: 2px solid;
  background: var(--demo-bg-surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
  flex-shrink: 0;
}

.arrow-label-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--demo-text-primary);
}

/* Activation box (when agent is processing) */
.activation-box {
  width: 16px;
  background: var(--demo-bg-elevated);
  border: 2px solid var(--demo-border-strong);
  border-radius: 3px;
  min-height: 24px;
}

.activation-box.orchestrator {
  border-color: var(--demo-accent-primary);
  background: rgba(255, 148, 0, 0.1);
}

.activation-box.searcher {
  border-color: #00ddff;
  background: rgba(0, 221, 255, 0.1);
}

.activation-box.reader {
  border-color: #30e60b;
  background: rgba(48, 230, 11, 0.1);
}

.activation-box.writer {
  border-color: #ffbd4f;
  background: rgba(255, 189, 79, 0.1);
}

/* Status node */
.status-node {
  display: flex;
  align-items: center;
  gap: var(--demo-space-2);
  padding: var(--demo-space-2) var(--demo-space-3);
  background: var(--demo-bg-elevated);
  border: 1px solid var(--demo-border-default);
  border-radius: var(--demo-radius-md);
  font-size: var(--demo-text-xs);
  color: var(--demo-text-secondary);
  white-space: nowrap;
}

.status-node.success {
  border-color: var(--demo-success);
  color: var(--demo-success);
  background: var(--demo-success-dim);
}

.status-node.error {
  border-color: var(--demo-error);
  color: var(--demo-error);
  background: var(--demo-error-dim);
}

.status-node .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--demo-border-default);
  border-top-color: var(--demo-accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Self message (loop) */
.self-message {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.self-arrow {
  width: 40px;
  height: 30px;
  border: 2px solid var(--arrow-color, var(--demo-accent-primary));
  border-left: none;
  border-radius: 0 8px 8px 0;
  position: relative;
}

.self-arrow::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: -1px;
  border: 5px solid transparent;
  border-top-color: var(--arrow-color, var(--demo-accent-primary));
}

/* Output Section */
.output-section .output-meta {
  display: flex;
  align-items: center;
  gap: var(--demo-space-2);
  font-size: var(--demo-text-xs);
  color: var(--demo-text-muted);
  margin-top: var(--demo-space-1);
}

.meta-sep {
  color: var(--demo-border-default);
}

.output-body {
  padding: var(--demo-space-4);
  font-size: var(--demo-text-sm);
  line-height: var(--demo-leading-relaxed);
  color: var(--demo-text-secondary);
  max-height: 400px;
  overflow-y: auto;
}

.output-body h3 {
  font-size: var(--demo-text-base);
  font-weight: var(--demo-weight-semibold);
  color: var(--demo-text-primary);
  margin: var(--demo-space-4) 0 var(--demo-space-2) 0;
}

.output-body h3:first-child {
  margin-top: 0;
}

.output-body p {
  margin-bottom: var(--demo-space-3);
}

.output-body ul {
  margin-bottom: var(--demo-space-3);
  padding-left: var(--demo-space-5);
}

.output-body li {
  margin-bottom: var(--demo-space-2);
}

.output-body .source-citation {
  font-size: var(--demo-text-xs);
  color: var(--demo-text-muted);
  margin-top: var(--demo-space-4);
  padding-top: var(--demo-space-3);
  border-top: 1px solid var(--demo-border-default);
}

.output-body .source-citation a {
  color: var(--demo-accent-primary);
  word-break: break-all;
}

/* Responsive */
@media (max-width: 800px) {
  .sequence-header {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .agent-icon {
    width: 36px;
    height: 36px;
  }
  
  .agent-label {
    font-size: var(--demo-text-xs);
  }
  
  .input-row {
    flex-direction: column;
  }
}
