* { box-sizing: border-box; }
:root {
  --bg: #0e1117;
  --panel: #161b22;
  --panel-2: #1c232c;
  --border: #2a323d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2da44e;
  --accent-2: #58a6ff;
  --bot-bg: #1f2937;
  --user-bg: #2da44e;
  --error: #f85149;
}
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  display: flex;
  flex-direction: column;
}

/* ===== Hero / encabezado de la página ===== */
.hero {
  flex: none;
  text-align: center;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(900px 200px at 50% -40px, rgba(45,164,78,0.18), transparent 70%),
    var(--panel);
}
.hero-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(45,164,78,0.14);
  border: 1px solid rgba(45,164,78,0.4);
  padding: 4px 10px;
  border-radius: 999px;
}
.hero-title {
  font-size: clamp(20px, 3.2vw, 30px);
  line-height: 1.2;
  margin: 12px 0 6px;
}
.hero-sub {
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
  max-width: 680px;
  margin: 0 auto;
}

.app {
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: auto 1fr auto auto;
  grid-template-areas:
    "topbar  sidebar"
    "chat    sidebar"
    "lead    sidebar"
    "composer sidebar";
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}
.topbar {
  grid-area: topbar;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 16px; margin: 0; }
.brand small { color: var(--muted); }
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 12px var(--accent);
}
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-actions button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.topbar-actions button:hover { background: #283341; }

.chat {
  grid-area: chat;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.45;
}
.msg.user { align-self: flex-end; background: var(--user-bg); color: white; border-bottom-right-radius: 4px; }
.msg.bot  { align-self: flex-start; background: var(--bot-bg); border-bottom-left-radius: 4px; }
.msg.typing { color: var(--muted); font-style: italic; }
.msg.error  { background: rgba(248, 81, 73, 0.15); border: 1px solid var(--error); color: var(--error); }

.composer {
  grid-area: composer;
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.composer input {
  flex: 1;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
}
.composer input:focus { outline: none; border-color: var(--accent-2); }
.composer button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 600;
}
.composer button:hover { filter: brightness(1.1); }
.composer button:disabled { opacity: 0.5; cursor: not-allowed; }

.sidebar {
  grid-area: sidebar;
  border-left: 1px solid var(--border);
  background: var(--panel);
  padding: 20px;
  overflow-y: auto;
}
.sidebar h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 14px 0 8px;
}
.sidebar h3:first-child { margin-top: 0; }
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.sidebar li .k { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.sidebar li .v { color: var(--text); }

.prop {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}
.prop a { color: var(--accent-2); text-decoration: none; }
.prop a:hover { text-decoration: underline; }
.prop .title { font-weight: 600; margin-bottom: 4px; }
.prop .meta { color: var(--muted); font-size: 12px; }
.prop .price { color: var(--accent); font-weight: 600; }

.lead-banner {
  grid-area: lead;
  background: rgba(45, 164, 78, 0.15);
  border-top: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent);
  padding: 12px 20px;
  color: var(--accent);
}
.lead-banner.hidden { display: none; }
.lead-banner pre {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin-top: 8px;
  color: var(--text);
  font-size: 12px;
  overflow-x: auto;
}

/* ===== Pantalla de registro ===== */
.reg-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 11, 16, 0.92);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.reg-overlay.hidden { display: none; }
.reg-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.reg-head { text-align: center; margin-bottom: 6px; }
.reg-head .dot { display: inline-block; margin-bottom: 10px; }
.reg-head h2 { margin: 0 0 4px; font-size: 20px; }
.reg-head p { margin: 0; color: var(--muted); font-size: 13px; }
.reg-card label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}
.reg-card input {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}
.reg-card input:focus { outline: none; border-color: var(--accent-2); }
.reg-card button {
  margin-top: 6px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.reg-card button:hover { filter: brightness(1.1); }
.reg-card button:disabled { opacity: 0.6; cursor: not-allowed; }
.reg-note { text-align: center; color: var(--muted); font-size: 11px; }

/* ===== Avatar BuddyIA ===== */
.avatar {
  width: 40px; height: 40px;
  border-radius: 10px;
  object-fit: cover;
  image-rendering: pixelated;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.avatar-lg { width: 84px; height: 84px; border-radius: 16px; margin-bottom: 10px; }
.avatar-top { width: 110px; height: 110px; border-radius: 16px; }

/* ===== Panel de impacto (tarjetas) ===== */
.panel-title {
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  margin: 18px 0 10px;
  font-weight: 500;
}
.panel-title:first-child { margin-top: 0; }
.cards { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.card-label { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.card-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.card-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card-green {
  background: rgba(45, 164, 78, 0.16);
  border-color: rgba(45, 164, 78, 0.5);
}
.card-green .card-label, .card-green .card-sub { color: #6fcf8e; }
.card-green .card-value { color: #56d364; }
.card-blue {
  background: rgba(88, 166, 255, 0.14);
  border-color: rgba(88, 166, 255, 0.45);
}
.card-blue .card-label, .card-blue .card-sub { color: #79b8ff; }
.card-blue .card-value { color: #79b8ff; }

/* ===== Planes ===== */
.planes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.plan {
  position: relative;
  background: var(--panel-2);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 14px 8px 12px;
  cursor: pointer;
  text-align: center;
  color: var(--text);
  transition: border-color .15s, transform .1s;
}
.plan:hover { transform: translateY(-2px); }
.plan.sel { border-color: var(--accent); background: rgba(45,164,78,0.12); }
.plan.top { border-style: solid; }
.plan-badge {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  background: var(--accent-2); color: #04101f;
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  padding: 2px 6px; border-radius: 6px; white-space: nowrap;
}
.plan-nombre { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.plan-precio { font-size: 20px; font-weight: 700; }
.plan-precio small { font-size: 11px; color: var(--muted); font-weight: 400; }
.plan-desc { font-size: 10px; color: var(--muted); margin-top: 4px; }

/* ===== CTA ===== */
.cta { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.btn-primary {
  background: var(--accent); color: white; border: none;
  border-radius: 10px; padding: 13px; font-size: 15px; font-weight: 700;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-wa {
  background: #25D366; color: #04231a; border: none;
  border-radius: 10px; padding: 12px; font-size: 14px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-wa:hover { filter: brightness(1.05); }
.btn-wa .wa-ico { font-size: 16px; }

.card-red {
  background: rgba(248, 81, 73, 0.14);
  border-color: rgba(248, 81, 73, 0.45);
}
.card-red .card-label, .card-red .card-sub { color: #ff9b95; }
.card-red .card-value { color: #ff7b72; }

/* Botón destacado (pulso) */
.btn-featured {
  font-size: 16px;
  padding: 15px;
  animation: pulseGlow 2s infinite;
}
@keyframes pulseGlow {
  0%   { box-shadow: 0 0 0 0 rgba(45, 164, 78, 0.55); }
  70%  { box-shadow: 0 0 0 14px rgba(45, 164, 78, 0); }
  100% { box-shadow: 0 0 0 0 rgba(45, 164, 78, 0); }
}

/* Link al modal de info */
.link-info {
  display: block; width: 100%; margin-top: 12px;
  background: transparent;
  border: 1px dashed var(--accent-2);
  color: var(--accent-2);
  border-radius: 8px; padding: 9px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.link-info:hover { background: rgba(88, 166, 255, 0.1); }

/* ===== Modal "¿Qué hace tu BuddyIA?" ===== */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(8, 11, 16, 0.85);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  position: relative;
  width: 100%; max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 26px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  max-height: 90vh; overflow-y: auto;
}
.modal-close {
  position: absolute; top: 10px; right: 14px;
  background: transparent; border: none;
  color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-card h2 { margin: 8px 0 6px; font-size: 21px; }
.modal-lead { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.modal-feats {
  list-style: none; padding: 0; margin: 0 0 22px;
  text-align: left; display: flex; flex-direction: column; gap: 15px;
}
.modal-feats li { display: flex; gap: 12px; align-items: flex-start; }
.modal-feats li > span { font-size: 22px; line-height: 1.1; }
.modal-feats li b { display: block; font-size: 14px; margin-bottom: 2px; }
.modal-feats li small { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.modal-card .btn-featured { width: 100%; }

/* ===== Detalle colapsable ===== */
.extra { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 10px; }
.extra summary {
  cursor: pointer; color: var(--muted); font-size: 12px;
  list-style: none; padding: 4px 0;
}
.extra summary::-webkit-details-marker { display: none; }
.extra summary::before { content: '▸ '; }
.extra[open] summary::before { content: '▾ '; }

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "chat"
      "lead"
      "composer"
      "sidebar";
  }
  .sidebar { border-left: none; border-top: 1px solid var(--border); max-height: 250px; }
}
