/**
 * Agent Frontend - Chat Widget Styles
 * Embeddable chat widget CSS - works standalone without any framework dependencies.
 *
 * CSS Isolation:
 * - All classes prefixed with 'cw-' to avoid conflicts
 * - CSS variables scoped to .cw-container
 * - Uses 'all: initial' to reset inherited styles
 * - High z-index to stay above host page content
 */

/* Container - resets all inherited styles and scopes CSS variables */
.cw-container {
  /* Reset all inherited styles */
  all: initial;

  /* CSS Variables scoped to widget */
  --cw-primary: #0066cc;
  --cw-bg: #ffffff;
  --cw-bg-muted: #f5f5f5;
  --cw-text: #1a1a1a;
  --cw-text-muted: #666666;
  --cw-border: #e0e0e0;
  --cw-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  --cw-radius: 12px;
  --cw-radius-sm: 8px;

  /* Positioning */
  position: fixed;
  z-index: 99999;

  /* Typography baseline */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cw-text);

  /* Ensure text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ensure all children inherit from container, not host page */
.cw-container *,
.cw-container *::before,
.cw-container *::after {
  box-sizing: border-box;
}

.cw-position-bottom-right {
  bottom: 24px;
  right: 24px;
}

.cw-position-bottom-left {
  bottom: 24px;
  left: 24px;
}

/* Floating Action Button */
.cw-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--cw-shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  color: white;
}

.cw-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

.cw-icon {
  width: 24px;
  height: 24px;
}

.cw-icon-sm {
  width: 16px;
  height: 16px;
}

/* Widget container */
.cw-widget {
  width: 380px;
  height: 500px;
  background: var(--cw-bg);
  border-radius: var(--cw-radius);
  box-shadow: var(--cw-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.2s ease;
}

.cw-widget-expanded {
  width: 600px;
  height: 80vh;
  max-height: 800px;
}

/* Header */
.cw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  color: white;
  border-radius: var(--cw-radius) var(--cw-radius) 0 0;
}

.cw-title {
  font-weight: 600;
  font-size: 15px;
}

.cw-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cw-header-btn {
  background: transparent;
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  font-size: 14px;
}

.cw-header-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.cw-header-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cw-btn-active {
  background: rgba(255, 255, 255, 0.3);
}

.cw-icon-warning {
  color: #ffd700;
}

.cw-btn-speaking {
  animation: pulse-speaking 1.5s ease-in-out infinite;
}

@keyframes pulse-speaking {
  0%, 100% {
    background: rgba(255, 255, 255, 0.3);
  }
  50% {
    background: rgba(255, 255, 255, 0.5);
  }
}

/* Voice Settings */
.cw-voice-settings {
  background: var(--cw-bg-muted);
  border-bottom: 1px solid var(--cw-border);
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    max-height: 0;
    opacity: 0;
  }
  to {
    max-height: 200px;
    opacity: 1;
  }
}

.cw-voice-settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cw-text);
  border-bottom: 1px solid var(--cw-border);
}

.cw-voice-settings-close {
  all: initial;
  font-family: inherit;
  background: none;
  border: none;
  color: var(--cw-text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}

.cw-voice-settings-close:hover {
  color: var(--cw-text);
}

.cw-voice-settings-content {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cw-voice-setting {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cw-voice-setting label {
  font-size: 12px;
  font-weight: 500;
  color: var(--cw-text-muted);
}

.cw-voice-select {
  all: initial;
  font-family: inherit;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--cw-border);
  border-radius: 6px;
  background: var(--cw-bg);
  color: var(--cw-text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.cw-voice-select:hover {
  border-color: var(--cw-primary);
}

.cw-voice-select:focus {
  outline: none;
  border-color: var(--cw-primary);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

/* Status bar */
.cw-status-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 4px 16px;
  background: var(--cw-bg-muted);
  color: var(--cw-text-muted);
  font-size: 12px;
  border-bottom: 1px solid var(--cw-border);
}

/* Messages area */
.cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Empty state */
.cw-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--cw-text-muted);
  padding: 24px;
}

.cw-empty-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.cw-empty-state h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--cw-text);
}

.cw-empty-state p {
  margin: 0;
  font-size: 13px;
}

/* Message rows */
.cw-message-row {
  display: flex;
  justify-content: flex-start;
}

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

/* Messages */
.cw-message {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--cw-radius-sm);
  background: var(--cw-bg-muted);
  color: var(--cw-text);
  word-wrap: break-word;
}

.cw-message-user {
  background: var(--cw-primary);
  color: white;
}

.cw-message-tool-call {
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
  border: 1px solid rgba(59, 130, 246, 0.2);
  font-family: monospace;
  font-size: 12px;
}

.cw-message-tool-result {
  background: rgba(34, 197, 94, 0.1);
  color: #15803d;
  border: 1px solid rgba(34, 197, 94, 0.2);
  font-family: monospace;
  font-size: 12px;
}

.cw-message-error {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.cw-tool-args {
  margin: 8px 0 0 0;
  padding: 8px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  font-size: 11px;
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Compact inline tool messages */
.cw-tool-message {
  padding: 6px 12px;
  margin: 4px 16px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  border-radius: 6px;
}

.cw-tool-message.cw-tool-call {
  background: rgba(59, 130, 246, 0.08);
  color: #2563eb;
  border-left: 3px solid #3b82f6;
}

.cw-tool-message.cw-tool-result {
  background: rgba(34, 197, 94, 0.08);
  color: #16a34a;
  border-left: 3px solid #22c55e;
}

.cw-tool-label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cw-tool-expand {
  font-size: 10px;
  opacity: 0.6;
}

.cw-tool-details {
  margin: 8px 0 0 0;
  padding: 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 4px;
  font-size: 11px;
  overflow-x: auto;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

/* Markdown styles in messages */
.cw-message a {
  color: inherit;
  text-decoration: underline;
}

.cw-message a:hover {
  text-decoration: none;
}

.cw-message code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 4px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 12px;
}

.cw-message strong {
  font-weight: 600;
}

.cw-message ul, .cw-message ol {
  margin: 8px 0;
  padding-left: 20px;
}

.cw-message li {
  margin: 4px 0;
}

/* Typing indicator */
.cw-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--cw-bg-muted);
  border-radius: var(--cw-radius-sm);
  color: var(--cw-text-muted);
  font-size: 13px;
}

/* Spinner */
.cw-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: cw-spin 0.75s linear infinite;
}

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

/* Load more messages indicator */
.cw-load-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  margin: 8px 16px;
  background: var(--cw-bg-muted);
  border-radius: var(--cw-radius-sm);
  color: var(--cw-text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border: 1px dashed var(--cw-border);
}

.cw-load-more:hover {
  background: var(--cw-border);
}

.cw-load-more .cw-spinner {
  width: 14px;
  height: 14px;
}

/* Error bar */
.cw-error-bar {
  padding: 8px 16px;
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  font-size: 13px;
  border-top: 1px solid rgba(239, 68, 68, 0.2);
}

/* Input form */
.cw-input-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--cw-border);
  background: var(--cw-bg);
}

.cw-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--cw-border);
  border-radius: var(--cw-radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  resize: none;
  min-height: 40px;
  max-height: 150px;
  line-height: 1.4;
  font-family: inherit;
}

.cw-input:focus {
  border-color: var(--cw-primary);
}

.cw-input:disabled {
  background: var(--cw-bg-muted);
  cursor: not-allowed;
}

.cw-send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--cw-radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  transition: background-color 0.15s, opacity 0.15s;
}

.cw-send-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.cw-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Loading state - clickable to cancel */
.cw-send-btn.cw-send-btn-loading {
  cursor: pointer;
  opacity: 1;
}

.cw-send-btn.cw-send-btn-loading:hover {
  opacity: 1;
}

/* Stop button state on hover */
.cw-send-btn.cw-send-btn-stop {
  background-color: #dc2626 !important;
}

/* Dropdown */
.cw-dropdown {
  position: relative;
}

.cw-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 200px;
  background: var(--cw-bg);
  border: 1px solid var(--cw-border);
  border-radius: var(--cw-radius-sm);
  box-shadow: var(--cw-shadow);
  z-index: 100;
  overflow: hidden;
}

.cw-dropdown-hidden {
  display: none;
}

.cw-dropdown-label {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--cw-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cw-dropdown-separator {
  height: 1px;
  background: var(--cw-border);
  margin: 4px 0;
}

.cw-dropdown-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 14px;
  color: var(--cw-text);
  cursor: pointer;
  transition: background 0.15s;
}

.cw-dropdown-item:hover {
  background: var(--cw-bg-muted);
}

.cw-dropdown-item-danger {
  color: #dc2626;
}

.cw-dropdown-item-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Auto-run controls */
.cw-autorun-controls {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cw-control-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--cw-text);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.15s;
}

.cw-control-label:hover {
  background: var(--cw-bg-muted);
}

.cw-control-label input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

.cw-delay-control {
  padding: 8px 12px;
}

.cw-delay-control input[type="range"] {
  width: 100%;
  margin-top: 4px;
  cursor: pointer;
}

/* Continue button */
.cw-continue-bar {
  padding: 12px 16px;
  background: var(--cw-bg-muted);
  border-top: 1px solid var(--cw-border);
  display: flex;
  justify-content: center;
}

.cw-continue-btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--cw-radius-sm);
  background: var(--cw-primary);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cw-continue-btn:hover {
  opacity: 0.9;
}

.cw-continue-btn:active {
  opacity: 0.8;
}

/* Responsive */
@media (max-width: 480px) {
  .cw-widget {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    max-height: none;
  }

  .cw-widget-expanded {
    width: calc(100vw - 16px);
    height: calc(100vh - 32px);
  }

  .cw-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .cw-position-bottom-left {
    right: 16px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --cw-bg: #1a1a1a;
    --cw-bg-muted: #2a2a2a;
    --cw-text: #f0f0f0;
    --cw-text-muted: #999999;
    --cw-border: #3a3a3a;
  }

  .cw-message-tool-call {
    color: #93c5fd;
  }

  .cw-message-tool-result {
    color: #86efac;
  }

  .cw-message code {
    background: rgba(255, 255, 255, 0.1);
  }

  .cw-tool-args {
    background: rgba(255, 255, 255, 0.05);
  }
}

/* Enhanced Markdown Styles (for chat-widget-markdown.js) */
.cw-message pre {
  background: var(--cw-bg-muted);
  border: 1px solid var(--cw-border);
  border-radius: var(--cw-radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.4;
}

.cw-message pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

.cw-message table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}

.cw-message table th,
.cw-message table td {
  border: 1px solid var(--cw-border);
  padding: 8px 12px;
  text-align: left;
}

.cw-message table th {
  background: var(--cw-bg-muted);
  font-weight: 600;
}

.cw-message table tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

.cw-message blockquote {
  border-left: 3px solid var(--cw-primary);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--cw-text-muted);
  font-style: italic;
}

.cw-message h1,
.cw-message h2,
.cw-message h3,
.cw-message h4,
.cw-message h5,
.cw-message h6 {
  margin: 12px 0 8px 0;
  font-weight: 600;
  line-height: 1.3;
}

.cw-message h1 { font-size: 1.5em; }
.cw-message h2 { font-size: 1.3em; }
.cw-message h3 { font-size: 1.1em; }
.cw-message h4 { font-size: 1em; }

.cw-message hr {
  border: none;
  border-top: 1px solid var(--cw-border);
  margin: 12px 0;
}

.cw-message ul,
.cw-message ol {
  margin: 8px 0;
  padding-left: 24px;
}

.cw-message li {
  margin: 4px 0;
}

.cw-message p {
  margin: 8px 0;
}

.cw-message p:first-child {
  margin-top: 0;
}

.cw-message p:last-child {
  margin-bottom: 0;
}

/* Dark mode adjustments for enhanced markdown */
@media (prefers-color-scheme: dark) {
  .cw-message pre {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
  }

  .cw-message table th {
    background: rgba(255, 255, 255, 0.05);
  }

  .cw-message table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
  }

  .cw-message table th,
  .cw-message table td {
    border-color: rgba(255, 255, 255, 0.1);
  }
}

/* ============================================================================
   Embedded Mode Styles
   ============================================================================ */

/* Container for embedded widgets */
.cw-container-embedded {
  all: initial;
  position: relative;
  width: 100%;
  height: 100%;
  display: block;

  /* Typography baseline */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cw-text);

  /* CSS Variables */
  --cw-primary: #0066cc;
  --cw-bg: #ffffff;
  --cw-bg-muted: #f5f5f5;
  --cw-text: #1a1a1a;
  --cw-text-muted: #666666;
  --cw-border: #e0e0e0;
  --cw-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  --cw-radius: 12px;
  --cw-radius-sm: 8px;
}

.cw-container-embedded *,
.cw-container-embedded *::before,
.cw-container-embedded *::after {
  box-sizing: border-box;
}

/* Embedded widget fills its container */
.cw-widget-embedded {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  border-radius: 0;
  box-shadow: none;
}

/* Embedded widget header can have rounded corners if desired */
.cw-widget-embedded .cw-header {
  border-radius: 0;
}

/* Ensure messages area fills available space */
.cw-widget-embedded .cw-messages {
  flex: 1;
  min-height: 0;
}

/* ============================================================================
   Conversation Sidebar Styles
   ============================================================================ */

/* Hamburger menu button */
.cw-hamburger {
  margin-right: 8px;
}

.cw-hamburger svg {
  stroke: currentColor;
}

/* Sidebar overlay */
.cw-sidebar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 10;
}

.cw-sidebar-overlay-visible {
  opacity: 1;
  visibility: visible;
}

/* Sidebar panel */
.cw-sidebar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 80%;
  background: var(--cw-bg);
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 20;
  display: flex;
  flex-direction: column;
}

.cw-sidebar-open {
  transform: translateX(0);
}

/* Sidebar header */
.cw-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--cw-border);
  font-weight: 600;
  font-size: 15px;
  color: var(--cw-text);
}

.cw-sidebar-close {
  all: initial;
  font-family: inherit;
  background: none;
  border: none;
  color: var(--cw-text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.cw-sidebar-close:hover {
  background: var(--cw-bg-muted);
  color: var(--cw-text);
}

/* New conversation button */
.cw-new-conversation {
  all: initial;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 16px;
  padding: 10px 16px;
  background: var(--cw-primary);
  color: white;
  border: none;
  border-radius: var(--cw-radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.cw-new-conversation:hover {
  opacity: 0.9;
}

/* Conversation list */
.cw-conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.cw-sidebar-loading,
.cw-sidebar-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  color: var(--cw-text-muted);
  font-size: 13px;
}

/* Conversation item */
.cw-conversation-item {
  display: block;
  padding: 12px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.cw-conversation-item:hover {
  background: var(--cw-bg-muted);
}

.cw-conversation-active {
  background: var(--cw-bg-muted);
  border-left-color: var(--cw-primary);
}

.cw-conversation-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--cw-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.cw-conversation-date {
  font-size: 12px;
  color: var(--cw-text-muted);
}

/* Dark mode for sidebar */
@media (prefers-color-scheme: dark) {
  .cw-sidebar {
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
  }

  .cw-sidebar-overlay {
    background: rgba(0, 0, 0, 0.5);
  }
}

/* ============================================================================
   Model Selector
   ============================================================================ */

.cw-model-selector {
  position: relative;
  padding: 8px 12px;
  border-top: 1px solid var(--cw-border);
  background: var(--cw-bg-muted);
}

.cw-model-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: var(--cw-bg);
  border: 1px solid var(--cw-border);
  border-radius: var(--cw-radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--cw-text);
  transition: all 0.2s ease;
}

.cw-model-btn:hover {
  border-color: var(--cw-primary);
  background: var(--cw-bg);
}

.cw-model-icon {
  font-size: 16px;
}

.cw-model-name {
  flex: 1;
  text-align: left;
  font-weight: 500;
}

.cw-model-chevron {
  font-size: 10px;
  color: var(--cw-text-muted);
}

.cw-model-dropdown {
  position: absolute;
  bottom: 100%;
  left: 12px;
  right: 12px;
  margin-bottom: 4px;
  background: var(--cw-bg);
  border: 1px solid var(--cw-border);
  border-radius: var(--cw-radius-sm);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  max-height: 300px;
  overflow-y: auto;
  z-index: 10;
}

.cw-model-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--cw-border);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.cw-model-option:last-child {
  border-bottom: none;
}

.cw-model-option:hover {
  background: var(--cw-bg-muted);
}

.cw-model-option-selected {
  background: rgba(0, 102, 204, 0.1);
}

.cw-model-option-selected:hover {
  background: rgba(0, 102, 204, 0.15);
}

.cw-model-option-name {
  font-weight: 500;
  font-size: 13px;
  color: var(--cw-text);
}

.cw-model-option-provider {
  font-size: 11px;
  color: var(--cw-text-muted);
  text-transform: capitalize;
}

.cw-model-option-desc {
  font-size: 11px;
  color: var(--cw-text-muted);
  margin-top: 2px;
}

/* ============================================================================
   Tool Call Cards (Claude-style)
   ============================================================================ */

.cw-tool-card {
  background: var(--cw-bg);
  border: 1px solid var(--cw-border);
  border-radius: var(--cw-radius-sm);
  margin: 8px 0;
  overflow: hidden;
}

.cw-tool-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--cw-bg-muted);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.cw-tool-header:hover {
  background: #e8e8e8;
}

.cw-tool-icon {
  font-size: 14px;
  display: flex;
  align-items: center;
}

.cw-tool-name {
  flex: 1;
  font-weight: 500;
  font-size: 13px;
  color: var(--cw-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.cw-tool-status {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
}

.cw-tool-running {
  background: #fef3c7;
  color: #92400e;
}

.cw-tool-complete {
  background: #d1fae5;
  color: #065f46;
}

.cw-tool-chevron {
  font-size: 10px;
  color: var(--cw-text-muted);
  transition: transform 0.2s ease;
}

.cw-tool-body {
  border-top: 1px solid var(--cw-border);
  padding: 12px;
}

.cw-tool-section {
  margin-bottom: 12px;
}

.cw-tool-section:last-child {
  margin-bottom: 0;
}

.cw-tool-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--cw-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.cw-tool-code {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  max-height: 200px;
  overflow-y: auto;
}

.cw-spinner-small {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid #e5e7eb;
  border-top-color: var(--cw-primary);
  border-radius: 50%;
  animation: cw-spin 0.8s linear infinite;
}

/* Debug payload viewer */
.cw-debug-payload-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: rgba(0, 0, 0, 0.1);
  color: #666;
  font-size: 10px;
  font-family: monospace;
  border-radius: 3px;
  cursor: pointer;
  opacity: 0.3;
  transition: opacity 0.15s;
}

.cw-debug-payload-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.2);
}

.cw-debug-payload {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 100;
  width: 400px;
  max-width: 90vw;
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  margin-top: 4px;
}

.cw-debug-payload-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: #333;
  color: #999;
  font-size: 14px;
  line-height: 1;
  border-radius: 3px;
  cursor: pointer;
}

.cw-debug-payload-close:hover {
  background: #444;
  color: #fff;
}

.cw-debug-payload-content {
  margin: 0;
  padding: 12px;
  font-size: 11px;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  color: #d4d4d4;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
}
