/* STEP71: Global responsive + iPhone SE safe + Safari */
* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
img, svg, video, canvas { max-width: 100%; height: auto; }
input, select, textarea, button { max-width: 100%; }
.page, .wrap, main { max-width: 100%; }
.container { width: 100%; }

/* Prevent accidental horizontal scroll */
.panel, .card, .section, .box { max-width: 100%; }
.row { flex-wrap: wrap; }
@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
}

/* Buttons: consistent, readable */
.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;            /* iOS tap target */
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.2;
  font-weight: 700;
  text-decoration: none;
  white-space: normal;
  word-break: break-word;
  max-width: 100%;
}
.btn.full, .btn.block, .btn.primary.full { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* Some pages use .primary/.secondary without .btn */
button.primary, a.primary, .primary-btn {
  min-height: 44px;
  border-radius: 12px;
}

/* Avoid 100vw overflow issues */
.w-100vw, .vw100 { width: 100%; }

/* iPhone SE (320px) */
@media (max-width: 360px) {
  .btn, button.btn { padding: 10px 12px; }
  .panel, .card { padding: 12px !important; }
  h1 { font-size: 22px !important; }
  h2 { font-size: 18px !important; }
}

/* Safari flex overflow fix */
.flex, .row { min-width: 0; }
.col, .cell { min-width: 0; }

/* STEP78: app layout - angosto centrado en desktop, full en mobile */
body.page-app .container{
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}
@media (min-width: 900px){
  body.page-app .container{
    max-width: 560px;   /* ~1/3 pantalla */
    padding-left: 16px;
    padding-right: 16px;
    padding-top: 14px;
  }
}
@media (max-width: 899px){
  body.page-app .container{
    max-width: 100%;
    padding-left: 14px;
    padding-right: 14px;
  }
}

/* STEP79: panel layout - header full-bleed + contenido centrado en desktop */
body.page-panel .nav{ display:none !important; } /* Precio/Como funciona son solo /home */
body.page-panel .container, body.page-panel .wrap{
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}
@media (min-width: 900px){
  body.page-panel .container, body.page-panel .wrap{
    max-width: 720px;
    padding-left: 16px;
    padding-right: 16px;
  }
}
@media (max-width: 899px){
  body.page-panel .container, body.page-panel .wrap{
    max-width: 100%;
    padding-left: 14px;
    padding-right: 14px;
  }
}

/* STEP80: session header - mostrar solo "Sesión activa" (sin email) */
header .session-email { display: none !important; }

/* STEP80: start - ocultar nav de /home (Precio / Cómo funciona) */
body.page-start .nav { display: none !important; }

/* STEP81: danger-ish outline button hover (opcional) */
.btn.btn-outline:hover { filter: brightness(.98); }

/* STEP123: mobile UX hardening across /app /admin /select /start /panel
   Goal: eliminate right-shifted inputs and cramped action rows without changing desktop layout. */
@media (max-width: 720px) {
  html, body { overflow-x: hidden; }

  /* Safer content width */
  body.page-app .container,
  body.page-panel .wrap,
  body.page-start .wrap,
  body .wrap,
  body .container {
    width: 100%;
    max-width: 100%;
  }

  /* Forms and fields */
  form,
  .form,
  .grid,
  .grid2,
  .grid3,
  #start-form,
  #biz-form,
  #service-form,
  #pro-form,
  #work-form,
  #break-form,
  #rep-form {
    width: 100%;
    min-width: 0;
  }

  label,
  .block,
  .checks,
  .actions,
  .inline-actions,
  .row,
  .row-actions,
  .topbar-inner,
  .topbar-actions,
  .authbar,
  #auth-bar,
  .trialtop,
  .bizhead,
  .bizsection-head,
  .turno-item {
    min-width: 0;
  }

  input,
  select,
  textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: block;
  }

  /* Generic stacked controls on mobile */
  .actions,
  .inline-actions,
  .row-actions,
  .topbar-actions,
  #auth-bar,
  #auth-box .actions,
  .authbox .actions,
  .wa .row,
  .bizactions,
  .trialcta {
    width: 100%;
    align-items: stretch !important;
  }

  #auth-box .actions,
  .authbox .actions,
  .wa .row,
  #auth-bar,
  .topbar-actions {
    display: flex;
    flex-direction: column;
    justify-content: flex-start !important;
    gap: 10px;
  }

  #auth-box .actions > *,
  .authbox .actions > *,
  .wa .row > *,
  #auth-bar > *,
  .topbar-actions > * {
    width: 100%;
    max-width: 100%;
    margin-left: 0 !important;
  }

  /* Buttons fill available width neatly */
  .btn,
  button,
  .btn.small,
  .btn.tiny,
  .confirm-btn,
  .delete-btn,
  .btn-sena,
  .btn-comprobante {
    max-width: 100%;
  }

  #auth-box button,
  .authbox .btn,
  .wa .row .btn,
  .bizactions .btn,
  .trialcta .btn,
  #rep-form .btn,
  #work-form .btn,
  #break-form .btn,
  #service-form .btn,
  #pro-form .btn,
  #biz-form .btn {
    width: 100%;
    justify-content: center;
  }

  /* Mobile cards / sections */
  .card,
  .panel,
  .authbox,
  #auth-box,
  .picker,
  .section,
  .report,
  .item,
  .bizcard,
  .bizsection,
  .guide-box,
  .applybox,
  .notice {
    width: 100%;
    max-width: 100%;
  }

  /* App page: stacked appointment actions */
  body.page-app .turno-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  body.page-app .turno-info {
    margin: 0;
    width: 100%;
  }
  body.page-app .turno-actions-left,
  body.page-app .turno-actions-right {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  body.page-app .delete-btn,
  body.page-app .btn-sena,
  body.page-app .btn-comprobante {
    width: 100%;
    height: auto;
    min-height: 42px;
  }

  /* Headers and split rows */
  .topbar-inner,
  .bizhead,
  .trialtop,
  .bizsection-head,
  .applybox-top,
  .row-actions.row-between {
    display: flex;
    flex-direction: column;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 10px;
  }

  .brand {
    min-width: 0;
  }
  .brand span,
  .title,
  .biztitle,
  #auth-who,
  #auth-who-bar,
  #session-pill {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Availability editor and report filters */
  #rep-form > div,
  .row-actions > .chkline,
  .row-actions > .btn,
  .apply-presets,
  .apply-days {
    width: 100%;
  }

  .apply-presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .checks {
    display: grid;
    grid-template-columns: 1fr;
  }

  /* Avoid tight outer gutters on very narrow screens */
  body.page-app .container,
  body.page-panel .wrap,
  body.page-start .wrap,
  body .wrap {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

@media (max-width: 420px) {
  .topbar-inner,
  .topbar-actions,
  #auth-box .actions,
  .authbox .actions,
  .trialcta,
  .bizactions,
  .apply-presets {
    grid-template-columns: 1fr;
  }

  .card,
  .panel,
  .authbox,
  #auth-box,
  .bizcard,
  .bizsection,
  .applybox,
  .notice {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  body.page-app .container {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
}

/* STEP124: /start mobile specific fix
   The generic responsive pass was not enough here because start.html has inline layout rules
   and mixed admin/home styles. We force a clean single-column mobile composition. */
@media (max-width: 720px) {
  body.page-start .topbar-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 10px;
    padding-left: 12px;
    padding-right: 12px;
  }

  body.page-start .brand {
    width: 100%;
    justify-content: center;
  }

  body.page-start .topbar .btn,
  body.page-start .topbar .btn.btn-primary {
    width: 100%;
    min-height: 44px;
  }

  body.page-start .wrap {
    width: 100%;
    max-width: 100%;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  body.page-start main.card {
    width: 100%;
    max-width: 100%;
    margin: 14px 0 0 !important;
    padding: 14px !important;
    border-radius: 18px;
  }

  body.page-start .panel,
  body.page-start .panel .box,
  body.page-start .authbox,
  body.page-start #auth-box,
  body.page-start #view,
  body.page-start #start-form,
  body.page-start #start-form label,
  body.page-start #start-form .full,
  body.page-start .wa,
  body.page-start .wa .row,
  body.page-start .links,
  body.page-start #msg,
  body.page-start #slug-help,
  body.page-start #slug-preview {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  body.page-start #start-form {
    display: grid;
    grid-template-columns: 1fr !important;
    gap: 14px;
    align-items: stretch;
  }

  body.page-start #start-form input,
  body.page-start #start-form select,
  body.page-start .wa input {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  body.page-start #auth-box .actions,
  body.page-start .authbox .actions,
  body.page-start .wa .row {
    display: flex;
    flex-direction: column;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 10px;
  }

  body.page-start #auth-box .actions > *,
  body.page-start .authbox .actions > *,
  body.page-start .wa .row > * {
    width: 100%;
    max-width: 100%;
    margin: 0 !important;
  }

  body.page-start #auth-who,
  body.page-start #auth-status,
  body.page-start #slug-preview-url,
  body.page-start .links a,
  body.page-start h1,
  body.page-start h2,
  body.page-start p,
  body.page-start .muted {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

@media (max-width: 420px) {
  body.page-start main.card,
  body.page-start .panel .box,
  body.page-start .authbox,
  body.page-start #auth-box {
    padding: 12px !important;
  }

  body.page-start .topbar-inner,
  body.page-start .wrap {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
}

/* STEP125: mobile layout system
   Goal: fix right-shifted controls across the full customer journey, not just /start.
   We stack mixed input+button rows, allow flex children to shrink, and constrain long links/texts. */
.created-links-card {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 16px;
  background: rgba(255,255,255,.65);
  width: 100%;
  max-width: 100%;
}
.created-links-title {
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 6px;
}
.created-links-subtitle,
.created-copy-msg,
.created-links-copy,
.created-links-details {
  margin-top: 10px;
}
.created-links-row,
.created-links-actions,
.created-links-more {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.created-link-input {
  flex: 1 1 280px;
  min-width: 0;
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,.12);
  background: #fff;
}
.created-link-btn {
  min-height: 44px;
}
.created-links-details summary {
  cursor: pointer;
}
.created-links-alt,
.created-links-alt a,
.created-links-card a,
.created-links-card .muted,
.created-links-card b {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.created-links-alt > div + div {
  margin-top: 8px;
}

@media (max-width: 720px) {
  body.page-start .wrap,
  body.page-select .wrap,
  body.page-panel .wrap,
  body.page-app .container,
  body .wrap,
  body .container {
    width: 100%;
    max-width: 100%;
  }

  body.page-start main.card,
  body.page-select main.card,
  body.page-panel .card,
  body.page-app .section,
  body.page-app .picker,
  body.page-app #auth-box,
  body.page-app #booking-box,
  body.page-select .authbox,
  body.page-select .bizcard,
  body.page-panel .bizcard,
  body.page-panel #auth-card,
  .created-links-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  /* Common horizontal rows become safe stacks on mobile */
  .bizcontrols,
  .bizmeta,
  .guide-link-row,
  .guide-actions,
  .trialcta,
  .created-links-row,
  .created-links-actions,
  .created-links-more,
  #auth-box .actions,
  #auth-bar,
  .actions[style],
  #dev-tools > div:first-child,
  #auth-card > div,
  .bizhead,
  .bizsection-head,
  .topbar-inner,
  .topbar-actions,
  .wa .row,
  .row-actions.row-between {
    display: flex;
    flex-direction: column;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 10px;
    min-width: 0;
  }

  .actions,
  .bizactions,
  .bizsection-actions,
  .apply-presets {
    width: 100%;
    min-width: 0;
  }

  .bizactions,
  .bizsection-actions,
  .apply-presets {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .actions > *,
  .bizcontrols > *,
  .bizmeta > *,
  .trialcta > *,
  .guide-link-row > *,
  .guide-actions > *,
  .created-links-row > *,
  .created-links-actions > *,
  .created-links-more > *,
  .bizactions > *,
  .bizsection-actions > *,
  #auth-box .actions > *,
  #auth-bar > *,
  .wa .row > *,
  .topbar-actions > * {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0 !important;
  }

  .actions > .muted,
  #auth-who,
  #auth-who-bar,
  #auth-status,
  #session-pill,
  .bizpill,
  .tag,
  .pill,
  .biztitle,
  .guide-link,
  .guide-link a,
  .bizlinks,
  .bizlinks a,
  #slug-preview-url,
  #share-link,
  .created-links-card,
  .created-links-card * {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
  }

  input,
  select,
  textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .created-link-input,
  .wa input,
  #dev-trial-bid,
  #auth-box input,
  body.page-app #auth-box input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
  }

  .btn,
  button,
  a.btn,
  .btn.small,
  .btn.tiny,
  .btn-primary,
  .btn-outline,
  .btn-danger,
  .btn-owner-suspend,
  .created-link-btn {
    width: 100%;
    max-width: 100%;
  }

  body.page-start .brand,
  body.page-select .brand,
  body.page-panel .brand,
  body.page-app .brand {
    width: 100%;
    justify-content: center;
  }

  body.page-select .wrap,
  body.page-panel .wrap,
  body.page-start .wrap,
  body.page-app .container,
  body .wrap {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

@media (max-width: 420px) {
  body.page-select .wrap,
  body.page-panel .wrap,
  body.page-start .wrap,
  body.page-app .container,
  body .wrap {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  body.page-select .card,
  body.page-panel .card,
  body.page-start main.card,
  .created-links-card {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

/* STEP127: ocultar resumen de sesión en header/topbar sin tocar la lógica de auth */
body.page-app #auth-pill,
body.page-admin #auth-pill,
body.page-panel #session-pill {
  display: none !important;
}

/* Reserva visual por si el header auth se reinyecta con otros wrappers */
body.page-panel .topbar-actions #session-pill,
body.page-app .topbar-actions #auth-pill,
body.page-admin .topbar-actions #auth-pill {
  display: none !important;
}

/* FIX: restore auth-bar in /app */
body.page-app #auth-bar {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px;
  min-width: 0;
  margin: 10px 0 16px !important;
}

body.page-app #auth-bar > * {
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
}

body.page-app #btn-logout-bar {
  display: inline !important;
  width: auto !important;
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  color: #16b5cf !important;
  text-decoration: none;
  cursor: pointer;
}

body.page-app #btn-logout-bar:hover {
  text-decoration: underline;
}


/* Fix negocio card alignment */
.biz-name,
.business-name,
.location-name,
.place-name,
.card-business-name,
.map-title,
.map-business-name,
#businessName {
  display: block !important;
  width: 100% !important;
  text-align: center !important;
  margin: 0 auto 10px auto !important;
  color: #5f6673 !important;
  text-shadow: none !important;
}

.biz-address,
.business-address,
.location-address,
.place-address,
.card-business-address,
.map-address,
#businessAddress {
  display: block !important;
  width: 100% !important;
  text-align: center !important;
  margin: 0 auto 10px auto !important;
  color: #6b7280 !important;
  text-shadow: none !important;
}

.biz-maps,
.business-maps,
.location-maps,
.place-maps,
.card-business-maps,
.map-link,
#businessMaps {
  display: block !important;
  width: fit-content !important;
  max-width: 100% !important;
  text-align: center !important;
  margin: 0 auto !important;
  color: #6b7280 !important;
  text-shadow: none !important;
}

.business-info,
.biz-info,
.location-info,
.place-info,
.card-business-info,
.map-overlay,
.map-content,
.map-info,
.map-labels {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  width: 100% !important;
}

.business-info > *,
.biz-info > *,
.location-info > *,
.place-info > *,
.card-business-info > *,
.map-overlay > *,
.map-content > *,
.map-info > *,
.map-labels > * {
  align-self: center !important;
  text-align: center !important;
}



/* Specific business frame fix */
.business-card .business-info,
.business-frame .business-info,
.location-card .location-info,
.map-card .map-info,
.map-preview .map-overlay,
.map-preview .map-content,
.store-card .store-info {
  position: absolute !important;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: calc(100% - 32px) !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
}

.business-card .business-name,
.business-frame .business-name,
.location-card .location-name,
.map-card .map-title,
.map-preview .map-title,
.store-card .store-name {
  display: block !important;
  width: 100% !important;
  text-align: center !important;
  margin: 0 0 10px 0 !important;
  color: #5f6673 !important;
  text-shadow: none !important;
}

.business-card .business-address,
.business-frame .business-address,
.location-card .location-address,
.map-card .map-address,
.map-preview .map-address,
.store-card .store-address {
  display: block !important;
  width: 100% !important;
  text-align: center !important;
  margin: 0 0 10px 0 !important;
  color: #6b7280 !important;
  text-shadow: none !important;
}

.business-card .map-link,
.business-frame .map-link,
.location-card .map-link,
.map-card .map-link,
.map-preview .map-link,
.store-card .map-link {
  display: inline-block !important;
  margin: 0 auto !important;
  color: #6b7280 !important;
  text-shadow: none !important;
  float: none !important;
}
