.chatAssistantRoot {
  --chat-panel-width: 20vw;
  --chat-brand: #405189;
  --chat-brand-dark: #364574;
  --chat-brand-soft: #eef1f8;
  --chat-brand-soft-hover: #e3e8f4;
  --chat-surface: #ffffff;
  --chat-surface-muted: #f4f6f9;
  --chat-border: #e4e7ec;
  --chat-text: #212529;
  --chat-text-muted: #6c757d;
  --chat-footer-height: 60px;
  --chat-fab-offset: calc(var(--chat-footer-height) + 0.75rem);
  --chat-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --chat-shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
}

.chatPanel {
  display: flex;
  flex-direction: column;
  background: var(--chat-surface);
  border-left: 1px solid var(--chat-border);
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.12);
  z-index: 1045;
  isolation: isolate;
}

.chatPanelEmbedded {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--chat-panel-width);
  min-width: 320px;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
}

.chatPanelFloating {
  position: fixed;
  bottom: var(--chat-fab-offset);
  right: 1.25rem;
  width: 420px;
  max-width: calc(100vw - 2rem);
  height: min(640px, calc(100vh - 3rem));
  height: min(640px, calc(100dvh - 3rem));
  border: 1px solid var(--chat-border);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.18);
}

.chatToggle {
  position: fixed;
  bottom: var(--chat-fab-offset);
  right: 1.25rem;
  z-index: 1050;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: none;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  appearance: none;
  background: linear-gradient(135deg, var(--chat-brand) 0%, var(--chat-brand-dark) 100%);
  box-shadow: 0 8px 22px rgba(64, 81, 137, 0.32);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chatToggleIcon {
  font-size: 1.25rem;
  line-height: 1;
  display: block;
  color: #fff;
  pointer-events: none;
}

.chatToggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(64, 81, 137, 0.4);
}

.chatToggle:focus-visible,
.chatHeaderButton:focus-visible,
.chatSendButton:focus-visible,
.chatInput:focus-visible,
.chatModeButton:focus-visible,
.chatMenuButton:focus-visible,
.chatRetryButton:focus-visible {
  outline: 2px solid var(--chat-brand);
  outline-offset: 2px;
}

.chatHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: linear-gradient(135deg, var(--chat-brand) 0%, var(--chat-brand-dark) 100%);
  color: #fff;
  flex-shrink: 0;
}

.chatHeaderBrand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
}

.chatHeaderIcon {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.125rem;
}

.chatHeaderText {
  min-width: 0;
}

.chatHeaderTitle {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}

.chatHeaderSubtitle {
  margin: 0.125rem 0 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatHeaderActions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

.chatHeaderButton,
.chatModeButton {
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  border-radius: 0.5rem;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.chatHeaderButton:hover,
.chatModeButton:hover {
  background: rgba(255, 255, 255, 0.22);
}

.chatModeGroup {
  display: inline-flex;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.5rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.chatModeButton {
  border-radius: 0;
  background: transparent;
}

.chatModeButtonActive {
  background: rgba(255, 255, 255, 0.95);
  color: var(--chat-brand);
}

.chatBody {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--chat-surface-muted);
}

.chatMessageList {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background:
    linear-gradient(180deg, #eef1f6 0%, var(--chat-surface-muted) 48%, #eef1f6 100%);
  scrollbar-width: thin;
  scrollbar-color: #c4cad4 transparent;
}

.chatMessageList::-webkit-scrollbar {
  width: 6px;
}

.chatMessageList::-webkit-scrollbar-thumb {
  background: #c4cad4;
  border-radius: 999px;
}

.chatMessageRow {
  display: flex;
  flex-direction: column;
  gap: 0.3125rem;
  max-width: 92%;
  animation: chatMessageIn 0.28s ease-out;
}

@keyframes chatMessageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

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

.chatMessageRowUser {
  align-self: flex-end;
  align-items: flex-end;
}

.chatMessageRowAssistant {
  align-self: flex-start;
  align-items: flex-start;
}

.chatMessageLabel {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--chat-text-muted);
  padding: 0 0.25rem;
}

.chatBubbleText {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin: 0;
}

.chatBubbleTextLine {
  margin: 0;
  line-height: 1.5;
}

.chatBubbleTextSpacer {
  min-height: 0.5rem;
}

.chatBubble {
  padding: 0.875rem 1rem;
  border-radius: 1.125rem;
  line-height: 1.55;
  word-break: break-word;
  font-size: 0.875rem;
  /* Saira no incluye glifos emoji; priorizar fuentes emoji por carácter. */
  font-family:
    'Apple Color Emoji',
    'Segoe UI Emoji',
    'Segoe UI Symbol',
    'Noto Color Emoji',
    emoji,
    var(--bs-font-sans-serif, 'Saira', sans-serif);
  font-variant-emoji: emoji;
}

.chatBubbleUser {
  background: linear-gradient(145deg, var(--chat-brand) 0%, #4a5f9c 55%, var(--chat-brand-dark) 100%);
  color: #fff;
  border-bottom-right-radius: 0.3125rem;
  box-shadow: 0 6px 16px rgba(64, 81, 137, 0.24);
}

.chatBubbleAssistant {
  background: var(--chat-surface);
  color: var(--chat-text);
  border: 1px solid rgba(228, 231, 236, 0.95);
  border-bottom-left-radius: 0.3125rem;
  box-shadow: var(--chat-shadow-md);
}

.chatBubbleError {
  background: #fff8f7;
  color: #b42318;
  border: 1px solid #fecdca;
  border-bottom-left-radius: 0.3125rem;
  box-shadow: var(--chat-shadow-sm);
}

.chatInputArea {
  border-top: 1px solid var(--chat-border);
  padding: 0.875rem;
  display: flex;
  gap: 0.625rem;
  align-items: flex-end;
  background: var(--chat-surface);
  flex-shrink: 0;
}

.chatInput {
  flex: 1;
  resize: none;
  min-height: 2.75rem;
  max-height: 8rem;
  border: 1px solid var(--chat-border);
  border-radius: 0.75rem;
  padding: 0.625rem 0.875rem;
  font: inherit;
  font-size: 0.875rem;
  background: var(--chat-surface-muted);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chatInput:focus {
  border-color: var(--chat-brand);
  box-shadow: 0 0 0 3px rgba(64, 81, 137, 0.12);
  background: var(--chat-surface);
  outline: none;
}

.chatSendButton {
  border: none;
  background: linear-gradient(135deg, var(--chat-brand) 0%, var(--chat-brand-dark) 100%);
  color: #fff;
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.chatSendButton:hover:not(:disabled) {
  transform: scale(1.04);
}

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

.chatTypingBubble {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 4.5rem;
  padding: 0.875rem 1rem;
}

.chatTypingDots {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  height: 1rem;
}

.chatTypingDots span {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: #8696a0;
  animation: chatTypingBounce 1.4s infinite ease-in-out;
}

.chatTypingDots span:nth-child(1) {
  animation-delay: 0s;
}

.chatTypingDots span:nth-child(2) {
  animation-delay: 0.2s;
}

.chatTypingDots span:nth-child(3) {
  animation-delay: 0.4s;
}

.chatTypingText {
  font-size: 0.8125rem;
  color: var(--chat-text-muted);
  font-style: italic;
}

@keyframes chatTypingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }

  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.chatTableWrapper {
  overflow-x: auto;
  margin-top: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid var(--chat-border);
  box-shadow: var(--chat-shadow-sm);
}

.chatTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  background: var(--chat-surface);
}

.chatTable th,
.chatTable td {
  border-bottom: 1px solid var(--chat-border);
  padding: 0.5rem 0.625rem;
  text-align: left;
}

.chatTable tr:last-child td {
  border-bottom: none;
}

.chatTable th {
  background: var(--chat-brand-soft);
  color: var(--chat-brand-dark);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.chatCardList {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-top: 0.75rem;
}

.chatCardItem {
  border: 1px solid var(--chat-border);
  border-radius: 0.875rem;
  padding: 0.75rem 0.875rem;
  background: linear-gradient(180deg, #ffffff 0%, var(--chat-brand-soft) 160%);
  box-shadow: var(--chat-shadow-sm);
}

.chatCardField {
  font-size: 0.8125rem;
  margin: 0.2rem 0;
  color: var(--chat-text);
}

.chatCardField strong {
  color: var(--chat-brand-dark);
  font-weight: 600;
}

.chatCardFieldGroup {
  margin: 0.35rem 0;
}

.chatCardNested {
  margin-left: 0.5rem;
  margin-top: 0.25rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--chat-brand-soft-hover);
}

.chatMenu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.875rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--chat-border);
}

.chatMenuHint {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--chat-text-muted);
  letter-spacing: 0.01em;
}

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

.chatMenuButton {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  padding: 0.75rem 0.875rem;
  border: 1px solid transparent;
  border-radius: 0.875rem;
  background: var(--chat-brand-soft);
  color: var(--chat-brand-dark);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--chat-shadow-sm);
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease,
    color 0.18s ease;
}

.chatMenuButtonIndex {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.625rem;
  height: 1.625rem;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--chat-surface);
  color: var(--chat-brand);
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(64, 81, 137, 0.18);
}

.chatMenuButtonLabel {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.chatMenuButtonIcon {
  flex-shrink: 0;
  font-size: 1.125rem;
  color: var(--chat-brand);
  opacity: 0.7;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.chatMenuButton:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--chat-brand) 0%, var(--chat-brand-dark) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(64, 81, 137, 0.28);
  transform: translateY(-1px);
}

.chatMenuButton:hover:not(:disabled) .chatMenuButtonIndex {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: none;
}

.chatMenuButton:hover:not(:disabled) .chatMenuButtonIcon {
  color: #fff;
  opacity: 1;
  transform: translateX(2px);
}

.chatMenuButton:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--chat-shadow-sm);
}

.chatMenuButton:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.chatRetryButton {
  margin-top: 0.625rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid #fecdca;
  border-radius: 0.625rem;
  background: #fff;
  color: #b42318;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background-color 0.15s ease;
}

.chatRetryButton:hover {
  background: #fff5f5;
}

.chatEmptyState {
  color: var(--chat-text-muted);
  font-size: 0.875rem;
  text-align: center;
  margin: auto 0;
  padding: 1.75rem 1.25rem;
  line-height: 1.55;
  background: rgba(255, 255, 255, 0.65);
  border: 1px dashed var(--chat-border);
  border-radius: 1rem;
}

.chatEmptyTitle {
  margin: 0 0 0.375rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--chat-brand-dark);
}

.chatEmptyIcon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--chat-brand-soft);
  font-size: 1.5rem;
  color: var(--chat-brand);
  opacity: 1;
}

