/* =========================================================
   HOPPY – Mobile First UI (v2026-01-06)
   ========================================================= */

/* -----------------------------
   Tokens
----------------------------- */
:root{
  --bg: #faf7f2;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;

  --brand: #6d28d9;     /* morado */
  --brand2: #16a34a;    /* verde */

  --radius: 16px;
  --shadow: 0 10px 25px rgba(0,0,0,.08);
  --border: rgba(17,24,39,.10);

  --container: 960px;

  /* espacios */
  --pad: 14px;
  --gap: 10px;

  /* footer height aproximado para reservar espacio */
  --footer-h: 134px;
}

/* -----------------------------
   Base / Reset
----------------------------- */
*{ box-sizing:border-box; }
html, body{ height:100%; }
body{
  margin:0;
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, #fff 0%, var(--bg) 100%);

  /* Mobile keyboard friendly: svh/dvh */
  min-height: 100svh;
  min-height: 100dvh;

  display:flex;
  flex-direction:column;
}

a{ color:var(--brand); text-decoration:none; }
a:hover{ text-decoration:underline; }

/* -----------------------------
   Header
----------------------------- */
.app-header{
  position: sticky;
  top: 0;
  z-index: 10;

  background: rgba(255,255,255,.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);

  padding:
    calc(env(safe-area-inset-top, 0px) + 10px)
    var(--pad)
    10px
    var(--pad);
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  max-width: var(--container);
  margin: 0 auto;
}

.brand__logo{
  width:40px;
  height:40px;
  border-radius: 12px;
}

.brand__name{
  font-weight:800;
  letter-spacing:.2px;
  line-height:1.1;
}

.brand__tagline{
  font-size:12px;
  color:var(--muted);
  margin-top:2px;
}

/* -----------------------------
   Main / Chat container
----------------------------- */
.app-main{
  flex: 1;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;

  /* reserva espacio para footer sticky */
  padding: 14px var(--pad) calc(var(--footer-h) + 18px) var(--pad);
}

.chat{
  display:flex;
  flex-direction:column;
  gap:12px;
  padding-top: 6px;
}

/* -----------------------------
   Messages
----------------------------- */
.msg{
  display:flex;
  width:100%;
}

.msg .bubble{
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 8px 18px rgba(0,0,0,.04);
  line-height: 1.35;
  font-size: 14.5px;
  word-wrap: break-word;
}

/* bot / assistant */
.msg.you{ justify-content:flex-start; }
.msg.you .bubble{
  border-top-left-radius: 10px;
}

/* user */
.msg.me{ justify-content:flex-end; }
.msg.me .bubble{
  background: #dcfce7;
  border-color: rgba(22,163,74,.25);
  border-top-right-radius: 10px;
}

/* typing dots */
.typing{
  display:inline-flex;
  gap:6px;
  align-items:center;
}
.typing .dot{
  width:6px; height:6px;
  border-radius:999px;
  background: rgba(0,0,0,.35);
  animation: hop 1s infinite ease-in-out;
}
.typing .dot:nth-child(2){ animation-delay:.15s; }
.typing .dot:nth-child(3){ animation-delay:.3s; }

@keyframes hop{
  0%,100%{ transform: translateY(0); opacity:.4; }
  50%{ transform: translateY(-4px); opacity:1; }
}

/* -----------------------------
   Footer (sticky composer)
----------------------------- */
.app-footer{
  position: sticky;
  bottom: 0;
  z-index: 10;

  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);

  border-top: 1px solid var(--border);
  padding:
    10px
    var(--pad)
    calc(env(safe-area-inset-bottom, 0px) + 10px)
    var(--pad);
}

/* quick actions */
.quick-actions{
  display:flex;
  gap:10px;
  flex-wrap:nowrap;
  overflow:auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}

.starter-btn{
  flex: 0 0 auto;
  scroll-snap-align: start;

  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor:pointer;
  white-space:nowrap;
}

.starter-btn:active{ transform: translateY(1px); }

/* composer */
.composer{
  display:flex;
  align-items:center;
  gap:10px;

  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
}

.composer__input{
  flex:1;
  height: 46px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 0 16px;
  outline:none;
  font-size: 15px;
}

.composer__input:focus{
  border-color: rgba(109,40,217,.35);
  box-shadow: 0 0 0 4px rgba(109,40,217,.10);
}

.composer__send{
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: none;
  background: var(--brand2);
  color: #fff;
  font-weight: 800;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
}
.composer__send:active{ transform: translateY(1px); }

.footer-note{
  font-size: 12px;
  color: var(--muted);
  text-align:center;
  margin-top: 8px;
}

/* -----------------------------
   Modal (mobile-first)
----------------------------- */
.modal-backdrop{
  position: fixed;
  inset: 0;
  z-index: 50;

  background: rgba(0,0,0,.45);

  display:flex;
  align-items:center;
  justify-content:center;

  padding: 16px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);

  overflow:auto; /* clave en mobile */
}

.hidden{ display:none !important; }

.modal{
  width: 100%;
  max-width: 520px;

  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);

  overflow:hidden;
}

/* header */
.modal__header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
}

.modal__title{
  font-weight: 900;
  font-size: 15.5px;
}

.icon-btn{
  width: 40px; height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background:#fff;
  cursor:pointer;
}

/* body */
.modal__body{
  padding: 14px;
  max-height: min(70svh, 560px);  /* scroll real en móvil */
  overflow:auto;
}

.modal__desc{
  margin: 0 0 14px 0;
  color: var(--muted);
  font-size: 13.5px;
}

/* fields */
.grid2{
  display:grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.field span{
  display:block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input{
  width:100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0 12px;
  outline:none;
  font-size: 14.5px;
}
.field input:focus{
  border-color: rgba(109,40,217,.35);
  box-shadow: 0 0 0 4px rgba(109,40,217,.10);
}

/* checkbox */
.checkbox{
  display:flex;
  gap:10px;
  align-items:flex-start;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 10px;
}
.checkbox input{
  margin-top: 3px;
}

/* alert */
.alert{
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fef2f2;
  border: 1px solid rgba(239,68,68,.25);
  color: #991b1b;
  font-size: 13px;
}

/* footer */
.modal__footer{
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display:flex;
  gap:10px;
  justify-content:flex-end;
  flex-wrap: wrap;
}

/* buttons */
.btn{
  height: 42px;
  border-radius: 999px;
  padding: 0 14px;
  border: 1px solid var(--border);
  cursor:pointer;
  font-weight: 800;
  font-size: 13.5px;
}

.btn-primary{
  background: var(--brand);
  color: #fff;
  border-color: rgba(0,0,0,0);
}
.btn-primary:active{ transform: translateY(1px); }

.btn-ghost{
  background:#fff;
  color: var(--text);
}

/* Result step (badge view) */
.badge-hero{
  display:flex;
  flex-direction:column;
  gap:10px;
  align-items:flex-start;
}

.badge-hero img{
  width: 160px;
  max-width: 70vw;
  height:auto;
  border-radius: 14px;
}

.progress{
  margin-top: 10px;
}
.progress__label{
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.progress__bar{
  height: 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.08);
  overflow:hidden;
}
.progress__fill{
  height: 100%;
  width: 0%;
  background: var(--brand2);
  border-radius: 999px;
  transition: width .25s ease;
}

.next-badge{
  margin-top: 14px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  display:flex;
  gap: 12px;
  align-items:center;
}
.next-badge img{
  width: 92px;
  height:auto;
}

/* share buttons inside modal */
.share-actions{
  display:flex;
  flex-direction:column;
  gap:10px;
  width:100%;
  margin-top: 10px;
}
.share-actions .btn{
  width: 100%;
  justify-content:center;
}

/* -----------------------------
   Desktop enhancements
----------------------------- */
@media (min-width: 768px){
  :root{
    --pad: 18px;
    --footer-h: 140px;
  }

  .app-main{
    padding-top: 18px;
    padding-bottom: calc(var(--footer-h) + 22px);
  }

  .msg .bubble{
    max-width: 70%;
    font-size: 15px;
  }

  .grid2{
    grid-template-columns: 1fr 1fr; /* solo en desktop */
  }

  .share-actions{
    flex-direction:row;
  }
  .share-actions .btn{
    width: auto;
    flex: 1;
  }
}

/* --- Quick actions: SIN scroll horizontal (mobile-first) --- */
.quick-actions{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;

  /* mata el carrusel */
  overflow: visible;
  padding-bottom: 8px;
}

/* botones ocupan todo el ancho de su celda */
.starter-btn{
  width: 100%;
  white-space: normal;     /* permite salto de línea */
  text-align: center;

  border-radius: 14px;     /* se ven más “app” */
  padding: 10px 12px;
  line-height: 1.15;
}

/* si algún texto es muy largo, que no reviente */
.starter-btn{
  overflow: hidden;
  text-overflow: ellipsis;
}

/* En pantallas un poquito más grandes, 4 en fila */
@media (min-width: 520px){
  .quick-actions{
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ===== Modal Result polish (mobile-first) ===== */
.modal{
  width: min(92vw, 520px);
  max-height: 82vh;
  overflow: hidden;
  border-radius: 18px;
}

.modal__header{
  padding: 14px 16px;
}

.modal__body{
  padding: 14px 16px 0;
  overflow: auto;
  max-height: calc(82vh - 140px); /* header+footer aprox */
  -webkit-overflow-scrolling: touch;
}

/* Footer siempre visible (clave para UX) */
.modal__footer{
  padding: 12px 16px 16px;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,.06);
}

/* Badge principal */
.badge-hero{
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 8px 0 6px;
}

.badge-hero img{
  width: min(170px, 70vw);
  height: auto;
  display: block;
}

.badge-title{
  font-size: 20px;
  font-weight: 800;
  margin: 4px 0 0;
}

.badge-sub{
  margin: 0;
  opacity: .85;
  line-height: 1.35;
}

.result-card{
  border: 1px solid rgba(0,0,0,.07);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  margin-top: 12px;
}

.result-card__title{
  font-weight: 700;
  margin: 0 0 8px;
  font-size: 14px;
  opacity: .85;
}

/* Siguiente insignia: alineación bonita */
.next-badge{
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: center;
}

.next-badge img{
  width: 64px;
  height: auto;
  display: block;
}

.next-badge .name{
  font-weight: 800;
  margin: 0;
}

.modal__footer .btn{
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 800;
}

.modal__footer .btn + .btn{
  margin-top: 10px;
}

/* Si tienes un contenedor extra que deja un bloque vacío, esto lo “mata” */
.modal__footer:empty{ display:none; }

.progress{
  height: 10px;
  background: rgba(0,0,0,.08);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.progress__fill{
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #6d28d9; /* tu morado */
  transition: width .35s ease;
}

