* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #0066cc;
  --primary-dark: #0052a3;
  --secondary: #f0f2f5;
  --text: #333333;
  --text-light: #666666;
  --border: #e0e0e0;
  --bg: #ffffff;
  --bg-light: #fafafa;
  --success: #00aa00;
  --warning: #ff9900;
  --error: #cc0000;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-light);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.container {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* Header */
.header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header h1 {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #0099ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.header-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1c274c;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.2s ease, background-color 0.2s ease;
  width: 36px;
  height: 36px;
  outline: none;
}

.header-btn:hover {
  transform: scale(1.03);
  color: var(--primary);
  background-color: rgba(0, 0, 0, 0.04);
}

.header-btn:active {
  transform: scale(0.95);
}

.header-btn svg {
  width: 20px;
  height: 20px;
}

.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-light);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 16px 240px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  margin-bottom: 0;
  min-height: 24px; /* Altura mínima idéntica para todos los encabezados */
}

.sidebar-header.collapsible {
  cursor: pointer;
}

.sidebar-header-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-header .btn {
  width: 20px !important;
  height: 20px !important;
  padding: 0 !important;
  min-width: 20px !important;
  min-height: 20px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  border: none;
  background: transparent !important; /* sin fondo por defecto */
  color: var(--text-light) !important; /* del mismo color que "herramientas" */
  border-radius: 4px;
  transition: background 0.15s ease;
}

.sidebar-header .btn:hover {
  background: rgba(0, 0, 0, 0.06) !important; /* al pasar el ratón encima, aparece el gris claro */
  color: var(--text-light) !important; /* no cambia de color al pasar el cursor */
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.sidebar-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sidebar-section h2 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-light);
  letter-spacing: 0.5px;
  flex: 1;
  margin: 0;
}

.sidebar-items,
.checkbox-list,
.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Base item — todos los tipos comparten esto */
.sidebar-list-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
  user-select: none;
}

.sidebar-list-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* Label dentro del item */
.sidebar-list-item label {
  display: flex;
  align-items: center;
  flex: 1;
  cursor: pointer;
  margin: 0;
  padding: 0;
  background: transparent;
}

/* Hover por defecto (sin estado activo) */
.sidebar-list-item:hover {
  background: #f9f9f9;
}

/* Agentes (verde) */
.sidebar-item--agent.selected {
  background: #e4ffe4;
}

.sidebar-item--agent.selected:hover {
  background: #d4ffd4;
}

/* Skills (azul) */
.sidebar-item--skill.selected {
  background: #e4f0ff;
}

.sidebar-item--skill.selected:hover {
  background: #d4e5ff;
}

/* Contextos (morado) */
.sidebar-item--context.selected {
  background: #f3e5f5;
}

.sidebar-item--context.selected:hover {
  background: #e1bee7;
}

/* Configuraciones (rojo) */
.sidebar-item--config.active {
  background: #ffe4e4;
}

.sidebar-item--config.active:hover {
  background: #ffd4d4;
}

.sidebar-items::-webkit-scrollbar {
  width: 6px;
}

.sidebar-items::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-items::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.checkbox-list label,
.radio-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  border-radius: 4px;
  transition: background 0.2s;
}

/* Hover handled by inline styles in JavaScript */
/*.checkbox-list label:hover,
.radio-list label:hover {
  background: var(--secondary);
}*/

.checkbox-list input,
.radio-list input {
  cursor: pointer;
  accent-color: var(--primary);
}

.radio-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: var(--shadow);
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--secondary);
  color: var(--text);
  width: 100%;
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #e0e0e0;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  width: auto;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  padding: 8px 12px;
}

.btn-ghost:hover {
  background: var(--secondary);
}

.icon-only {
  padding: 4px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.btn-danger {
  background: #f0f2f5 !important;
  color: #cc0000 !important;
  border: 1px solid #e0e0e0 !important;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn-danger:hover {
  background: #cc0000 !important;
  color: white !important;
  border-color: #cc0000 !important;
}

/* Chat Area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

/* Tabs */
.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: #f8f9fa;
  overflow-x: auto;
}

.tabs-list {
  display: flex;
  gap: 6px;
  flex: 1;
  align-items: center;
}

.tab {
  padding: 0 16px 0 10px;
  background: #eff0f1; /* Solid light grey instead of semi-transparent rgba */
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 34px;
}

.tab:hover {
  background: #e1e3e6; /* Solid slightly darker grey */
  color: var(--text);
}

.tab.active {
  background: var(--bg); /* Blanco */
  color: #0066cc;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  font-weight: 500; /* Igual peso que inactiva para evitar saltos de texto */
}

/* Botón de cerrar pestaña */
.tab-close-btn {
  opacity: 0.35; /* Visible en todas las pestañas por defecto, con tono claro */
  pointer-events: auto; /* Habilitado en todas las pestañas */
  transition: opacity 0.15s ease, transform 0.1s ease, color 0.15s ease;
  color: inherit; /* Hereda el tono de la pestaña */
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-close-btn:hover {
  opacity: 1;
  color: #cc0000;
  transform: scale(1.1);
}

.tab-close-btn:active {
  transform: scale(0.9);
}

.tab.active .tab-close-btn {
  opacity: 0.7; /* Más visible/mismo tono en la pestaña seleccionada */
  color: inherit; /* Hereda el color #0066cc del texto activo */
}

.tab.active .tab-close-btn:hover {
  opacity: 1;
  color: #cc0000;
}

/* Botón de añadir pestaña */
.tab-btn-add {
  width: 32px;
  height: 32px;
  padding: 0;
  background: rgba(0, 0, 0, 0.04); /* Color de fondo sutil */
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  transition: all 0.15s ease;
}

.tab-btn-add:hover {
  background: rgba(0, 0, 0, 0.08); /* Más oscuro en hover */
  color: var(--text);
}

/* Chips */
.chips-container {
  padding: 8px 16px; /* Ajuste para mantener la altura constante de 44px */
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  min-height: 44px;
  align-items: center;
}

.chip {
  background: linear-gradient(135deg, #e3f2fd, #bbdefb);
  color: var(--primary);
  height: 28px; /* Altura fija */
  padding: 0 12px; /* Solo relleno lateral */
  border-radius: 14px; /* Rueda completa */
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chip-close {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  margin-left: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.chip-close:hover {
  opacity: 1;
}

.empty-chips {
  color: var(--text-light);
  font-size: 13px;
  font-style: italic;
  margin: 0; /* Evita que los márgenes del párrafo causen saltos visuales */
  line-height: 28px; /* Mantiene la misma altura que los chips */
}

/* Messages */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#messages::-webkit-scrollbar {
  width: 8px;
}

#messages::-webkit-scrollbar-track {
  background: transparent;
}

#messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.empty-messages {
  color: var(--text-light);
  text-align: center;
  margin: auto;
  font-size: 14px;
}

.message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--radius);
  word-wrap: break-word;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-user {
  background: linear-gradient(135deg, var(--primary), #0099ff);
  color: white;
  align-self: flex-end;
  box-shadow: var(--shadow);
}

.message-assistant {
  background: #f5f7fa;
  color: var(--text);
  align-self: flex-start;
  border: 2px solid #f4f4f4;
}

.message-error {
  background: #ffebee;
  color: var(--error);
  align-self: flex-start;
  max-width: 100%;
  border-left: 4px solid var(--error);
}

.message.message-anchored {
  border: 2px solid var(--primary);
}

.message-system {
  align-self: center;
  background: var(--secondary);
  color: var(--text-light);
  font-size: 13px;
}

.message-header {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.7;
  margin-bottom: 4px;
}

.error-header {
  font-weight: 600;
  margin-bottom: 4px;
}

.message-content {
  font-size: 14px;
  white-space: pre-wrap;
  line-height: 1.6;
}

.message-content strong {
  font-weight: 600;
  color: inherit;
}

.message-content em {
  font-style: italic;
  color: inherit;
}

.message-content br {
  display: block;
  content: '';
}

.error-content {
  font-size: 14px;
}

.processing {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.processing-text {
  font-size: 14px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--secondary);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Message Action Buttons */
.message-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.message-wrapper-assistant {
  align-items: flex-start;
}

.message-wrapper-user {
  align-items: flex-end;
}

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

.message-action-btn,
.message-anchor-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #999;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.1s, background 0.1s, opacity 0.15s;
  opacity: 0;
}

.message-wrapper:hover .message-action-btn,
.message-wrapper:hover .message-anchor-btn {
  opacity: 1;
}

.message-action-btn:hover,
.message-anchor-btn:hover {
  color: #555;
  background: #f5f7fa;
}

.message-anchor-btn.anchor-active {
  color: #0066cc !important;
  opacity: 1 !important;
  position: relative;
  z-index: 10;
}

/* Input Area */
.input-area {
    padding: 12px 12px 12px 12px;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 24px 24px 24px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    z-index: 10;
}

.input-area:focus-within {
  border-color: rgba(0, 102, 204, 0.4);
  box-shadow: 0 4px 22px rgba(0, 102, 204, 0.08);
}

#message-input {
    width: 100%;
    padding: 7px 10px;
    border: none;
    border-radius: 0;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    background: transparent;
    outline: none;
    box-shadow: none;
    color: var(--text);
    line-height: 1.5;
}

#message-input::placeholder {
  color: #bbb;
}

.input-divider {
  height: 1px;
  background-color: #f1f2f4;
  width: 100%;
  margin: 2px 0;
}

.input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toolbar-group-left,
.toolbar-group-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-spacer {
  flex: 1;
}

.toolbar-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.2s ease, background-color 0.2s ease;
  width: 32px;
  height: 32px;
  outline: none;
}

.toolbar-btn:hover {
  transform: scale(1.03);
  color: var(--primary);
  background-color: rgba(0, 0, 0, 0.04);
}

.toolbar-btn:active {
  transform: scale(0.95);
}

/* History context dropdown styling */
.history-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 16px 6px 6px;
  border-radius: 16px;
  width: auto;
  height: 32px;
  position: relative;
}

.dropdown-toggle:hover {
  border-radius: 16px;
}

.dropdown-toggle .caret-container {
  display: flex;
  align-items: center;
  margin-top: 1px;
  position: relative;
  left: 8px;
}

.context-badge {
  position: absolute;
  bottom: 6px;
  left: 16px;
  right: auto;
  background-color: var(--primary);
  color: #ffffff;
  font-size: 8px;
  font-weight: 700;
  border-radius: 6px;
  min-width: 12px;
  height: 12px;
  padding: 0 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 12px;
}

#history-context-btn .context-badge {
  left: 17px;
}

.dropdown-menu {
  position: absolute;
  bottom: 40px;
  left: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: 6px;
  animation: popUp 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom left;
}

.hidden {
  display: none !important;
}

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

@keyframes popUp {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dropdown-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-light);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  text-align: left;
}

.dropdown-item:hover {
  background: #f5f7fa;
  color: var(--primary);
}

.dropdown-item.active {
  background: #e4f0ff;
  color: var(--primary);
  font-weight: 500;
}

/* Model selector custom styles (Dropdown) */
.model-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

#model-context-menu {
  bottom: 40px;
  right: 0;
  left: auto;
  min-width: 190px;
  max-width: 250px;
  display: flex;
  flex-direction: column;
  padding: 6px;
  overflow: visible;
}

#model-options-list {
  overflow-y: auto;
  max-height: 180px;
  display: flex;
  flex-direction: column;
  scrollbar-width: none; /* Firefox */
}

#model-options-list::-webkit-scrollbar {
  display: none; /* Safari/Chrome */
}

.model-item {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.model-favorite-btn {
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.15s ease;
  padding: 2px;
  flex-shrink: 0;
}

.model-favorite-btn.active {
  opacity: 1 !important;
  pointer-events: auto !important;
}

.model-item:hover .model-favorite-btn {
  opacity: 1;
  pointer-events: auto;
}

.model-favorite-btn:hover {
  transform: scale(1.18);
}

.inline-settings-btn {
  width: 28px;
  height: 28px;
}

/* Send button styling */
.send-btn-icon {
  width: 33px !important;
  height: 33px !important;
  padding: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0;
  border: none !important;
  color: #224380;
}

.send-btn-icon svg {
  width: 33px !important;
  height: 33px !important;
}

.send-btn-icon:hover {
  transform: scale(1.03) !important;
  background-color: transparent !important;
  color: #0B62CC !important;
}

/* Modals */
.modal {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-light);
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-light);
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text);
}

#prompt-text {
  padding: 20px;
  background: var(--secondary);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  max-height: 400px;
  font-family: 'Monaco', 'Courier New', monospace;
}

.modal-form {
  max-width: 500px;
}

.form-group {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s;
}

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

.form-actions {
  display: flex;
  gap: 8px;
  padding: 20px;
  background: var(--bg-light);
  border-top: 1px solid var(--border);
}

.form-actions .btn {
  flex: 1;
}

.modal-actions {
  display: flex;
  gap: 8px;
  padding: 20px;
  background: var(--bg-light);
  border-top: 1px solid var(--border);
}

.modal-actions .btn {
  flex: 1;
}

/* Item Lists (Agents, Skills) */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s;
}

.item-row:hover {
  background: var(--bg-light);
  box-shadow: var(--shadow);
}

.item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.item-name {
  font-weight: 600;
  font-size: 14px;
}

.item-desc {
  font-size: 12px;
  color: var(--text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-actions {
  display: flex;
  gap: 4px;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    max-height: 35vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .main {
    flex-direction: column;
  }

  .message {
    max-width: 100%;
  }

  .modal-content {
    max-width: 95%;
    max-height: 85vh;
  }
}

@keyframes blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Ensure accordion items stay behind context section */
.sidebar-items {
  position: relative;
  z-index: 1;
}

.sidebar-section:last-child {
  position: relative;
  z-index: 10;
}

/* Copy toast */
.copy-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 9999;
}

.copy-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Edit mode indicator */
#edit-mode-indicator {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(0, 102, 204, 0.07);
  border: 1px solid rgba(0, 102, 204, 0.2);
  border-radius: var(--radius);
  font-size: 12px;
  color: #0066cc;
}

#message-input.editing-mode {
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.edit-cancel-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.1s, color 0.1s;
}

.edit-cancel-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #333;
}

/* Markdown table styles */
.markdown-table-wrapper {
  overflow-x: auto;
  margin: 12px 0;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
}

.markdown-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 500px;
}

.markdown-table thead {
  background: #f5f5f5;
  position: sticky;
  top: 0;
}

.markdown-table th {
  padding: 12px 10px;
  text-align: left;
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #d0d0d0;
  font-size: 12px;
  word-break: break-word;
}

.markdown-table td {
  padding: 10px;
  border-bottom: 1px solid #e8e8e8;
  color: #555;
  font-size: 12px;
  word-break: break-word;
}

.markdown-table tbody tr:hover {
  background: #fafafa;
}

.markdown-table tbody tr:last-child td {
  border-bottom: none;
}

/* Markdown headers */
.message-content h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 16px 0 8px 0;
}

.message-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 14px 0 6px 0;
}

.message-content h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 12px 0 4px 0;
}

/* Markdown code blocks */
.message-content code {
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

.message-content pre {
  background: #f5f5f5;
  padding: 12px;
  border-radius: 6px;
  border-left: 3px solid #0066cc;
  margin: 8px 0;
  overflow-x: auto;
}

.message-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 12px;
}

/* Markdown lists */
.message-content ul {
  margin: 8px 0;
  padding-left: 24px;
}

.message-content li {
  margin: 4px 0;
  list-style-type: disc;
}

/* Markdown links */
.message-content a {
  color: #0066cc;
  text-decoration: none;
  border-bottom: 1px solid #0066cc;
}

.message-content a:hover {
  color: #0052a3;
}

/* Estilizado moderno para selectores de la barra lateral */
.sidebar-section select {
  border: 1px solid #dcdcdc;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  background-color: #fff;
  font-family: inherit;
  font-size: 12px;
  padding: 6px 8px;
}

.sidebar-section select:hover {
  border-color: #0066cc;
  background-color: #fafafa;
}

.sidebar-section select:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.12);
}

/* Estilizado y micro-animaciones del botón de ajustes de API */
#api-settings-btn {
  border-radius: 4px;
  transition: background-color 0.2s, transform 0.15s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

#api-settings-btn:hover {
  background-color: #e6f0fa;
  transform: scale(1.08);
}

#api-settings-btn:active {
  transform: scale(0.92);
}

/* Iconos de estado de pestañas y animaciones */
.tab-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(0, 0, 0, 0.25); /* Gris de contraste intermedio */
  border-top-color: #0066cc;
  border-radius: 50%;
  animation: spin 0.6s linear infinite, tab-icon-fade 0.2s ease-out;
  flex-shrink: 0;
  box-sizing: border-box;
}

.tab-notification-circle {
  width: 8px;
  height: 8px;
  background-color: #24e464; /* Verde neón muy fuerte e intenso */
  border-radius: 50%;
  flex-shrink: 0;
  box-sizing: border-box;
  box-shadow: 0 0 3px rgba(36, 228, 100, 0.5);
  animation: tab-icon-fade 0.25s ease-out, pulse-notification-glow 1.2s ease-in-out 3;
}

.tab-close-btn svg {
  animation: tab-icon-fade 0.2s ease-out;
}

@keyframes tab-icon-fade {
  from {
    opacity: 0;
    transform: scale(0.65);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse-notification-glow {
  0%, 100% {
    box-shadow: 0 0 3px rgba(36, 228, 100, 0.5);
  }
  50% {
    box-shadow: 0 0 6px rgba(36, 228, 100, 0.95); /* Parpadeo de luz sutil de max 6px sin anillos sólidos */
  }
}

.tab.dragging-active {
  z-index: 100;
  cursor: grabbing;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  transition: none !important; /* Desactivar transiciones durante el arrastre para evitar retrasos */
  background: #eff0f1 !important; /* Asegura fondo gris sólido al arrastrar pestaña inactiva */
}

.tab.active.dragging-active {
  background: #ffffff !important; /* Asegura fondo blanco sólido al arrastrar pestaña activa */
}

/* Custom global cursor overrides to keep default arrow pointer on buttons and selects */
button, select, option, input[type="button"], input[type="submit"], [role="button"], .tab, .chip, .accordion-header, .dropdown-item, .clean-select, .model-select-wrapper {
  cursor: default !important;
}

/* Estilos adicionales para navegación de anclas y botón scroll al final */
.chat-area {
  position: relative;
}

.anchor-dropdown-wrapper {
  position: relative;
  display: inline-block;
  max-width: 0;
  opacity: 0;
  pointer-events: none;
  margin-right: 0;
  transition: max-width 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s ease, margin-right 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  overflow: hidden;
  vertical-align: middle;
}

.anchor-dropdown-wrapper.visible {
  max-width: 80px;
  opacity: 1;
  pointer-events: auto;
  margin-right: 2px;
}

.anchor-dropdown-wrapper.visible.menu-open {
  overflow: visible;
}

#add-media-btn.dropdown-toggle .caret-container {
  left: 9px;
}

#anchor-context-menu {
  bottom: 40px;
  left: 0;
  min-width: 210px;
  max-width: 250px;
  max-height: 250px;
  overflow-y: auto;
}

.anchor-item-text {
  display: inline-block;
  max-width: 185px;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  vertical-align: middle;
}

.anchor-item-text::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  width: 35px;
  height: 100%;
  background: linear-gradient(to right, transparent, var(--bg));
  pointer-events: none;
}

.dropdown-item:hover .anchor-item-text::after {
  background: linear-gradient(to right, transparent, #f5f7fa);
}

.dropdown-item.active .anchor-item-text::after {
  background: linear-gradient(to right, transparent, #e4f0ff);
}

.message-wrapper {
  scroll-margin-top: 30px;
}

#scroll-to-bottom-btn {
  position: absolute;
  bottom: 155px;
  right: 27px;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.1);
  color: #003366;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 11;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease, color 0.2s ease;
  opacity: 0;
  pointer-events: none;
}

.input-area-container {
  position: relative;
  background: var(--bg);
  z-index: 10;
  padding-top: 1px;
}

.input-area-container::before {
  content: '';
  position: absolute;
  top: -25px;
  left: 0;
  right: 0;
  height: 25px;
  background: linear-gradient(to top, var(--bg) 0%, rgba(255, 255, 255, 0.8) 25%, rgba(255, 255, 255, 0.35) 65%, transparent 100%);
  pointer-events: none;
  z-index: 5;
}

#scroll-to-bottom-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

#scroll-to-bottom-btn:hover {
  transform: scale(1.08);
  color: var(--primary);
}

@keyframes highlightFlash {
  0% {
    background-color: rgba(0, 102, 204, 0.2);
    box-shadow: 0 0 10px rgba(0, 102, 204, 0.35);
  }
  100% {
    background-color: transparent;
    box-shadow: none;
  }
}

.highlight-flash {
  animation: highlightFlash 1.5s ease-out;
}

/* Cabeceras y divisores para los menús desplegables */
.dropdown-header {
  padding: 6px 10px 4px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #888888;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  user-select: none;
  font-family: Arial, Helvetica, sans-serif;
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border) !important;
  margin: 3px -6px 6px -6px;
  display: block !important;
}

#model-select-btn {
  padding: 6px 12px 6px 12px !important;
}

#model-select-btn .caret-container {
  left: 3px !important;
}

/* Media files dropdown wrapper */
.media-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

#add-media-btn .context-badge {
  left: 16px;
}

#media-files-menu {
  bottom: 40px;
  left: 0;
  min-width: 240px;
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.media-file-thumbnail {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 4px;
}

.media-file-thumbnail-image {
  position: relative;
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f5f5f5;
  flex-shrink: 0;
}

.media-file-thumbnail-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-file-thumbnail-name {
  flex: 1;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-light);
}

.media-file-remove-btn {
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: #cc0000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 4px;
}

/* File chips for enhanced file handling */
.file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  margin: 4px 0;
  font-size: 12px;
  color: var(--text);
  transition: all 0.2s ease;
}

.file-chip:hover {
  border-color: var(--primary);
  background: rgba(0, 102, 204, 0.05);
}

.file-chip--sticky {
  border-color: var(--primary);
  background: rgba(0, 102, 204, 0.1);
  box-shadow: inset 0 0 0 1px rgba(0, 102, 204, 0.3);
}

.file-chip--processing {
  opacity: 0.6;
}

.file-chip__format-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.file-chip__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip__status {
  font-size: 10px;
  color: var(--text-light);
}

.file-chip__status--error {
  color: #cc0000;
}

.file-chip__sticky-btn {
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.file-chip__sticky-btn:hover {
  color: var(--primary);
}

.file-chip__remove-btn {
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.file-chip__remove-btn:hover {
  color: #cc0000;
}

/* Enhanced model selector */
.model-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

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

.model-badges {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

.badge--new {
  display: inline-block;
  background: #10b981;
  color: white;
  font-size: 8px;
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 3px;
  text-transform: uppercase;
  line-height: 1;
}

.model-capability {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.model-capability:hover {
  opacity: 1;
}

.model-capability svg {
  display: block;
}

/* Estilos para ítems anclados en el menú y botón anti-ancla */
.anchor-dropdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.anchor-dropdown-item .anchor-item-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.anchor-dropdown-item .unanchor-item-btn {
  opacity: 0;
  pointer-events: none;
  color: #888888;
  transition: opacity 0.2s ease, color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.anchor-dropdown-item:hover .unanchor-item-btn {
  opacity: 1;
  pointer-events: auto;
}

.anchor-dropdown-item .unanchor-item-btn:hover {
  color: #ff3b30; /* Rojo */
}

/* Switcher Premium */
.switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #e2e8f0;
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid #cbd5e1;
}

.slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

input:checked + .slider {
  background-color: var(--primary);
  border-color: var(--primary-dark);
}

input:checked + .slider:before {
  transform: translateX(14px);
}

.slider.round {
  border-radius: 18px;
}

.slider.round:before {
  border-radius: 50%;
}

.model-scroll-indicator {
  position: absolute;
  left: 6px;
  right: 6px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888888;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 10;
}

#model-scroll-indicator-up {
  top: 38px;
  height: 30px;
  background: linear-gradient(to bottom, var(--bg) 35%, transparent 100%);
}

#model-scroll-indicator-down {
  bottom: 6px;
  height: 44px;
  align-items: flex-end;
  padding-bottom: 6px;
  background: linear-gradient(to top, var(--bg) 60%, transparent 100%);
}

.model-scroll-indicator.visible {
  opacity: 1;
}

/* ==========================================================================
   Folder System Styles
   ========================================================================== */

.sidebar-folder-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 2px;
}

.folder-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  background: transparent;
  user-select: none;
  transition: background 0.2s, transform 0.1s;
}

.folder-header:hover {
  background: transparent;
}

.folder-header:active {
  transform: scale(0.99);
}

.folder-header.folder-favorite {
  border-left: 3px solid #ffcc00;
}

.folder-title-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.folder-caret {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
  color: var(--text-light);
}

.folder-header.collapsed .folder-caret {
  transform: rotate(-90deg);
}

.folder-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-left: 16px;
  padding-left: 8px;
  border-left: 1.5px dashed var(--border);
  overflow: hidden;
  margin-top: 4px;
  margin-bottom: 4px;
}

.folder-header.collapsed + .folder-content {
  display: none !important;
}

.subfolder-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-left: 16px;
  padding-left: 8px;
  border-left: 1.2px dashed var(--border);
  overflow: hidden;
  margin-top: 4px;
  margin-bottom: 4px;
}

.folder-header.collapsed + .subfolder-content {
  display: none !important;
}

/* Modals context selection list */
#folder-contexts-list label {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 8px 10px !important;
  background: #f8fafc !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  cursor: pointer !important;
  font-weight: 500 !important;
  font-size: 13px !important;
  margin-bottom: 0 !important;
  color: var(--text) !important;
  width: 100% !important;
  justify-content: flex-start !important;
  transition: background 0.15s, border-color 0.15s !important;
}

#folder-contexts-list label:hover {
  background: #f0f4f8 !important;
  border-color: #cbd5e1 !important;
}

#folder-contexts-list input[type="checkbox"] {
  width: 16px !important;
  height: 16px !important;
  margin: 0 !important;
  padding: 0 !important;
  cursor: pointer !important;
  flex-shrink: 0 !important;
  border: none !important;
  box-shadow: none !important;
}

/* Ocultar botones de ajustes para demostración pública */
#settings-btn, #extra-settings-btn, #api-settings-btn {
  display: none !important;
}

/* Estilos del contador de usos */
.usage-counter {
  flex: 1;
  font-size: 12px;
  color: #666;
  padding: 4px 8px;
  text-align: center;
}

.usage-counter--exhausted {
  color: #cc0000;
  font-weight: 500;
}

/* ── Tutorial Popup ────────────────────────────────── */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.tutorial-overlay.hidden { display: none; }

.tutorial-modal {
  position: relative;
  width: min(1000px, 80vw);
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

.tutorial-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 10;
  background: rgba(0,0,0,0.45);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.tutorial-close:hover { background: rgba(0,0,0,0.7); }

.tutorial-track { position: relative; }

.tutorial-slide { display: none; }
.tutorial-slide.active { display: block; }

.tutorial-slide img {
  width: 100%;
  max-height: 75vh;
  object-fit: contain;
  display: block;
  user-select: none;
}

.tutorial-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  background: #fff;
}

.tutorial-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ccc;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.tutorial-dot.active {
  background: var(--primary);
  transform: scale(1.3);
}
.tutorial-dot:hover { background: #999; }

.tutorial-arrow {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #bbb;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.2s;
  user-select: none;
}
#tutorial-prev { margin-right: 16px; }
#tutorial-next { margin-left: 16px; }
.tutorial-arrow:hover { color: var(--primary, #0066cc); }
.tutorial-arrow:disabled { opacity: 0.25; cursor: default; }

