/* ============================================
   Terminal Components - Matching ClaudTerm App
   ============================================ */

/* ============================================
   Terminal Grid
   ============================================ */

.terminal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  min-height: 320px;
}

/* ============================================
   Terminal Tile
   ============================================ */

.terminal-tile {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 140px;
  transition: all 0.3s ease;
  opacity: 0;
  transform: scale(0.9);
}

.terminal-tile.visible {
  opacity: 1;
  transform: scale(1);
}

.terminal-tile.status-idle {
  border-color: var(--status-idle);
}

.terminal-tile.status-working {
  border-color: var(--status-working);
  box-shadow: 0 0 20px rgba(88, 166, 255, 0.15);
}

.terminal-tile.status-waiting {
  border-color: var(--status-waiting);
  box-shadow: 0 0 20px rgba(210, 153, 34, 0.2);
}

.terminal-tile.status-complete {
  border-color: var(--status-complete);
  box-shadow: 0 0 20px rgba(63, 185, 80, 0.15);
}

.terminal-tile.status-error {
  border-color: var(--status-error);
  box-shadow: 0 0 20px rgba(248, 81, 73, 0.15);
}

/* Tile Header */
.tile-header {
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
  gap: var(--space-sm);
}

.tile-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.tile-icon svg {
  width: 14px;
  height: 14px;
  color: var(--accent-primary);
}

.tile-info {
  flex: 1;
  min-width: 0;
}

.tile-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-path {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tile-badge.status-idle {
  background: rgba(139, 148, 158, 0.2);
  color: var(--status-idle);
  border: 1px solid var(--status-idle);
}

.tile-badge.status-working {
  background: rgba(88, 166, 255, 0.2);
  color: var(--status-working);
  border: 1px solid var(--status-working);
}

.tile-badge.status-waiting {
  background: rgba(210, 153, 34, 0.2);
  color: var(--status-waiting);
  border: 1px solid var(--status-waiting);
}

.tile-badge.status-complete {
  background: rgba(63, 185, 80, 0.2);
  color: var(--status-complete);
  border: 1px solid var(--status-complete);
}

.tile-badge.status-error {
  background: rgba(248, 81, 73, 0.2);
  color: var(--status-error);
  border: 1px solid var(--status-error);
}

.badge-spinner {
  width: 10px;
  height: 10px;
  animation: spin 1s linear infinite;
}

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

/* Tile Preview */
.tile-preview {
  flex: 1;
  margin: var(--space-sm);
  padding: var(--space-sm);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1.4;
  color: var(--text-secondary);
  overflow: hidden;
}

.preview-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-line.command {
  color: var(--text-primary);
}

.preview-line.output {
  color: var(--status-complete);
}

.preview-line.prompt {
  color: var(--accent-primary);
}

/* Tile Footer */
.tile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  font-size: 10px;
}

.tile-agent {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-primary);
}

.tile-agent svg {
  width: 12px;
  height: 12px;
}

.tile-progress {
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.tile-index {
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  color: var(--text-secondary);
  font-weight: 600;
}

/* ============================================
   New Terminal Button
   ============================================ */

.new-terminal-wrapper {
  min-height: 140px;
}

.new-terminal-btn {
  height: 100%;
  min-height: 140px;
  background: var(--bg-primary);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
}

.new-terminal-btn:hover {
  border-color: var(--accent-primary);
  background: rgba(88, 166, 255, 0.05);
}

.new-terminal-collapsed {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--space-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
}

.new-terminal-btn:hover .new-terminal-collapsed {
  color: var(--accent-primary);
}

.plus-icon {
  width: 32px;
  height: 32px;
}

.new-terminal-expanded {
  display: none;
  flex-direction: column;
  height: 100%;
}

.new-terminal-btn.expanded .new-terminal-collapsed {
  display: none;
}

.new-terminal-btn.expanded .new-terminal-expanded {
  display: flex;
}

.new-terminal-top {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--accent-primary);
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: background 0.2s;
}

.new-terminal-top:hover {
  background: var(--border);
}

.new-terminal-agents {
  display: flex;
  border-top: 1px solid var(--border);
}

.agent-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--space-md);
  background: var(--bg-primary);
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-sans);
}

.agent-btn:first-child {
  border-right: 1px solid var(--border);
}

.agent-btn:hover {
  background: var(--bg-tertiary);
  color: var(--accent-primary);
}

.agent-btn svg {
  width: 16px;
  height: 16px;
}

/* ============================================
   Fullscreen Terminal View
   ============================================ */

.terminal-fullscreen {
  position: absolute;
  inset: var(--space-md);
  top: 60px; /* Below status bar */
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: none;
  flex-direction: column;
  z-index: 10;
  transform: scale(0.95);
  opacity: 0;
  transition: all 0.3s ease;
}

.terminal-fullscreen.visible {
  display: flex;
  transform: scale(1);
  opacity: 1;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.terminal-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  font-size: 14px;
}

.terminal-icon {
  width: 20px;
  height: 20px;
  color: var(--accent-primary);
}

.terminal-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.terminal-badge.status-working {
  background: rgba(88, 166, 255, 0.2);
  color: var(--status-working);
  border: 1px solid var(--status-working);
}

.terminal-badge.status-complete {
  background: rgba(63, 185, 80, 0.2);
  color: var(--status-complete);
  border: 1px solid var(--status-complete);
}

.terminal-body {
  flex: 1;
  padding: var(--space-md);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  overflow: auto;
}

.terminal-prompt {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: var(--space-sm);
}

.prompt-user { color: var(--status-complete); }
.prompt-at { color: var(--text-secondary); }
.prompt-host { color: var(--accent-primary); }
.prompt-colon { color: var(--text-secondary); }
.prompt-path { color: var(--status-waiting); }
.prompt-dollar { color: var(--text-secondary); margin-right: 8px; }

.prompt-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--text-primary);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.prompt-cursor.typing {
  animation: none;
  opacity: 1;
}

.terminal-output {
  color: var(--text-secondary);
}

.output-line {
  margin: 4px 0;
}

.output-line.command {
  color: var(--text-primary);
}

.output-line.result {
  color: var(--status-complete);
}

.output-line.agent-prompt {
  color: var(--accent-primary);
  margin-top: var(--space-md);
}

.output-line.agent-response {
  color: var(--text-secondary);
  padding-left: var(--space-md);
  border-left: 2px solid var(--accent-primary);
  margin: var(--space-sm) 0;
}

.output-line.task-list {
  color: var(--text-secondary);
  padding-left: var(--space-lg);
}

.output-line.task-list::before {
  content: "•";
  margin-right: var(--space-sm);
  color: var(--status-working);
}

/* ============================================
   Demo Cursor
   ============================================ */

.demo-cursor {
  position: absolute;
  width: 24px;
  height: 24px;
  color: white;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s;
}

.demo-cursor.visible {
  opacity: 1;
}

.demo-cursor svg {
  width: 100%;
  height: 100%;
}

/* Click effect */
.demo-cursor.clicking::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  background: rgba(88, 166, 255, 0.5);
  border-radius: 50%;
  animation: click-ripple 0.4s ease-out;
}

@keyframes click-ripple {
  from {
    transform: scale(0.5);
    opacity: 1;
  }
  to {
    transform: scale(2);
    opacity: 0;
  }
}

/* ============================================
   Agent-specific styling
   ============================================ */

.tile-header.agent-claude .tile-icon {
  background: var(--agent-claude);
}

.tile-header.agent-claude .tile-icon svg {
  color: white;
}

.tile-header.agent-opencode .tile-icon {
  background: var(--agent-opencode);
}

.tile-header.agent-opencode .tile-icon svg {
  color: white;
}

/* OpenCode specific prompt */
.opencode-prompt {
  color: var(--agent-opencode);
  font-weight: 500;
}

.opencode-prompt::before {
  content: "opencode>";
  margin-right: var(--space-sm);
}

/* Claude specific prompt */
.claude-prompt {
  color: var(--agent-claude);
  font-weight: 500;
}

.claude-prompt::before {
  content: "claude>";
  margin-right: var(--space-sm);
}

/* ============================================
   Pulse Animation for Waiting State
   ============================================ */

.terminal-tile.pulsing {
  animation: tile-pulse 1.5s ease-in-out infinite;
}

@keyframes tile-pulse {
  0%, 100% {
    box-shadow: 0 0 20px rgba(210, 153, 34, 0.2);
    border-width: 1.5px;
  }
  50% {
    box-shadow: 0 0 30px rgba(210, 153, 34, 0.4);
    border-width: 3px;
  }
}

/* ============================================
   Status Transition Flash
   ============================================ */

.terminal-tile.status-flash {
  animation: status-flash 0.5s ease-out;
}

@keyframes status-flash {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}
