/* =========================================================
   Sistema de diseño — reservas de la pista
   Los colores viven aquí para poder cambiar la marca por comunidad.
   ========================================================= */
:root {
  --navy: #0A1A3C;
  --lime: #CBFA3C;
  --blue: #2F6FED;
  --blue-soft: #E0EEFC;
  --grey: #8C949E;
  --grey-line: #E1E5EC;
  --border: #D9DBE3;
  --stepper-off: #D1D6DE;
  --surface: #F3F4F6;
  --divider: #E6E8ED;
  --available: #2ECC5B;
  --error: #E5484D;
  --error-soft: #FDECEC;
  --error-ink: #B4232A;
  --white: #FFFFFF;
  --page: #EDEFF3;
  --radius-input: 12px;
  --radius-card: 16px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--navy);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
button:disabled { cursor: default; }

/* ---------- Contenedor móvil ---------- */
.app {
  position: relative;
  width: 100%;
  max-width: 390px;
  height: 100dvh;
  background: var(--white);
  /* 'clip' además de 'hidden': el marco nunca debe desplazarse. Con 'hidden'
     a secas, enfocar un campo lo desplaza y la cabecera se va hacia arriba. */
  overflow: hidden;
  overflow: clip;
  display: flex;
  flex-direction: column;
}
@media (min-width: 500px) {
  body { align-items: center; }
  .app { height: min(844px, 100dvh); border-radius: 28px; box-shadow: 0 20px 60px rgba(10, 26, 60, .15); }
}

.screen { display: none; flex: 1; flex-direction: column; min-height: 0; }
.screen.active { display: flex; }
.scroll { flex: 1; overflow-y: auto; min-height: 0; padding-bottom: 24px; }

/* ---------- Splash ---------- */
.splash { background: var(--lime); align-items: center; justify-content: center; }
.splash svg { width: 110px; height: 157px; animation: pop .6s ease-out; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Header ---------- */
.header { height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 20px; flex-shrink: 0; }
.header h1 { font-size: 18px; font-weight: 700; }
.back { font-size: 22px; font-weight: 700; line-height: 1; padding: 4px 0; }

/* ---------- Banner "ahora mismo" ---------- */
.status {
  flex-shrink: 0;
  margin: 0 20px;
  padding: 12px 14px;
  border-radius: var(--radius-input);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
}
.status .dot-live {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: var(--grey);
}
.status.libre .dot-live { background: var(--available); box-shadow: 0 0 0 4px rgba(46, 204, 91, .18); }
.status.ocupada .dot-live { background: var(--error); }
.status strong { font-weight: 700; }

/* ---------- Stepper ---------- */
.stepper { position: relative; height: 90px; flex-shrink: 0; }
.stepper .line { position: absolute; top: 31px; height: 2px; width: 84px; background: var(--grey-line); }
.stepper .line.l1 { left: 95px; }
.stepper .line.l2 { left: 211px; }
.stepper .line.done { background: var(--blue); }
.step { position: absolute; top: 16px; width: 80px; display: flex; flex-direction: column; align-items: center; }
.step.s1 { left: 39px; } .step.s2 { left: 155px; } .step.s3 { left: 271px; }
.step .dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  background: var(--white); border: 1.5px solid var(--stepper-off); color: var(--grey);
}
.step .label { margin-top: 8px; font-size: 11px; font-weight: 500; color: var(--grey); white-space: nowrap; }
.step.active .dot, .step.done .dot { background: var(--blue); border-color: var(--blue); color: var(--white); }
.step.active .label, .step.done .label { font-weight: 700; color: var(--navy); }

/* ---------- Tipografía de contenido ---------- */
.title { font-size: 20px; font-weight: 700; padding: 16px 20px 0; }
.subtitle { font-size: 13px; color: var(--grey); padding: 6px 20px 0; }

/* ---------- Calendario ---------- */
.month-row { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.month-row h3 { font-size: 17px; font-weight: 700; }
.nav { display: flex; gap: 8px; }
.nav button {
  width: 36px; height: 36px; border-radius: 50%; background: var(--surface);
  font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.nav button:disabled { opacity: .35; }
.weekdays, .days { display: grid; grid-template-columns: repeat(7, 50px); padding: 0 20px; }
.weekdays { margin-top: 24px; }
.weekdays span { text-align: center; font-size: 12px; font-weight: 500; color: var(--grey); }
.days { margin-top: 10px; row-gap: 26px; }
.day {
  position: relative; justify-self: center;
  width: 36px; height: 36px; border-radius: 50%;
  font-size: 15px; display: flex; align-items: center; justify-content: center;
  border: 1.5px solid transparent;
}
.day.off { color: #C3C8D0; text-decoration: line-through; text-decoration-thickness: 1.4px; }
.day.today { border-color: var(--blue); }
.day.available::after {
  content: ""; position: absolute; bottom: -8px; left: 11px;
  width: 14px; height: 3px; border-radius: 2px; background: var(--available);
}
.day.selected { background: var(--blue-soft); border-color: var(--blue); font-weight: 700; }

.hint { text-align: center; font-size: 13px; color: var(--grey); padding: 28px 35px 0; line-height: 1.4; }

/* ---------- Píldoras de hora ---------- */
.hours { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 8px; padding: 26px 20px 0; }
.pill {
  height: 40px; border-radius: 20px; background: var(--surface);
  font-size: 14px; font-weight: 500; color: var(--grey);
  border: 1.5px solid transparent;
}
.pill.taken { text-decoration: line-through; opacity: .55; }
.pill.selected { background: var(--blue-soft); border-color: var(--blue); color: var(--navy); font-weight: 700; }
.hours-empty { grid-column: 1 / -1; text-align: center; font-size: 13px; color: var(--grey); padding: 8px 0; }

/* ---------- Formulario ---------- */
.form { padding: 22px 20px 0; display: flex; flex-direction: column; gap: 16px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--grey); margin-bottom: 4px; }
.input, .select {
  width: 100%; height: 52px; padding: 0 16px;
  border: 1.5px solid var(--border); border-radius: var(--radius-input);
  font-family: inherit; font-size: 14px; color: var(--navy); background: var(--white);
  outline: none; transition: border-color .15s;
}
.input::placeholder { color: var(--grey); }
.input:focus, .select:focus { border-color: var(--blue); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='m6 9 6 6 6-6' stroke='%230A1A3C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
.select.placeholder { color: var(--grey); }
.select:disabled { background-color: var(--surface); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field.invalid .input, .field.invalid .select { border-color: var(--error); }
.err { display: none; font-size: 12px; color: var(--error); margin-top: 4px; }
.field.invalid .err { display: block; }
.note { font-size: 12px; color: var(--grey); line-height: 1.4; }
.banner-error {
  display: none; margin: 16px 20px 0; padding: 12px 14px; border-radius: var(--radius-input);
  background: var(--error-soft); color: var(--error-ink); font-size: 13px; line-height: 1.4;
}
.banner-error.show { display: block; }

/* ---------- Footer ---------- */
.footer {
  flex-shrink: 0; height: 96px; border-top: 1px solid var(--divider);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px;
  background: var(--white);
}
/* El texto no debe partirse ni empujar al botón fuera del footer. */
.footer .meta { min-width: 0; }
.footer .meta small { display: block; font-size: 12px; color: var(--grey); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.footer .meta strong { font-size: 19px; font-weight: 700; white-space: nowrap; }
.btn {
  height: 48px; padding: 0 24px; border-radius: 24px;
  font-size: 15px; font-weight: 700; color: var(--navy); background: var(--lime);
  white-space: nowrap; flex-shrink: 0;
  transition: transform .1s, opacity .15s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { background: var(--white); border: 1.5px solid var(--border); color: var(--grey); }
.btn.wide { width: 100%; }
.btn.loading { opacity: .7; }

/* ---------- Confirmación ---------- */
.success { display: flex; flex-direction: column; align-items: center; padding-top: 24px; }
.badge {
  width: 72px; height: 72px; border-radius: 50%; background: var(--lime);
  display: flex; align-items: center; justify-content: center;
  animation: pop .45s ease-out;
}
.badge.neutral { background: var(--surface); }
.success h2 { font-size: 20px; font-weight: 700; margin-top: 20px; text-align: center; padding: 0 24px; }
.success p { font-size: 13px; color: var(--grey); margin-top: 8px; text-align: center; padding: 0 28px; line-height: 1.5; }
.card {
  margin: 22px 20px 0; padding: 16px; border-radius: var(--radius-card); background: var(--white);
  box-shadow: 0 2px 12px rgba(10, 26, 60, .08), 0 0 0 1px rgba(10, 26, 60, .03);
}
.card .name { font-size: 15px; font-weight: 700; }
.card .when { font-size: 13px; color: var(--grey); margin-top: 4px; }
.card hr { border: none; height: 1px; background: var(--divider); margin: 12px 0; }
.card .who { font-size: 13px; font-weight: 500; }
.cancel-box { margin: 20px 20px 0; padding: 16px; border-radius: var(--radius-card); background: var(--surface); }
.cancel-box .top { display: flex; justify-content: space-between; align-items: center; }
.cancel-box .top span { font-size: 12px; font-weight: 500; color: var(--grey); }
.cancel-box .copy { font-size: 13px; font-weight: 700; color: var(--blue); }
.cancel-box .url { font-size: 14px; font-weight: 500; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cancel-box .note { margin-top: 6px; }
.link-btn { display: block; margin: 18px auto 0; font-size: 13px; font-weight: 600; color: var(--blue); }

/* ---------- Pantalla de error / estados vacíos ---------- */
.centro { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.centro .badge { margin-bottom: 20px; }
.centro h2 { font-size: 20px; font-weight: 700; text-align: center; }
.centro p { font-size: 13px; color: var(--grey); margin-top: 8px; text-align: center; line-height: 1.5; max-width: 280px; }
.centro .btn { margin-top: 24px; }

/* ---------- Skeleton ---------- */
@keyframes brillo { from { opacity: .55; } to { opacity: 1; } }
.skeleton {
  background: var(--surface); border-radius: 8px;
  animation: brillo 1s ease-in-out infinite alternate;
}
.skeleton-card { margin: 22px 20px 0; height: 118px; border-radius: var(--radius-card); }
.skeleton-line { height: 14px; margin: 12px 20px 0; }
.skeleton-line.corta { width: 45%; }

/* =========================================================
   Panel del conserje (admin.html)
   Botones grandes, nada de configuración: si le cuesta más que la
   libreta, no lo va a usar.
   ========================================================= */
.app.ancho { max-width: 980px; }
@media (min-width: 500px) {
  .app.ancho { height: min(900px, 100dvh); }
}

.barra-sup { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px; height: 60px; flex-shrink: 0; }
.barra-sup .titulo h1 { font-size: 18px; font-weight: 700; }
.barra-sup .titulo small { display: block; font-size: 12px; color: var(--grey); margin-top: 1px; }
.btn-texto { font-size: 13px; font-weight: 700; color: var(--blue); padding: 8px; }

/* Navegación de fechas y cambio de vista */
.barra-fechas { display: flex; align-items: center; gap: 8px; padding: 0 20px 12px; flex-shrink: 0; }
.barra-fechas .rango { flex: 1; font-size: 15px; font-weight: 700; text-align: center; }
.redondo {
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface); flex-shrink: 0;
  font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.chip-hoy { height: 40px; padding: 0 16px; border-radius: 20px; background: var(--surface); font-size: 13px; font-weight: 700; flex-shrink: 0; }

.tabs { display: flex; gap: 6px; margin: 0 20px 14px; padding: 4px; background: var(--surface); border-radius: 22px; flex-shrink: 0; }
.tabs button { flex: 1; height: 36px; border-radius: 18px; font-size: 14px; font-weight: 600; color: var(--grey); }
.tabs button.on { background: var(--white); color: var(--navy); font-weight: 700; box-shadow: 0 1px 4px rgba(10, 26, 60, .12); }

/* Vista día: una fila por hora */
.dia { padding: 0 20px; display: flex; flex-direction: column; gap: 8px; }
.franja {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  min-height: 60px; padding: 10px 14px; border-radius: var(--radius-input);
  border: 1.5px solid var(--grey-line); background: var(--white);
}
.franja .hora { font-size: 15px; font-weight: 700; width: 52px; flex-shrink: 0; }
.franja .cuerpo { flex: 1; min-width: 0; }
.franja .cuerpo .que { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.franja .cuerpo .quien { display: block; font-size: 12px; color: var(--grey); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.franja .mas { font-size: 22px; color: var(--grey); font-weight: 400; }
.franja.libre { border-style: dashed; }
.franja.libre .que { color: var(--grey); font-weight: 500; }
.franja.reservada { background: var(--blue-soft); border-color: transparent; border-left: 4px solid var(--blue); }
.franja.bloqueada {
  border-color: transparent; color: var(--navy);
  background: repeating-linear-gradient(135deg, #ECEEF2, #ECEEF2 7px, #E2E5EB 7px, #E2E5EB 14px);
}
.franja.pasada { opacity: .5; }

.etiqueta { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 2px 6px; border-radius: 6px; background: rgba(10, 26, 60, .08); margin-left: 6px; vertical-align: 1px; }

/* Vista semana: horas en filas, días en columnas */
.semana-scroll { overflow-x: auto; padding: 0 20px 4px; }
.semana { width: 100%; min-width: 620px; border-collapse: collapse; table-layout: fixed; }
.semana th, .semana td { border: 1px solid var(--divider); padding: 0; }
.semana thead th { font-size: 12px; font-weight: 700; padding: 6px 2px; background: var(--surface); text-transform: capitalize; }
.semana thead th.hoy { background: var(--blue-soft); color: var(--blue); }
.semana th.col-hora, .semana td.col-hora { width: 56px; font-size: 12px; font-weight: 700; color: var(--grey); text-align: center; background: var(--surface); }
.celda { width: 100%; height: 46px; padding: 3px 4px; font-size: 11px; line-height: 1.25; text-align: left; overflow: hidden; display: block; }
.celda .n { font-weight: 700; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.celda .v { color: var(--grey); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.celda.reservada { background: var(--blue-soft); box-shadow: inset 3px 0 0 var(--blue); }
.celda.bloqueada { background: repeating-linear-gradient(135deg, #ECEEF2, #ECEEF2 6px, #E2E5EB 6px, #E2E5EB 12px); }
.celda.pasada { opacity: .5; }

/* Hoja de acciones */
.velo { position: absolute; inset: 0; background: rgba(10, 26, 60, .35); display: none; z-index: 10; }
.velo.abierto { display: block; }
.hoja {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 11;
  background: var(--white); border-radius: 20px 20px 0 0; padding: 8px 20px 24px;
  max-height: 88%; overflow-y: auto; transform: translateY(100%); transition: transform .22s ease-out;
}
.hoja.abierta { transform: translateY(0); }
.hoja .asa { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 6px auto 14px; }
.hoja h3 { font-size: 18px; font-weight: 700; }
.hoja .cuando { font-size: 13px; color: var(--grey); margin-top: 4px; }
.hoja .acciones { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.accion {
  width: 100%; min-height: 52px; border-radius: var(--radius-input); padding: 0 16px;
  border: 1.5px solid var(--border); background: var(--white);
  font-size: 15px; font-weight: 600; text-align: left;
}
.accion.principal { background: var(--lime); border-color: var(--lime); font-weight: 700; }
.accion.peligro { color: var(--error-ink); border-color: #F3C9CB; background: var(--error-soft); }
.accion.plana { border: none; text-align: center; color: var(--grey); min-height: 44px; font-weight: 600; }
.hoja .form { padding: 18px 0 0; }
.hoja .banner-error { margin: 14px 0 0; }

/* Motivos de bloqueo */
.motivos { display: flex; flex-wrap: wrap; gap: 8px; }
.motivo { height: 36px; padding: 0 14px; border-radius: 18px; background: var(--surface); font-size: 13px; font-weight: 600; color: var(--grey); }
.motivo.on { background: var(--blue-soft); color: var(--navy); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--blue); }

.vacio { text-align: center; font-size: 13px; color: var(--grey); padding: 40px 24px; }
.solo-impresion { display: none; }

/* =========================================================
   Imprimir la semana para colgarla en la garita
   ========================================================= */
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: var(--white); display: block; }
  .app, .app.ancho { max-width: none; width: auto; height: auto; box-shadow: none; border-radius: 0; overflow: visible; display: block; }
  .barra-sup, .barra-fechas, .tabs, .footer, .velo, .hoja, #screen-login, .btn, .scroll { all: unset; }
  .scroll { display: block; }
  #screen-login, .barra-sup, .barra-fechas, .tabs, .footer, .velo, .hoja { display: none !important; }
  .solo-impresion { display: block; margin-bottom: 10px; }
  .solo-impresion h2 { font-size: 16pt; font-weight: 700; }
  .solo-impresion p { font-size: 10pt; color: #000; margin-top: 2px; }
  .semana-scroll { overflow: visible; padding: 0; }
  .semana { min-width: 0; }
  .semana th, .semana td { border: 1px solid #999; }
  .semana thead th { background: #EEE !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .celda { height: auto; min-height: 34px; font-size: 9pt; }
  .celda .v { color: #333; }  /* el gris claro no se ve en papel */
  .celda.reservada, .celda.bloqueada, .semana td.col-hora { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .celda.pasada { opacity: 1; }
}
