/* Unified Tool Call Component */
.tool-call {
  margin-bottom: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  overflow: hidden;
}

.tool-call[data-status="completed"] {
  border-left-color: var(--success);
}

.tool-call[data-status="error"] {
  border-left-color: var(--error);
}

.tool-call[data-status="stopped"] {
  border-left-color: var(--warning);
}

/* Header */
.tool-call-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-lighter);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
}

.tool-call-header:hover {
  background: var(--border);
}

.tool-call-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tool-call-icon .spinner {
  width: 14px;
  height: 14px;
}

.tool-call-check-icon {
  color: var(--success);
  font-weight: bold;
  font-size: 14px;
}

.tool-call-error-icon {
  color: var(--error);
  font-weight: bold;
  font-size: 14px;
}

.tool-call-stopped-icon {
  color: var(--warning);
  font-weight: bold;
  font-size: 14px;
}

.tool-call-name {
  font-weight: 500;
  color: var(--text);
  flex-shrink: 0;
}

.tool-call-input {
  color: var(--text-muted);
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.tool-call-toggle {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.tool-call-credits {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
  flex-shrink: 0;
  font-family: 'SF Mono', Monaco, monospace;
}

.tool-call.child .tool-call-credits {
  font-size: 10px;
}

/* Body */
.tool-call-body {
  padding: 8px 12px;
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.tool-call.collapsed .tool-call-body {
  display: none;
}

/* Status text (streaming) */
.tool-call-status {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 8px;
}

.tool-call-status:empty {
  display: none;
}

.tool-call-status:last-child {
  margin-bottom: 0;
}

.tool-call-status-part {
  margin-bottom: 4px;
}

.tool-call-status-part:last-child {
  margin-bottom: 0;
}

.tool-call-status p,
.tool-call-status-part p {
  margin: 4px 0;
}

.tool-call-status p:first-child,
.tool-call-status-part p:first-child {
  margin-top: 0;
}

.tool-call-status p:last-child,
.tool-call-status-part p:last-child {
  margin-bottom: 0;
}

.tool-call-status ul,
.tool-call-status-part ul {
  margin: 4px 0 4px 20px;
}

.tool-call-status ol,
.tool-call-status-part ol {
  margin: 4px 0 4px 20px;
}

.tool-call-status li,
.tool-call-status-part li {
  margin: 2px 0;
}

.tool-call-status h1,
.tool-call-status h2,
.tool-call-status h3,
.tool-call-status-part h1,
.tool-call-status-part h2,
.tool-call-status-part h3 {
  margin: 8px 0 4px;
  line-height: 1.3;
}

.tool-call-status h1,
.tool-call-status-part h1 { font-size: 1.2em; }
.tool-call-status h2,
.tool-call-status-part h2 { font-size: 1.1em; }
.tool-call-status h3,
.tool-call-status-part h3 { font-size: 1em; }

.tool-call-status a,
.tool-call-status-part a {
  color: var(--accent-hover);
  text-decoration: underline;
}

.tool-call-status blockquote,
.tool-call-status-part blockquote {
  border-left: 3px solid var(--border);
  margin: 6px 0;
  padding: 4px 12px;
  color: var(--text-muted);
}

.tool-call-status hr,
.tool-call-status-part hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

.tool-call-status table,
.tool-call-status-part table {
  border-collapse: collapse;
  width: 100%;
  margin: 6px 0;
  font-size: 12px;
}

.tool-call-status th,
.tool-call-status td,
.tool-call-status-part th,
.tool-call-status-part td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: left;
}

.tool-call-status th,
.tool-call-status-part th {
  background: var(--bg-lighter);
  font-weight: 600;
}

.tool-call-status tr:nth-child(even),
.tool-call-status-part tr:nth-child(even) {
  background: var(--bg-light);
}

.tool-call-status code,
.tool-call-status-part code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 12px;
}

.tool-call-status pre,
.tool-call-status-part pre {
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 6px 0;
}

.tool-call-status pre code,
.tool-call-status-part pre code {
  padding: 0;
  background: none;
}

/* Timeline (interleaved text + tool calls inside step builds) */
.tool-call-timeline {
  margin: 4px 0;
  padding: 4px 6px;
}

.tool-call-timeline:empty {
  display: none;
}

.tool-call-timeline .tool-call-status-part {
  margin-bottom: 4px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

/* Children (nested tool calls) */
.tool-call-children {
  margin: 4px 0;
}

.tool-call-children:empty {
  display: none;
}

.tool-call.child {
  border-left-width: 2px;
  margin-bottom: 4px;
}

.tool-call.child .tool-call-header {
  padding: 6px 10px;
  font-size: 12px;
}

.tool-call.child .tool-call-icon {
  width: 14px;
  height: 14px;
}

.tool-call.child .tool-call-icon .spinner {
  width: 12px;
  height: 12px;
  border-width: 1.5px;
}

.tool-call.child .tool-call-check-icon,
.tool-call.child .tool-call-error-icon,
.tool-call.child .tool-call-stopped-icon {
  font-size: 12px;
}

.tool-call.child .tool-call-name {
  font-size: 12px;
}

.tool-call.child .tool-call-input {
  font-size: 11px;
}

.tool-call.child .tool-call-body {
  padding: 6px 10px;
}

/* Grandchild (e.g. opencode tools nested under step builds) */
.tool-call.grandchild {
  border-left-width: 2px;
  margin-bottom: 2px;
}

.tool-call.grandchild .tool-call-header {
  padding: 4px 8px;
  font-size: 11px;
}

.tool-call.grandchild .tool-call-icon {
  width: 12px;
  height: 12px;
}

.tool-call.grandchild .tool-call-icon .spinner {
  width: 10px;
  height: 10px;
  border-width: 1.5px;
}

.tool-call.grandchild .tool-call-check-icon,
.tool-call.grandchild .tool-call-error-icon,
.tool-call.grandchild .tool-call-stopped-icon {
  font-size: 11px;
}

.tool-call.grandchild .tool-call-name {
  font-size: 11px;
}

.tool-call.grandchild .tool-call-input {
  font-size: 10px;
}

.tool-call.grandchild .tool-call-body {
  padding: 4px 8px;
}

/* Custom content slot */
.tool-call-custom:empty {
  display: none;
}

.tool-call-custom {
  margin: 8px 0;
}

/* Output details */
.tool-call-output {
  margin-top: 8px;
}

.tool-call-output summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  user-select: none;
}

.tool-call-output summary:hover {
  color: var(--text);
}

.tool-call-output-content {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 11px;
  color: var(--text-muted);
  overflow-x: auto;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Error */
.tool-call-error {
  color: var(--error);
  font-size: 12px;
  padding: 6px 10px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 4px;
  margin-top: 8px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Browser steps inside prepare_page child tool calls */
.browser-steps {
  padding: 0;
}

.browser-step {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.browser-step:last-child:not(.browser-summary) {
  border-bottom: none;
}

.browser-step-number {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  padding-top: 2px;
}

.browser-step-content {
  flex: 1;
  min-width: 0;
}

.browser-step-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.browser-step-action {
  background: var(--accent);
  color: white;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.browser-step-goal {
  font-size: 12px;
  color: var(--text);
  margin-bottom: 4px;
}

.browser-step-eval {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.browser-step-error {
  font-size: 11px;
  color: var(--error);
  margin-top: 4px;
}

.browser-step.has-error {
  border-left: 2px solid var(--error);
  padding-left: 8px;
}

.browser-step-empty {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.browser-summary {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 0;
  font-style: italic;
}

.browser-summary.error {
  color: var(--error);
}
