/* ============================================
   AI Chat Widget - Galactic Cyberpunk Style
   ============================================ */

/* Agents Chat Section - Now part of layout grid, directly contains ai-column-chat */

/* Agents Chat Section - Consolidated: Uses .flex-col utility (but keep overflow: visible) */
section.agents-chat,
.flex-col.section.agents-chat {
  min-height: 0;
  overflow: visible; /* Special case - not hidden */

  /* width from index.css: var(--agents-chat-width) to match #canvasUnifiedToolbar */
  box-sizing: border-box;
  padding: 0;
  gap: 0;

  /* display: flex; flex-direction: column; now from .flex-col */
}

/* Ensure ai-column-chat takes full width of section */
section.agents-chat > .ai-column-chat {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

/* Chat Layout - No longer an overlay */

/* Chat Layout - Consolidated: Uses .full-size-flex utility */
.ai-chat-overlay,
.full-size-flex.ai-chat-overlay {
  box-sizing: border-box;

  /* width: 100%; height: 100%; display: flex; flex-direction: column; overflow: hidden; min-height: 0; now from .full-size-flex */
}

/* Removed: .ai-chat-layout - No longer needed, section.agents-chat directly contains ai-column-chat */

.agents-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Consolidated: Uses .flex-row-center utility */
.agents-selector-wrapper,
.flex-row-center.agents-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.agents-select {
  flex: 1;
  padding: 9px 12px;

  /* OPTIMIZED: Removed backdrop-filter - nested form element doesn't need it */
  background: var(--space-opacity-80);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--text-primary);
  font-size: var(--font-12);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 6px var(--blue-opacity-10);
}

.agents-select:hover {
  border-color: var(--blue-opacity-50);
  background: rgb(0 153 255 / 5%);
  box-shadow: 0 0 12px var(--blue-opacity-20);
}

.agents-select:focus {
  outline: none;
  border-color: var(--blue-electric);
  box-shadow: 
    0 0 12px var(--blue-opacity-40),
    0 0 24px var(--blue-opacity-20);
  background: var(--blue-opacity-10);
}

/* Consolidated: Uses .flex-center and .flex-no-shrink utilities */
.ai-refresh-btn,
.flex-center/* Consolidated: Uses .flex-center and .flex-no-shrink utilities */
.ai-refresh-btn,
.flex-center.ai-refresh-btn,
.flex-no-shrink.ai-refresh-btn {
  padding: 9px;

  /* OPTIMIZED: Removed backdrop-filter - nested button doesn't need it */
  background: var(--space-opacity-80);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--text-secondary);
  cursor: pointer;

  /* display: flex; align-items: center; justify-content: center; now from .flex-center */
  transition: all 0.3s ease;

  /* flex-shrink: 0; now from .flex-no-shrink */
  box-shadow: 0 0 6px var(--blue-opacity-10);
}

.ai-refresh-btn:hover {
  background: var(--blue-opacity-10);
  color: var(--cyan-bright);
  border-color: var(--blue-electric);
  box-shadow: 0 0 12px var(--blue-opacity-40);
}

.ai-refresh-btn.spinning {
  animation: spin 1s linear infinite;
}

.agents-details {
  padding: 18px;
  border-radius: 12px;
  border: 2px solid var(--blue-opacity-30);

  /* OPTIMIZED: Removed backdrop-filter - nested element doesn't need it */
  background: var(--space-opacity-90);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 0 18px var(--blue-opacity-10);
}

.agents-details-empty {
  font-size: var(--font-12);
  color: var(--text-muted);
  text-align: center;
  padding: 18px;
}

.agents-details-content h4 {
  font-size: var(--font-18);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 12px;
  text-shadow: 0 0 9px var(--blue-opacity-30);
}

.agents-details-content .field-group {
  margin-bottom: 0.75rem;
}

.agents-details-content .field-group label {
  font-size: var(--font-9);
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.agents-details-content .badge {
  display: inline-block;
  padding: 6px 12px;
  background: var(--blue-opacity-15);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--cyan-bright);
  font-size: var(--font-9);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  box-shadow: 0 0 9px var(--blue-opacity-20);
}

/* Column 2: Chat Widget - Consolidated: Uses .flex-col and .flex-grow-shrink utilities */
.ai-column-chat,
.flex-col.ai-column-chat,
.flex-grow-shrink.ai-column-chat {
  /* display: flex; flex-direction: column; now from .flex-col */

  /* flex: 1 1 auto; min-width: 0; min-height: 0; now from .flex-grow-shrink */
  height: auto;
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              flex 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}


/* Consolidated: Uses .flex-col-hidden utility (but keep all height constraints, transitions, background patterns) */
.ai-chat-container,
.flex-col-hidden.ai-chat-container {
  /* display: flex; flex-direction: column; min-height: 0; overflow: hidden; now from .flex-col-hidden */
  height: 100%;
  min-height: 200px;
  max-height: min(600px, 70vh); /* Flexible height with viewport constraint */
  background: var(--space-mid-opacity-92);
  backdrop-filter: blur(18px) saturate(120%);
  border-radius: 12px;
  border: 2px solid var(--blue-opacity-30);
  box-shadow: 
    0 -18px 48px var(--black-opacity-70),
    0 0 36px var(--blue-opacity-15),
    inset 0 0 18px var(--blue-opacity-08),
    inset 0 1px 0 var(--green-opacity-10);
  position: relative;
  width: 100%;
  min-width: 0; /* Allow flex shrinking */
  max-width: 100%; /* Prevent overflow */
  box-sizing: border-box;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.3s ease;

  /* Subtle pattern overlay to complement canvas starfield */
  background-image: 
    radial-gradient(circle at 2px 2px, rgb(0 255 153 / 8%) 1px, transparent 0),
    radial-gradient(circle at 6px 6px, rgb(0 153 255 / 5%) 1px, transparent 0);
  background-size: 12px 12px, 18px 18px;
  background-position: 0 0, 0 0;
  background-blend-mode: overlay;

  /* OPTIMIZED: CSS containment - isolate chat container */
  contain: layout style paint;
}

/* Expanded state when messages are visible */
.ai-chat-container.has-messages {
  max-height: min(800px, 85vh);
  border-color: var(--blue-opacity-50);
}

.ai-chat-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgb(0 153 255 / 80%) 20%, 
    rgb(0 255 153 / 80%) 50%, 
    rgb(0 153 255 / 80%) 80%, 
    transparent 100%);
  opacity: 0.6;
  z-index: var(--z-base);
}

/* Chat Header */
.ai-chat-header {
  display: none; /* Header content moved to input area */
}

/* Consolidated: Uses .flex-grow-shrink utility */
.ai-chat-header-left,
.flex-grow-shrink.ai-chat-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;

  /* flex: 1 1 auto; min-width: 0; min-height: 0; now from .flex-grow-shrink */
  overflow: hidden;
}

/* Removed: .ai-chat-header-center - Context selector buttons removed (context now switches automatically) */

.agents-selector-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.agents-select-header {
  padding: 6px 10px;

  /* OPTIMIZED: Removed backdrop-filter - nested form element doesn't need it */
  background: var(--space-opacity-80);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--text-primary);
  font-size: var(--font-9);
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 140px;
  max-width: 200px;
  flex: 0 1 auto;
  box-shadow: 0 0 6px var(--blue-opacity-10);
  font-weight: 600;
}

.agents-select-header:hover {
  border-color: var(--blue-opacity-50);
  background: rgb(0 153 255 / 5%);
  box-shadow: 0 0 12px var(--blue-opacity-20);
}

.agents-select-header:focus {
  outline: 2px solid var(--blue-electric);
  outline-offset: 2px;
  border-color: var(--blue-electric);
  box-shadow: 
    0 0 12px var(--blue-opacity-40),
    0 0 24px var(--blue-opacity-20);
  background: var(--blue-opacity-10);
}

.agents-select-header:focus-visible {
  outline: 2px solid var(--blue-electric);
  outline-offset: 2px;
}

/* Inspector / Clipper Toggle Button */
.inspector-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--space-opacity-80);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--text-secondary);
  font-size: var(--font-9);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
  box-shadow: 0 0 6px var(--blue-opacity-10);
  position: relative;
}

/* Clipper: icon-only variant (right header) */
.inspector-toggle-btn.clipper-btn {
  padding: 6px 10px;
  gap: 0;
  min-width: 32px;
}

.inspector-toggle-btn.clipper-btn i {
  font-size: 1.1rem;
}

.inspector-toggle-btn:hover {
  background: var(--blue-opacity-10);
  color: var(--cyan-bright);
  border-color: var(--blue-electric);
  box-shadow: 0 0 12px var(--blue-opacity-40);
  transform: translateY(-1px);
}

.inspector-toggle-btn:active {
  transform: translateY(0);
}

.inspector-toggle-btn.active {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border-color: var(--blue-electric);
  box-shadow:
    0 0 0 3px rgb(59 130 246 / 30%),
    0 0 12px var(--blue-opacity-40);
}

.inspector-toggle-btn.active::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  background: #10b981;
  border: 2px solid rgb(15 23 42 / 90%);
  border-radius: 50%;
  animation: inspectorPulse 2s ease-in-out infinite;
}

@keyframes inspectorPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgb(16 185 129 / 70%);
  }

  50% {
    box-shadow: 0 0 0 6px rgb(16 185 129 / 0%);
  }
}

.inspector-toggle-btn .inspector-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.inspector-toggle-btn i {
  font-size: 1.1rem;
}

/* Inspector Attachment Chip */
.inspector-attachment-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgb(16 185 129 / 10%);
  border: 1px solid rgb(16 185 129 / 30%);
  border-radius: 8px;
  margin: 6px 0;
  transition: all 0.2s ease;
}

.inspector-attachment-chip:hover {
  background: rgb(16 185 129 / 15%);
  border-color: rgb(16 185 129 / 50%);
}

.inspector-attachment-chip .attachment-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgb(16 185 129 / 20%);
  border-radius: 6px;
  color: #10b981;
  font-size: 16px;
}

.inspector-attachment-chip .attachment-info {
  flex: 1;
  min-width: 0;
}

.inspector-attachment-chip .attachment-name {
  font-size: 13px;
  font-weight: 600;
  color: #10b981;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inspector-attachment-chip .attachment-meta {
  font-size: 11px;
  color: rgb(16 185 129 / 70%);
  margin-top: 2px;
}

.inspector-attachment-chip .attachment-copy,
.inspector-attachment-chip .attachment-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: rgb(16 185 129 / 50%);
  cursor: pointer;
  transition: all 0.2s ease;
}

.inspector-attachment-chip .attachment-copy:hover,
.inspector-attachment-chip .attachment-remove:hover {
  background: rgb(16 185 129 / 20%);
  color: #10b981;
}

/* CLIPPED @ menu keyboard highlight */
.mention-item.inspector-mention-highlight {
  background: rgb(16 185 129 / 20%);
}

/* Collapsible Inspected Element Blocks */
.ai-inspected-element-block {
  margin: 12px 0;
  border: 1px solid rgb(16 185 129 / 30%);
  border-radius: 8px;
  background: rgb(16 185 129 / 5%);
  overflow: hidden;
  transition: all 0.3s ease;
}

.ai-inspected-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
}

.ai-inspected-header:hover {
  background: rgb(16 185 129 / 10%);
}

.ai-inspected-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.ai-inspected-header-left i {
  color: #10b981;
  font-size: 18px;
  flex-shrink: 0;
}

.ai-inspected-name {
  font-weight: 600;
  font-size: 14px;
  color: #10b981;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-inspected-type {
  font-size: 11px;
  color: rgb(16 185 129 / 70%);
  padding: 2px 8px;
  background: rgb(16 185 129 / 15%);
  border-radius: 4px;
  white-space: nowrap;
}

.ai-inspected-toggle {
  color: #10b981;
  font-size: 16px;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.ai-inspected-element-block.expanded .ai-inspected-toggle {
  transform: rotate(180deg);
}

.ai-inspected-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  border-top: 1px solid rgb(16 185 129 / 20%);
}

.ai-inspected-element-block.expanded .ai-inspected-content {
  max-height: 600px;
  overflow-y: auto;
}

.ai-inspected-content pre {
  margin: 0;
  padding: 16px;
  background: rgb(15 23 42 / 50%);
  overflow-x: auto;
}

.ai-inspected-content code {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #e2e8f0;
  white-space: pre;
}

/* Collapsed state (default) */
.ai-inspected-element-block.collapsed .ai-inspected-content {
  max-height: 0;
}

.ai-refresh-btn-header {
  padding: 6px;

  /* OPTIMIZED: Removed backdrop-filter - nested button doesn't need it */
  background: var(--space-opacity-80);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  box-shadow: 0 0 6px var(--blue-opacity-10);
}

.ai-refresh-btn-header:hover {
  background: var(--blue-opacity-10);
  color: var(--cyan-bright);
  border-color: var(--blue-electric);
  box-shadow: 0 0 12px var(--blue-opacity-40);
}

.ai-refresh-btn-header.spinning {
  animation: spin 1s linear infinite;
}

.ai-chat-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 0 0 auto;
  flex-shrink: 0;
}

/* Context Badge - Replaces disabled thread selector */
.ai-context-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;

  /* OPTIMIZED: Removed backdrop-filter - nested badge doesn't need it */
  background: var(--blue-opacity-20);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--text-primary);
  font-size: var(--font-9);
  font-weight: 600;
  box-shadow: 0 0 6px var(--blue-opacity-10);
  transition: all 0.3s ease;
  white-space: nowrap;
  min-width: fit-content;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-context-badge-icon {
  display: inline-flex;
  align-items: center;
  font-size: 1em;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.ai-context-badge-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Context badge states */
.ai-context-badge[data-context-type="global"] {
  border-color: var(--blue-opacity-40);
  background: var(--blue-opacity-12);
  color: var(--blue-electric);
}

.ai-context-badge[data-context-type="element"] {
  border-color: var(--green-opacity-40);
  background: rgb(0 255 153 / 12%);
  color: var(--green-ghost);
}

.ai-context-badge[data-context-type="connection"] {
  border-color: rgb(0 255 255 / 40%);
  background: rgb(0 255 255 / 12%);
  color: var(--cyan-bright);
}

/* Context badge animation on change */
.ai-context-badge.updating {
  animation: contextPulse 0.6s ease;
}

@keyframes contextPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Improved focus states for better accessibility */
.ai-chat-container:focus-within {
  border-color: var(--blue-opacity-50);
  box-shadow: 
    0 -18px 48px var(--black-opacity-70),
    0 0 36px var(--blue-opacity-20),
    inset 0 0 18px var(--blue-opacity-12);
}

/* Visual connection when thread history is active - enhance chat container */
.ai-chat-container:has(+ .ai-thread-history-section.active),
main.layout:has(.ai-thread-history-section.active) .ai-chat-container {
  border-bottom-color: var(--blue-opacity-50);
  box-shadow: 
    0 -18px 48px var(--black-opacity-70),
    0 0 36px var(--blue-opacity-20),
    inset 0 0 18px var(--blue-opacity-12),
    0 2px 0 var(--green-opacity-30); /* Bottom glow to connect with thread history */
}

/* Enhanced styling when thread history is expanded */
section.agents-chat.is-expanded .ai-chat-container {
  border-bottom-color: var(--blue-opacity-50);
}

/* Smooth transitions for agent selection */
.agents-select-header option {
  background: rgb(15 23 42 / 95%);
  color: var(--text-primary);
  padding: 8px;
}

.agents-select-header option:hover {
  background: var(--blue-opacity-15);
}

.ai-advanced-prompt-btn,
.ai-context-mode-btn,
.ai-thread-history-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--space-opacity-40);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--text-secondary);
  font-size: var(--font-9);
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  box-shadow: 0 0 6px var(--blue-opacity-10);
}

.ai-advanced-prompt-btn:hover,
.ai-context-mode-btn:hover,
.ai-thread-history-btn:hover {
  background: var(--blue-opacity-10);
  border-color: var(--blue-opacity-50);
  color: var(--text-primary);
  box-shadow: 0 0 12px var(--blue-opacity-20);
}

.ai-advanced-prompt-btn.active,
.ai-context-mode-btn.active,
.ai-thread-history-btn.active {
  background: var(--blue-opacity-20);
  border-color: var(--blue-electric);
  color: var(--cyan-bright);
  box-shadow: 
    0 0 18px var(--blue-opacity-40),
    0 0 36px var(--blue-opacity-20);
  text-shadow: 0 0 9px rgb(51 204 255 / 60%);
}

/* Removed: .ai-context-selector and .ai-context-btn - Context selector buttons removed (context now switches automatically based on selection) */

.ai-chat-header-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  flex-shrink: 0;
}

.ai-context-indicator {
  padding: 6px 12px;

  /* OPTIMIZED: Removed backdrop-filter - nested badge doesn't need it */
  background: var(--space-opacity-80);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  font-size: var(--font-9);
  color: var(--text-secondary);
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: 0 0 6px var(--blue-opacity-10);
}

.ai-context-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

/* Context Mode Panel */
.ai-context-mode-panel {
  border-top: 2px solid var(--blue-opacity-30);

  /* OPTIMIZED: Removed backdrop-filter - nested panel doesn't need it */
  background: var(--space-opacity-95);
  flex-shrink: 0;
  max-height: 300px;
  overflow: hidden;
  display: none;
  flex-direction: column;
  box-shadow: 0 -6px 18px var(--blue-opacity-10);
}

/* Consolidated: Uses .flex-col-scroll and .flex-grow utilities */
.ai-context-content {
  padding: 0.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
}

.ai-thread-details {
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgb(30 41 59 / 80%);
  background: rgb(15 23 42 / 60%);
  min-height: 80px;
}

.ai-thread-details-empty {
  font-size: 0.875rem;
  color: #64748b;
  text-align: center;
  padding: 1rem;
}

.ai-context-content .field-group {
  margin: 0;
}

.ai-context-content .field-group label {
  display: block;
  font-size: 0.75rem;
  color: #9ca3b8;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.ai-output-preview {
  width: 100%;
  min-height: 120px;
  max-height: 200px;
  padding: 12px;

  /* OPTIMIZED: Removed backdrop-filter - nested textarea doesn't need it */
  background: var(--space-opacity-90);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--text-primary);
  font-size: var(--font-12);
  font-family: Monaco, Menlo, 'Ubuntu Mono', monospace;
  resize: vertical;
  overflow-y: auto;
  line-height: 1.5;
  box-shadow: 0 0 9px var(--blue-opacity-10);
}

/* Consolidated: Scrollbar styles moved to index.css .scrollbar-standard */

/* Advanced Prompting Panel */
.ai-advanced-prompt-panel {
  border-top: 2px solid var(--blue-opacity-30);

  /* OPTIMIZED: Removed backdrop-filter - nested panel doesn't need it */
  background: var(--space-opacity-95);
  flex-shrink: 0;
  max-height: 500px;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  box-shadow: 0 -6px 18px var(--blue-opacity-10);
  padding: 12px;
}

.ai-prompt-builder {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ai-prompt-section {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.ai-prompt-section-label {
  font-size: var(--font-12);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Prompt Templates */
.ai-prompt-templates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-template-btn {
  padding: 6px 12px;
  background: var(--space-opacity-60);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--text-secondary);
  font-size: var(--font-9);
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: 0 0 6px var(--blue-opacity-10);
}

.ai-template-btn:hover {
  background: var(--blue-opacity-10);
  border-color: var(--blue-electric);
  color: var(--cyan-bright);
  box-shadow: 0 0 12px var(--blue-opacity-40);
}

.ai-template-btn.active {
  background: var(--blue-opacity-20);
  border-color: var(--blue-electric);
  color: var(--cyan-bright);
  box-shadow: 0 0 18px var(--blue-opacity-40);
}

/* Format Options */
.ai-format-options {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.ai-format-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--space-opacity-60);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: var(--font-9);
  color: var(--text-secondary);
  font-weight: 600;
  box-shadow: 0 0 6px var(--blue-opacity-10);
}

.ai-format-option:hover {
  background: var(--blue-opacity-10);
  border-color: var(--blue-electric);
  color: var(--cyan-bright);
}

.ai-format-option input[type="radio"] {
  accent-color: var(--blue-electric);
  cursor: pointer;
}

.ai-format-option input[type="radio"]:checked + span {
  color: var(--cyan-bright);
}

.ai-format-option:has(input[type="radio"]:checked) {
  background: var(--blue-opacity-20);
  border-color: var(--blue-electric);
  color: var(--cyan-bright);
  box-shadow: 0 0 12px var(--blue-opacity-40);
}

/* Context Helpers */
.ai-context-helpers-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.ai-context-helpers-header .ai-prompt-section-label {
  margin: 0;
}

.ai-collapse-toggle {
  padding: 3px 6px;
  background: transparent;
  border: 1px solid var(--blue-opacity-30);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.ai-collapse-toggle:hover {
  background: var(--blue-opacity-10);
  border-color: var(--blue-electric);
  color: var(--cyan-bright);
}

.ai-collapse-toggle.collapsed i {
  transform: rotate(180deg);
}

.ai-context-helpers-content {
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: all 0.3s ease;
  overflow: hidden;
}

.ai-context-helpers-content.collapsed {
  display: none;
}

.ai-context-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 9px;
  background: rgb(3 6 9 / 50%);
  border-radius: 9px;
  border: 1px solid var(--blue-opacity-20);
}

.ai-context-checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: var(--font-12);
  color: var(--text-primary);
  position: relative;
}

.ai-context-checkbox-label:hover {
  background: var(--blue-opacity-10);
}

.ai-context-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--blue-electric);
  flex-shrink: 0;
}

.ai-context-checkbox-label span {
  flex: 1;
  user-select: none;
}

/* Advanced Prompt Input */
.ai-advanced-prompt-input {
  width: 100%;
  min-height: 80px;
  max-height: 150px;
  padding: 12px;

  /* OPTIMIZED: Removed backdrop-filter - nested textarea doesn't need it */
  background: var(--space-opacity-90);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--text-primary);
  font-size: var(--font-12);
  font-family: inherit;
  resize: vertical;
  overflow-y: auto;
  line-height: 1.5;
  box-shadow: 0 0 9px var(--blue-opacity-10);
}

.ai-advanced-prompt-input:focus {
  outline: none;
  border-color: var(--blue-electric);
  box-shadow: 
    0 0 18px var(--blue-opacity-40),
    0 0 36px var(--blue-opacity-20);
  background: rgb(0 153 255 / 5%);
}

.ai-advanced-prompt-input::placeholder {
  color: var(--text-muted);
}

/* Prompt Actions */
.ai-prompt-actions {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  padding-top: 9px;
  border-top: 1px solid var(--blue-opacity-20);
}

.ai-prompt-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--space-opacity-60);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--text-secondary);
  font-size: var(--font-9);
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: 0 0 6px var(--blue-opacity-10);
}

.ai-prompt-action-btn:hover {
  background: var(--blue-opacity-10);
  border-color: var(--blue-electric);
  color: var(--cyan-bright);
  box-shadow: 0 0 12px var(--blue-opacity-40);
}

.ai-prompt-action-btn.primary {
  background: var(--blue-opacity-20);
  border-color: var(--blue-electric);
  color: var(--cyan-bright);
}

.ai-prompt-action-btn.primary:hover {
  background: var(--blue-opacity-30);
  box-shadow: 0 0 18px var(--blue-opacity-60);
}

/* Chat Messages Area - Hidden by default */
.ai-chat-messages-wrapper {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: hidden;

  /* OPTIMIZED: CSS containment - isolate scrollable messages area */
  contain: layout style;
}

.ai-chat-messages-wrapper:not([style*="display: none"]) {
  display: flex;
  flex-direction: column;
}

.ai-chat-transcript {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  scroll-behavior: smooth;

  /* OPTIMIZED: CSS containment - isolate transcript scroll area */
  contain: layout style;
}

/* ============================================
   Persistent Header - Always Visible
   ============================================ */
.ai-chat-persistent-header {
  display: flex;
  flex-direction: column;
  position: relative;

  /* OPTIMIZED: Removed backdrop-filter - nested header doesn't need it (parent has it) */
  background: var(--space-mid-opacity-98);
  border-bottom: 2px solid var(--blue-opacity-30);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  flex-shrink: 0;
  box-sizing: border-box;
  z-index: var(--z-dropdown);
}

/* Resize handle integrated into header top */
.ai-header-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
  z-index: var(--z-dropdown);
  background: transparent;
  transition: background 0.2s ease;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  display: none; /* Hidden by default */
}

/* Show resize handle only when thread is expanded */
section.agents-chat.is-expanded .ai-header-resize-handle {
  display: block;
}

.ai-header-resize-handle::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 3px;
  background: var(--blue-opacity-40);
  border-radius: 2px;
  transition: all 0.2s ease;
}

.ai-header-resize-handle:hover {
  background: var(--blue-opacity-10);
}

.ai-header-resize-handle:hover::before {
  width: 60px;
  background: rgb(0 153 255 / 70%);
  box-shadow: 0 0 8px var(--blue-opacity-50);
}

/* Header content row - contains left and right sections */
.ai-header-content-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  gap: 10px;
  min-height: 36px;
}

/* Left section - Agent Selector */
.ai-persistent-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  z-index: var(--z-elevated);
}

.ai-persistent-header-left .agents-selector-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Sample Prompts Selector */
.sample-prompts-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  border-left: 1px solid rgb(255 255 255 / 10%);
  padding-left: 10px;
  margin-left: 2px;
}

.sample-prompts-select {
  background: linear-gradient(135deg, rgb(139 92 246 / 20%), rgb(124 58 237 / 15%));
  border: 1px solid rgb(139 92 246 / 40%);
  border-radius: 6px;
  color: #c4b5fd;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 140px;
  max-width: 180px;
}

.sample-prompts-select:hover {
  background: linear-gradient(135deg, rgb(139 92 246 / 30%), rgb(124 58 237 / 25%));
  border-color: rgb(139 92 246 / 60%);
  color: #e9d5ff;
}

.sample-prompts-select:focus {
  outline: none;
  border-color: rgb(139 92 246 / 80%);
  box-shadow: 0 0 0 2px rgb(139 92 246 / 20%);
}

.sample-prompts-select option {
  background: #1e1e2e;
  color: #e2e8f0;
  padding: 8px;
}

.sample-prompts-select option:disabled {
  color: #64748b;
}

/* Right section - Context Badge + Clipper */
.ai-persistent-header-right {
  position: absolute;
  top: 50%;
  right: 12px;
  left: auto;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  z-index: var(--z-base);
  pointer-events: none;
}

.ai-persistent-header-right .clipper-btn {
  pointer-events: auto;
}

.ai-context-badge-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  background: var(--blue-opacity-15);
  border: 2px solid var(--blue-opacity-40);
  border-radius: 20px;
  color: var(--cyan-bright, #3cf);
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 
    0 0 12px var(--blue-opacity-20),
    inset 0 0 8px var(--blue-opacity-10);
  transition: all 0.3s ease;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
}

.ai-context-badge-header:hover {
  background: rgb(0 153 255 / 25%);
  border-color: rgb(0 153 255 / 70%);
  box-shadow: 
    0 0 20px var(--blue-opacity-40),
    inset 0 0 12px var(--blue-opacity-20);
  transform: scale(1.02);
}

.ai-context-badge-header:active {
  transform: scale(0.98);
  box-shadow: 
    0 0 12px var(--blue-opacity-30),
    inset 0 0 8px var(--blue-opacity-15);
}

.ai-context-badge-header .ai-context-badge-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
}

.ai-context-badge-header .ai-context-badge-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.ai-context-badge-header .ai-context-badge-counter {
  font-size: 0.75rem;
  opacity: 0.8;
  margin-left: 4px;
  flex-shrink: 0;
}

/* Context badge states */
.ai-context-badge-header[data-context-type="global"] {
  border-color: var(--blue-opacity-50);
  background: var(--blue-opacity-15);
  color: var(--cyan-bright, #3cf);
}

.ai-context-badge-header[data-context-type="element"] {
  border-color: var(--green-opacity-50);
  background: var(--green-opacity-15);
  color: var(--green-ghost, #0f9);
}

.ai-context-badge-header[data-context-type="connection"] {
  border-color: rgb(0 255 255 / 50%);
  background: rgb(0 255 255 / 15%);
  color: #0ff;
}

/* Right section - Actions: Pin/Toggle removed in favor of gestures */

/* Thread History Section - Consolidated: Uses .flex-grow-shrink utility */
.ai-thread-history-section,
.flex-grow-shrink.ai-thread-history-section {
  display: none;
  position: relative;
  flex-direction: column;

  /* flex: 1 1 auto; min-width: 0; min-height: 0; now from .flex-grow-shrink */
  border: none;
  border-bottom: 2px solid var(--blue-opacity-30);
  background: transparent;
  overflow: hidden;
  max-height: 0;
  transition: 
    max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s ease,
    border-color 0.3s ease;
  box-sizing: border-box;
  pointer-events: auto;

  /* OPTIMIZED: CSS containment - isolate thread history section */
  contain: layout style;
}

/* When expanded, show the section */
.ai-thread-history-section.is-expanded {
  display: flex;
  max-height: 500px;
  opacity: 1;
}

@keyframes connectionPulse {
  0%, 100% { opacity: 0.4; width: 200px; }
  50% { opacity: 0.8; width: 250px; }
}

/* Pinned state - prevents auto-hide */
.ai-thread-history-section.is-pinned {
  border-bottom-color: var(--green-opacity-60);
}

section.agents-chat.is-pinned {
  border-color: var(--green-opacity-60);
}

/* Old resize handle - hidden (now using .ai-header-resize-handle in header) */
.ai-thread-resize-handle {
  display: none;
}

/* Thread history content wrapper */
.ai-thread-history-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;

  /* OPTIMIZED: CSS containment - isolate thread history content */
  contain: layout style;
}

/* Removed duplicate - using definition above */

.ai-thread-history-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-thread-history-header h3 {
  margin: 0;
  font-size: var(--font-16);
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 0 9px var(--blue-opacity-50);
  line-height: 1.3;
}

/* Expanded state styling */
section.agents-chat.is-expanded {
  max-height: min(900px, 85vh);
}

section.agents-chat.is-expanded .ai-thread-history-section {
  display: flex;
  max-height: 400px;
}

.ai-minimize-overlay-btn.minimized {
  background: var(--blue-opacity-15);
  border-color: var(--blue-opacity-50);
  color: var(--cyan-bright);
  box-shadow: 0 0 12px var(--blue-opacity-40);
}

.ai-minimize-overlay-btn.minimized:hover {
  background: var(--blue-opacity-20);
  border-color: var(--blue-electric);
  box-shadow: 0 0 16px var(--blue-opacity-60);
}

/* Minimize button icon - changes when minimized */
.ai-minimize-overlay-btn.minimized svg {
  transform: rotate(180deg);
}

/* Consolidated: Uses .flex-grow-shrink utility */
.ai-chat-transcript-overlay,
.flex-grow-shrink.ai-chat-transcript-overlay {
  /* flex: 1 1 auto; min-width: 0; min-height: 0; now from .flex-grow-shrink */
  overflow-y: auto;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
  background: transparent;
  border: none;
  border-radius: 0;
}

.ai-chat-transcript-overlay::-webkit-scrollbar {
  width: 9px;
}

.ai-chat-transcript-overlay::-webkit-scrollbar-track {
  background: var(--space-opacity-60);
}

.ai-chat-transcript-overlay::-webkit-scrollbar-thumb {
  background: var(--blue-opacity-40);
  border-radius: 6px;
  border: 1px solid var(--blue-opacity-20);
}

.ai-chat-transcript-overlay::-webkit-scrollbar-thumb:hover {
  background: var(--blue-opacity-60);
  box-shadow: 0 0 9px var(--blue-opacity-60);
}

/* Welcome Message */
.chat-welcome-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 2rem;
  max-width: 600px;
  margin: 0 auto;
}

.chat-welcome-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-electric), var(--purple-neon));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--space-deep);
  margin-bottom: 18px;
  box-shadow: 
    0 0 24px var(--blue-opacity-60),
    0 0 48px rgb(102 0 255 / 40%);
  border: 3px solid var(--cyan-bright);
  font-size: 36px;
  font-weight: 700;
}

.chat-welcome-message h3 {
  font-size: var(--font-24);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 12px;
  text-shadow: 0 0 12px var(--blue-opacity-60);
}

.chat-welcome-message p {
  font-size: var(--font-15);
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 18px;
}

.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  margin-top: 1rem;
}

.suggestion-btn {
  padding: 12px 18px;

  /* OPTIMIZED: Removed backdrop-filter - nested button doesn't need it */
  background: var(--space-opacity-80);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--text-primary);
  font-size: var(--font-12);
  text-align: left;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  box-shadow: 0 0 6px var(--blue-opacity-10);
}

.suggestion-btn:hover {
  background: var(--blue-opacity-10);
  border-color: var(--blue-electric);
  color: var(--cyan-bright);
  transform: translateX(6px);
  box-shadow: 
    0 0 18px var(--blue-opacity-30),
    0 0 36px var(--blue-opacity-20);
}

/* Chat Messages */
.chat-message {
  display: flex;
  gap: 1rem;
  animation: messageSlideIn 0.3s ease-out;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;

  /* OPTIMIZED: CSS containment - isolate individual messages */
  contain: layout style;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-message.ai {
  flex-direction: row;
}

.chat-message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  font-weight: 700;
  margin-top: 3px;
  border: 2px solid;
  box-shadow: 0 0 12px;
}

.chat-message.user .chat-message-avatar {
  background: linear-gradient(135deg, #09F, #06C);
  color: #030609;
  border-color: #3CF;
  box-shadow: 0 0 12px var(--blue-opacity-60);
}

.chat-message.ai .chat-message-avatar {
  background: linear-gradient(135deg, #0F9, #0C6);
  color: #030609;
  border-color: #0F9;
  box-shadow: 0 0 12px var(--green-opacity-60);
}

.chat-message.typing .chat-message-avatar {
  background: linear-gradient(135deg, #666, #999);
  border-color: #666;
  box-shadow: 0 0 9px rgb(102 102 102 / 40%);
}

.chat-bubble {
  flex: 1;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.6;
  word-wrap: break-word;
  position: relative;

  /* OPTIMIZED: Removed backdrop-filter - chat bubble has solid background gradient */
  transition: all 0.3s ease;
}

.chat-message.user .chat-bubble {
  background: linear-gradient(135deg, rgb(0 153 255 / 90%) 0%, rgb(0 102 204 / 90%) 100%);
  color: #030609;
  border-bottom-right-radius: 3px;
  border: 2px solid var(--blue-opacity-60);
  box-shadow: 
    0 6px 18px var(--blue-opacity-40),
    0 0 24px var(--blue-opacity-30);
  font-weight: 600;
}

.chat-message.ai .chat-bubble {
  background: rgb(3 6 9 / 70%);
  color: #CCC;
  border: 2px solid var(--green-opacity-30);
  border-bottom-left-radius: 3px;
  box-shadow: 
    0 6px 18px var(--black-opacity-40),
    0 0 18px var(--green-opacity-10),
    inset 0 0 12px rgb(0 255 153 / 5%);
}

.chat-message.ai .chat-bubble::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    var(--green-opacity-60) 50%, 
    transparent 100%);
  opacity: 0.6;
}

.chat-message.typing .chat-bubble {
  background: rgb(3 6 9 / 70%);
  color: #999;
  border: 2px solid var(--green-opacity-20);
  box-shadow: 0 6px 18px rgb(0 0 0 / 30%);
}

/* Markdown styling in chat bubbles */
.chat-bubble h1, .chat-bubble h2, .chat-bubble h3 {
  margin: 1rem 0 0.5rem;
  font-weight: 600;
}

.chat-bubble h1:first-child, .chat-bubble h2:first-child, .chat-bubble h3:first-child {
  margin-top: 0;
}

.chat-bubble p {
  margin: 0.75rem 0;
}

.chat-bubble p:first-child {
  margin-top: 0;
}

.chat-bubble p:last-child {
  margin-bottom: 0;
}

.chat-bubble code {
  background: rgb(0 0 0 / 30%);
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-family: Monaco, Menlo, 'Ubuntu Mono', monospace;
  font-size: 0.875em;
}

.chat-message.user .chat-bubble code {
  background: rgb(255 255 255 / 20%);
}

.chat-bubble pre {
  background: var(--black-opacity-40);
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.75rem 0;
  border: 1px solid rgb(255 255 255 / 10%);
}

.chat-message.user .chat-bubble pre {
  background: rgb(255 255 255 / 15%);
  border-color: rgb(255 255 255 / 20%);
}

.chat-bubble pre code {
  background: none;
  padding: 0;
}

.chat-bubble ul, .chat-bubble ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

.chat-bubble li {
  margin: 0.375rem 0;
}

.chat-bubble blockquote {
  border-left: 3px solid rgb(59 130 246 / 50%);
  padding-left: 0.875rem;
  margin: 0.75rem 0;
  opacity: 0.9;
}

.chat-bubble strong {
  font-weight: 600;
}

.chat-bubble em {
  font-style: italic;
}

.chat-bubble a {
  color: var(--cyan-bright);
  text-decoration: underline;
  text-shadow: 0 0 6px rgb(51 204 255 / 40%);
}

.chat-message.user .chat-bubble a {
  color: rgb(255 255 255 / 90%);
}

/* Typing indicator */
.chat-message.typing .chat-bubble::after {
  content: '...';
  animation: typingDots 1.5s infinite;
}

@keyframes typingDots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* Chat Input Area */
.ai-chat-input-area {
  position: relative;
  border-top: 1.5px solid var(--blue-opacity-20);

  /* OPTIMIZED: Removed backdrop-filter - nested section doesn't need it (parent has it) */
  background: rgb(15 23 42 / 95%);
  padding: 10px 16px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.3s ease;

  /* Snuggle into the section.agents-chat bottom corners */
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

.ai-chat-input-area:focus-within {
  border-top-color: var(--blue-opacity-40);
}

/* Attachment Toolbar */
.ai-attachment-toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.ai-attach-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;

  /* OPTIMIZED: Removed backdrop-filter - nested button doesn't need it */
  background: var(--space-opacity-80);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--text-secondary);
  font-size: var(--font-9);
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: 0 0 6px var(--blue-opacity-10);
}

.ai-attach-btn:hover {
  background: var(--blue-opacity-10);
  border-color: var(--blue-electric);
  color: var(--cyan-bright);
  box-shadow: 0 0 12px var(--blue-opacity-40);
}

.ai-attach-btn i {
  font-size: 0.9rem;
}

/* Attachment Preview Area – collapsible, collapsed by default */
.ai-attachments-preview {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: var(--space-opacity-80);
  border: 2px solid var(--blue-opacity-20);
  border-radius: 9px;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
  overflow: hidden;
}

.ai-attachments-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s ease, color 0.2s ease;
}

.ai-attachments-preview-header:hover {
  background: var(--blue-opacity-10);
  color: var(--cyan-bright, #3cf);
}

.ai-attachments-preview-chevron {
  font-size: 14px;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.ai-attachments-preview[data-collapsed="false"] .ai-attachments-preview-chevron {
  transform: rotate(-180deg);
}

.ai-attachments-preview-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px 12px;
  max-height: 150px;
  overflow-y: auto;
  border-top: 1px solid var(--blue-opacity-20);
}

.ai-attachments-preview-body[hidden] {
  display: none !important;
}

.ai-attachments-device,
.ai-attachments-inspector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.ai-attachments-inspector {
  flex: 1;
  min-height: 0;
}

.ai-attachment-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  background: var(--blue-opacity-10);
  border: 1px solid var(--blue-opacity-30);
  border-radius: 6px;
  font-size: var(--font-9);
  color: var(--text-primary);
}

.ai-attachment-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--cyan-bright);
}

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

.ai-attachment-name {
  font-weight: 600;
  color: var(--text-primary);
}

.ai-attachment-size {
  font-size: var(--font-9);
  color: var(--text-muted);
  margin-left: 6px;
}

.ai-attachment-remove {
  padding: 3px 6px;
  background: rgb(255 0 0 / 20%);
  border: 1px solid rgb(255 0 0 / 40%);
  border-radius: 4px;
  color: #ff6b6b;
  cursor: pointer;
  font-size: var(--font-9);
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.ai-attachment-remove:hover {
  background: rgb(255 0 0 / 30%);
  border-color: #ff6b6b;
  box-shadow: 0 0 6px rgb(255 0 0 / 40%);
}

.ai-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
}

/* Input text wrapper */
.ai-input-text-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  background: rgb(3 6 9 / 50%);
  border: 1.5px solid var(--blue-opacity-15);
  border-radius: 12px;
  padding: 6px 12px;
  transition: all 0.3s ease;
  box-shadow: inset 0 1px 4px rgb(0 0 0 / 20%);
}

/* Attach buttons inside input wrapper */
.ai-input-attach-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ai-input-attach-buttons .ai-attach-btn-compact {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border-width: 1px;
  background: transparent;
  box-shadow: none;
}

.ai-input-attach-buttons .ai-attach-btn-compact:hover {
  background: var(--blue-opacity-15);
}

.ai-input-text-wrapper:focus-within {
  border-color: #09f;
  background: rgb(3 6 9 / 70%);
  box-shadow: 0 0 12px var(--blue-opacity-20), inset 0 1px 4px rgb(0 0 0 / 20%);
}

/* Input actions group (attachments + send) */
.ai-input-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Compact attachment buttons */
.ai-attach-btn-compact {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;

  /* OPTIMIZED: Removed backdrop-filter - nested button doesn't need it */
  background: var(--space-opacity-80);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 9px;
  color: var(--text-secondary, #9ca3af);
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
  box-shadow: 0 0 6px var(--blue-opacity-10);
}

.ai-attach-btn-compact:hover {
  background: var(--blue-opacity-10);
  border-color: var(--blue-electric, #09f);
  color: var(--cyan-bright, #3cf);
  box-shadow: 0 0 12px var(--blue-opacity-40);
}

.ai-attach-btn-compact:focus {
  outline: 2px solid var(--blue-electric, #09f);
  outline-offset: 2px;
}

.ai-attach-btn-compact i {
  font-size: 1rem;
}

.ai-chat-input {
  flex: 1;
  width: 100%;
  background: transparent !important;
  border: none !important;
  color: var(--text-primary);
  font-size: 15px;
  resize: none;
  min-height: 24px;
  max-height: 200px;
  line-height: 1.5;
  font-family: inherit;
  outline: none !important;
  box-shadow: none !important; /* Remove internal focus highlight */
  padding: 0;
  margin: 0;
  padding-right: 10px; /* Space for progress bar */
  box-sizing: border-box;
  overflow: hidden auto;
  z-index: var(--z-base);
  position: relative;
  overflow-wrap: break-word;
  word-wrap: break-word;
  transition: height 0.2s ease;
}

/* Hide default scrollbar */
.ai-chat-input::-webkit-scrollbar {
  width: 0;
  height: 0;
  background: transparent;
}

.ai-chat-input::-webkit-scrollbar-track {
  display: none;
}

.ai-chat-input::-webkit-scrollbar-thumb {
  display: none;
}

/* Custom scroll progress bar indicator */
.ai-chat-input-scroll-progress {
  position: absolute;
  top: 0;
  right: 6px;
  width: 3px;
  min-height: 20px;
  height: 0;
  background: linear-gradient(to bottom, var(--blue-opacity-60), var(--green-opacity-40));
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.3s ease, height 0.1s ease, top 0.1s ease;
  pointer-events: none;
  z-index: var(--z-elevated);
  box-shadow: 0 0 6px var(--blue-opacity-40);
}

.ai-chat-input-scroll-progress.visible {
  opacity: 0.8;
}

/* Auto-resize textarea */
.ai-chat-input:not([style*="height"]) {
  height: 24px;
}

.ai-chat-input::placeholder {
  color: var(--text-muted);
}

/* Rich contenteditable input */
.ai-chat-input-rich {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Placeholder when empty (JS toggles .ai-chat-input-placeholder) */
.ai-chat-input-rich[data-placeholder].ai-chat-input-placeholder::before {
  content: attr(data-placeholder);
  color: var(--text-muted, #94a3b8);
  pointer-events: none;
}

/* Inline badge (clipped content) inside input */
.inspector-inline-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  margin: 0 2px;
  background: rgb(16 185 129 / 15%);
  border: 1px solid rgb(16 185 129 / 35%);
  border-radius: 6px;
  font-size: 13px;
  color: #10b981;
  vertical-align: middle;
  white-space: nowrap;
  cursor: default;
  user-select: none;
}

.inspector-inline-badge i {
  font-size: 14px;
  opacity: 0.9;
}

.inspector-inline-badge-label {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chat-input:focus,
.ai-chat-input:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

.ai-send-button {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  background: linear-gradient(135deg, #09F 0%, #0F9 100%);
  border: 2px solid #0F9;
  border-radius: 9px;
  color: #030609;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 
    0 0 12px var(--green-opacity-40),
    0 0 24px var(--blue-opacity-30);
  font-weight: 700;
}

.ai-send-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #3CF 0%, #0F9 100%);
  box-shadow: 
    0 0 18px var(--green-opacity-60),
    0 0 36px var(--blue-opacity-50);
  transform: scale(1.1);
}

.ai-send-button:active:not(:disabled) {
  transform: scale(1.0);
}

.ai-send-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  box-shadow: none;
}


/* Scrollbar styling */

/* Consolidated: Scrollbar styles moved to index.css .scrollbar-standard */

/* Data Form File Browser Styles */
.data-form-file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--blue-opacity-30);
  border-radius: 9px;
  margin-bottom: 9px;
  transition: all 0.3s ease;

  /* OPTIMIZED: Removed backdrop-filter - nested file item doesn't need it */
  background: var(--space-opacity-80);
}

.data-form-file-item:hover {
  background: var(--blue-opacity-10);
  border-color: var(--blue-electric);
  box-shadow: 0 0 12px var(--blue-opacity-30);
}

.data-form-file-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.data-form-file-info {
  flex: 1;
  min-width: 0;
}

.data-form-file-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--font-12);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 3px;
}

.data-form-file-meta {
  font-size: var(--font-9);
  color: var(--text-muted);
}

.data-form-file-attach {
  padding: 6px 12px;
  background: var(--blue-opacity-20);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 6px;
  color: var(--cyan-bright);
  font-size: var(--font-9);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-form-file-attach:hover {
  background: var(--blue-opacity-30);
  border-color: var(--blue-electric);
  box-shadow: 0 0 9px var(--blue-opacity-40);
}

.data-form-file-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: var(--font-12);
}

.data-form-file-loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: var(--font-12);
}

.data-form-file-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 12px 0;
}

/* Consolidated: Scrollbar styles moved to index.css .scrollbar-standard */

/* Responsive Design for Zoho Creator Widget */
@media (width <= 1400px) {
  section.agents-chat {
    padding: 0.75rem;
    transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .ai-column-chat {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .ai-chat-container {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.3s ease;
  }
}

@media (width <= 1200px) {
  section.agents-chat {
    padding: 0.5rem;
    transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .ai-column-chat {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .ai-chat-container {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.3s ease;
  }
}

@media (width <= 900px) {
  section.agents-chat {
    padding: 0.5rem;
    transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .ai-column-chat {
    width: 100%;
    min-width: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .ai-chat-container {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.3s ease;
  }
  
  .ai-column-agents-editor {
    border-right: none;
    border-bottom: 1px solid rgb(30 41 59 / 80%);
    padding-right: 0;
    padding-bottom: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
  }
  
  .ai-column-thread-context {
    border-left: none;
    border-top: 1px solid rgb(30 41 59 / 80%);
    padding-left: 0;
    padding-top: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
  }

  /* Chat container responsive improvements */
  .ai-chat-container {
    max-height: min(500px, 60vh);
    border-radius: 10px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-radius 0.3s ease;
  }

  .ai-chat-container.has-messages {
    max-height: min(700px, 75vh);
  }

  .ai-chat-header {
    padding: 10px 12px;
    gap: 12px;
    min-height: 48px;
  }

  .agents-select-header {
    min-width: 120px;
    max-width: 160px;
    padding: 7px 10px;
  }

  .ai-context-badge {
    max-width: 140px;
    padding: 5px 10px;
    font-size: 0.85rem;
  }
}

@media (width <= 600px) {
  section.agents-chat {
    padding: 0.5rem;
    transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .ai-column-chat {
    width: 100%;
    min-width: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .ai-chat-container {
    max-height: min(400px, 50vh);
    border-radius: 8px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-radius 0.3s ease;
  }

  .ai-chat-container.has-messages {
    max-height: min(600px, 70vh);
  }

  .ai-chat-header {
    padding: 8px 10px;
    gap: 10px;
    flex-wrap: wrap;
    min-height: auto;
  }

  .ai-chat-header-left {
    flex: 1 1 100%;
    min-width: 100%;
  }

  .ai-chat-header-right {
    flex: 1 1 auto;
    justify-content: flex-end;
  }

  .agents-select-header {
    min-width: 100%;
    max-width: 100%;
  }

  .ai-context-badge {
    max-width: 120px;
    font-size: 0.8rem;
  }

  .ai-context-badge-text {
    display: none; /* Hide text on very small screens, show icon only */
  }

  /* Thread history responsive adjustments */
  .ai-thread-history-section {
    left: var(--space-9);
    right: var(--space-9);
    max-height: 40vh;
    min-height: 90px;
    height: 30vh;
  }

  .ai-thread-history-header {
    padding: 10px 12px; /* Match responsive chat header */
    flex-wrap: wrap;
    min-height: 38px; /* Combined with 12px resize handle = 50px total */
  }

  .ai-thread-history-header h3 {
    font-size: 0.875rem;
    line-height: 1.2;
  }

  .ai-thread-history-actions {
    gap: 6px;
  }

  .ai-close-overlay-btn {
    padding: 6px;
  }
}

/* Tablet adjustments */
@media (width <= 900px) and (width >= 601px) {
  .ai-thread-history-section {
    left: calc(var(--space-270) + var(--space-9));
    right: var(--space-9);
    max-height: 45vh;
  }
}


/* ============================================================================
   AI LAYOUT & AGENT STYLES (moved from index.css)
   ============================================================================ */

/* AI layout grid */
.ai-layout-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1.5fr) 260px;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
}

.ai-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-column-agents {
  border-right: 1px solid #1f2937;
  padding-right: 0.75rem;
}

.agents-details {
  margin-top: 0.5rem;
  padding: 0.6rem 0.7rem;
  border-radius: 0.75rem;
  border: 1px solid #1f2937;
  background: radial-gradient(circle at top left, rgb(56 189 248 / 18%), rgb(15 23 42 / 95%));
  box-shadow: 0 14px 35px rgb(0 0 0 / 65%);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.agents-details-empty {
  font-size: 0.75rem;
  color: #9ca3af;
}

.agents-name {
  font-size: 0.86rem;
  font-weight: 600;
}

.agents-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
  font-size: 0.76rem;
}

.agents-detail-row .label {
  color: #9ca3af;
}

.agents-detail-row .value {
  color: #e5e7eb;
  text-align: right;
}

.ai-column-context {
  border-left: 1px solid #1f2937;
  padding-left: 0.75rem;
}

/* Thread tools */
.chip-btn {
  border-radius: 999px;
  border: 1px solid #374151;
  background: #020617;
  color: #e5e7eb;
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  cursor: pointer;
}

.chip-btn:hover {
  border-color: #4b5563;
  background: #020617;
}

/* Thread panels */
.ai-thread-prompt,
.ai-prompt-builder {
  border-radius: 0.55rem;
  border: 1px solid #1f2937;
  padding: 0.4rem 0.5rem;
  background: rgb(15 23 42 / 85%);
  margin-bottom: 0.4rem;
}

.ai-thread-prompt textarea,
.ai-prompt-builder textarea {
  margin-top: 0.25rem;
  min-height: 56px;
  max-height: 120px;
  resize: vertical;
}

/* Chat transcript + message bar */
.ai-chat-thread-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0.5rem;
}

/* Message bar */
.ai-message-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-message-input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-end;

  /* OPTIMIZED: Removed backdrop-filter - nested input wrapper doesn't need it */
  background: var(--space-opacity-90);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 12px;
  padding: 12px 18px;
  transition: all 0.3s ease;
  box-shadow: 0 0 12px var(--blue-opacity-10);
}

.ai-message-input-wrapper:focus-within {
  border-color: var(--blue-electric);
  box-shadow: 
    0 0 18px var(--blue-opacity-40),
    0 0 36px var(--blue-opacity-20);
  background: rgb(0 153 255 / 5%);
}

.ai-message-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: var(--font-15);
  resize: none;
  min-height: 24px;
  max-height: 200px;
  line-height: 1.5;
  font-family: inherit;
  outline: none;
}

.ai-message-input::placeholder {
  color: var(--text-muted);
}

.ai-message-input-wrapper .btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-message-hints {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-9);
  color: var(--text-muted);
  padding: 0 6px;
}

.ai-message-hints kbd {
  /* OPTIMIZED: Removed backdrop-filter - small keyboard hint doesn't need it */
  background: var(--space-opacity-90);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: var(--font-9);
  font-family: monospace;
  color: var(--text-secondary);
  font-weight: 700;
  box-shadow: 0 0 6px var(--blue-opacity-20);
}

/* Accessibility - Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* REMOVED: Legacy message styles (.ai-msg, .ai-msg-meta, .ai-msg-body) - no longer used */

/* Added missing chat column style */

/* Duplicate definition removed - using the main definition above */

/* =================================
   AI Chat Revamp Styles
   ================================= */

.ai-layout-container {
  display: flex;
  height: 100%;
  background: #0f172a;
  overflow: hidden;
  position: relative;
}

.ai-sidebar {
  width: 260px;
  background: #1e293b;
  border-right: 1px solid #334155;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.ai-sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid #334155;
}

.agents-selector {
  padding: 1rem;
  border-bottom: 1px solid #334155;
}

.ai-thread-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
}

.ai-thread-list-container label {
  padding: 0 1rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: block;
}

.ai-thread-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ai-thread-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.2s;
}

.ai-thread-item:hover {
  background: #334155;
}

.ai-thread-item.active {
  background: #334155;
  border-left-color: #3b82f6;
}

.thread-title {
  display: block;
  color: #e2e8f0;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-date {
  display: block;
  color: #94a3b8;
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.ai-main-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #0f172a;
}

.ai-chat-agents-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.agents-avatar {
  width: 32px;
  height: 32px;
  background: #3b82f6;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.agents-details {
  display: flex;
  flex-direction: column;
}

.agents-name {
  font-weight: 600;
  color: #e2e8f0;
  font-size: 0.9rem;
}

.agents-model {
  font-size: 0.75rem;
  color: #94a3b8;
}

.ai-welcome-message {
  text-align: center;
  margin-top: 4rem;
  color: #94a3b8;
}

.ai-welcome-message h3 {
  color: #e2e8f0;
  margin-bottom: 0.5rem;
}

/* Removed redundant .ai-chat-input-area definitions */

.ai-chat-thread-selector {
  display: flex;
  align-items: center;
  flex: 1;
}

.thread-dropdown {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  max-width: 300px;
}

.ai-welcome-popover {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: #1e293b;
  border: 1px solid #334155;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 10px 25px var(--black-opacity-50);
  width: 300px;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: var(--z-dropdown);
}

.ai-welcome-popover::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -8px;
  border-width: 8px;
  border-style: solid;
  border-color: #334155 transparent transparent;
}

.ai-chat-input-area {
  position: relative;
}

.ai-chat-input-area:hover .ai-welcome-popover,
.ai-chat-input-area:focus-within .ai-welcome-popover {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-20px);
}

.ai-welcome-popover h3 {
  margin-top: 0;
  font-size: 1rem;
  color: #e2e8f0;
}

.ai-welcome-popover p {
  margin-bottom: 0;
  font-size: 0.85rem;
  color: #94a3b8;
}

/* ============================================
   Chat Transcript Messages
   ============================================ */

.ai-chat-transcript-overlay {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  max-height: 100%;
}

.ai-chat-message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 85%;
  animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-chat-message-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--blue-opacity-20), rgb(0 102 204 / 15%));
  border: 1px solid var(--blue-opacity-40);
  border-radius: 12px 12px 4px;
}

.ai-chat-message-assistant {
  align-self: flex-start;
  background: rgb(30 41 59 / 90%);
  border: 1px solid rgb(100 116 139 / 30%);
  border-radius: 12px 12px 12px 4px;
}

.ai-message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: #94a3b8;
}

.ai-message-role {
  font-weight: 600;
  color: #e2e8f0;
}

.ai-chat-message-user .ai-message-role {
  color: var(--cyan-bright, #3cf);
}

.ai-chat-message-assistant .ai-message-role {
  color: #a78bfa;
}

.ai-message-context-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgb(0 0 0 / 30%);
  border-radius: 10px;
  font-size: 0.7rem;
  color: #64748b;
}

.ai-message-time {
  margin-left: auto;
  font-size: 0.7rem;
  color: #64748b;
}

.ai-message-content {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #e2e8f0;
  word-wrap: break-word;
}

.ai-message-content code.ai-inline-code {
  background: var(--black-opacity-40);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Fira Code', Monaco, monospace;
  font-size: 0.85em;
  color: #f97316;
}

.ai-message-content pre.ai-code-block {
  background: var(--black-opacity-50);
  border: 1px solid rgb(100 116 139 / 30%);
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
}

.ai-message-content pre.ai-code-block code {
  font-family: 'Fira Code', Monaco, monospace;
  font-size: 0.85rem;
  color: #e2e8f0;
}

.ai-message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.ai-message-attachment {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgb(0 0 0 / 30%);
  border: 1px solid rgb(100 116 139 / 30%);
  border-radius: 6px;
  font-size: 0.8rem;
}

.ai-attachment-icon {
  font-size: 1rem;
}

.ai-attachment-name {
  color: #94a3b8;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* AI Thinking Indicator */
.ai-thinking .ai-thinking-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.ai-thinking-dot {
  width: 8px;
  height: 8px;
  background: #a78bfa;
  border-radius: 50%;
  animation: thinkingPulse 1.4s infinite ease-in-out both;
}

.ai-thinking-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.ai-thinking-dot:nth-child(2) {
  animation-delay: -0.16s;
}

.ai-thinking-dot:nth-child(3) {
  animation-delay: 0s;
}

@keyframes thinkingPulse {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* System Context Display */
.ai-message-system-context {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--blue-opacity-08);
  border: 1px solid rgb(0 153 255 / 25%);
  border-left: 3px solid var(--blue-opacity-60);
  border-radius: 6px;
  font-size: 0.8rem;
  color: #94a3b8;
}

.ai-system-context-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--cyan-bright, #3cf);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ai-system-context-header i {
  font-size: 0.9rem;
}

.ai-system-context-content {
  font-size: 0.75rem;
  line-height: 1.5;
  color: #cbd5e1;
  font-family: Monaco, Menlo, 'Ubuntu Mono', monospace;
}

/* Different context type colors */
.ai-chat-message[data-context-type="global"] .ai-message-system-context {
  background: var(--blue-opacity-08);
  border-color: rgb(0 153 255 / 25%);
  border-left-color: var(--blue-opacity-60);
}

.ai-chat-message[data-context-type="element"] .ai-message-system-context {
  background: rgb(0 255 153 / 8%);
  border-color: rgb(0 255 153 / 25%);
  border-left-color: var(--green-opacity-60);
}

.ai-chat-message[data-context-type="element"] .ai-system-context-header {
  color: var(--green-ghost, #0f9);
}

.ai-chat-message[data-context-type="connection"] .ai-message-system-context {
  background: rgb(0 255 255 / 8%);
  border-color: rgb(0 255 255 / 25%);
  border-left-color: rgb(0 255 255 / 60%);
}

.ai-chat-message[data-context-type="connection"] .ai-system-context-header {
  color: #0ff;
}

/* AI Generation Mode Active State */
.ai-chat-input-area.ai-generation-active {
  border-top-color: var(--green-opacity-50);
  background: rgb(0 255 153 / 3%);
  box-shadow: 
    inset 0 1px 0 var(--green-opacity-20),
    0 0 12px var(--green-opacity-10);
}

/* AI Preview Modal Styles */
.ai-preview-modal .wb-modal-dialog {
  max-width: 800px;
  max-height: 85vh;
}

.ai-preview-dialog {
  display: flex;
  flex-direction: column;
}

.ai-preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  min-height: 400px;
  max-height: 60vh;
}

/* In-chat AI Proposal Block (replaces modal) */
.ai-chat-proposal-block {
  font-size: 0.9rem;
  border: 1px solid var(--blue-opacity-30);
  border-radius: 8px;
  overflow: hidden;
  background: var(--space-opacity-40);
}

.ai-proposal-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--blue-opacity-20);
}

.ai-proposal-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.ai-proposal-intent {
  font-weight: 700;
  color: var(--text-primary);
}

.ai-proposal-status {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 10px;
}

.ai-proposal-status.valid {
  background: var(--green-opacity-15);
  color: var(--green-ghost);
}

.ai-proposal-status.invalid {
  background: rgb(255 0 0 / 15%);
  color: #ff6b6b;
}

.ai-proposal-desc {
  margin: 0.5rem 0 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.4;
}

.ai-proposal-actions {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--blue-opacity-20);
}

.ai-proposal-section-title {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.ai-proposal-toggles {
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}

.ai-proposal-select-all,
.ai-proposal-deselect-all {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--blue-ghost);
  text-decoration: underline;
}

.ai-proposal-actions-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 200px;
  overflow-y: auto;
}

.ai-proposal-action-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 4px 0;
}

.ai-proposal-action-row input {
  margin: 0;
  flex-shrink: 0;
}

.ai-proposal-action-icon {
  flex-shrink: 0;
}

.ai-proposal-action-desc {
  flex: 1;
  font-size: 0.85rem;
}

.ai-proposal-action-status {
  flex-shrink: 0;
  font-weight: 700;
}

.ai-proposal-action-status.success {
  color: var(--green-ghost);
}

.ai-proposal-action-status.warning {
  color: #ffc107;
}

.ai-proposal-action-status.error {
  color: #ff6b6b;
}

.ai-proposal-empty {
  color: var(--text-muted);
  font-style: italic;
}

.ai-proposal-footer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  flex-wrap: wrap;
}

.ai-proposal-footer .btn {
  flex: 0 0 auto;
}

.ai-preview-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Preview Header */
.ai-preview-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ai-preview-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.ai-preview-title h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 0 9px var(--blue-opacity-50);
}

.ai-preview-status {
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.ai-preview-status.valid {
  background: var(--green-opacity-15);
  color: var(--green-ghost);
  border: 2px solid var(--green-opacity-40);
}

.ai-preview-status.invalid {
  background: rgb(255 0 0 / 15%);
  color: #ff6b6b;
  border: 2px solid rgb(255 0 0 / 40%);
}

.ai-preview-description {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* Preview Actions List */
.ai-preview-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ai-preview-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ai-preview-action-item {
  padding: 1rem;
  border-radius: 8px;
  border: 2px solid;
  background: var(--space-opacity-40);
  transition: all 0.3s ease;
}

.ai-preview-action-item.valid {
  border-color: var(--green-opacity-40);
  background: rgb(0 255 153 / 5%);
}

.ai-preview-action-item.warning {
  border-color: rgb(255 193 7 / 40%);
  background: rgb(255 193 7 / 5%);
}

.ai-preview-action-item.invalid {
  border-color: rgb(255 0 0 / 40%);
  background: rgb(255 0 0 / 5%);
}

.ai-action-item-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ai-action-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.ai-action-description {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.ai-action-status {
  font-size: 1.2rem;
  font-weight: 700;
  flex-shrink: 0;
}

.ai-action-status.success {
  color: var(--green-ghost);
}

.ai-action-status.warning {
  color: #ffc107;
}

.ai-action-status.error {
  color: #ff6b6b;
}

/* Action Details */
.ai-action-details {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--blue-opacity-20);
}

.ai-action-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.ai-info-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.ai-info-row .label {
  color: var(--text-muted);
  min-width: 100px;
}

.ai-info-row .value {
  color: var(--text-primary);
  font-weight: 600;
}

.ai-action-errors,
.ai-action-warnings {
  margin-top: 0.5rem;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
}

.ai-action-errors {
  background: rgb(255 0 0 / 10%);
  border: 1px solid rgb(255 0 0 / 30%);
  color: #ff6b6b;
}

.ai-action-warnings {
  background: rgb(255 193 7 / 10%);
  border: 1px solid rgb(255 193 7 / 30%);
  color: #ffc107;
}

.ai-action-errors strong,
.ai-action-warnings strong {
  display: block;
  margin-bottom: 0.5rem;
}

.ai-action-errors ul,
.ai-action-warnings ul {
  margin: 0;
  padding-left: 1.5rem;
}

.ai-action-errors li,
.ai-action-warnings li {
  margin: 0.25rem 0;
}

/* Preview Summary */
.ai-preview-summary {
  padding: 1.25rem;
  background: rgb(0 153 255 / 5%);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 10px;
}

.ai-summary-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.ai-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--space-opacity-60);
  border: 2px solid var(--blue-opacity-30);
  border-radius: 8px;
  min-width: 80px;
}

.ai-stat.success {
  border-color: var(--green-opacity-40);
  background: rgb(0 255 153 / 5%);
}

.ai-stat.error {
  border-color: rgb(255 0 0 / 40%);
  background: rgb(255 0 0 / 5%);
}

.ai-stat.warning {
  border-color: rgb(255 193 7 / 40%);
  background: rgb(255 193 7 / 5%);
}

.ai-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.ai-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ai-reasoning,
.ai-next-steps {
  margin-top: 1rem;
}

.ai-reasoning strong,
.ai-next-steps strong {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.ai-reasoning p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 0.9rem;
}

.ai-next-steps ul {
  margin: 0;
  padding-left: 1.5rem;
  color: var(--text-secondary);
}

.ai-next-steps li {
  margin: 0.5rem 0;
  line-height: 1.5;
}

/* Preview Footer Buttons */
.ai-preview-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.ai-preview-footer .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Empty transcript state */
.ai-chat-transcript-overlay:empty::before {
  content: 'No messages yet. Start a conversation!';
  display: block;
  text-align: center;
  padding: 40px 20px;
  color: #64748b;
  font-size: 0.9rem;
  font-style: italic;
}

/* ===========================
   Enhanced Agent Selector
   =========================== */

.agents-selector-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}

.manage-agents-btn {
  padding: 6px 12px !important;
  background: rgb(0 153 255 / 10%) !important;
  border: 1px solid rgb(0 153 255 / 30%) !important;
  border-radius: 9px;
  color: #38bdf8 !important;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.manage-agents-btn:hover {
  background: rgb(0 153 255 / 20%) !important;
  border-color: rgb(0 153 255 / 50%) !important;
  transform: translateY(-1px);
}

.agent-quick-info {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.agent-quick-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid transparent;
}

.chip-base {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 500;
}

.chip-success {
  background: rgb(34 197 94 / 20%);
  color: #4ade80;
  border: 1px solid rgb(34 197 94 / 30%);
}

.chip-muted {
  background: rgb(100 116 139 / 20%);
  color: #94a3b8;
  border: 1px solid rgb(100 116 139 / 30%);
}

/* Enhanced select dropdown */
.agents-select-header {
  flex: 1;
  padding: 9px 15px;
  background: rgb(15 23 42 / 80%);
  border: 1px solid rgb(0 153 255 / 30%);
  border-radius: 9px;
  color: #f8fafc;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.agents-select-header:hover {
  border-color: rgb(0 153 255 / 50%);
  background: rgb(0 153 255 / 5%);
}

.agents-select-header:focus {
  border-color: #09f;
  box-shadow: 0 0 0 3px rgb(0 153 255 / 10%);
}
