:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1c2430;
  --muted: #6b7482;
  --brand: #f5c518;
  --brand-ink: #1c2430;
  --user-bubble: #1c2430;
  --user-ink: #ffffff;
  --bot-bubble: #eef1f5;
  --accent: #2563eb;
  --ok: #1c9c5b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.app {
  max-width: 820px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.header-title { display: flex; align-items: center; gap: 12px; }
.header-title h1 { font-size: 17px; margin: 0; line-height: 1.2; }
.header-title p { font-size: 12.5px; margin: 2px 0 0; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #29c467; box-shadow: 0 0 0 4px rgba(41, 196, 103, 0.18); }
.btn-soporte {
  border: 1px solid var(--border);
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 600; font-size: 13px;
  padding: 9px 14px; border-radius: 999px;
  cursor: pointer; white-space: nowrap;
  transition: filter 0.15s;
}
.btn-soporte:hover { filter: brightness(0.95); }

.chat {
  flex: 1; overflow-y: auto;
  padding: 20px 18px 8px;
  display: flex; flex-direction: column; gap: 14px;
}

.msg { display: flex; flex-direction: column; max-width: 90%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.bot { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 11px 14px; border-radius: 16px;
  font-size: 15px; line-height: 1.5;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg.user .bubble { background: var(--user-bubble); color: var(--user-ink); border-bottom-right-radius: 5px; }
.msg.bot .bubble { background: var(--bot-bubble); color: var(--text); border-bottom-left-radius: 5px; }

.bubble img.manual-img {
  display: block; max-width: 200px; max-height: 170px; width: auto; height: auto; object-fit: contain;
  margin: 10px 0 4px; border-radius: 10px;
  border: 1px solid var(--border); cursor: zoom-in; background: #fff;
}
.bubble .img-caption { font-size: 12px; color: var(--muted); margin: -2px 0 6px; }

/* Botones de opción (dispositivos, problemas, sí/no) */
.choices {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 4px; max-width: 90%;
  align-self: flex-start;
}
.choice {
  border: 1px solid var(--border);
  background: #fff; color: var(--text);
  font-size: 14px; font-weight: 500;
  padding: 10px 14px; border-radius: 12px;
  cursor: pointer; text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.choice:hover { border-color: var(--accent); background: #f7f9ff; }
.choice.primary { background: var(--user-bubble); color: #fff; border-color: var(--user-bubble); }
.choice.primary:hover { filter: brightness(1.15); background: var(--user-bubble); }
.choice.ok { border-color: var(--ok); color: var(--ok); }
.choice.ok:hover { background: #f0faf4; }
.choice.ghost { color: var(--muted); }

.step-badge {
  display: inline-block; font-size: 12px; font-weight: 700;
  color: var(--muted); margin-bottom: 4px;
}

/* Tarjeta de escalado */
.escalation {
  margin-top: 6px; border: 1px solid var(--border);
  border-left: 4px solid var(--brand); background: #fffdf3;
  border-radius: 12px; padding: 12px 14px;
  max-width: 90%; align-self: flex-start;
}
.escalation h3 { margin: 0 0 6px; font-size: 14px; }
.escalation p { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.escalation a {
  display: inline-flex; align-items: center; gap: 7px;
  text-decoration: none; color: var(--text); font-weight: 600; font-size: 14px;
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 8px 14px; margin: 4px 6px 0 0;
}
.escalation a:hover { border-color: var(--brand); }
.contacto { margin: 2px 0 4px; }
.contacto-nombre { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.contacto-sep { margin-top: 12px !important; }

.composer { border-top: 1px solid var(--border); padding: 12px 18px 14px; }
.composer-form { display: flex; align-items: center; gap: 10px; }
.input {
  flex: 1; border: 1px solid var(--border); border-radius: 14px;
  padding: 11px 14px; font-size: 15px; font-family: inherit; outline: none;
}
.input:focus { border-color: var(--accent); }
.btn-send {
  border: none; background: var(--user-bubble); color: #fff;
  width: 44px; height: 44px; border-radius: 50%; font-size: 17px;
  cursor: pointer; flex-shrink: 0;
}
.disclaimer { margin: 8px 2px 0; font-size: 11.5px; color: var(--muted); text-align: center; }

.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.8);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; cursor: zoom-out; z-index: 50;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* Pantalla inicial (identificar tienda) */
.setup {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(28, 36, 48, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.setup[hidden] { display: none; }
.setup-card {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow);
  width: 100%; max-width: 380px; padding: 24px;
  display: flex; flex-direction: column; gap: 12px;
}
.setup-card h2 { margin: 0; font-size: 18px; }
.setup-card > p { margin: 0 0 4px; font-size: 13.5px; color: var(--muted); }
.setup-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--text); }
.setup-card input {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 12px; font-size: 15px; font-family: inherit; outline: none; font-weight: 400;
}
.setup-card input:focus { border-color: var(--accent); }
.setup-btn {
  margin-top: 6px; border: none; background: var(--user-bubble); color: #fff;
  font-size: 15px; font-weight: 600; padding: 12px; border-radius: 12px; cursor: pointer;
}
.setup-btn:hover { filter: brightness(1.15); }
.setup-error { margin: 0; font-size: 13px; color: var(--danger); font-weight: 600; }

@media (max-width: 640px) {
  .header-title p { display: none; }
  .msg, .escalation, .choices { max-width: 100%; }
}
