/*
 * Reservas en línea (reservas.js): hoja "Reservar". El botón "Agenda" de la cinta está en styles.css (app.js).
 * Solo se carga en negocios con reservas. Usa los colores de cada sitio (variables de styles.css y del <style> del
 * index.html). En celular la hoja ocupa toda la pantalla; desde 600 px es una ventana centrada.
 */

/* Hoja */
.rv {
  width: 100%;
  max-width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100%;
  max-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}
.rv[open] { display: flex; flex-direction: column; }
.rv::backdrop { background: rgb(var(--shade) / .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@media (min-width: 600px) {
  .rv {
    width: min(560px, calc(100vw - 48px));
    height: fit-content;
    min-height: min(620px, calc(100vh - 48px));
    max-height: min(900px, calc(100vh - 48px));
    max-height: min(900px, calc(100dvh - 48px));
    margin: auto;
    border-radius: 26px;
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45);
  }
}
@media (prefers-reduced-motion: no-preference) {
  .rv[open] { animation: rv-entra .24s ease-out; }
  @keyframes rv-entra { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
}

.rv-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
@media (min-width: 600px) { .rv-head { padding: 12px 12px 12px 16px; } }
.rv-head-text { flex: 1; min-width: 0; padding-inline: 6px; }
.rv-kicker {
  color: var(--accent-deep);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rv-title {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 1.75rem;
  line-height: 1.1;
}
.rv-title:focus { outline: none; }
.rv-back, .rv-close { flex: none; color: var(--ink); }
.rv-back:hover, .rv-close:hover { background: var(--bg-alt); }
.rv-back .icon, .rv-close .icon { width: 24px; height: 24px; }
.rv-bar { flex: none; height: 3px; background: var(--bg-alt); }
.rv-bar span { display: block; width: 0; height: 100%; background: var(--primary); transition: width .25s ease; }

.rv-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 28px;
}
.rv-foot {
  flex: none;
  display: grid;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
@media (min-width: 600px) {
  .rv-body { padding: 22px 24px 28px; }
  .rv-foot { padding: 14px 24px 18px; }
}
.rv .btn { text-decoration: none; }
/* El foco de teclado conserva la forma redondeada de cada control (styles.css pone border-radius: 6px) */
.rv-opcion:focus-visible, .rv-dia:focus-visible { border-radius: 16px; }
.rv-hora:focus-visible { border-radius: 12px; }
.rv-input:focus-visible { border-radius: 14px; outline-offset: 2px; }
.rv-cel .rv-input:focus-visible { border-radius: 0 14px 14px 0; }
.rv-ancho { width: 100%; }
.rv-grande { min-height: 60px; font-size: 1.08rem; }
.rv-confirmar { min-height: 62px; font-size: 1.14rem; }
.rv-confirmar[aria-busy="true"] { opacity: .8; cursor: progress; }
.rv-fino { color: var(--ink-soft); font-size: .86rem; line-height: 1.45; text-align: center; }
.rv-fino a { color: var(--ink); font-weight: 700; text-underline-offset: 3px; }
.rv-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-deep);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

/* Opciones (servicio y profesional) */
.rv-sub { margin-bottom: 10px; color: var(--accent-deep); font-weight: 700; }
.rv-lista { display: grid; gap: 10px; }
.rv-opcion {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 66px;
  padding: 12px 12px 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.rv-opcion-texto { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.rv-opcion-nombre { font-size: 1.04rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.rv-opcion-meta { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: .88rem; font-weight: 600; }
.rv-opcion-meta .icon { width: 1em; height: 1em; color: var(--accent-deep); }
.rv-opcion-ir { color: var(--ink-soft); }
.rv-opcion:hover, .rv-hora:hover, .rv-dia:not(:disabled):hover { border-color: var(--accent); }
.rv-opcion[aria-pressed="true"] { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }

/* Día y hora */
.rv-elegido {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: .94rem;
}
.rv-elegido strong { color: var(--ink); }
.rv-elegido .icon { margin-top: 3px; color: var(--accent-deep); }
.rv-dias-caja { display: flex; align-items: center; gap: 6px; margin-top: 16px; }
.rv-dias-nav {
  display: none;
  flex: none;
  width: 40px; height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
.rv-dias-nav:hover { border-color: var(--accent); }
@media (min-width: 600px) { .rv-dias-nav { display: inline-grid; } }
.rv-dias {
  position: relative;
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 4px 2px 8px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.rv-dias::-webkit-scrollbar { display: none; }
.rv-dia {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 64px;
  min-height: 78px;
  padding: 6px 4px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.15;
  cursor: pointer;
  scroll-snap-align: start;
}
.rv-dia-sem { color: var(--ink-soft); font-size: .78rem; font-weight: 700; text-transform: capitalize; }
.rv-dia-num { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.rv-dia-mes { color: var(--ink-soft); font-size: .74rem; font-weight: 600; }
.rv-dia[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.rv-dia[aria-pressed="true"] span { color: inherit; }
.rv-dia:disabled { opacity: .45; background: transparent; cursor: not-allowed; }
.rv-dia-elegido { margin-top: 14px; font-size: 1.08rem; font-weight: 800; }
.rv-horas { min-height: 140px; }
.rv-horas-titulo {
  margin: 14px 0 8px;
  color: var(--ink-soft);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.rv-horas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.rv-hora {
  min-height: 50px;
  padding: 6px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
}
.rv-hora[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

.rv-cargando { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 36px 0; color: var(--ink-soft); font-weight: 600; }
.rv-spin {
  width: 20px; height: 20px;
  border: 2.5px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: rv-giro .8s linear infinite;
}
@keyframes rv-giro { to { transform: rotate(360deg); } }
.rv-vacio { display: grid; justify-items: center; gap: 12px; padding: 26px 0 8px; color: var(--ink-soft); text-align: center; }
.rv-alerta {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0 4px;
  padding: 12px 14px;
  border: 1px solid #E3B4A6;
  border-radius: 14px;
  background: #FCEDE8;
  color: #7A2914;
  font-weight: 600;
  line-height: 1.45;
}
.rv-alerta .icon { margin-top: 2px; }
.rv-alerta a { color: inherit; font-weight: 800; text-underline-offset: 3px; }

/* Datos */
.rv-resumen { padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.rv-resumen-nombre { font-size: 1.08rem; font-weight: 800; line-height: 1.3; }
.rv-resumen-cuando { display: flex; align-items: center; gap: 8px; margin-top: 4px; color: var(--accent-deep); font-weight: 700; }
.rv-resumen-meta { margin-top: 2px; color: var(--ink-soft); font-size: .92rem; }
.rv-form { display: grid; margin-top: 10px; }
.rv-label { display: block; margin: 12px 0 6px; font-weight: 700; }
.rv-input {
  width: 100%;
  min-height: 54px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.08rem; /* 16 px o más: el iPhone no acerca la pantalla al escribir */
}
.rv-input:focus { border-color: var(--primary); }
.rv-input[aria-invalid="true"] { border-color: #B3261E; }
.rv-cel { display: flex; }
.rv-cel-pre {
  display: grid;
  place-items: center;
  padding: 0 12px;
  border: 1.5px solid var(--line);
  border-right: 0;
  border-radius: 14px 0 0 14px;
  background: var(--bg-alt);
  color: var(--ink-soft);
  font-weight: 700;
}
.rv-cel .rv-input { flex: 1; min-width: 0; border-radius: 0 14px 14px 0; }
/* El país del celular: se ven la bandera y el indicativo (.rv-cel-pre); encima, invisible, el selector del aparato */
.rv-cel-pais { position: relative; flex: none; display: flex; }
.rv-cel-sel {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  font: inherit;
  font-size: 1.08rem; /* 16 px o más: el iPhone no acerca la pantalla */
}
.rv-cel-pais .rv-cel-pre {
  display: flex;
  align-items: center;
  padding: 0 28px 0 12px;
  white-space: nowrap;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 10px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}
.rv-cel-sel:focus + .rv-cel-pre { border-color: var(--primary); }
.rv-cel-sel:focus-visible + .rv-cel-pre { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 14px 0 0 14px; }
.rv-err { margin-top: 6px; color: #B3261E; font-size: .9rem; font-weight: 600; }

/* Freno a robots: campo trampa fuera de la pantalla; casilla de Turnstile, que solo aparece si pide un toque */
.rv-hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.rv-ts { max-width: 100%; overflow: hidden; }
.rv-ts--ver { margin-top: 16px; }

/* Confirmación */
.rv-centro { display: grid; justify-items: center; gap: 10px; text-align: center; }
.rv-badge {
  display: grid;
  place-items: center;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--wa);
  color: #fff;
}
.rv-badge .icon { width: 32px; height: 32px; }
.rv-badge--aviso { background: var(--badge-bg); color: var(--icon); }
.rv-texto { max-width: 42ch; color: var(--ink-soft); font-size: 1.02rem; }
.rv-texto strong { color: var(--ink); }
.rv-falta {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 14px;
  border: 1.5px dashed var(--wa);
  border-radius: 16px;
  background: var(--surface);
}
.rv-datos { margin: 18px 0 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.rv-datos div { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
.rv-datos div:first-child { border-top: 0; }
.rv-datos dt { color: var(--ink-soft); font-size: .9rem; }
.rv-datos dd { margin: 0; font-weight: 700; }
.rv-acciones { display: grid; gap: 10px; margin-top: 18px; }
.rv-body > .rv-fino { margin-top: 16px; }

/* "¿Confirmar la cita?" (reservas.js arma #rv-conf): ventana sobre la hoja con el estilo .modal de styles.css (fondo,
   bordes, sombra, ícono y botones a lo ancho); el título del tamaño del de la hoja y la cita en palabras bien legible */
.rv-conf .modal-title { font-size: 1.75rem; line-height: 1.1; }
.rv-conf-titulo:focus { outline: none; }
.rv-conf-texto { font-size: 1.08rem; line-height: 1.5; text-wrap: pretty; }
.rv-conf-texto strong { color: var(--ink); }
.rv-conf-hora { white-space: nowrap; } /* "3:00 p. m." en un solo renglón */

/* "Ver en Mis Citas" en la confirmación (solo sitios de demostración en *.nayerly.com) */
.rv-demo-btn { border-color: #E9D49A; background: #FFF4D6; color: #4A3B12; }
.rv-demo-btn:hover { border-color: #D9BE6E; background: #FBE7B0; }
