/* CSS Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  /* ===========================================
   * Theme Variables with VS Code fallbacks
   * These use VS Code theme variables when available,
   * falling back to light-dark() for browser UIKit
   * Light values from VS Code Light Default, Dark from VS Code Dark Default
   * =========================================== */

  /* Core Colors */
  --foreground: var(--vscode-foreground, light-dark(#3b3b3b, #cccccc));
  --description-foreground: var(
    --vscode-descriptionForeground,
    light-dark(#3b3b3b, #9d9d9d)
  );
  --error-foreground: var(--vscode-errorForeground, #f85149);
  --focus-border: var(--vscode-focusBorder, light-dark(#005fb8, #0078d4));

  /* Sidebar */
  --sidebar-background: var(
    --vscode-sideBar-background,
    light-dark(#f8f8f8, #181818)
  );

  /* Editor */
  --editor-background: var(
    --vscode-editor-background,
    light-dark(#ffffff, #1e1e1e)
  );

  /* Input */
  --input-foreground: var(
    --vscode-input-foreground,
    light-dark(#3b3b3b, #cccccc)
  );
  --input-border: var(
    --vscode-editorWidget-border,
    light-dark(#c8c8c8, #454545)
  );
  --input-placeholder-foreground: var(
    --vscode-input-placeholderForeground,
    light-dark(#767676, #989898)
  );
  --input-validation-error-background: var(
    --vscode-inputValidation-errorBackground,
    light-dark(#f2dede, #5a1d1d)
  );
  --input-validation-error-border: var(
    --vscode-inputValidation-errorBorder,
    #be1100
  );

  /* Button */
  --button-secondary-background: var(
    --vscode-button-secondaryBackground,
    light-dark(#e5e5e5, #313131)
  );
  --button-secondary-foreground: var(
    --vscode-button-secondaryForeground,
    light-dark(#3b3b3b, #cccccc)
  );
  --button-secondary-hover-background: var(
    --vscode-button-secondaryHoverBackground,
    light-dark(#cccccc, #3c3c3c)
  );

  /* Panel */
  --panel-border: var(--vscode-panel-border, light-dark(#e5e5e5, #2b2b2b));

  /* Text */
  --text-link-foreground: var(
    --vscode-textLink-foreground,
    light-dark(#005fb8, #4daafc)
  );
  --text-link-active-foreground: var(
    --vscode-textLink-activeForeground,
    light-dark(#005fb8, #4daafc)
  );
  --text-code-block-background: var(
    --vscode-textCodeBlock-background,
    light-dark(#f8f8f8, #2b2b2b)
  );
  --text-blockquote-border: var(
    --vscode-textBlockQuote-border,
    light-dark(#e5e5e5, #616161)
  );
  --text-blockquote-foreground: var(
    --vscode-textBlockQuote-foreground,
    light-dark(#3b3b3b, #cccccc)
  );
  --text-blockquote-background: var(
    --vscode-textBlockQuote-background,
    light-dark(#f8f8f8, #2b2b2b)
  );

  /* Editor */
  --editor-font-family: var(
    --vscode-editor-font-family,
    "SF Mono",
    Monaco,
    "Cascadia Code",
    "Roboto Mono",
    Consolas,
    "Courier New",
    monospace
  );
  --editor-line-number-foreground: var(
    --vscode-editorLineNumber-foreground,
    #6e7681
  );

  /* Diff */
  --diff-inserted-line-background: var(
    --vscode-diffEditor-insertedLineBackground,
    rgba(155, 185, 85, 0.2)
  );
  --diff-removed-line-background: var(
    --vscode-diffEditor-removedLineBackground,
    rgba(255, 0, 0, 0.2)
  );

  /* Git Decorations */
  --git-added-foreground: var(
    --vscode-gitDecoration-addedResourceForeground,
    light-dark(#587c0c, #89d185)
  );
  --git-deleted-foreground: var(
    --vscode-gitDecoration-deletedResourceForeground,
    light-dark(#ad0707, #f48771)
  );

  /* Scrollbar */
  --scrollbar-slider-background: var(
    --vscode-scrollbarSlider-background,
    rgba(121, 121, 121, 0.4)
  );
  --scrollbar-slider-hover-background: var(
    --vscode-scrollbarSlider-hoverBackground,
    rgba(100, 100, 100, 0.7)
  );
  --scrollbar-slider-active-background: var(
    --vscode-scrollbarSlider-activeBackground,
    rgba(191, 191, 191, 0.4)
  );

  /* Card background - relative lightness reduction for perceptual consistency */
  --card-background: oklch(from var(--sidebar-background) calc(l * 0.98) c h);

  /* Fonts */
  --font-family: var(
    --vscode-font-family,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif
  );
  --font-size: var(--vscode-font-size, 13px);

  /* ===========================================
   * Derived Variables (using theme variables above)
   * =========================================== */

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 6px;
  --spacing-md: 8px;

  /* Typography */
  --font-size-base: var(--font-size);
  --font-size-small: calc(var(--font-size) - 1px);

  /* Backgrounds */
  --input-background: var(--editor-background);
  --input-background-muted: var(--card-background);
  --hover-background: var(--card-background);
  --hover-background-muted: var(--card-background);

  /* Borders */
  --border-color: var(
    --input-border,
    color-mix(in srgb, var(--foreground) 20%, var(--sidebar-background))
  );
  --border-color-muted: color-mix(
    in oklab,
    var(--border-color) 80%,
    var(--sidebar-background)
  );
  --focus-border-color: var(--focus-border);

  /* Padding combinations */
  --padding-button: var(--spacing-xs) var(--spacing-md);
  --padding-button-compact: var(--spacing-xs) var(--spacing-sm);
}

/* Use theme variables */
body {
  margin: 0;
  padding: 0;
  color: var(--foreground);
  background-color: var(--sidebar-background);
  font-family: var(--font-family);
  font-size: var(--font-size);
  overflow: hidden;
}

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

/* Input Bar Wrapper */
.input-bar-wrapper {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  margin: var(--spacing-md);
  flex-shrink: 0;
}

/* Input Container */
.input-container {
  padding: var(--spacing-sm);
  background-color: var(--input-background);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  cursor: text;
}

.input-container:focus-within {
  background-color: var(--input-background);
  border-color: var(--focus-border-color);
}

.input-divider {
  height: 1px;
  background-color: var(--border-color);
  flex-shrink: 0;
}

.prompt-input {
  width: 100%;
  min-height: 36px;
  max-height: 120px;
  padding: 0;
  border: none;
  border-radius: 0;
  background-color: transparent;
  color: var(--input-foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 20px;
  resize: none;
  outline: none;
  box-sizing: border-box;
  overflow-y: auto;
}

.prompt-input:focus {
  outline: none;
}

.prompt-input:focus-visible {
  outline: none;
}

.prompt-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.prompt-input::placeholder {
  color: var(--input-placeholder-foreground);
}

/* Button row below input */
.input-buttons {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--spacing-md);
}

.shortcut-button {
  padding: 4px 6px;
  border: none;
  border-radius: 3px;
  background-color: transparent;
  color: var(--input-foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-small);
  cursor: pointer;
  opacity: 0.5;
  line-height: 1;
  user-select: none;
  min-height: 20px;
}

.shortcut-button:hover:not(:disabled) {
  opacity: 1;
  background-color: var(--hover-background);
}

.shortcut-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.shortcut-button:focus-visible {
  outline: 2px solid var(--focus-border);
  outline-offset: 1px;
}

.shortcut-button--secondary {
  border: none;
  background-color: var(--button-secondary-background);
  color: var(--button-secondary-foreground);
  opacity: 0.8;
}

.shortcut-button--secondary:hover:not(:disabled) {
  opacity: 1;
  background-color: var(--button-secondary-hover-background);
}

.shortcut-button--stop {
  border: none;
  background-color: var(--button-secondary-background);
  color: var(--button-secondary-foreground);
  opacity: 0.8;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shortcut-button--stop:hover {
  opacity: 1;
  background-color: var(--button-secondary-hover-background);
}

.shortcut-button--stop svg {
  width: 8px;
  height: 8px;
}

.shortcut-button--queue {
  border: none;
  background-color: var(--button-secondary-background);
  color: var(--button-secondary-foreground);
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.shortcut-button--queue:hover:not(:disabled) {
  opacity: 1;
  background-color: var(--button-secondary-hover-background);
}

.shortcut-button--queue .queue-label {
  font-size: var(--font-size-small);
}

/* Queued Messages */
.queued-messages {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.queued-message {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  background-color: var(--card-background);
  border: 1px solid var(--border-color-muted);
  border-radius: 4px;
  cursor: pointer;
}

.queued-message:hover {
  background-color: var(--hover-background);
  border-color: var(--border-color);
}

.queued-message__text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-size-small);
  color: var(--description-foreground);
}

.queued-message__remove {
  flex-shrink: 0;
  padding: 2px;
  border: none;
  background: transparent;
  color: var(--description-foreground);
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
}

.queued-message__remove:hover {
  color: var(--foreground);
  background-color: var(--hover-background);
}

/* Loading Indicator */
.loading-indicator {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: var(--font-size-base);
  color: var(--description-foreground);
  padding: var(--spacing-md);
  user-select: none;
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow: auto;
  position: relative;
  height: 100%;
  max-height: 100%;
  scroll-padding: var(--spacing-md);
  padding: var(--spacing-md);
  overscroll-behavior: contain;
}

.messages-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Message Styles */
.message {
  width: 100%;
}

.message--user .message-content {
  width: 100%;
  padding: var(--padding-button);
  background-color: var(--input-background);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--description-foreground);
  line-height: 20px;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  transition: color 0.15s ease-in-out;
}

.message--user .message-content:hover {
  color: var(--input-foreground);
}

.message--assistant .message-content {
  background-color: transparent;
  color: var(--foreground);
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-content a {
  color: var(--text-link-foreground);
  text-decoration: none;
}

.message-content a:hover {
  color: var(--text-link-active-foreground);
  text-decoration: underline;
}

.message-content code {
  font-family: var(--editor-font-family);
  background-color: var(--text-code-block-background);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 0 3px;
}

.message-content pre {
  font-family: ui-monospace, monospace;
}

/* Scrollbar styling */
.messages-container::-webkit-scrollbar {
  width: 10px;
}

.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
  background: var(--scrollbar-slider-background);
  border-radius: 5px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-slider-hover-background);
}

.messages-container::-webkit-scrollbar-thumb:active {
  background: var(--scrollbar-slider-active-background);
}

/* Tool Call Styles */
.tool-call {
  border: 1px solid var(--border-color-muted);
  border-radius: 4px;
  background-color: var(--input-background-muted);
  font-size: var(--font-size-base);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tool-call--needs-permission {
  border: 1px solid light-dark(rgba(255, 165, 0, 0.18), rgba(255, 165, 0, 0.15));
  outline: none;
}

.tool-call--needs-permission:focus {
  border: 1px solid light-dark(rgba(255, 165, 0, 0.18), rgba(255, 165, 0, 0.15));
  outline: none;
}

.tool-call-light {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 0;
  font-size: var(--font-size-base);
  font-weight: 500;
  color: color-mix(in oklab, var(--foreground) 60%, transparent);
}

.tool-header {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  padding: var(--spacing-xs);
}

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

.tool-text {
  flex: 1;
  color: var(--foreground);
  font-size: var(--font-size-base);
  line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-text--bash {
  font-size: var(--font-size-small);
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
}

.tool-file-path {
  display: flex;
  overflow: hidden;
}

.tool-file-dir {
  color: color-mix(in oklab, var(--foreground) 50%, transparent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
}

.tool-file-name {
  color: var(--foreground);
  white-space: nowrap;
  flex-shrink: 0;
}

.tool-diff-stats {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: var(--font-size-small);
  font-weight: 500;
  flex-shrink: 0;
  margin-left: auto;
}

.tool-diff-stats__additions {
  color: var(--git-added-foreground);
}

.tool-diff-stats__deletions {
  color: var(--git-deleted-foreground);
}

.tool-output-container {
  background-color: var(--text-code-block-background);
  border-top: 1px solid var(--border-color-muted);
}

.tool-output {
  margin: 0;
  padding: var(--spacing-md);
  background-color: transparent;
  border: none;
  border-radius: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--foreground);
  overflow-x: auto;
  white-space: pre-wrap;
  max-height: 160px;
  overflow-y: auto;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.tool-output--bash {
  font-size: var(--font-size-small);
}

.tool-content a {
  color: var(--text-link-foreground);
  text-decoration: none;
}

.tool-content a:hover {
  color: var(--text-link-active-foreground);
  text-decoration: underline;
}

.tool-error {
  color: var(--error-foreground);
  background-color: var(--input-validation-error-background);
  border-color: var(--input-validation-error-border);
}

/* Error Banner */
.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background-color: var(--input-validation-error-background);
  border-bottom: 1px solid var(--input-validation-error-border);
  color: var(--error-foreground);
  font-size: var(--font-size-small);
}

.error-banner__message {
  flex: 1;
  word-break: break-word;
}

.error-banner__dismiss {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--error-foreground);
  font-size: 16px;
  cursor: pointer;
  border-radius: 2px;
}

.error-banner__dismiss:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Tool Permission Buttons */
.tool-permission-buttons {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs);
  border-top: 1px solid var(--border-color-muted);
  background: repeating-linear-gradient(
    -45deg,
    light-dark(rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.25)),
    light-dark(rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.25)) 8px,
    light-dark(rgba(255, 165, 0, 0.3), rgba(255, 165, 0, 0.15)) 8px,
    light-dark(rgba(255, 165, 0, 0.3), rgba(255, 165, 0, 0.15)) 16px
  );
}

.permission-spacer {
  flex: 1;
}

.permission-button {
  display: inline-flex;
  align-items: center;
  padding: var(--padding-button);
  border: none;
  border-radius: 3px;
  font-family: var(--font-family);
  font-size: var(--font-size-small);
  cursor: default;
  line-height: 1;
  user-select: none;
  white-space: nowrap;
}

.permission-button--quiet {
  background-color: transparent;
  color: var(--foreground);
}

.permission-button--quiet:hover {
  background-color: var(--hover-background);
}

.permission-button--quiet:focus-visible {
  outline: 2px solid var(--focus-border);
  outline-offset: 1px;
}

.permission-button--primary {
  background-color: var(--button-secondary-background);
  color: var(--button-secondary-foreground);
}

.permission-button--primary:hover {
  background-color: var(--button-secondary-hover-background);
}

.permission-button--primary:focus-visible {
  outline: 2px solid var(--focus-border);
  outline-offset: 1px;
}

/* Reasoning Block */
.reasoning-block {
  display: inline;
  margin: 0;
  padding: 0;
}

.reasoning-block summary {
  display: inline;
  cursor: pointer;
  list-style: none;
  color: color-mix(in srgb, var(--foreground) 60%, transparent);
  font-size: var(--font-size-small);
  font-weight: 500;
  user-select: none;
}

.reasoning-block summary::-webkit-details-marker {
  display: none;
}

.reasoning-content {
  padding: var(--spacing-md) 12px;
  margin-top: var(--spacing-xs);
  background-color: var(--input-background-muted);
  border-left: 2px solid var(--border-color);
  color: var(--description-foreground);
  font-size: var(--font-size-small);
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Step Indicator */
.step-indicator {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md) 12px;
  margin: var(--spacing-xs) 0;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  background-color: var(--sidebar-background);
  color: var(--description-foreground);
  font-size: var(--font-size-small);
}

.step-icon {
  font-size: 14px;
}

.step-text {
  font-style: italic;
}

/* Theme-specific adjustments */
body.vscode-light {
  /* Light theme specific styles if needed */
}

body.vscode-dark {
  /* Dark theme specific styles if needed */
}

body.vscode-high-contrast {
  /* High contrast specific styles */
}

/* Agent Switcher */
.agent-switcher-button {
  padding: var(--padding-button-compact);
  border: none;
  border-radius: 3px;
  background-color: transparent;
  color: var(--foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-small);
  cursor: pointer;
  opacity: 0.6;
  white-space: nowrap;
  box-sizing: border-box;
}

.agent-switcher-button:hover {
  opacity: 1;
  background-color: var(--hover-background);
}

.agent-switcher-button:focus-visible {
  outline: 2px solid var(--focus-border);
  outline-offset: 1px;
}

/* Top Bar Styles */
.top-bar {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--sidebar-background);
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}

/* Session Switcher */
.session-switcher {
  flex: 1;
  min-width: 0;
  position: relative;
}

.session-switcher-button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-xs);
  padding: var(--padding-button-compact);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--input-background-muted);
  color: color-mix(in oklab, var(--foreground) 80%, var(--sidebar-background));
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  user-select: none;
  box-sizing: border-box;
}

.session-switcher-button:hover:not(:disabled),
.session-switcher-button:active:not(:disabled),
.session-switcher-button.active:not(:disabled) {
  background-color: var(--hover-background);
  color: var(--foreground);
  border-color: var(--border-color);
}

.session-switcher-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.session-switcher-button:focus-visible {
  outline: 1px solid var(--focus-border);
  outline-offset: 0;
}

.session-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-bottom: 1px;
  font-family: var(--font-family);
  font-size: var(--font-size-small);
  font-weight: 500;
  /* To align with the session dropdown rows */
  border-left: 2px solid transparent;
}

.dropdown-arrow {
  font-size: 10px;
  opacity: 0.7;
  margin-left: var(--spacing-md);
  flex-shrink: 0;
}

/* Session Dropdown */
.session-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--input-background);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  z-index: 1000;
}

.session-dropdown:focus-visible {
  outline: 1px solid var(--focus-border);
  outline-offset: 0;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  cursor: pointer;
  border-bottom: 1px solid var(--border-color-muted);
  border-left: 2px solid transparent;
  background-color: transparent;
  color: color-mix(in oklab, var(--foreground) 80%, var(--input-background));
}

.session-item:last-child {
  border-bottom: none;
}

.session-item:hover {
  background-color: var(--hover-background);
  color: var(--foreground);
}

.session-item.selected {
  background-color: var(--hover-background);
  color: var(--foreground);
  border-left-color: var(--focus-border);
}

.session-item-title {
  font-family: var(--font-family);
  font-size: var(--font-size-small);
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-bottom: 1px;
}

.session-item-time {
  font-size: var(--font-size-small);
  opacity: 0.7;
  margin-left: var(--spacing-md);
  flex-shrink: 0;
}

/* New Session Button */
.new-session-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: var(--spacing-md);
  border: 1px solid transparent;
  border-radius: 4px;
  background-color: transparent;
  color: var(--input-foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  flex: 0;
  line-height: 1;
  opacity: 0.7;
}

.new-session-button:hover {
  background-color: var(--hover-background);
  opacity: 1;
}

.new-session-button:focus-visible {
  outline: 1px solid var(--focus-border);
  outline-offset: 0;
  border-color: transparent;
}

/* Input Status Row */
.input-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-sm) 10px 0;
  margin: 0;
  flex-shrink: 0;
}

/* File Changes Summary */
.file-changes-summary {
  font-family: var(--font-family);
  font-size: var(--font-size-small);
  color: var(--description-foreground);
  user-select: none;
  line-height: 12px;
}

.file-changes-summary__additions {
  color: var(--git-added-foreground);
}

.file-changes-summary__deletions {
  color: var(--git-deleted-foreground);
}

/* Context Indicator */
.context-indicator {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-shrink: 0;
  margin-left: auto;
}

.context-indicator__ring {
  flex-shrink: 0;
  width: 11px;
  height: 11px;
  display: block;
}

.context-indicator__ring-bg {
  stroke: color-mix(in srgb, var(--foreground) 15%, transparent);
}

.context-indicator__ring-progress {
  transition: stroke-dashoffset 0.3s ease-in-out, stroke 0.3s ease-in-out;
}

.context-indicator__text {
  font-family: var(--font-family);
  font-size: var(--font-size-small);
  color: var(--description-foreground);
  font-weight: 500;
  user-select: none;
  line-height: 12px;
  font-variant-numeric: tabular-nums;
}

/* Markdown Styles */
.message-text {
  line-height: 1.6;
}

.user-message-text {
  margin: 0;
  font-family: inherit;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message-text > *:first-child {
  margin-top: 0;
}

.message-text > *:last-child {
  margin-bottom: 0;
}

.message-text p {
  margin: 0.5em 0;
}

.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
  margin: 1em 0 0.5em 0;
  font-weight: 560;
  line-height: 1.3;
}

.message-text h1 {
  font-size: 1.5em;
}
.message-text h2 {
  font-size: 1.3em;
}
.message-text h3 {
  font-size: 1.1em;
}
.message-text h4 {
  font-size: 1em;
}
.message-text h5 {
  font-size: 0.95em;
}
.message-text h6 {
  font-size: 0.9em;
}

.message-text ul,
.message-text ol {
  margin: 0.5em 0;
  padding-left: 1.1em;
}

.message-text li {
  margin: 0.25em 0;
}

.message-text li > p {
  margin: 0.25em 0;
}

.message-text blockquote {
  margin: 0.5em 0;
  padding: 0.25em 0 0.25em 1em;
  border-left: 3px solid var(--text-blockquote-border);
  color: var(--text-blockquote-foreground);
  background-color: var(--text-blockquote-background);
}

.message-text blockquote > *:first-child {
  margin-top: 0;
}

.message-text blockquote > *:last-child {
  margin-bottom: 0;
}

.message-text hr {
  margin: 1em 0;
  border: none;
  border-top: 1px solid var(--panel-border);
}

.message-text pre {
  margin: 0.5em 0;
  padding: 0.75em;
  background-color: var(--text-code-block-background);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  overflow-x: auto;
  font-family: var(--editor-font-family);
  font-size: 0.9em;
  line-height: 1.4;
}

.message-text pre code {
  background-color: transparent;
  border: none;
  padding: 0;
  font-size: inherit;
}

.message-text code {
  font-family: var(--editor-font-family);
  font-size: 0.9em;
  background-color: var(--text-code-block-background);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 0.1em 0.3em;
}

.message-text a {
  color: var(--text-link-foreground);
  text-decoration: none;
}

.message-text a:hover {
  color: var(--text-link-active-foreground);
  text-decoration: underline;
}

.message-text strong {
  font-weight: 560;
}

.message-text em {
  font-style: italic;
}

.message-text del {
  text-decoration: line-through;
}

.message-text table {
  margin: 0.5em 0;
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9em;
}

.message-text th,
.message-text td {
  padding: 0.5em 0.75em;
  border: 1px solid var(--panel-border);
  text-align: left;
}

.message-text th {
  background-color: var(--card-background);
  font-weight: 600;
}

.message-text tr:nth-child(even) td {
  background-color: var(--card-background);
}

.message-text img {
  max-width: 100%;
  height: auto;
}

.message-text input[type="checkbox"] {
  margin-right: 0.5em;
  vertical-align: middle;
}

/* Diff Viewer */
.diff-viewer {
  font-family: var(--editor-font-family);
  font-size: var(--font-size-small);
  line-height: 1.4;
  overflow-x: auto;
  max-height: 300px;
  overflow-y: auto;
  min-width: fit-content;
}

.diff-line-range {
  padding: 2px var(--spacing-md);
  color: var(--editor-line-number-foreground);
  font-size: var(--font-size-small);
  user-select: none;
}

.diff-line-range-num {
  opacity: 0.7;
}

.diff-line {
  display: flex;
  white-space: pre;
  min-width: 100%;
}

.diff-line--add {
  background-color: var(--diff-inserted-line-background);
}

.diff-line--remove {
  background-color: var(--diff-removed-line-background);
}

.diff-line--context {
  background-color: transparent;
}

.diff-line-sign {
  display: inline-block;
  width: 2ch;
  padding-left: var(--spacing-xs);
  text-align: center;
  flex-shrink: 0;
  font-weight: 600;
}

.diff-line--add .diff-line-sign {
  color: var(--git-added-foreground);
}

.diff-line--remove .diff-line-sign {
  color: var(--git-deleted-foreground);
}

.diff-line-content {
  flex: 1;
}

/* Message wrapper for editing state */
.message-wrapper {
  transition: opacity 0.2s ease-in-out;
}

.message-wrapper--dimmed {
  opacity: 0.4;
  pointer-events: none;
}

/* Editable User Message */
.editable-message {
  padding: var(--spacing-sm);
  background-color: var(--input-background);
  border: 1px solid var(--focus-border-color);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  cursor: text;
}

.editable-message__input {
  width: 100%;
  min-height: 36px;
  max-height: 200px;
  padding: 0;
  border: none;
  border-radius: 0;
  background-color: transparent;
  color: var(--input-foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 20px;
  resize: none;
  outline: none;
  box-sizing: border-box;
  overflow-y: auto;
}

.editable-message__input:focus {
  outline: none;
}

.editable-message__actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--spacing-md);
}

.editable-message__cancel {
  padding: var(--padding-button);
  border: none;
  border-radius: 3px;
  background-color: transparent;
  color: var(--description-foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-small);
  cursor: pointer;
  line-height: 1;
  user-select: none;
}

.editable-message__cancel:hover {
  color: var(--foreground);
  background-color: var(--hover-background);
}
