/* Tool call rendering */
@import "./tool-call/todo.css";
@import "./tool-call/task.css";

.tool-call-message {
  @apply flex flex-col gap-2 p-3 w-full;
  background-color: var(--message-tool-bg);
  border-left: 4px solid var(--message-tool-border);
  color: inherit;
}

.tool-call-header-label {
  @apply flex items-center justify-between gap-2 font-semibold text-sm;
  color: var(--message-tool-border);
  margin-bottom: 1px;
}

.tool-call-header-meta {
  @apply flex items-center gap-2;
}

.tool-call-header-button {
  background-color: transparent;
  border: 1px solid var(--border-base);
  color: var(--message-tool-border);
  padding: 0.15rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.5rem;
  transition: all 0.2s ease;
}

.tool-call-header-button:hover:not(:disabled) {
  background-color: var(--surface-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.tool-call-header-button:active:not(:disabled) {
  transform: scale(0.95);
}

.tool-call-header-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tool-call-header-label .tool-call-icon {
  @apply text-base;
}

.tool-call-header-label .tool-name {
  font-family: var(--font-family-mono);
  color: inherit;
  background-color: var(--surface-secondary);
  border: 1px solid var(--border-base);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
}

.tool-call {
  @apply border overflow-hidden;
  border-color: var(--border-base);
  color: inherit;
  --tool-call-line-unit: 1.4em;
  --tool-call-lines-compact: 15;
  --tool-call-lines-large: 30;
  --tool-call-max-height-compact: calc(var(--tool-call-lines-compact) * var(--tool-call-line-unit));
  --tool-call-max-height-large: calc(var(--tool-call-lines-large) * var(--tool-call-line-unit));
}

.tool-call-message .tool-call {
  border: none;
  border-radius: 0;
  margin: 0;
}

.tool-call-header {
  @apply flex items-center gap-2 p-2 w-full bg-transparent border-none cursor-pointer text-left;
  font-family: var(--font-family-mono);
  font-size: 13px;
  border-radius: 0;
}

.tool-call-header::before {
  content: "▶";
  font-size: 11px;
  margin-right: 0.35rem;
  color: var(--text-muted);
}

.tool-call-header[aria-expanded="true"]::before {
  content: "▼";
}

.tool-call-header::after {
  content: attr(data-status-icon);
  font-size: 0.95rem;
  margin-left: 0.5rem;
}

.tool-call-header[data-status-icon=""]::after {
  margin-left: 0;
}

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

.tool-call-summary {
  @apply flex-1 text-left inline-flex items-center gap-2;
}

.tool-call-summary::before {
  content: attr(data-tool-icon);
}

.tool-call-summary[data-tool-icon=""]::before {
  margin-right: 0;
  content: "";
}

.tool-call-summary[data-tool-icon]:not([data-tool-icon=""])::before {
  margin-right: 0.35rem;
}

.tool-call-status-success {
  border-left: 3px solid var(--status-success);
}

.tool-call-status-error {
  border-left: 3px solid var(--status-error);
}

.tool-call-status-running {
  border-left: 3px solid var(--status-warning);
}

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

.tool-call-status-pending {
  border-left: 3px solid var(--accent-primary);
}

.tool-call-status-pending .tool-call-summary {
  animation: shimmer 2s ease-in-out infinite;
}

.tool-call-preview {
  @apply p-2 flex flex-col gap-1.5;
  background-color: var(--surface-code);
  border-top: 1px solid var(--border-base);
}

.tool-call-preview-label {
  @apply text-xs font-semibold uppercase tracking-wide;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.tool-call-preview-text {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-tight);
  color: var(--text-muted);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-height: var(--tool-call-max-height-compact, calc(25 * 1.4em));
  overflow-y: scroll;
}

.tool-call-details {
  @apply flex flex-col;
  background-color: var(--surface-code);
  font-size: var(--font-size-xs);
}

.tool-call-markdown {
  background-color: var(--surface-code);
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: var(--font-size-xs);
  line-height: var(--line-height-tight);
  max-height: var(--tool-call-max-height-compact, calc(25 * 1.4em));
  overflow-y: scroll;
  scrollbar-width: thin;
  scrollbar-color: var(--border-base) transparent;
  scrollbar-gutter: stable both-edges;
  position: relative;
}

.tool-call-markdown-large {
  max-height: var(--tool-call-max-height-large, calc(48 * 1.4em));
}

.tool-call-diff-shell {
  padding: 0;
}

.tool-call-diff-viewer {
  max-height: var(--tool-call-max-height-large, calc(48 * 1.4em));
  overflow: auto;
  background-color: var(--surface-code);
}

.tool-call-diff-toolbar {
  @apply flex items-center justify-between gap-3 px-3 py-2;
  background-color: var(--surface-secondary);
  border-bottom: 1px solid var(--border-base);
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Diff shell already provides the scroll container.
   Avoid nested scroll areas inside the diff viewer. */
.tool-call-diff-shell .tool-call-diff-viewer {
  max-height: none;
  overflow: visible;
}

.tool-call-diff-toolbar-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tool-call-diff-toggle {
  @apply inline-flex items-center gap-1;
}

.tool-call-diff-mode-button {
  @apply border text-xs font-semibold px-3 py-1 rounded transition-all duration-150;
  border-color: var(--border-base);
  background-color: transparent;
  color: var(--text-muted);
}

.tool-call-diff-mode-button:hover {
  background-color: var(--surface-hover);
  color: var(--text-primary);
}

.tool-call-diff-mode-button.active {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--text-inverted);
}

.tool-call-diff-viewer .diff-tailwindcss-wrapper {
  background-color: transparent;
  color: inherit;
}

.tool-call-diff-viewer .diff-view-wrapper {
  font-family: var(--font-family-mono);
}

.tool-call-diff-fallback {
  margin: 0;
  padding: 0.75rem;
  background-color: var(--surface-code);
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-tight);
}

.tool-call-awaiting-permission {
  border-left-color: var(--status-warning);
}

.tool-call-permission {
  @apply flex flex-col gap-3;
  border: 2px solid var(--status-warning);
  border-radius: 0;
  margin: 0;
  padding: 1rem 1.25rem;
  background-color: var(--message-tool-bg);
}

.tool-call-permission-header {
  @apply flex items-center justify-between gap-3;
}

.tool-call-permission-label {
  @apply font-semibold text-sm;
  color: var(--text-primary);
}

.tool-call-permission-type {
  font-family: var(--font-family-mono);
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 0.375rem;
  border: 1px solid var(--border-base);
  background-color: var(--surface-code);
}

.tool-call-permission-title code {
  display: block;
  font-size: 13px;
  color: var(--text-primary);
  background-color: var(--surface-code);
  border: 1px solid var(--border-base);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  word-break: break-word;
}

.tool-call-permission-actions {
  @apply flex items-center justify-between gap-3 flex-wrap;
  margin-top: 0.75rem;
}

.tool-call-permission-buttons {
  @apply flex flex-wrap gap-2;
}

.tool-call-permission-button {
  background-color: var(--surface-base);
  border: 1px solid var(--status-warning);
  color: var(--text-secondary);
  padding: 0.4rem 1.05rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: var(--font-weight-medium);
  line-height: 1.15;
  transition: transform 0.15s ease, color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.75rem;
}

.tool-call-permission-button:hover:not(:disabled) {
  background-color: var(--surface-hover);
  border-color: var(--status-warning);
  color: var(--status-warning);
}

.tool-call-permission-button:active:not(:disabled) {
  transform: scale(0.97);
}

.tool-call-permission-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tool-call-permission-shortcuts {
  @apply flex items-center gap-2 text-xs text-muted;
}

.tool-call-permission-shortcuts .kbd {
  margin-right: 0.25rem;
}

.tool-call-permission-queued-text {
  @apply text-sm text-muted;
}

.tool-call-permission-error {
  @apply text-sm;
  color: var(--status-error);
  margin-top: 0.5rem;
}

.tool-call-permission-diff {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.tool-call-permission-diff .tool-call-diff-shell {
  margin: 0;
}

.tool-call-diff-viewer .diff-line-old-num,
.tool-call-diff-viewer .diff-line-new-num,
.tool-call-diff-viewer .diff-line-num {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
}

.tool-call-markdown .markdown-code-block {
  margin: 0;
  border-radius: 0;
}


.tool-call-markdown .markdown-code-block {
  margin: 0;
  border: none;
  background-color: transparent;
}

.tool-call-markdown .code-block-header {
  position: sticky;
  top: 0;
  z-index: auto;
  box-shadow: 0 1px 0 var(--border-base);
}

.tool-call-markdown .markdown-code-block pre {
  margin: 0 !important;
  min-height: auto;
  max-height: none;
  overflow-y: visible;
}

.tool-call-markdown::-webkit-scrollbar {
  width: 8px;
}

.tool-call-markdown::-webkit-scrollbar-track {
  background: transparent;
}

.tool-call-markdown::-webkit-scrollbar-thumb {
  background-color: var(--border-base);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* apply_patch multi-file layout */
.tool-call-apply-patch {
  @apply flex flex-col;
}

.tool-call-apply-patch-file {
  margin-top: 0.75rem;
}

.tool-call-apply-patch-file:first-child {
  margin-top: 0;
}

.tool-call-section h4 {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  margin-bottom: 4px;
  color: var(--text-muted);
}

.tool-call-diagnostics {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--border-base);
  background-color: var(--surface-base);
}

.tool-call-diagnostics-wrapper {
  border-top: 1px solid var(--border-base);
  background-color: var(--surface-base);
  margin-top: var(--space-md);
}

.tool-call-diagnostics-heading {
  @apply flex items-center gap-2 p-2 w-full border-none cursor-pointer text-left;
  font-family: var(--font-family-mono);
  font-size: 13px;
  color: var(--message-tool-border);
  background-color: var(--surface-code);
}

.tool-call-diagnostics-heading:hover {
  background-color: var(--surface-hover);
}

.tool-call-diagnostics-file {
  @apply inline-flex items-center;
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  justify-content: flex-end;
}


.tool-call-diagnostics-heading {
  @apply flex items-center gap-2 p-2 w-full border-none cursor-pointer text-left;
  font-family: var(--font-family-mono);
  font-size: 13px;
  color: var(--message-tool-border);
  background-color: var(--surface-code);
}

.tool-call-diagnostics-heading:hover {
  background-color: var(--surface-hover);
}

.tool-call-diagnostics-title {
  font-size: 13px;
}

.tool-call-diagnostics-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-base);
  font-size: 12px;
}

.tool-call-diagnostics-file {
  @apply inline-flex items-center;
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-call-diagnostics-spacer {
  flex: 1;
}

.tool-call-diagnostics-caret {
  font-size: 12px;
  color: var(--text-muted);
}

.tool-call-diagnostics {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md) var(--space-sm) var(--space-md);
  background-color: var(--surface-base);
}

.tool-call-diagnostics-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  max-height: calc(4 * var(--tool-call-line-unit, 1.4em));
  overflow-y: scroll;
  padding-right: 0;
  margin-right: 0;
  scrollbar-gutter: stable both-edges;
  scrollbar-width: thin;
}

.tool-call-diagnostic-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-sm);
  font-size: var(--font-size-xs);
  color: var(--text-primary);
}

.tool-call-diagnostic-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 var(--space-sm);
  min-height: 20px;
  border-radius: var(--pill-radius);
  font-size: 11px;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.02em;
}

.tool-call-diagnostic-error {
  background-color: var(--status-error-bg);
  color: var(--status-error);
}

.tool-call-diagnostic-warning {
  background-color: var(--status-starting-bg);
  color: var(--status-warning);
}

.tool-call-diagnostic-info {
  background-color: var(--badge-neutral-bg);
  color: var(--badge-neutral-text);
}

.tool-call-diagnostic-path {
  font-family: var(--font-family-mono);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2xs);
}

.tool-call-diagnostic-coords {
  color: var(--text-muted);
}

.tool-call-diagnostic-message {
  flex: 1;
  min-width: 200px;
  color: var(--text-primary);
}

.tool-call-section pre {
  margin: 0;
  padding: 8px;
  background-color: var(--surface-base);
  border-radius: 0px;
  overflow-x: auto;
  max-height: var(--tool-call-max-height-compact, calc(25 * 1.4em));
  overflow-y: scroll;
}

.tool-call-section code {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-tight);
}

.tool-call-section pre::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.tool-call-section pre::-webkit-scrollbar-track {
  background: var(--surface-secondary);
  border-radius: 0px;
}

.tool-call-section pre::-webkit-scrollbar-thumb {
  background: var(--border-base);
  border-radius: 0px;
}

.tool-call-section pre::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.tool-call-pending-message {
  @apply flex items-center gap-2 p-3 text-xs italic;
  color: var(--text-muted);
}

.tool-call-emoji {
  @apply text-base mr-1;
}

.tool-call-action-button {
  @apply border text-xs font-semibold px-3 py-1 rounded transition-colors h-8 flex items-center;
  border-color: var(--border-base);
  color: var(--text-muted);
  background-color: transparent;
}

.tool-call-action-button:hover:not(:disabled) {
  background-color: var(--surface-hover);
  color: var(--text-primary);
}

.tool-call-action-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tool-call-bash,
.tool-call-diff {
  @apply my-2;
}

.tool-call-content {
  background-color: var(--surface-secondary);
  border: 1px solid var(--border-base);
  border-radius: 0;
  padding: 8px 12px;
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-tight);
  overflow-x: auto;
  margin: 0;
}

.tool-call-content code {
  font-family: inherit;
  background: none;
  padding: 0;
  font-size: inherit;
}


.tool-call-error-content {
  background-color: var(--message-error-bg);
  border-left: 3px solid var(--status-error);
  padding: 12px;
  margin: 8px 0;
  border-radius: 4px;
  color: var(--status-error);
  font-size: var(--font-size-xs);
}

.tool-call-error-content strong {
  font-weight: var(--font-weight-semibold);
}

.dropdown-diff-added {
  @apply text-xs;
  color: var(--status-success);
}

.dropdown-diff-removed {
  @apply text-xs;
  color: var(--status-error);
}
