/**
 * Chat component styles
 * Uses VS Code CSS variables for theming
 */

/* ============================================
   Chat View Layout
   ============================================ */

.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.chat-input {
  flex-shrink: 0;
  border-top: 1px solid var(--vscode-panel-border);
}

/* ============================================
   Message List
   ============================================ */

.message-list-container {
  position: relative;
  height: 100%;
}

.message-list {
  height: 100%;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--vscode-descriptionForeground);
  text-align: center;
  padding: 20px;
  gap: 20px;
}

.message-list-empty p {
  margin: 0;
}

/* ============================================
   Kilo Logo (empty state)
   ============================================ */

.kilo-logo {
  width: 48px;
  height: 48px;
  opacity: 0.85;
}

.kilo-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.kilo-about-text {
  max-width: 260px;
  font-size: 13px;
  line-height: 1.4;
}

/* ============================================
   Recent Sessions (empty state)
   ============================================ */

.recent-sessions {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 300px;
  gap: 4px;
}

.recent-sessions-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--vscode-descriptionForeground);
  padding: 0 8px 4px;
  text-align: left;
}

.recent-session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--vscode-foreground);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  gap: 8px;
}

.recent-session-item:hover {
  background: var(--vscode-list-hoverBackground);
}

.recent-session-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.recent-session-date {
  font-size: 11px;
  color: var(--vscode-descriptionForeground);
  white-space: nowrap;
  flex-shrink: 0;
}

.scroll-to-bottom-button {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--vscode-button-background);
  color: var(--vscode-button-foreground);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: background-color 0.2s;
}

.scroll-to-bottom-button:hover {
  background: var(--vscode-button-hoverBackground);
}

/* ============================================
   Prompt Input
   ============================================ */

.prompt-input-container {
  margin: 12px;
  border-radius: 0.25rem;
  background-color: var(--input-base, var(--vscode-input-background, #3c3c3c));
  border: 1px solid var(--border-weak-base, var(--vscode-input-border, #3c3c3c));
  box-shadow: none;

  &:focus-within {
    border-color: var(--border-focus, var(--vscode-focusBorder, #007fd4));
    box-shadow: none;
  }
}

.prompt-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.prompt-input {
  flex: 1;
  min-height: 54px;
  max-height: 200px;
  padding: 8px;
  color: var(--vscode-input-foreground);
  font-family: var(--vscode-font-family);
  font-size: 13px;
  line-height: 1.4;
  resize: none;
  outline: none;
}

.prompt-input:focus {
  border-color: var(--vscode-focusBorder);
}

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

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

/* Ghost text autocomplete overlay */
.prompt-input-ghost-wrapper {
  position: relative;
  flex: 1;
  min-width: 0;
}

.prompt-input-ghost-wrapper .prompt-input {
  position: relative;
  z-index: 1;
  background: transparent;
  width: 100%;
  box-sizing: border-box;
}

.prompt-input-ghost-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  padding: 8px 12px;
  font-family: var(--vscode-font-family);
  font-size: var(--vscode-font-size, 13px);
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: hidden;
  z-index: 0;
}

.prompt-input-ghost-text-hidden {
  visibility: hidden;
}

.prompt-input-ghost-text {
  color: var(--vscode-editorGhostText-foreground, rgba(255, 255, 255, 0.35));
}

.prompt-input-hint {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--vscode-descriptionForeground);
  padding: 6px;
}

.prompt-input-hint-selectors {
  display: flex;
  gap: 4px;

  [data-component="button"] {
    height: auto !important;
    min-height: 22px;
    padding: 4px 6px !important;
    font-size: 12px;
    line-height: normal;
    border-radius: 6px;
    background: var(--surface-base);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: none;
    opacity: 1;
    gap: 6px;
    white-space: nowrap;
    transition: all 150ms;
    color: var(--text-base, var(--vscode-foreground));

    &[data-expanded] {
      background: var(--surface-base-hover) !important;
      background-color: var(--surface-base-hover) !important;
    }

    &:hover:not(:disabled) {
      background: var(--surface-base-hover);
      background-color: var(--surface-base-hover);
    }

    &:focus-visible {
      outline: none;
      box-shadow: 0 0 0 1px var(--border-focus);
    }
  }
}

.prompt-input-hint-actions {
  display: flex;
  gap: 4px;

  [data-component="button"] {
    background: transparent;
    border: none;
    padding: 0;

    [data-slot="icon-svg"] {
      color: var(--icon-base);
    }

    [data-slot="progress-circle-background"] {
      stroke: var(--icon-base);
    }

    [data-slot="progress-circle-progress"] {
      stroke: var(--border-focus, var(--vscode-focusBorder, #007fd4));
    }
  }
  [data-component="icon-button"] {
    [data-slot="icon-svg"] {
      color: var(--icon-base) !important;
    }
  }
}

/* ============================================
   Model Selector (uses kilo-ui Popover)
   ============================================ */

.model-selector-popover {
  width: 300px;
  max-width: 300px;
}

.model-selector-trigger-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-selector-trigger-chevron {
  flex-shrink: 0;
}

.model-selector-search-wrapper {
  padding: 8px;
  border-bottom: 1px solid var(--border-base, var(--vscode-panel-border));
}

.model-selector-search {
  width: 100%;
  padding: 5px 8px;
  background: var(--vscode-input-background);
  color: var(--vscode-input-foreground);
  border: 1px solid var(--vscode-input-border);
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--vscode-font-family);
  outline: none;
  box-sizing: border-box;
}

.model-selector-search:focus {
  border-color: var(--vscode-focusBorder);
}

.model-selector-search::placeholder {
  color: var(--vscode-input-placeholderForeground);
}

.model-selector-list {
  overflow-y: auto;
  max-height: 300px;
  padding: 4px 0;
}

.model-selector-empty {
  padding: 12px 16px;
  color: var(--text-weak, var(--vscode-descriptionForeground));
  font-size: 12px;
  text-align: center;
}

.model-selector-group-label {
  padding: 6px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-weak, var(--vscode-descriptionForeground));
  user-select: none;
}

.model-selector-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.model-selector-item:hover,
.model-selector-item.active {
  background: var(--surface-interactive-hover, var(--vscode-list-hoverBackground));
}

.model-selector-item.selected {
  font-weight: 600;
}

.model-selector-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.model-selector-tag {
  flex-shrink: 0;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 3px;
  background: var(--vscode-badge-background);
  color: var(--vscode-badge-foreground);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ============================================
   Mode Switcher (uses kilo-ui Popover)
   ============================================ */

.mode-switcher-trigger-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: capitalize;
}

.mode-switcher-list {
  max-height: 280px;
  overflow-y: auto;
}

.mode-switcher-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
}

.mode-switcher-item:hover {
  background: var(--surface-interactive-hover, var(--vscode-list-hoverBackground));
}

.mode-switcher-item.selected {
  background: var(
    --surface-interactive-active,
    var(--vscode-list-activeSelectionBackground, var(--vscode-list-hoverBackground))
  );
}

.mode-switcher-item-name {
  font-weight: 500;
}

.mode-switcher-item-desc {
  font-size: 11px;
  color: var(--text-weak, var(--vscode-descriptionForeground));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================
   Permission Dock (patterns inside BasicTool)
   ============================================ */

.permission-dock-patterns {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
  padding: 8px 12px;
}

.permission-dock-pattern {
  font-size: 12px;
  font-family: var(--vscode-editor-font-family, monospace);
  color: var(--vscode-foreground);
  word-break: break-all;
}

/* ============================================
   Text Part Copy Button Fix
   In the sidebar, the text-part copy button overflows into the
   element above because the gap between messages is smaller.
   Position it inside the text body instead of above it.
   ============================================ */

[data-component="text-part"] [data-slot="text-part-body"] {
  margin-top: 8px;
}

[data-component="text-part"] [data-slot="text-part-copy-wrapper"] {
  top: 4px;
  right: 4px;
}

/* Dialog Confirmation */
.dialog-confirm-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 24px 12px 24px;
}

.dialog-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================================
   Working Indicator
   ============================================ */

.working-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--vscode-descriptionForeground);
}

.working-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.working-elapsed {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

/* Session List Items */
.session-list [data-slot="list-item-title"] {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.session-list [data-slot="list-item-description"] {
  flex-shrink: 0;
  margin-left: 8px;
  font-size: 12px;
  color: var(--text-weak, var(--vscode-descriptionForeground));
  white-space: nowrap;
}
