/* src/ui/styles.css */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1a1a1a;
  --surface3: #1e1e1e;
  --border: #2a2a2a;
  --border-hover: #3a3a3a;
  --text: #e0e0e0;
  --text-dim: #888;
  --text-faint: #555;
  --accent: #4a9eff;
  --accent-dim: #2a5e9f;
  --green: #4ade80;
  --yellow: #fbbf24;
  --red: #f87171;
  --orange: #fb923c;
  --mono: "SF Mono", "Cascadia Code", "Fira Code", "Consolas", monospace;
  --panel-width: 420px;
}

html, body, #root {
  height: 100%;
}

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
}

.app-layout {
  display: flex;
  overflow: hidden;
  height: 100vh;
}

.chat-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  transition: margin-right .25s;
}

.panel-open .chat-pane {
  margin-right: 0;
}

header {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  justify-content: space-between;
  align-items:  center;
  padding: 12px 24px;
}

header h1 {
  color: var(--text);
  letter-spacing: -.5px;
  font-size: 14px;
  font-weight: 600;
}

header h1 span {
  color: var(--text-dim);
  font-weight: 400;
}

.status-dot {
  background: var(--green);
  display: inline-block;
  border-radius: 50%;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
}

.status-dot.offline {
  background: var(--red);
}

.chat-messages {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 16px;
  padding: 24px;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: center;
  align-items:  center;
  gap: 4px;
}

.chat-empty-title {
  color: var(--text-dim);
  letter-spacing: -.5px;
  font-size: 20px;
  font-weight: 600;
}

.chat-empty-sub {
  color: var(--text-faint);
  font-size: 12px;
}

.chat-row {
  display: flex;
}

.chat-row.user {
  justify-content: flex-end;
}

.chat-row.assistant {
  justify-content: flex-start;
}

.chat-bubble {
  border-radius: 12px;
  max-width: 75%;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
}

.user-bubble {
  background: var(--accent-dim);
  color: #fff;
  white-space: pre-wrap;
  word-break: break-word;
  border-bottom-right-radius: 4px;
}

.assistant-bubble {
  background: var(--surface2);
  border: 1px solid var(--border);
  cursor: pointer;
  border-bottom-left-radius: 4px;
  transition: border-color .15s;
}

.assistant-bubble:hover {
  border-color: var(--border-hover);
}

.assistant-bubble.selected {
  border-color: var(--accent);
}

.error-bubble {
  cursor: pointer;
  background: #1a0a0a;
  border: 1px solid #3a1a1a;
  border-bottom-left-radius: 4px;
}

.error-bubble:hover {
  border-color: #4a2a2a;
}

.error-bubble.selected {
  border-color: var(--red);
}

.bubble-error-label {
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--red);
  margin-bottom: 4px;
  font-size: 10px;
}

.bubble-output {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  max-height: 300px;
  margin-bottom: 8px;
}

.bubble-meta {
  display: flex;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  align-items:  center;
  gap: 10px;
  padding-top: 8px;
  font-size: 10px;
}

.bubble-expand {
  color: var(--accent);
  margin-left: auto;
  font-size: 10px;
}

.loading-bubble {
  display: flex;
  color: var(--text-dim);
  cursor: default;
  align-items:  center;
  gap: 8px;
}

.loading-bubble:hover {
  border-color: var(--border);
}

.chat-input-area {
  flex-shrink: 0;
  padding: 16px 24px 24px;
}

.chat-input-wrap {
  display: flex;
  gap: 8px;
  max-width: 800px;
  margin: 0 auto;
}

.chat-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  outline: none;
  resize: none;
  border-radius: 12px;
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 12px 16px;
  font-size: 13px;
}

.chat-input:focus {
  border-color: var(--accent);
}

.chat-input::placeholder {
  color: var(--text-faint);
}

.send-btn {
  background: var(--accent);
  display: flex;
  color: #fff;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  flex-shrink: 0;
  justify-content: center;
  align-items:  center;
  width: 44px;
  height: 44px;
}

.send-btn:hover {
  background: #5aabff;
}

.send-btn:disabled {
  background: var(--surface2);
  color: var(--text-faint);
  cursor: not-allowed;
}

.detail-panel {
  width: var(--panel-width);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  overflow: hidden;
  animation: slideIn .2s ease;
  flex-direction: column;
  flex-shrink: 0;
}

@keyframes slideIn {
  from {
    width: 0;
    opacity: 0;
  }

  to {
    width: var(--panel-width);
    opacity: 1;
  }
}

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

.detail-header h2 {
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-size: 12px;
}

.detail-close {
  color: var(--text-dim);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0 4px;
  font-size: 20px;
  line-height: 1;
}

.detail-close:hover {
  color: var(--text);
}

.detail-body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 16px;
  padding: 16px;
}

.detail-prompt {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.detail-prompt label {
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
}

.detail-prompt-text {
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
}

.detail-section {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.detail-section h3 {
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 10px;
  font-size: 10px;
}

.detail-error {
  background: #1a0a0a;
  border-color: #3a1a1a;
}

.detail-error h3 {
  color: var(--red);
}

.detail-error p {
  color: var(--text);
  font-size: 13px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-field label {
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-faint);
  display: block;
  margin-bottom: 2px;
  font-size: 9px;
}

.detail-field span {
  color: var(--text);
  font-size: 12px;
}

.detail-reasoning {
  color: var(--text-dim);
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.5;
}

.detail-meta {
  color: var(--text-faint);
  margin-top: 6px;
  font-size: 10px;
}

.exit-ok {
  color: var(--green);
}

.exit-err {
  color: var(--red);
}

.mono-dim {
  color: var(--text-dim);
}

.model-badge {
  display: inline-block;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}

.model-badge.sm {
  padding: 1px 6px;
  font-size: 10px;
}

.model-badge.haiku {
  color: var(--green);
  background: #1a3a2a;
}

.model-badge.sonnet {
  color: var(--accent);
  background: #1a2a3a;
}

.model-badge.opus {
  color: #c084fc;
  background: #2a1a3a;
}

.model-badge.gemini {
  color: var(--yellow);
  background: #2a2a1a;
}

.human-gate {
  display: inline-block;
  color: var(--red);
  background: #3a1a1a;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.skill-tag {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 10px;
}

.spinner {
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
  border-radius: 50%;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

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

@media (width <= 768px) {
  .detail-panel {
    position: fixed;
    z-index: 100;
    height: 100vh;
    top: 0;
    right: 0;
    box-shadow: -4px 0 20px #00000080;
  }

  .chat-bubble {
    max-width: 90%;
  }
}
