/* ========================================
   DAVAI — Demo Terminal Styles
   ======================================== */

/* ── Phase Navigation ── */
.demo-phases {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-bottom: var(--space-lg);
  flex-wrap: nowrap;
}

.phase-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.phase-btn:hover {
  color: var(--text-primary);
  background: var(--accent-glow);
}

.phase-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

.phase-btn.completed {
  color: var(--accent-success);
}

.phase-btn .phase-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid currentColor;
}

.phase-btn.active .phase-num {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: var(--accent);
}

.phase-btn.completed .phase-num {
  background: var(--accent-success);
  color: var(--bg-deep);
  border-color: var(--accent-success);
}

/* ── Phase connector lines ── */
.phase-connector {
  width: 10px;
  height: 1px;
  background: var(--border);
  flex-shrink: 0;
}

/* ── Artifacts Section ── */
.artifacts-section {
  padding: var(--space-3xl) 0;
}

.artifacts-container {
  max-width: 780px;
  margin: 0 auto;
}

.artifacts-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  border: 1px solid var(--fw-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg), var(--shadow-glow);

  --fw-bg: #0C1220;
  --fw-header: #111827;
  --fw-border: #1E293B;
  --fw-text: #D8DEE9;
  --fw-text-dim: #636E83;
  --fw-hover: rgba(34, 211, 238, 0.08);
  --fw-accent: #22D3EE;
}

/* ── Finder sidebar ── */
.finder-window {
  background: var(--fw-bg);
  border-right: 1px solid var(--fw-border);
  display: flex;
  flex-direction: column;
}

.finder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--fw-header);
  border-bottom: 1px solid var(--fw-border);
}

.finder-dots {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.finder-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.finder-dot.red { background: #FF5F57; }
.finder-dot.yellow { background: #FFBD2E; }
.finder-dot.green { background: #28C840; }

.finder-path {
  font-size: var(--text-xs);
  color: var(--fw-text-dim);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  text-align: center;
  padding: 0 var(--space-sm);
}

.finder-actions {
  width: 52px;
  flex-shrink: 0;
}

.finder-body {
  padding: var(--space-xs) 0;
  flex: 1;
}

.finder-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 7px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.finder-item:hover {
  background: var(--fw-hover);
}

.finder-item.active {
  background: rgba(34, 211, 238, 0.12);
}

.finder-icon {
  font-size: var(--text-base);
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.finder-name {
  font-size: var(--text-sm);
  color: var(--fw-text);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.finder-item.active .finder-name {
  color: var(--fw-accent);
}

.finder-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--fw-border);
  font-size: 11px;
  color: var(--fw-text-dim);
}

/* ── Preview panel ── */
.preview-window {
  background: var(--fw-bg);
  display: flex;
  flex-direction: column;
  min-height: 380px;
}

.preview-header {
  padding: 12px 16px;
  background: var(--fw-header);
  border-bottom: 1px solid var(--fw-border);
}

.preview-filename {
  font-size: var(--text-xs);
  color: var(--fw-text-dim);
  font-weight: 500;
  font-family: var(--font-mono);
}

.preview-body {
  flex: 1;
  padding: var(--space-md) var(--space-lg);
  overflow-y: auto;
  max-height: 380px;
}

.preview-body::-webkit-scrollbar {
  width: 4px;
}

.preview-body::-webkit-scrollbar-thumb {
  background: var(--fw-border);
  border-radius: 2px;
}

.preview-content {
  display: none;
}

.preview-content.active {
  display: block;
}

.preview-content pre {
  margin: 0;
}

.preview-content code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.7;
  color: var(--fw-text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Markdown-like syntax highlighting */
.preview-content .md-h1 {
  color: #EFF2F7;
  font-weight: 700;
  font-size: var(--text-sm);
}

.preview-content .md-h2 {
  color: #22D3EE;
  font-weight: 600;
}

.preview-content .md-h3 {
  color: #D8DEE9;
  font-weight: 600;
}

.preview-content .md-dim {
  color: #636E83;
}

.preview-content .md-label {
  color: #22D3EE;
  font-weight: 500;
}

.preview-content .md-success {
  color: #34D399;
}

.preview-content .md-warn {
  color: #F59E0B;
}

.preview-content .md-accent {
  color: #22D3EE;
}

.preview-content .md-li {
  color: #22D3EE;
  font-weight: 600;
}

/* ── Artifacts responsive ── */
@media (max-width: 768px) {
  .artifacts-layout {
    grid-template-columns: 1fr;
    /* Remove overflow:hidden so finder-body can scroll horizontally.
       Use border-radius on children instead for rounded corners. */
    overflow: visible;
    border-radius: var(--radius-xl);
  }

  .finder-window {
    border-right: none;
    border-bottom: 1px solid var(--fw-border);
  }

  .finder-header {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .finder-body {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-xs) var(--space-sm);
    gap: 2px;
  }

  .finder-item {
    padding: 6px 10px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .preview-window {
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  }

  .preview-window {
    min-height: 300px;
  }

  .preview-body {
    max-height: 300px;
  }
}

@media (max-width: 480px) {
  .finder-name {
    font-size: 11px;
  }

  .preview-content code {
    font-size: 11px;
  }
}

/* ── Terminal Window ──
   Always dark regardless of theme */
.terminal-window {
  --tw-bg: #0A0E18;
  --tw-header: #111827;
  --tw-border: #1E293B;
  --tw-text: #D8DEE9;
  --tw-text-dim: #636E83;
  --tw-text-heading: #EFF2F7;
  --tw-accent: #22D3EE;
  --tw-success: #34D399;
  --tw-warm: #F59E0B;
  --tw-error: #F87171;

  background: var(--tw-bg);
  border: 1px solid var(--tw-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--tw-header);
  border-bottom: 1px solid var(--tw-border);
}

.terminal-dots {
  display: flex;
  gap: 8px;
}

.terminal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.terminal-dot.red { background: #FF5F57; }
.terminal-dot.yellow { background: #FFBD2E; }
.terminal-dot.green { background: #28C840; }

.terminal-title {
  font-size: var(--text-xs);
  color: var(--tw-text-dim);
  font-weight: 500;
}

.terminal-actions {
  display: flex;
  gap: 8px;
}

/* ── Terminal Body ── */
.terminal-body {
  padding: var(--space-lg);
  height: 380px;
  overflow-y: auto;
  font-size: var(--text-sm);
  line-height: 1.7;
}

.terminal-body::-webkit-scrollbar {
  width: 4px;
}

.terminal-body::-webkit-scrollbar-thumb {
  background: var(--tw-border);
  border-radius: 2px;
}

/* ── Terminal Line Types ── */
.term-line {
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.term-line.visible {
  opacity: 1;
  transform: translateY(0);
}

.term-line.typing {
  opacity: 1;
  transform: translateY(0);
}

.term-line .cursor-blink {
  display: inline-block;
  width: 8px;
  height: 1.1em;
  background: var(--tw-accent);
  vertical-align: text-bottom;
  animation: blink-cursor 1s step-end infinite;
  margin-left: 1px;
}

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

/* Line types — hardcoded dark colors for always-dark terminal */
.term-line .cmd {
  color: var(--tw-success);
  font-weight: 500;
}

.term-line .ai {
  color: var(--tw-accent);
}

.term-line .user {
  color: var(--tw-text);
}

.term-line .success {
  color: var(--tw-success);
  font-weight: 500;
}

.term-line .warning {
  color: var(--tw-warm);
}

.term-line .error {
  color: var(--tw-error);
}

.term-line .dim {
  color: var(--tw-text-dim);
}

.term-line .accent {
  color: var(--tw-accent);
}

.term-line .bold {
  font-weight: 700;
  color: var(--tw-text-heading);
}

/* ── Terminal Status Bar ── */
.terminal-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  border-top: 1px solid var(--tw-border);
  font-size: 11px;
  color: var(--tw-text-dim);
}

.terminal-status-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tw-success);
}

.status-indicator.running {
  animation: pulse-dot 1.5s ease-in-out infinite;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .demo-phases {
    gap: 4px;
  }

  .phase-btn {
    padding: 6px 8px;
    font-size: 11px;
  }

  .phase-btn .phase-label {
    display: none;
  }

  .phase-connector {
    width: 8px;
  }

  .terminal-body {
    padding: var(--space-md);
    height: 320px;
    font-size: var(--text-xs);
  }
}

@media (max-width: 480px) {
  .terminal-body {
    height: 260px;
    font-size: 11px;
    line-height: 1.6;
  }

  .terminal-header {
    padding: 10px 12px;
  }

  .terminal-dot {
    width: 10px;
    height: 10px;
  }
}
