* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: Arial, sans-serif;
  overflow-x: hidden;
}

body {
  position: relative;
  background: transparent;
}

.page {
  position: relative;
  min-height: 100vh;
  z-index: 1;
}

/* CHAT FLOTANTE */
.floating-chat {
  position: fixed;
  right: 28px;
  bottom: 120px;
  width: 420px;
  max-width: calc(100vw - 28px);
  z-index: 999999 !important;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.floating-chat.hidden-chat {
  opacity: 0;
  transform: translateY(18px) scale(0.98);
  pointer-events: none;
}

/* TARJETA DEL CHAT */
.chat-card {
  position: relative;
  z-index: 999999 !important;
  width: 100%;
  height: 58vh;
  max-height: 700px;
  min-height: 380px;
  background: rgba(5, 6, 30, 0.98);
  border-radius: 28px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(180, 140, 255, 0.25);
  box-shadow:
    0 28px 80px rgba(2, 6, 23, 0.70),
    0 0 40px rgba(140, 90, 255, 0.22),
    0 0 24px rgba(56, 189, 248, 0.10);
}

/* HEADER */
.chat-header {
  position: relative;
  z-index: 3;
  padding: 18px 54px 18px 22px;
  border-bottom: 1px solid rgba(180, 140, 255, 0.20);
  background: #17124a;
}

.chat-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chat-header h2 {
  margin: 0;
  font-size: 1.18rem;
  color: #ffffff;
  line-height: 1.2;
}

.chat-header span {
  display: block;
  margin-top: 5px;
  color: #d6c9ff;
  font-size: 0.95rem;
  line-height: 1.25;
}

.chat-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  z-index: 5;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.20);
}

/* CUERPO */
.chat-body {
  position: relative;
  z-index: 2;
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 16px;
  background: #111330;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.chat-body::-webkit-scrollbar {
  width: 10px;
}

.chat-body::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.04);
  border-radius: 999px;
}

.chat-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(150,100,255,0.72), rgba(14,165,233,0.82));
  border-radius: 999px;
}

/* MENSAJES */
.message-row {
  display: flex;
  width: 100%;
  align-items: flex-end;
  gap: 10px;
}

.message-row.assistant {
  justify-content: flex-start;
}

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

.avatar {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  overflow: hidden;
  box-shadow:
    0 8px 20px rgba(2, 6, 23, 0.25),
    0 0 14px rgba(140, 90, 255, 0.12);
}

.avatar.bot {
  background: linear-gradient(135deg, rgba(24, 34, 82, 0.96), rgba(135, 65, 255, 0.22));
  border: 1px solid rgba(180, 140, 255, 0.30);
}

.avatar.user {
  background: linear-gradient(135deg, #5b21b6, #2563eb);
  color: white;
  border: 1px solid rgba(180, 140, 255, 0.18);
}

.avatar-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: block;
}

.bubble {
  max-width: 74%;
  padding: 15px 18px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 20px;
  font-size: 15px;
}

.bubble.assistant {
  background: #090d25;
  border: 1px solid rgba(180, 140, 255, 0.18);
  color: #f7f4ff;
  border-bottom-left-radius: 8px;
  box-shadow:
    0 16px 34px rgba(2, 6, 23, 0.40),
    0 0 16px rgba(140, 90, 255, 0.10);
}

.bubble.user {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: white;
  border-bottom-right-radius: 8px;
  box-shadow:
    0 14px 30px rgba(91, 33, 182, 0.36),
    0 0 18px rgba(37, 99, 235, 0.16);
}

/* BOTONES PRINCIPALES */
.topic-actions {
  position: relative;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px 10px;
  background: #1a163a;
  border-top: 1px solid rgba(180, 140, 255, 0.16);
  max-width: 100%;
  overflow: visible;
}

.topic-btn {
  flex: 0 0 auto;
  border: 1px solid rgba(180, 140, 255, 0.28);
  background: rgba(255, 255, 255, 0.04);
  color: #f0e9ff;
  border-radius: 999px;
  padding: 9px 13px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s ease;
  white-space: nowrap;
}

.topic-btn:hover {
  background: rgba(140, 90, 255, 0.18);
  border-color: rgba(180, 140, 255, 0.48);
}

.topic-btn.active {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: white;
  border-color: rgba(180, 140, 255, 0.24);
}

/* BOTONES SECUNDARIOS */
.quick-actions {
  position: relative;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px 20px 16px;
  background: #1a163a;
}

.quick-btn {
  border: 1px solid rgba(180, 140, 255, 0.20);
  background: rgba(255, 255, 255, 0.04);
  color: #efe8ff;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: 0.18s ease;
  white-space: nowrap;
}

.quick-btn:hover {
  background: rgba(124, 58, 237, 0.16);
  border-color: rgba(180, 140, 255, 0.38);
}

/* FORMULARIO */
.chat-form {
  position: relative;
  z-index: 3;
  display: flex;
  gap: 12px;
  padding: 16px 18px 18px;
  border-top: 1px solid rgba(180, 140, 255, 0.16);
  background: #0c1028;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(180, 140, 255, 0.24);
  background: #151936;
  color: #f8fbff;
  border-radius: 18px;
  padding: 16px 18px;
  font-size: 1rem;
  outline: none;
  transition: 0.2s ease;
}

.chat-form input::placeholder {
  color: #d0c8ff;
}

.chat-form input:focus {
  background: #111630;
  border-color: #a855f7;
  box-shadow:
    0 0 0 4px rgba(124, 58, 237, 0.18),
    0 0 16px rgba(168, 85, 247, 0.16);
}

.chat-form button {
  min-width: 125px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: white;
  font-weight: 700;
  font-size: 0.96rem;
  cursor: pointer;
  transition: 0.15s ease;
}

.chat-form button:hover {
  transform: translateY(-1px);
}

/* AGENTE */
.agent-sequence {
  position: fixed;
  right: 28px;
  bottom: 24px;
  z-index: 999998;
  display: flex;
  align-items: flex-end;
}

.rocket-landing {
  width: 150px;
  height: auto;
  opacity: 0;
  transform: translate(220px, -260px) rotate(-30deg) scale(0.4);
  animation: rocketArrival 2.4s ease-out forwards;
  filter: drop-shadow(0 14px 24px rgba(0, 0, 0, 0.25));
}

.rocket-landing.rocket-exit {
  animation: rocketExit 0.85s ease-in forwards;
}

.astronaut-container {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 18px;
}

.agent-orb {
  position: absolute;
  right: 132px;
  bottom: 24px;
  width: 122px;
  height: 122px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(168, 85, 247, 0.26) 0%, rgba(37, 99, 235, 0.14) 45%, rgba(15, 23, 42, 0) 74%);
  filter: blur(5px);
  animation: orbPulse 3s ease-in-out infinite;
  pointer-events: none;
}

.astronaut-img {
  width: 138px;
  height: auto;
  display: block;
  position: relative;
  z-index: 2;
  filter:
    drop-shadow(0 14px 26px rgba(0, 0, 0, 0.28))
    drop-shadow(0 0 18px rgba(168, 85, 247, 0.14));
  animation: astronautStand 0.7s ease-out forwards;
}

.agent-side-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 24px;
  z-index: 3;
}

.agent-bubble {
  min-width: 230px;
  max-width: 300px;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(14, 18, 40, 0.86);
  color: #f8fbff;
  text-align: left;
  border: 1px solid rgba(180, 140, 255, 0.28);
  box-shadow:
    0 18px 40px rgba(2, 6, 23, 0.35),
    0 0 18px rgba(124, 58, 237, 0.14);
  animation: bubbleFloat 2.8s ease-in-out infinite;
}

.agent-bubble-title {
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
  color: #d8b4fe;
}

.agent-bubble-text {
  font-size: 0.98rem;
  line-height: 1.5;
  color: #f8fbff;
}

.open-chat-btn {
  border: 1px solid rgba(180, 140, 255, 0.28);
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 800;
  color: white;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.open-chat-btn:hover {
  transform: translateY(-2px) scale(1.02);
}

.hidden-chat {
  display: none !important;
}

.hidden-sequence {
  display: none !important;
}

/* ANIMACIONES */
@keyframes rocketArrival {
  0% {
    transform: translate(220px, -260px) rotate(-30deg) scale(0.4);
    opacity: 0;
  }

  35% {
    transform: translate(80px, -120px) rotate(-15deg) scale(0.8);
    opacity: 1;
  }

  65% {
    transform: translate(0, 0) rotate(0deg) scale(1.02);
    opacity: 1;
  }

  80% {
    transform: translate(0, -10px) rotate(0deg) scale(1);
  }

  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
}

@keyframes rocketExit {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }

  100% {
    transform: translate(90px, -160px) rotate(18deg) scale(0.45);
    opacity: 0;
  }
}

@keyframes astronautStand {
  0% {
    transform: translateY(-20px) scale(0.82);
    opacity: 0;
  }

  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes bubbleFloat {
  0% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }

  100% {
    transform: translateY(0);
  }
}

@keyframes orbPulse {
  0% {
    transform: scale(0.96);
    opacity: 0.82;
  }

  50% {
    transform: scale(1.08);
    opacity: 1;
  }

  100% {
    transform: scale(0.96);
    opacity: 0.82;
  }
}

/* TABLET */
@media (max-width: 900px) {
  .floating-chat {
    right: 16px;
    left: 16px;
    bottom: 220px;
    width: auto;
    max-width: none;
  }

  .chat-card {
    width: 100%;
    height: 78vh;
    min-height: auto;
    max-height: none;
    border-radius: 22px;
  }

  .bubble {
    max-width: 88%;
  }

  .chat-header h2 {
    font-size: 1rem;
  }

  .chat-header span {
    font-size: 0.85rem;
  }
}

/* CELULAR GRANDE */
@media (max-width: 768px) {
  .floating-chat {
    right: 10px;
    left: 10px;
    bottom: 150px;
    width: auto;
    max-width: none;
  }

  .chat-card {
    height: 78vh;
    min-height: auto;
    max-height: none;
    border-radius: 20px;
  }

  .chat-header {
    padding: 14px 48px 14px 14px;
  }

  .chat-title-group {
    gap: 10px;
  }

  .chat-header h2 {
    font-size: 0.95rem;
    line-height: 1.2;
  }

  .chat-header span {
    font-size: 0.78rem;
    line-height: 1.25;
  }

  .chat-body {
    padding: 14px;
    gap: 14px;
  }

  .avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
  }

  .avatar-img {
    width: 27px;
    height: 27px;
  }

  .bubble {
    max-width: 92%;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.55;
  }

  .topic-actions {
    flex-wrap: wrap;
    overflow-x: visible;
    gap: 7px;
    padding: 10px 10px 8px;
    scrollbar-width: auto;
  }

  .topic-actions::-webkit-scrollbar {
    display: none;
  }

  .topic-btn {
    flex: 0 0 auto;
    font-size: 12px;
    padding: 7px 10px;
    white-space: nowrap;
  }

  .quick-actions {
    flex-wrap: wrap;
    overflow-x: visible;
    gap: 8px;
    padding: 4px 12px 12px;
    scrollbar-width: auto;
  }

  .quick-actions::-webkit-scrollbar {
    display: none;
  }

  .quick-btn {
    flex: 0 0 auto;
    font-size: 12.5px;
    padding: 8px 11px;
    white-space: nowrap;
  }

  .chat-form {
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .chat-form input {
    width: 100%;
    font-size: 14px;
    padding: 13px 14px;
    border-radius: 14px;
  }

  .chat-form button {
    width: 100%;
    height: 48px;
    min-width: 0;
    border-radius: 14px;
  }

  .agent-sequence {
    right: 12px;
    bottom: 12px;
  }

  .astronaut-container {
    gap: 10px;
  }

  .astronaut-img {
    width: 96px;
  }

  .rocket-landing {
    width: 112px;
  }

  .agent-orb {
    right: 88px;
    bottom: 18px;
    width: 84px;
    height: 84px;
  }

  .agent-side-content {
    margin-bottom: 10px;
  }

  .agent-bubble {
    min-width: 180px;
    max-width: 220px;
    padding: 12px 14px;
  }

  .agent-bubble-title {
    font-size: 0.74rem;
  }

  .agent-bubble-text {
    font-size: 0.86rem;
  }

  .open-chat-btn {
    padding: 10px 16px;
    font-size: 13px;
  }
}

/* CELULAR PEQUEÑO */
@media (max-width: 480px) {
  .floating-chat {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
  }

  .chat-card {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .chat-header {
    padding: 12px 46px 12px 12px;
  }

  .chat-header h2 {
    font-size: 0.86rem;
  }

  .chat-header span {
    font-size: 0.72rem;
  }

  .chat-body {
    padding: 12px;
    gap: 12px;
  }

  .message-row {
    gap: 7px;
  }

  .avatar {
    width: 31px;
    height: 31px;
    min-width: 31px;
  }

  .avatar-img {
    width: 25px;
    height: 25px;
  }

  .bubble {
    max-width: calc(100% - 38px);
    padding: 11px 12px;
    font-size: 13px;
    line-height: 1.5;
    border-radius: 16px;
  }

  .topic-actions {
    flex-wrap: wrap;
    overflow-x: visible;
    padding: 8px 8px 6px;
    gap: 6px;
  }

  .topic-btn {
    flex: 0 0 auto;
    font-size: 11.5px;
    padding: 7px 9px;
    white-space: nowrap;
  }

  .quick-actions {
    flex-wrap: wrap;
    overflow-x: visible;
    padding: 3px 10px 10px;
    gap: 6px;
  }

  .quick-btn {
    flex: 0 0 auto;
    font-size: 11.5px;
    padding: 8px 10px;
    white-space: nowrap;
  }

  .chat-form {
    padding: 10px;
    gap: 8px;
  }

  .chat-form input {
    font-size: 13px;
    padding: 12px;
  }

  .chat-form button {
    height: 44px;
    font-size: 13px;
  }

  .agent-sequence {
    right: 8px;
    bottom: 8px;
  }

  .astronaut-img {
    width: 82px;
  }

  .rocket-landing {
    width: 98px;
  }

  .agent-orb {
    right: 72px;
    bottom: 14px;
    width: 70px;
    height: 70px;
  }

  .agent-bubble {
    min-width: 160px;
    max-width: 190px;
    padding: 10px 12px;
  }

  .agent-bubble-title {
    font-size: 0.68rem;
  }

  .agent-bubble-text {
    font-size: 0.78rem;
  }

  .open-chat-btn {
    padding: 9px 14px;
    font-size: 12px;
  }
}

/* CELULAR MUY PEQUEÑO */
@media (max-width: 360px) {
  .chat-header h2 {
    font-size: 0.78rem;
  }

  .chat-header span {
    font-size: 0.68rem;
  }

  .bubble {
    font-size: 12.5px;
  }

  .topic-btn,
  .quick-btn {
    font-size: 11px;
  }

  .astronaut-img {
    width: 74px;
  }

  .agent-bubble {
    min-width: 145px;
    max-width: 170px;
  }
}

/* RUTAS DEL OBSERVATORIO EN RESPUESTAS CONTROLADAS */
.ruta-temas {
  margin: 10px 0 0;
  padding-left: 18px;
}

.ruta-temas li {
  margin-bottom: 6px;
  line-height: 1.4;
}

.tema-resaltado {
  display: inline-block;
  padding: 5px 10px;
  border: 2px solid #38bdf8;
  border-radius: 999px;
  color: #e0f7ff;
  background: rgba(56, 189, 248, 0.12);
  font-weight: 800;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.45);
}

.ruta-observatorio {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.ruta-observatorio p {
  margin: 0 !important;
}

.ruta-observatorio ul {
  margin: 0 !important;
  padding-left: 18px;
}

.ruta-observatorio li {
  margin: 4px 0;
}