.nevia-widget-wrapper {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9998;
}

/* Contenedor combinado logo + botón (todo integrado) */
.nevia-fab-shell {
  position: relative;
  display: inline-block;
}

/* Panel del logo, aparece encima del botón al hacer hover */
.nevia-fab-logo-wrap {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: 8px;
  background: #ffffff;
  border-radius: 14px;
  padding: 6px 10px 4px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.35);
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}

.nevia-widget-wrapper:hover .nevia-fab-logo-wrap {
  opacity: 1;
  transform: translateY(0);
}

.nevia-fab-logo {
  width: 100%;
  height: auto;
  max-height: 72px;
  display: block;
}

.nevia-open-button {
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: var(--nevia-primary-bg, #1976d2);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.35);
}

.nevia-open-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 4px;
  background: #ffffff22;
}

.nevia-open-button:hover {
  filter: brightness(0.96);
}

.nevia-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  background: var(--nevia-overlay-bg, rgba(15, 23, 42, 0.55));
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.nevia-modal {
  background: var(--nevia-modal-bg, #ffffff);
  border-radius: 14px;
  width: min(960px, 100% - 32px);
  height: min(640px, calc(100vh - 64px)); /* alto fijo razonable, con margen superior/inferior */
  box-shadow: 0 22px 45px rgba(15, 23, 42, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.nevia-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(135deg, #e0f2fe 0%, #ffffff 55%);
}

.nevia-modal-header-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nevia-modal-logo {
  height: 32px;
  width: auto;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.nevia-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
}

.nevia-modal-subtitle {
  font-size: 12px;
  color: #6b7280;
}

.nevia-modal-close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: #4b5563;
}

.nevia-modal-close:hover {
  color: #111827;
}

.nevia-modal-body {
  flex: 1 1 auto;
  min-height: 0; /* permite que la zona de mensajes haga scroll dentro */
  padding: 0;
  display: flex;
}

/* Widget base (se adapta a modal) */
.nevia-widget {
  border: none;
  border-radius: 0;
  width: 100%;
  height: 100%;
  min-height: 0; /* combinado con flex permite scroll interno correcto */
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #fff;
}

.nevia-messages {
  flex: 1;
  padding: 14px 16px;
  overflow-y: auto;
  background: var(--nevia-messages-bg, #fafafa);
}

.nevia-msg {
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-line; /* respeta saltos de línea (\n) en los mensajes */
}

.nevia-msg-user {
  background: var(--nevia-user-bubble-bg, #e3f2fd);
  color: #0f172a;
  align-self: flex-end;
}

.nevia-msg-nevia {
  background: var(--nevia-nevia-bubble-bg, #ffffff);
  border: 1px solid #eee;
  color: #111827;
}

/* Indicador de escritura de Nevia */
.nevia-msg-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.nevia-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #9ca3af;
  display: inline-block;
  animation: nevia-typing-bounce 1.2s infinite ease-in-out;
}

.nevia-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.nevia-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes nevia-typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-3px); opacity: 1; }
}

.nevia-input-row {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid #eee;
}

.nevia-input {
  flex: 1;
  padding: 7px 9px;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 14px;
}

.nevia-btn {
  border: none;
  border-radius: 4px;
  padding: 7px 11px;
  font-size: 13px;
  cursor: pointer;
}

.nevia-btn-send,
.nevia-btn-primary {
  background: var(--nevia-primary-bg, #1976d2);
  color: #fff;
}

.nevia-btn-secondary {
  background: var(--nevia-secondary-bg, #eeeeee);
  color: #333;
}

.nevia-cta-test2 {
  border-top: 1px solid #eee;
  padding: 8px 12px;
  background: #fffde7;
}

.nevia-cta-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.nevia-emergency {
  box-shadow: 0 0 0 2px #f44336 inset;
}

@media (max-width: 640px) {
  .nevia-widget-wrapper {
    right: 14px;
    bottom: 14px;
  }
  .nevia-open-button {
    padding-inline: 14px;
    font-size: 13px;
  }
  .nevia-modal {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  .nevia-modal-header {
    padding-inline: 12px;
  }
}
