* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  min-width: 0;
}

:root {
  /* Paleta Oficial Ocean Focus (Fase 1) */
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --accent: #06b6d4;
  --bg-light: #f0f9ff;
  --bg-card: #ffffff;
  --text: #0c4a6e;
  --muted: #0369a1;
  --border: rgba(2, 132, 199, 0.16);
  --shadow: 0 20px 60px rgba(2, 132, 199, 0.12);
  --shadow-soft: 0 10px 30px rgba(2, 132, 199, 0.08);
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --white: #ffffff;

  /* Tipografía y bordes */
  --font-main: "Poppins", system-ui, -apple-system, sans-serif;
  --radius-card: 24px;
  --radius-btn: 14px;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-main);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 0% 0%, rgba(6, 182, 212, 0.18), transparent 28%),
    radial-gradient(circle at 100% 0%, rgba(2, 132, 199, 0.14), transparent 26%),
    linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 100%);
}

a {
  text-decoration: none;
  color: inherit;
}

img,
video,
iframe {
  max-width: 100%;
  height: auto;
}

input,
textarea,
select,
button {
  font: inherit;
}

/* HEADER / TOPBAR */
.topbar {
  width: 100%;
  padding: 18px 7%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(2, 132, 199, 0.12);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 18px;
}

.logo {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.7px;
  flex-shrink: 0;
}

.nav {
  display: flex;
  gap: 34px;
  flex-wrap: wrap;
}

.nav a {
  font-weight: 500;
  color: var(--text);
  transition: all 0.25s ease;
}

.nav a:hover,
.nav a.active {
  color: var(--primary);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.lang-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  padding: 10px 15px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
  transition: all 0.25s ease;
}

.lang-btn:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  transition: all 0.25s ease;
  border: none;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--white);
  box-shadow: 0 12px 24px rgba(2, 132, 199, 0.22);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  transform: translateY(-3px);
  box-shadow: 0 16px 32px rgba(2, 132, 199, 0.3);
}

/* BOTÓN DETENER PROCESO */
.btn-stop {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  color: var(--white) !important;
  box-shadow: 0 12px 24px rgba(239, 68, 68, 0.22) !important;
}

.btn-stop:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
  transform: translateY(-3px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(2, 132, 199, 0.22);
  color: var(--primary-dark);
  box-shadow: var(--shadow-soft);
}

.btn-secondary:hover {
  transform: translateY(-3px);
  background: var(--white);
  border-color: var(--primary);
}

.small-btn {
  padding: 10px 14px;
  font-size: 0.92rem;
}

/* ESTRUCTURA PÁGINA CHAT */
.chat-page {
  padding: 60px 7% 90px;
}

.chat-hero {
  text-align: center;
  margin-bottom: 34px;
}

.badge {
  display: inline-block;
  background: rgba(6, 182, 212, 0.12);
  color: var(--primary-dark);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 18px;
  border: 1px solid rgba(2, 132, 199, 0.18);
}

.chat-hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.08;
  margin-bottom: 14px;
  letter-spacing: -1px;
  color: var(--text);
}

.chat-hero p {
  color: var(--muted);
  max-width: 760px;
  margin: 0 auto;
  line-height: 1.8;
  font-size: clamp(0.95rem, 2vw, 1.04rem);
  opacity: 0.9;
}

.chat-box-section {
  display: flex;
  justify-content: center;
}

.chat-card {
  width: 100%;
  max-width: 1000px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 32px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* HEADER TARJETA CHAT */
.chat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.chat-top-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.assistant-icon {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--white);
  font-size: 1.2rem;
  box-shadow: 0 14px 24px rgba(2, 132, 199, 0.22);
  flex-shrink: 0;
}

.chat-top h2 {
  font-size: 1.8rem;
  letter-spacing: -0.5px;
  color: var(--text);
}

.chat-top p {
  color: var(--muted);
  margin-top: 4px;
}

/* CONTENEDOR DE MENSAJES */
.chat-messages {
  height: 520px;
  overflow-y: auto;
  background: linear-gradient(180deg, #ffffff 0%, #f0f9ff 100%);
  border: 1px solid rgba(2, 132, 199, 0.15);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow-soft);
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(2, 132, 199, 0.22);
  border-radius: 999px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(2, 132, 199, 0.38);
}

/* ESTADO VACÍO */
.empty-state {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--white);
  font-size: 1.5rem;
  margin-bottom: 16px;
  box-shadow: 0 16px 28px rgba(2, 132, 199, 0.22);
}

.empty-state h3 {
  font-size: 1.35rem;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state p {
  margin-bottom: 16px;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 700px;
}

.suggestion-btn {
  border: 1px solid rgba(2, 132, 199, 0.18);
  background: var(--white);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
  font-size: 0.95rem;
  text-align: left;
  box-shadow: var(--shadow-soft);
}

.suggestion-btn:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  background: #f0f9ff;
}

/* BURBUJAS DE MENSAJE */
.message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  width: 100%;
  position: relative;
}

.message.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--white);
  flex-shrink: 0;
}

.message.user .avatar {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.bubble {
  max-width: min(85%, 700px);
  padding: 16px 18px;
  border-radius: 18px;
  line-height: 1.8;
  background: var(--white);
  border: 1px solid rgba(2, 132, 199, 0.12);
  color: var(--text);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  box-shadow: 0 6px 18px rgba(12, 74, 110, 0.04);
  position: relative;
}

.message.user .bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
  border: none;
  margin-left: auto;
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.2);
}

/* BOTÓN COPIAR RESPUESTA */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.15);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  background: rgba(2, 132, 199, 0.18);
  color: var(--primary-dark);
}

.copy-btn.copied {
  background: var(--accent-green-bg, #ecfdf5);
  color: var(--accent-green, #10b981);
  border-color: rgba(16, 185, 129, 0.3);
}

/* INDICADOR DE ESCRITURA */
.typing .bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 52px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
  animation: bounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.30s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0.7);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* FORMATO DE TEXTO (MARKDOWN) */
.bubble p {
  margin-bottom: 12px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble h2,
.bubble h3,
.bubble h4 {
  color: var(--text);
  margin: 14px 0 10px;
  line-height: 1.4;
  font-weight: 700;
}

.message.user .bubble h2,
.message.user .bubble h3,
.message.user .bubble h4 {
  color: var(--white);
}

.bubble h2 {
  font-size: 1.2rem;
}

.bubble h3 {
  font-size: 1.1rem;
}

.bubble h4 {
  font-size: 1rem;
}

.bubble ul,
.bubble ol {
  margin: 10px 0 10px 22px;
  padding-left: 4px;
}

.bubble li {
  margin-bottom: 8px;
}

.bubble strong {
  font-weight: 700;
}

.bubble em {
  font-style: italic;
}

.inline-code {
  background: rgba(2, 132, 199, 0.1);
  color: var(--primary-dark);
  padding: 2px 8px;
  border-radius: 8px;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.92em;
}

.message.user .inline-code {
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
}

.code-block {
  background: #0f172a;
  color: #f8fafc;
  padding: 14px 16px;
  border-radius: 14px;
  overflow-x: auto;
  margin: 12px 0;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.92rem;
  line-height: 1.6;
}

.message.user .code-block {
  background: rgba(15, 23, 42, 0.6);
}

/* ÁREA DE ENTRADA */
.chat-input-wrapper {
  margin-top: 16px;
}

#chatInput {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  border: 1px solid rgba(2, 132, 199, 0.22);
  border-radius: 22px;
  padding: 18px;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.8;
  color: var(--text);
  background: var(--bg-light);
  outline: none;
  transition: all 0.25s ease;
}

#chatInput:focus {
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.12);
}

.chat-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.input-hint {
  color: var(--muted);
  font-size: 0.9rem;
}

/* FOOTER DE ALTO IMPACTO */
.footer {
  padding: 60px 7% 40px;
  background: transparent;
}

.footer-content {
  background: linear-gradient(135deg, #001e38, #003366);
  color: var(--white);
  border-radius: 36px;
  padding: 50px;
  display: flex;
  justify-content: space-between;
  gap: 50px;
  flex-wrap: wrap;
  box-shadow: 0 25px 50px rgba(0, 30, 56, 0.35);
  border: 1px solid rgba(0, 229, 255, 0.25);
  position: relative;
  overflow: hidden;
}

.footer-content::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.15), transparent 70%);
  pointer-events: none;
}

.footer-brand h2 {
  color: var(--accent);
  margin-bottom: 12px;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.footer-brand p {
  color: #bae6fd;
  font-size: 1.05rem;
  max-width: 380px;
  line-height: 1.6;
}

.footer-links-container {
  display: flex;
  gap: 60px;
  flex-wrap: wrap;
}

.footer-column h4 {
  margin-bottom: 16px;
  font-size: 1.1rem;
  color: var(--white);
  font-weight: 700;
  letter-spacing: 0.5px;
  position: relative;
}

.footer-column h4::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 24px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}

.footer-column a {
  display: block;
  color: #bae6fd;
  margin-bottom: 10px;
  transition: all 0.25s ease;
  font-weight: 500;
  font-size: 0.95rem;
}

.footer-column a:hover {
  color: var(--accent);
  transform: translateX(6px);
}

/* =========================================
   RESPONSIVE MEJORADO Y CORREGIDO PARA MÓVILES
========================================= */
@media (max-width: 1100px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 40px;
    padding: 50px 5% 60px;
  }
}

@media (max-width: 960px) {
  .nav {
    display: none;
  }
}

@media (max-width: 768px) {
  /* Arreglo estricto de la cabecera en móvil */
  .topbar {
    padding: 12px 4%;
    gap: 8px;
    flex-wrap: nowrap;
    justify-content: space-between;
  }

  .logo {
    font-size: 1.5rem;
  }

  .top-actions {
    gap: 8px;
    flex-shrink: 0;
  }

  .lang-btn {
    display: none; /* Oculta el selector de idioma en celulares para despejar espacio */
  }

  .topbar .btn {
    padding: 8px 12px;
    font-size: 0.8rem;
    border-radius: 12px;
    white-space: nowrap;
  }

  /* Chat y Contenedor */
  .chat-page {
    padding: 20px 4% 40px;
  }

  .chat-card {
    padding: 16px;
    border-radius: 24px;
  }

  .chat-messages {
    height: 60vh;
    min-height: 380px;
    padding: 12px;
  }

  .bubble {
    max-width: 90%;
    padding: 12px 14px;
    font-size: 0.95rem;
  }

  .suggestions {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .chat-actions {
    flex-direction: column;
    gap: 10px;
  }

  .chat-actions .btn {
    width: 100%;
  }

  .input-hint {
    display: none;
  }

  /* Footer */
  .footer {
    padding: 40px 4% 20px;
  }

  .footer-content {
    padding: 24px;
    border-radius: 24px;
    flex-direction: column;
    gap: 30px;
  }

  .footer-links-container {
    flex-direction: column;
    gap: 25px;
  }

  .footer-brand p {
    font-size: 0.95rem;
  }
}

@media (max-width: 380px) {
  .logo {
    font-size: 1.35rem;
  }
  
  .chat-hero h1 {
    font-size: 1.8rem;
  }
}