/* Frameflow · Layouts por vista. Móvil primero (360 px), escritorio desde 900 px. */
:root { --surface: var(--bg); }
body.pmv { --surface: #fff; }

/* ---------- Estructura general ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--border); }
body.focus .topbar, body.pmv .topbar { display: none; }
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 16px; min-height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); text-decoration: none; color: var(--text); font-weight: 700; font-size: 20px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: var(--blue); color: #fff; font-weight: 700; font-size: 18px;
}

#app { min-height: calc(100vh - var(--header-h) - 120px); }
#app.slide { animation: slide-in .28s ease-out; }
@keyframes slide-in { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }

.view { padding: 16px 16px 32px; }
.narrow { max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.container { max-width: 1120px; margin: 0 auto; }
.section { margin-top: 32px; display: flex; flex-direction: column; gap: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { min-width: 0; }
.section-head a { white-space: nowrap; font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }

.lead { color: var(--text-2-bg); font-size: 16px; }
.small { font-size: var(--fs-label); }
.legal { font-size: var(--fs-label); color: var(--text-2-bg); }
.muted { color: var(--text-2-bg); }
.desk-only { display: none; }
.meta-line { display: flex; align-items: center; gap: 8px; color: var(--text-2-bg); margin-top: 6px; }
.free-note {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--ok); color: var(--ok-text); font-size: 15px;
}
.free-note .icon-sm { margin-top: 3px; }
.free-note.big { font-size: 16px; }
.icon-xl { width: 40px; height: 40px; }

/* Modo prueba en escritorio: columna centrada, como un teléfono */
@media (min-width: 600px) {
  body.pmv #app { max-width: 440px; margin: 24px auto; background: #fff; border-radius: 28px; box-shadow: var(--shadow-lg); min-height: 720px; overflow: clip; }   /* clip (no hidden): mantiene el botón principal fijo abajo */
}
body.pmv #app { background: #fff; }
@media (max-width: 599px) { body.pmv { background: #fff; } }

.site-footer { padding: 24px 16px 16px; text-align: center; font-size: var(--fs-label); color: var(--text-2-bg); display: grid; gap: 4px; }
.site-footer[hidden] { display: none; }

/* ---------- Barra de pasos ---------- */
.stepbar { display: flex; align-items: center; gap: 8px; margin: -4px 0 4px -8px; }
.stepmeta { flex: 1; display: grid; gap: 6px; padding-right: 8px; }
.step-label { font-size: var(--fs-label); font-weight: 600; color: var(--text-2-bg); }
.group { display: flex; flex-direction: column; gap: 10px; margin: 0 0 20px; border: 0; padding: 0; }
.group-title { font-size: 15px; font-weight: 600; color: var(--text-2-bg); text-transform: none; }
.step { min-height: calc(100vh - var(--header-h) - var(--nav-h)); min-height: calc(100dvh - var(--header-h) - var(--nav-h)); }
.step form { flex: 1; }
.cta-bar {
  position: sticky; bottom: var(--nav-h); z-index: 5; margin: auto -16px -32px;   /* por encima del menú inferior cuando existe */ padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--surface) 78%, rgba(255, 255, 255, 0));
}
.cta-stack { display: flex; flex-direction: column; gap: 10px; }
form { display: flex; flex-direction: column; gap: 16px; }
.other-field[hidden] { display: none; }

/* ---------- Pantalla 1 · Bienvenida ---------- */
.hero-copy { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.hero { padding-top: 28px; }
.brand-line { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 22px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; min-width: 0; }
.hero-copy h1 { font-size: 28px; }
.hero-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.hero-card { padding: 20px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.hero-side { display: flex; flex-direction: column; gap: 12px; }
.hero-side .card { box-shadow: var(--shadow); }

@media (min-width: 900px) {
  .hero-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); align-items: center; gap: 40px; padding-top: 24px; }
  .hero-card { padding: 36px; }
  .hero-copy h1 { font-size: 40px; line-height: 1.15; }
  .hero-actions { flex-direction: row; }
  .hero-actions .btn { width: auto; flex: 1; }
}

/* ---------- Oficios (tarjetas) ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.oficio-tile {
  display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; min-height: 64px; padding: 10px 14px;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--text); font-weight: 600;
}
.oficio-tile:active { background: var(--blue-light); }
.oficio-tile:hover { outline: 2px solid var(--blue-light); }
.tile-ic { grid-row: span 2; font-size: 26px; line-height: 1; }
.tile-name { min-width: 0; overflow-wrap: break-word; line-height: 1.25; }
.tile-count { grid-column: 2; font-size: var(--fs-label); font-weight: 500; color: var(--text-2-bg); }
.oficio-tile:not(:has(.tile-count)) .tile-ic { grid-row: auto; }
/* En pantallas angostas el icono va arriba del nombre: las palabras largas no se cortan */
@media (max-width: 479px) {
  .oficio-tile { grid-template-columns: minmax(0, 1fr); row-gap: 2px; padding: 12px; justify-items: start; }
  .tile-ic, .oficio-tile:not(:has(.tile-count)) .tile-ic { grid-row: auto; }
  .tile-name, .tile-count { grid-column: 1; }
}
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ---------- Pasos y preguntas ---------- */
.steps3 { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 12px; }
.steps3 .card { display: flex; flex-direction: column; gap: 6px; }
.step-n { width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 700; }
@media (min-width: 900px) { .steps3 { grid-template-columns: repeat(3, 1fr); } }
.pairs { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pair { display: grid; gap: 10px; }
.pair-new { color: var(--ok-text); }
@media (min-width: 700px) { .pairs { grid-template-columns: repeat(2, 1fr); } }
.faqs { display: grid; gap: 10px; }
.faq summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.faq p { margin-top: 8px; }
.cta-inline { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }

/* ---------- Pantalla 5 · Perfil publicado ---------- */
.success { text-align: center; align-items: stretch; }
.success h1, .success .lead { text-align: center; }
.success-icon { width: 72px; height: 72px; border-radius: 50%; margin: 8px auto 0; display: grid; place-items: center; background: var(--ok); color: var(--ok-text); }
.success .profile-card { text-align: left; }
.success .card-blue { text-align: left; display: grid; gap: 6px; }

/* ---------- Pantalla 6 · Servicios y fotos ---------- */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 4px; }
.photo-count { font-size: var(--fs-label); color: var(--text-2-bg); margin-top: 4px; }
.slot { position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; }
.slot img { width: 100%; height: 100%; object-fit: cover; }
.slot-add {
  width: 100%; height: 100%; min-height: var(--tap); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 2px dashed var(--blue); border-radius: var(--radius); background: var(--blue-light); color: var(--blue-dark); font-weight: 600; cursor: pointer;
}
.slot-add:active { background: #d6e4fd; }
.slot-x {
  position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: rgba(17, 24, 39, .78); color: #fff; display: grid; place-items: center; cursor: pointer;
}

/* ---------- Pantalla 7 · Vista del cliente y detalle ---------- */
.detail .container { display: flex; flex-direction: column; gap: 16px; }
.detail .stepbar { margin-bottom: 0; }
.client-tag { font-weight: 700; }
.detail-grid { display: flex; flex-direction: column; gap: 16px; }
.detail-main, .detail-side { display: flex; flex-direction: column; gap: 16px; }
.detail-main .card h2 { margin-bottom: 8px; }
.pitch { color: var(--text); margin-bottom: 4px; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gallery.mini { gap: 6px; }
.gallery[data-collapsed="true"] > :nth-child(n+7) { display: none; }
.ph {
  --h: 215; position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: hsl(var(--h) 55% 88%); color: hsl(var(--h) 60% 22%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.ph-ic { font-size: 30px; line-height: 1; }
.ph-lb { font-size: 12px; font-weight: 600; text-align: center; padding: 0 4px; }
.ph.has-img img { width: 100%; height: 100%; object-fit: cover; }
.contact-card { display: flex; flex-direction: column; gap: 10px; }
.contact-tools { display: flex; justify-content: center; gap: 8px; }
.contact-note { font-size: var(--fs-label); text-align: center; }

@media (max-width: 899px) {
  /* El botón de contacto queda a la vista sobre el menú inferior mientras se recorre el perfil */
  .detail-side { position: sticky; bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom, 0px)); z-index: 10; }
  .contact-card { padding: 12px; box-shadow: 0 -2px 16px rgba(17, 24, 39, .14); gap: 6px; }
  .contact-tools { gap: 0; }
}
@media (min-width: 900px) {
  .desk-only { display: block; }
  .detail-grid { display: grid; grid-template-columns: 1fr 340px; align-items: start; gap: 24px; }
  .detail-side { position: sticky; top: calc(var(--header-h) + 16px); }
  .gallery { grid-template-columns: repeat(3, 1fr); gap: 12px; }
}

/* ---------- Pantalla 8 · Cierre ---------- */
.closing { text-align: center; }
.closing .lead, .closing h1 { text-align: center; }
.closing .card-blue { text-align: left; }
.closing-ic { width: 72px; height: 72px; border-radius: 50%; margin: 12px auto 0; display: grid; place-items: center; background: var(--blue-light); color: var(--blue); }
.closing .btn-primary { min-height: 56px; font-size: 17px; }

/* ---------- Estados vacíos ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 28px 20px; grid-column: 1 / -1; }
.empty-ic { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-light); color: var(--blue); }
.empty-view { padding-top: 32px; }

/* ---------- Tarjeta de resultado ---------- */
.results-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); align-content: start; }
.result {
  display: flex; align-items: flex-start; gap: 14px; text-decoration: none; color: var(--text);
  transition: box-shadow .15s, transform .05s;
}
.result:hover { box-shadow: 0 2px 4px rgba(17, 24, 39, .08), 0 8px 24px rgba(17, 24, 39, .1); }
.result:active { transform: scale(.99); background: var(--blue-light); }
.result-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.result-main h3 { font-size: 17px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; overflow-wrap: anywhere; }
.result-meta { display: flex; align-items: center; gap: 6px; font-size: var(--fs-label); }
.result-rate { margin-top: 6px; font-size: var(--fs-label); }
.result-go { align-self: center; color: var(--blue); display: none; }
@media (min-width: 400px) { .result-go { display: block; } }
.rating { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 2px 4px; }
.rating .muted { white-space: nowrap; }
.rating .star { color: var(--star); display: inline-flex; }
.rating .star svg { fill: currentColor; }
.ad { border: 1.5px dashed var(--border); box-shadow: none; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; grid-column: 1 / -1; }

/* ---------- Explorar ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.searchbar { position: relative; }
.searchbar .icon { position: absolute; left: 14px; top: 15px; color: var(--text-2-bg); pointer-events: none; }
.searchbar .input { padding-left: 46px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0; }
.sort { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sort .input { min-height: var(--tap); width: auto; min-width: 0; padding-block: 8px; }
@media (max-width: 899px) {
  .sort label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .sort .input { max-width: 210px; }
}
.badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--blue); color: #fff; font-size: 13px; display: inline-grid; place-items: center; }
.badge[hidden] { display: none; }
.count { font-size: var(--fs-label); font-weight: 500; margin: 4px 0 12px; }
.active-chips:empty { display: none; }
.active-chips { margin-bottom: 10px; }
.explorar-main { min-width: 0; }

.fgroup { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.fgroup h3 { font-size: 15px; color: var(--text-2-bg); }
.filters-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.filters-foot { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; position: sticky; bottom: -16px; background: #fff; padding: 12px 0 4px; }

.filters {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; max-height: 88vh; overflow: auto;
  background: #fff; border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%); visibility: hidden; transition: transform .25s ease, visibility .25s; box-shadow: var(--shadow-lg);
}
.filters.open { transform: none; visibility: visible; }
.filters-backdrop { position: fixed; inset: 0; z-index: 65; background: rgba(17, 24, 39, .5); opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; }
.filters-backdrop.open { opacity: 1; visibility: visible; }

@media (min-width: 900px) {
  .explorar-grid { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
  .filters {
    position: sticky; top: calc(var(--header-h) + 16px); transform: none; visibility: visible; z-index: 1;
    border-radius: var(--radius-lg); max-height: calc(100vh - var(--header-h) - 32px); box-shadow: var(--shadow); transition: none;
  }
  .filters-backdrop, #f-open, #f-close, #f-apply { display: none; }
  .filters-foot { grid-template-columns: 1fr; position: static; padding-top: 0; }
}

/* ---------- Modo observador ---------- */
.observer { position: fixed; top: 8px; right: 8px; z-index: 90; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.observer-pill { min-height: 40px; padding: 6px 12px; border: 0; border-radius: 999px; background: #111827; color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; box-shadow: var(--shadow-lg); }
.observer-panel { width: 250px; padding: 14px; border-radius: 14px; background: #fff; box-shadow: var(--shadow-lg); display: grid; gap: 6px; font-size: var(--fs-label); }
.ob-check { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.ob-check input { width: 20px; height: 20px; }
.ob-actions { display: grid; gap: 8px; margin-top: 4px; }

@media print { .topbar, .bottom-nav, .observer { display: none; } }

/* ---------- Pantallas bajas (celulares pequeños y celular en horizontal) ---------- */
@media (max-height: 700px) {
  .hero { padding-top: 12px; }
  .hero-copy { gap: 12px; }
  .hero-card { padding: 16px; }
  .hero-copy h1 { font-size: 24px; }
  .chip-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .chip-row::-webkit-scrollbar { display: none; }
  .chip-row .tag { white-space: nowrap; flex: none; }
  .hero-side { display: none; }
  .view { padding-top: 12px; }
}
@media (max-height: 500px) {
  .topbar { position: static; }
  .contact-note, .demo-note { display: none; }
  .success-icon, .closing-ic { display: none; }
  .detail-side { bottom: calc(var(--nav-h) + 4px); }
  .contact-card { padding: 8px; gap: 4px; }
}

/* ---------- Selector de oficios (hasta 5) ---------- */
.oficio-picker { display: flex; flex-direction: column; gap: 4px; }
.pick-count { font-size: var(--fs-label); color: var(--text-2-bg); margin-bottom: 8px; }
.pick-count strong { color: var(--text); }
.chip-main { font-size: var(--fs-label); font-weight: 600; padding: 0 8px; border-radius: 999px; background: #fff; color: var(--blue-dark); }
.chip-main[hidden] { display: none; }

/* ---------- Estrellas y opiniones ---------- */
.stars { display: inline-flex; gap: 2px; vertical-align: middle; }
.star-cell { position: relative; display: inline-block; width: 20px; height: 20px; }
.star-svg { width: 100%; height: 100%; display: block; }
.star-empty { color: #9CA3AF; }
.star-fill { position: absolute; left: 0; top: 0; height: 100%; overflow: hidden; }
.star-fill .star-svg { width: 20px; }
.star-full { color: var(--star); fill: currentColor; }
.stars-sm .star-cell { width: 16px; height: 16px; }
.stars-sm .star-fill .star-svg { width: 16px; }
.rating .stars { margin-right: 2px; }
.star-picker { display: flex; gap: 2px; }
.star-btn { width: var(--tap); height: var(--tap); padding: 6px; border: 0; border-radius: 10px; background: transparent; color: #6B7280; cursor: pointer; }
.star-btn .star-svg { fill: none; }
.star-btn[data-on="true"] { color: var(--star); }
.star-btn[data-on="true"] .star-svg { fill: currentColor; }
.star-btn:active { background: var(--blue-light); }
.rv-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.rv-summary { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.rv-avg { font-size: 40px; font-weight: 700; line-height: 1; }
.reviews { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 14px; }
.review { display: grid; gap: 6px; border-top: 1px solid var(--border); padding-top: 12px; overflow-wrap: anywhere; }
.review[hidden] { display: none; }
.rv-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
textarea.input { min-height: 104px; resize: vertical; line-height: 1.4; }

/* ---------- Paginación de Explorar (máximo 20 por página) ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.pager .btn { min-width: 110px; }
.pager-info { font-size: var(--fs-label); font-weight: 500; color: var(--text-2-bg); text-align: center; }

/* En modo prueba el flujo va siempre en una columna, aunque la pantalla sea ancha */
body.pmv .detail-grid { display: flex; flex-direction: column; }
body.pmv .detail-side { position: sticky; top: auto; bottom: 8px; z-index: 10; }
body.pmv .desk-only { display: none; }
body.pmv .contact-card { padding: 12px; gap: 6px; }

/* Celular en horizontal: el contacto va en una sola fila para no tapar el contenido */
@media (max-height: 500px) {
  .contact-card { flex-direction: row; align-items: center; gap: 8px; }
  .contact-card .btn-wa { flex: 1; }
  .contact-tools { flex: none; }
}
