/* ==========================================================================
   Gali IA - Sistema de Estilos Profesionales
   Diseño sobrio, refinado y centrado en el usuario (Sin estridencias de IA)
   ========================================================================== */

:root {
  /* Tema Gris y Rojo Profesional (Gali IA) */
  --bg-app: #121316;
  --bg-sidebar: #17181e;
  --bg-sidebar-hover: #20222a;
  --bg-surface: #1a1c23;
  --bg-surface-hover: #232630;
  --bg-surface-elevated: #262934;
  --bg-user-bubble: #252834;
  --bg-code: #0c0d10;
  --border-subtle: #272a35;
  --border-strong: #383c4b;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-faint: #6b7280;
  
  --accent: #e11d48;
  --accent-hover: #be123c;
  --accent-subtle: rgba(225, 29, 72, 0.12);
  --accent-border: rgba(225, 29, 72, 0.35);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-subtle: rgba(239, 68, 68, 0.12);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.45), 0 2px 4px -1px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.55), 0 4px 6px -2px rgba(0, 0, 0, 0.35);

  --sidebar-width: 270px;
  --header-height: 60px;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* Modo Claro Limpio */
[data-theme="light"] {
  --bg-app: #f4f4f6;
  --bg-sidebar: #eaebee;
  --bg-sidebar-hover: #dfdfe4;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f7f7f9;
  --bg-surface-elevated: #ffffff;
  --bg-user-bubble: #f0f0f3;
  --bg-code: #16171d;
  --border-subtle: #e2e3e8;
  --border-strong: #c8cbd4;

  --text-main: #111317;
  --text-muted: #525866;
  --text-faint: #868c98;

  --accent: #e11d48;
  --accent-hover: #be123c;
  --accent-subtle: rgba(225, 29, 72, 0.08);
  --accent-border: rgba(225, 29, 72, 0.25);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.06);
}

/* Reset y base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-main);
  background-color: var(--bg-app);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar refinado */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

/* Contenedor Principal de la App */
#app-root {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   Barra Lateral (Sidebar)
   ========================================================================== */

.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-normal), width var(--transition-normal);
  z-index: 50;
}

.sidebar.collapsed {
  transform: translateX(-100%);
  position: absolute;
}

.sidebar-header {
  padding: 16px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.5px;
}

.brand-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-main);
}

.brand-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  background-color: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.btn-sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.btn-sidebar-toggle:hover {
  background-color: var(--bg-sidebar-hover);
  color: var(--text-main);
}

/* Botón Nuevo Chat */
.sidebar-action-box {
  padding: 14px 14px 8px;
}

.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-new-chat:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-new-chat-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kbd-shortcut {
  font-size: 11px;
  color: var(--text-faint);
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  padding: 2px 5px;
  border-radius: 4px;
}

/* Buscador de conversaciones */
.sidebar-search-box {
  padding: 0 14px 8px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper svg {
  position: absolute;
  left: 10px;
  color: var(--text-faint);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.search-input:focus {
  border-color: var(--border-strong);
}

.search-input::placeholder {
  color: var(--text-faint);
}

/* Lista de conversaciones */
.sidebar-history {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 6px 8px 2px 8px;
}

.history-group-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conversation-item,
.history-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  font-size: 13.5px;
  border: 1px solid transparent;
  user-select: none;
}

.conversation-item:hover,
.history-item:hover {
  background-color: var(--bg-sidebar-hover);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.conversation-item.active,
.history-item.active {
  background-color: var(--bg-surface);
  color: #ffffff;
  border-color: rgba(225, 29, 72, 0.4);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.conversation-icon {
  flex-shrink: 0;
  color: var(--text-faint);
  transition: color var(--transition-fast);
}

.conversation-item:hover .conversation-icon {
  color: var(--text-muted);
}

.conversation-item.active .conversation-icon {
  color: var(--accent);
}

.conversation-title,
.history-item-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  padding-right: 4px;
}

.conversation-actions,
.history-item-actions {
  display: none;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  flex-shrink: 0;
}

.conversation-item:hover .conversation-actions,
.conversation-item.active .conversation-actions,
.history-item:hover .history-item-actions,
.history-item.active .history-item-actions {
  display: flex;
}

.btn-item-action {
  background: none;
  border: none;
  color: var(--text-faint);
  padding: 4px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.btn-item-action:hover {
  color: var(--text-main);
  background-color: var(--bg-surface-elevated);
}

.btn-item-action.btn-delete:hover,
.btn-item-action.delete:hover {
  color: var(--danger);
  background-color: var(--danger-subtle);
}

.history-empty-state,
.history-empty {
  text-align: center;
  padding: 32px 14px;
  color: var(--text-faint);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pie de la barra lateral (Usuario) */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-sidebar);
}

.user-profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.user-profile-left {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, #e11d48 0%, #991b1b 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(225, 29, 72, 0.3);
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-label {
  font-size: 11px;
  color: var(--text-muted);
}

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

/* ==========================================================================
   Contenedor Principal de Chat
   ========================================================================== */

.main-chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background-color: var(--bg-app);
  overflow: hidden;
}

/* Barra Superior (Top Bar) */
.top-bar {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-app);
  z-index: 20;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Selector de Modelo */
.model-selector {
  position: relative;
  display: flex;
  align-items: center;
}

.model-select {
  appearance: none;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 30px 6px 12px;
  color: var(--text-main);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-fast);
}

.model-select:hover, .model-select:focus {
  border-color: var(--border-strong);
  background-color: var(--bg-surface-hover);
}

.model-selector-chevron {
  position: absolute;
  right: 10px;
  pointer-events: none;
  color: var(--text-muted);
}

/* Píldora de Estado de la IA */
.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 999px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background-color: var(--text-faint);
}

.status-dot.online {
  background-color: var(--success);
  box-shadow: 0 0 0 2px var(--success-bg);
}

.status-dot.offline {
  background-color: var(--danger);
}

/* Botón de Memoria en Barra Superior */
.btn-memory-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-memory-indicator:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.btn-icon-square {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon-square:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
  background-color: var(--bg-surface-hover);
}

/* Área de Mensajes de Conversación */
.chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

.messages-inner-wrapper {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Estado de Bienvenida (Hero) */
.hero-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 20px 24px;
  margin: auto 0;
}

.hero-icon-box {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-lg);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.hero-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text-main);
  margin-bottom: 8px;
}

.hero-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  max-width: 480px;
  margin-bottom: 36px;
}

.prompt-suggestions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 680px;
}

.prompt-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.prompt-card:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.prompt-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.prompt-card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Mensajes Individuales */
.message-row {
  display: flex;
  gap: 16px;
  width: 100%;
}

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

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  object-fit: cover;
  border: 1px solid rgba(225, 29, 72, 0.25);
  background-color: var(--bg-surface);
}

.message-row.assistant .message-avatar {
  background-color: var(--bg-surface);
  border: 1px solid rgba(225, 29, 72, 0.3);
  color: var(--text-main);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.message-body {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

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

.message-bubble {
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  font-size: 15px;
  line-height: 1.65;
  word-break: break-word;
}

.message-row.user .message-bubble {
  background-color: var(--bg-user-bubble);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-bottom-right-radius: var(--radius-xs);
}

.message-row.assistant .message-bubble {
  background-color: transparent;
  color: var(--text-main);
  padding: 0;
  width: 100%;
}

/* Bloque de Pensamiento / Razonamiento (<think>) */
.reasoning-block {
  margin-bottom: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  overflow: hidden;
}

.reasoning-header {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  background-color: var(--bg-surface);
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
  user-select: none;
}

.reasoning-header:hover {
  color: var(--text-main);
}

.reasoning-content {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-muted);
  background-color: var(--bg-app);
  border-top: 1px solid var(--border-subtle);
  white-space: pre-wrap;
  font-family: var(--font-sans);
  line-height: 1.5;
  display: none;
}

.reasoning-block.expanded .reasoning-content {
  display: block;
}

/* Acciones del mensaje */
.message-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.message-row:hover .message-actions {
  opacity: 1;
}

.btn-msg-action {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.btn-msg-action:hover {
  color: var(--text-main);
  background-color: var(--bg-surface-hover);
}

/* Cursor de streaming */
.typing-cursor {
  display: inline-block;
  width: 7px;
  height: 16px;
  background-color: var(--accent);
  margin-left: 3px;
  vertical-align: middle;
  animation: blink 1s infinite;
}

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

/* ==========================================================================
   Contenedor de Entrada de Chat (Bottom Input)
   ========================================================================== */

.chat-input-container {
  padding: 12px 20px 20px;
  background-color: var(--bg-app);
  position: relative;
  z-index: 10;
}

.chat-input-wrapper {
  max-width: 820px;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

.input-box-card {
  position: relative;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 10px 14px 10px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-box-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  min-height: 24px;
  padding: 4px 0;
}

.chat-textarea::placeholder {
  color: var(--text-faint);
}

.input-action-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-send {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background-color: var(--accent);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 6px rgba(225, 29, 72, 0.35);
}

.btn-send:hover:not(:disabled) {
  background-color: var(--accent-hover);
  transform: scale(1.06);
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.45);
}

.btn-send:disabled {
  background-color: var(--border-subtle);
  color: var(--text-faint);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-stop {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background-color: var(--danger);
  color: #ffffff;
  border: none;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-stop:hover {
  background-color: var(--danger-hover);
  transform: scale(1.04);
}

.btn-stop.visible {
  display: flex;
}

.input-disclaimer {
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 8px;
}

/* ==========================================================================
   Modales (Memoria, Ajustes, Confirmación)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-window {
  width: 100%;
  max-width: 540px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px) scale(0.98);
  transition: transform var(--transition-normal);
}

.modal-backdrop.open .modal-window {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-main);
}

.modal-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background-color: var(--bg-app);
}

.btn-secondary {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.btn-primary {
  padding: 8px 18px;
  border-radius: var(--radius-md);
  background-color: var(--accent);
  border: 1px solid var(--accent);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

/* ==========================================================================
   Pantalla de Autenticación (Login / Register)
   ========================================================================== */

.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 36px 32px;
  border-radius: var(--radius-xl);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.auth-tab.active {
  color: var(--text-main);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.form-input {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background-color: var(--bg-app);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-input:focus {
  border-color: var(--accent);
}

.auth-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background-color: var(--danger-subtle);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 13px;
  display: none;
}

.auth-error.visible {
  display: block;
}

/* ==========================================================================
   Renderizado de Markdown y Código
   ========================================================================== */

.markdown-body {
  font-size: 15px;
  line-height: 1.7;
}

.markdown-body p {
  margin-bottom: 14px;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  font-weight: 600;
  color: var(--text-main);
  margin-top: 20px;
  margin-bottom: 10px;
  letter-spacing: -0.3px;
}

.markdown-body h1 { font-size: 22px; }
.markdown-body h2 { font-size: 18px; }
.markdown-body h3 { font-size: 16px; }

.markdown-body ul, .markdown-body ol {
  margin-bottom: 14px;
  padding-left: 24px;
}

.markdown-body li {
  margin-bottom: 4px;
}

.markdown-body blockquote {
  border-left: 3px solid var(--border-strong);
  padding: 6px 16px;
  margin: 14px 0;
  color: var(--text-muted);
  background-color: var(--bg-surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.markdown-body th, .markdown-body td {
  padding: 10px 14px;
  border: 1px solid var(--border-subtle);
  text-align: left;
}

.markdown-body th {
  background-color: var(--bg-surface);
  font-weight: 600;
}

.markdown-body tr:nth-child(even) td {
  background-color: var(--bg-surface);
}

.markdown-body code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

/* Bloques de Código */
.code-block-wrapper {
  margin: 16px 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-code);
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.btn-copy-code {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 3px 6px;
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
}

.btn-copy-code:hover {
  color: var(--text-main);
  background-color: var(--bg-surface-elevated);
}

.code-block-wrapper pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.55;
  background-color: var(--bg-code);
}

/* ==========================================================================
   Responsive & Mobile
   ========================================================================== */

@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
  }

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

  .prompt-suggestions-grid {
    grid-template-columns: 1fr;
  }

  .top-bar {
    padding: 0 12px;
  }

  .messages-inner-wrapper {
    padding: 0 12px;
  }

  .chat-input-container {
    padding: 10px 12px 14px;
  }
}

/* ==========================================================================
   Monedero, Tarjeta de Crédito y Pagos
   ========================================================================== */

.btn-wallet-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(26, 28, 35, 0.85);
  border: 1px solid rgba(225, 29, 72, 0.35);
  color: #ffffff;
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: all var(--transition-normal);
  user-select: none;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.btn-wallet-pill svg {
  color: var(--accent);
  transition: transform var(--transition-fast);
}

.btn-wallet-pill:hover {
  background: rgba(33, 36, 46, 0.95);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.25);
}

.btn-wallet-pill:hover svg {
  transform: scale(1.1);
}

#wallet-balance-text {
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #ffffff;
}

.wallet-badge-add {
  background: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2.5px 8px;
  border-radius: 9999px;
  margin-left: 2px;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 6px rgba(225, 29, 72, 0.4);
  transition: all var(--transition-fast);
}

.btn-wallet-pill:hover .wallet-badge-add {
  filter: brightness(1.12);
  transform: scale(1.03);
}

.wallet-balance-card {
  background: linear-gradient(135deg, #1d1f27 0%, #15161c 100%);
  border: 1px solid rgba(225, 29, 72, 0.25);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.wallet-balance-number {
  font-size: 32px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  text-shadow: 0 2px 10px rgba(225, 29, 72, 0.2);
}

.wallet-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
  padding-bottom: 8px;
}

.wallet-tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.wallet-tab-btn.active {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  border-bottom: 2px solid var(--accent);
}

.recharge-presets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.recharge-preset-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 6px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.recharge-preset-btn:hover {
  border-color: var(--accent);
  background: var(--bg-surface-hover);
}

.recharge-preset-btn.active {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: #f43f5e;
  box-shadow: 0 0 0 2px rgba(225, 29, 72, 0.25);
}

.recharge-preset-badge {
  position: absolute;
  top: -8px;
  right: -4px;
  background: var(--accent);
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 9999px;
  box-shadow: 0 2px 5px rgba(225, 29, 72, 0.4);
}

/* Maqueta visual de Tarjeta de Crédito */
.credit-card-preview {
  width: 100%;
  height: 170px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #242733 0%, #15161c 100%);
  border: 1px solid rgba(225, 29, 72, 0.3);
  padding: 18px 22px;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin-bottom: 20px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
  position: relative;
  overflow: hidden;
}

.credit-card-preview::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, rgba(225, 29, 72, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.card-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-chip {
  width: 38px;
  height: 28px;
  background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%);
  border-radius: 5px;
  position: relative;
  border: 1px solid #a16207;
}

.card-number-display {
  font-family: var(--font-mono);
  font-size: 19px;
  letter-spacing: 2px;
  color: #f1f5f9;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.card-bottom-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  text-transform: uppercase;
  color: #94a3b8;
}

.card-holder-name {
  font-size: 13px;
  font-weight: 600;
  color: #f8fafc;
  letter-spacing: 0.5px;
}

.transactions-table-container {
  max-height: 280px;
  overflow-y: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.transaction-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}

.transaction-row:last-child {
  border-bottom: none;
}

.tx-amount-positive {
  color: var(--success);
  font-weight: 700;
}

.tx-amount-negative {
  color: var(--text-faint);
  font-weight: 600;
}

/* ==========================================================================
   Estilos Corporativos de Gali IA (Logo, Perfil, Multimodal y Edición)
   ========================================================================== */

/* Logos corporativos */
.brand-logo-img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(225, 29, 72, 0.3);
}

.auth-logo-img {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 4px 18px rgba(225, 29, 72, 0.3);
  border: 1px solid rgba(225, 29, 72, 0.35);
}

.hero-logo-img {
  width: 76px;
  height: 76px;
  border-radius: 16px;
  object-fit: cover;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(225, 29, 72, 0.3);
  border: 1px solid rgba(225, 29, 72, 0.35);
}

/* Botón de Perfil en Cabecera */
.btn-profile-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 6px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.btn-profile-pill:hover {
  background-color: var(--bg-surface-hover);
  border-color: rgba(225, 29, 72, 0.4);
}

.user-avatar-small {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e11d48 0%, #991b1b 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(225, 29, 72, 0.3);
}

.profile-avatar-big {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e11d48 0%, #991b1b 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.35);
}

.profile-header-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

/* Botón y Barra de Adjuntos (Multimodal) */
.btn-input-attach {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.btn-input-attach:hover {
  color: var(--text-main);
  background-color: var(--bg-surface-hover);
}

.attachment-preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text-main);
}

.attachment-thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
}

.attachment-filename {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-remove-attachment {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 3px;
  transition: color var(--transition-fast);
}

.btn-remove-attachment:hover {
  color: var(--danger);
}

/* Renderizado de Imágenes en Mensajes de Chat */
.chat-message-image-wrap {
  margin-bottom: 10px;
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: 380px;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
}

.chat-message-image {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.chat-message-image:hover {
  opacity: 0.9;
}

/* Botón y Editor Inline de Mensajes */
.btn-edit-message {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  transition: all var(--transition-fast);
}

.btn-edit-message:hover {
  color: var(--text-main);
  background-color: var(--bg-surface-hover);
}

.message-inline-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 6px;
}

.message-edit-textarea {
  width: 100%;
  padding: 10px 12px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  resize: vertical;
  min-height: 80px;
}

.message-edit-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.message-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

