/* ===== 1. Design tokens ===== */
:root {
  --bg: #050914;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-strong: rgba(255, 255, 255, 0.07);
  --surface-border: rgba(255, 255, 255, 0.1);
  --text: #eef1fb;
  --text-dim: #99a3c4;
  --accent: #5b8cff;
  --accent-2: #4fd1ff;
  --accent-glow: rgba(91, 140, 255, 0.35);
  --danger: #ff8080;
  --success: #34d399;
  --radius: 16px;
  --radius-lg: 24px;
  --max-width: 1140px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ===== 2. Reset & base ===== */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

a { color: inherit; }

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  background: var(--accent);
  color: #04070f;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  z-index: 200;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 16px; }

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ===== 3. Background layers ===== */
.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(650px circle at 12% 8%, rgba(91, 140, 255, 0.22), transparent 60%),
    radial-gradient(550px circle at 88% 18%, rgba(79, 209, 255, 0.14), transparent 60%),
    radial-gradient(700px circle at 50% 100%, rgba(91, 140, 255, 0.1), transparent 60%),
    var(--bg);
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0px, rgba(255, 255, 255, 0.035) 1px, transparent 1px, transparent 64px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0px, rgba(255, 255, 255, 0.035) 1px, transparent 1px, transparent 64px);
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 90%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 90%);
}

.gradient-text {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.accent { color: var(--accent-2); }

/* ===== 4. Nav ===== */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: rgba(5, 9, 20, 0.72);
  border-bottom: 1px solid var(--surface-border);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 72px; gap: 24px; }
.logo { font-weight: 700; font-size: 1.3rem; text-decoration: none; letter-spacing: -0.02em; }
.nav-links { display: flex; gap: 28px; margin-left: auto; margin-right: 24px; }
.nav-links a { color: var(--text-dim); text-decoration: none; font-size: 0.95rem; transition: color 0.2s; }
.nav-links a:hover { color: var(--text); }

.nav-toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-toggle span { width: 22px; height: 2px; background: var(--text); border-radius: 2px; }
.nav-mobile { display: none; flex-direction: column; padding: 8px 24px 20px; border-top: 1px solid var(--surface-border); }
.nav-mobile a { color: var(--text-dim); text-decoration: none; padding: 12px 0; border-bottom: 1px solid var(--surface-border); }
.nav-mobile.open { display: flex; }

/* ===== 5. Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 22px; border-radius: 999px; font-weight: 600; font-size: 0.95rem;
  text-decoration: none; cursor: pointer; border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #04070f; box-shadow: 0 8px 24px -8px var(--accent-glow); }
.btn-primary:hover { box-shadow: 0 12px 28px -8px rgba(91, 140, 255, 0.55); }
.btn-ghost { color: var(--text); border-color: var(--surface-border); background: var(--surface); }
.btn-small { padding: 9px 18px; font-size: 0.88rem; }
.btn-full { width: 100%; }

/* ===== 6. Hero ===== */
.hero { position: relative; padding: 120px 0 100px; text-align: center; overflow: hidden; }
.hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.hero-inner { position: relative; z-index: 1; }

.badge { display: inline-block; padding: 8px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--surface-border); color: var(--text-dim); font-size: 0.85rem; margin-bottom: 28px; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.14; letter-spacing: -0.03em; margin: 0 0 24px; max-width: 820px; margin-inline: auto; }
.hero-sub { color: var(--text-dim); font-size: 1.15rem; max-width: 620px; margin: 0 auto 40px; }
.hero-cta { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* ===== 7. Sections & cards ===== */
section h2 { font-size: clamp(1.8rem, 4vw, 2.4rem); letter-spacing: -0.02em; margin: 0 0 12px; text-align: center; }
.section-sub { text-align: center; color: var(--text-dim); max-width: 580px; margin: 0 auto 56px; }
.problems, .services, .use-cases, .process, .tech, .why { padding: 96px 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.cards-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cards-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius);
  padding: 32px 24px; backdrop-filter: blur(8px);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.card:hover { transform: translateY(-4px); border-color: rgba(91, 140, 255, 0.4); background: var(--surface-strong); }
.card-icon { font-size: 1.8rem; margin-bottom: 16px; }
.card h3 { margin: 0 0 10px; font-size: 1.12rem; }
.card p { color: var(--text-dim); font-size: 0.94rem; margin: 0; }

/* ===== 8. Casos de uso ===== */
.use-case-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 40px; }
.use-case { display: flex; gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--surface-border); }
.uc-icon { font-size: 1.4rem; flex-shrink: 0; }
.use-case h3 { margin: 0 0 4px; font-size: 1rem; }
.use-case p { margin: 0; color: var(--text-dim); font-size: 0.9rem; }

/* ===== 9. Proceso ===== */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; }
.step { padding: 24px; border-left: 2px solid var(--surface-border); }
.step-num { font-size: 0.85rem; font-weight: 700; color: var(--accent-2); margin-bottom: 10px; letter-spacing: 0.05em; }
.step h3 { margin: 0 0 8px; font-size: 1.05rem; }
.step p { color: var(--text-dim); font-size: 0.9rem; margin: 0; }

/* ===== 10. Tecnologías ===== */
.tech-badges { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; padding: 0; margin: 0; }
.tech-badges li { background: var(--surface); border: 1px solid var(--surface-border); border-radius: 999px; padding: 10px 20px; font-size: 0.9rem; color: var(--text-dim); }

/* ===== 11. Contacto / formulario ===== */
.contact { padding: 96px 0 120px; }
.contact-inner {
  display: grid; grid-template-columns: 1fr 1.3fr; gap: 56px; align-items: start;
  background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-lg); padding: 56px;
}
.contact-text h2 { text-align: left; margin-bottom: 16px; }
.contact-text p { color: var(--text-dim); margin-bottom: 24px; }
.contact-email { color: var(--accent-2); font-weight: 600; text-decoration: none; font-size: 1.05rem; }
.contact-email:hover { text-decoration: underline; }

.contact-form { display: flex; flex-direction: column; gap: 20px; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--text-dim); }
.field-full { grid-column: 1 / -1; }

.field input, .field select, .field textarea {
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--surface-border); border-radius: 10px;
  padding: 12px 14px; color: var(--text); font-family: inherit; font-size: 0.95rem; resize: vertical;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field select { appearance: auto; }
.field[aria-invalid="true"] input, .field[aria-invalid="true"] select, .field[aria-invalid="true"] textarea { border-color: var(--danger); }

.phone-group { display: flex; gap: 8px; }
.phone-group select { flex: 0 0 128px; }
.phone-group input { flex: 1; }

.field-error { color: var(--danger); font-size: 0.8rem; min-height: 1em; }

.checkbox-field { display: flex; align-items: flex-start; gap: 10px; font-size: 0.85rem; color: var(--text-dim); }
.checkbox-field input { margin-top: 3px; accent-color: var(--accent); }
.checkbox-field a { color: var(--accent-2); }

.form-error {
  background: rgba(255, 128, 128, 0.1); border: 1px solid rgba(255, 128, 128, 0.35); color: #ffb3b3;
  border-radius: 10px; padding: 14px 16px; font-size: 0.9rem;
}

.contact-form[data-state="success"] .form-grid,
.contact-form[data-state="success"] .checkbox-field,
.contact-form[data-state="success"] #submitBtn,
.contact-form[data-state="success"] .hp-field {
  display: none;
}

.form-success { text-align: center; padding: 24px 0; }
.form-success:focus { outline: none; }
.form-success-icon {
  width: 56px; height: 56px; border-radius: 50%; background: rgba(52, 211, 153, 0.15); color: var(--success);
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem; margin: 0 auto 16px;
  border: 1px solid rgba(52, 211, 153, 0.4);
}
.form-success h3 { margin: 0 0 8px; }
.form-success p { color: var(--text-dim); margin: 0; }

/* ===== 12. Legal (privacidad.html) ===== */
.legal { padding: 100px 0 120px; }
.legal-inner { max-width: 720px; margin: 0 auto; }
.legal h1 { font-size: clamp(2rem, 4vw, 2.6rem); margin-bottom: 8px; }
.legal-updated { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 40px; }
.legal h2 { text-align: left; font-size: 1.25rem; margin: 36px 0 12px; }
.legal p, .legal li { color: var(--text-dim); font-size: 0.98rem; line-height: 1.7; }
.legal a { color: var(--accent-2); }
.legal ul { padding-left: 20px; }

/* ===== 13. Footer ===== */
.footer { border-top: 1px solid var(--surface-border); padding: 28px 0; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; color: var(--text-dim); font-size: 0.85rem; }
.footer-inner a { color: var(--text-dim); text-decoration: none; }
.footer-inner a:hover { color: var(--text); }

/* ===== 14. Reveal animation ===== */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ===== 15. Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .card, .btn { transition: none; }
  .chat-bubble-dot, .chat-status-dot, .chat-typing span { animation: none; }
}

/* ===== 16. Responsive ===== */
@media (max-width: 900px) {
  .contact-inner { grid-template-columns: 1fr; padding: 36px 28px; }
  .use-case-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .nav-links, .nav-inner .btn-small { display: none; }
  .nav-toggle { display: flex; }
  .hero { padding: 90px 0 70px; }
  .form-grid { grid-template-columns: 1fr; }
  .phone-group { flex-direction: column; }
  .phone-group select { flex: 1; }
}

/* ===== 17. Chatbot widget ===== */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-bubble {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px -8px var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.chat-bubble:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -8px rgba(91, 140, 255, 0.6); }
.chat-bubble-icon { font-size: 1.6rem; line-height: 1; }

.chat-bubble-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--bg);
  animation: chat-pulse 2.4s ease-in-out infinite;
}
@keyframes chat-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  50% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
}

.chat-panel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  z-index: 91;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: min(600px, 75vh);
  display: flex;
  flex-direction: column;
  background: rgba(10, 13, 26, 0.92);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--surface-border);
  flex-shrink: 0;
}
.chat-panel-identity { display: flex; align-items: center; gap: 10px; }
.chat-panel-logo { font-weight: 700; font-size: 0.95rem; white-space: nowrap; }
.chat-panel-name { margin: 0; font-weight: 600; font-size: 0.92rem; }
.chat-panel-status { margin: 2px 0 0; font-size: 0.78rem; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: chat-pulse 2.4s ease-in-out infinite;
}

.chat-panel-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.chat-demo-badge {
  font-size: 0.7rem;
  color: var(--text-dim);
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.chat-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.chat-icon-btn:hover { background: var(--surface); color: var(--text); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg-user {
  align-self: flex-end;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #04070f;
  border-bottom-right-radius: 4px;
}
.chat-msg-assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-handoff-actions, .chat-summary-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.chat-typing {
  display: flex;
  gap: 4px;
  padding: 10px 18px;
  flex-shrink: 0;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: chat-typing-bounce 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 12px;
  flex-shrink: 0;
}
.chat-chip {
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.chat-chip:hover { border-color: var(--accent); background: var(--surface-strong); }

.chat-lead-summary {
  padding: 14px 18px;
  border-top: 1px solid var(--surface-border);
  background: var(--surface);
  flex-shrink: 0;
  max-height: 45%;
  overflow-y: auto;
}
.chat-summary-title, .chat-summary-question { margin: 0 0 10px; font-size: 0.85rem; font-weight: 600; }
.chat-summary-list { margin: 0 0 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 0.82rem; }
.chat-summary-list dt { color: var(--text-dim); font-weight: 500; }
.chat-summary-list dd { margin: 0; color: var(--text); }
.chat-consent { margin: 10px 0; font-size: 0.78rem; }
.chat-copy-btn {
  background: none;
  border: none;
  color: var(--accent-2);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 6px 0 0;
  font-family: inherit;
}

.chat-connection-error {
  padding: 10px 18px;
  border-top: 1px solid var(--surface-border);
  color: var(--danger);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--surface-border);
  flex-shrink: 0;
}
.chat-text-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
}
.chat-text-input:focus { outline: none; border-color: var(--accent); }
.chat-send-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04070f;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.chat-send-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.chat-footer-actions {
  display: flex;
  gap: 10px;
  padding: 0 14px 14px;
  flex-shrink: 0;
}
.chat-footer-actions .btn { flex: 1; }

@media (max-width: 720px) {
  .chat-panel {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 82vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .chat-bubble { right: 16px; bottom: 16px; }
}

/* .chat-panel/.chat-typing/.chat-connection-error set their own `display`
   for when they're shown — [hidden] needs extra specificity here to still
   win, since the UA stylesheet's [hidden]{display:none} alone would lose to
   a same-specificity class rule that happens to come later in the file. */
.chat-panel[hidden],
.chat-typing[hidden],
.chat-connection-error[hidden] {
  display: none;
}
