/*
  Experimento LOCAL:
  compactar la reserva móvil sin modificar funcionalidad.
*/

@media (max-width: 760px) {
  body > .hero {
    padding: 11px 16px 10px;
  }

  .hero .eyebrow {
    display: none;
  }

  .hero h1 {
    margin: 0 0 2px;
    font-size: 24px;
    line-height: 1.05;
  }

  .hero p:not(.eyebrow) {
    margin: 0;
    font-size: 12px;
    line-height: 1.2;
  }

  .layout {
    padding-top: 8px;
  }

  .app-calendar-card {
    padding: 12px;
  }

  /* La flecha actual no es un control interactivo. */
  .app-title-back-icon {
    display: none;
  }

  .app-screen-title {
    gap: 7px;
    margin-bottom: 3px;
  }

  .app-screen-title strong {
    font-size: 16px;
    line-height: 1.2;
  }

  /* Integrar calendario en la tarjeta principal. */
  .visual-calendar {
    margin: 7px 0 9px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  /* Fecha seleccionada ya queda clara en el propio calendario. */
  .calendar-label-row {
    display: none;
  }

  .calendar-topbar {
    grid-template-columns: 40px 1fr 40px;
    gap: 5px;
    margin-bottom: 5px;
  }

  .calendar-nav {
    width: 40px;
    min-width: 40px;
    min-height: 40px;
  }

  .calendar-month {
    font-size: 17px;
  }

  .calendar-weekdays {
    margin-bottom: 3px;
  }

  .calendar-weekdays,
  .calendar-grid {
    gap: 3px;
  }

  .calendar-weekdays span {
    font-size: 11px;
  }

  /* Compacto, pero manteniendo un área táctil razonable. */
  .calendar-day {
    min-width: 40px;
    max-width: 40px;
    min-height: 40px;
    font-size: 13px;
  }

  .calendar-help {
    margin: 7px 2px 0;
    font-size: 11px;
    line-height: 1.25;
  }

  .availability-head {
    margin: 8px 0 5px;
  }

  .availability-head h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.15;
  }

  /* El plazo de 5 días ya se explica arriba. */
  .availability-head p {
    display: none;
  }

  .slots-legend {
    margin: 0 0 7px;
    gap: 4px 8px;
    font-size: 11px;
  }

  .slots-legend-icon {
    width: 13px;
    height: 13px;
  }

  .slot {
    min-height: 72px;
    padding: 10px 12px;
  }

  .slot-time {
    font-size: 18px;
  }

  .slot-cancel {
    min-width: 96px;
    min-height: 40px;
  }
}

@media (prefers-color-scheme: dark) and (max-width: 760px) {
  .visual-calendar {
    background: transparent;
    border-color: transparent;
  }
}

/* =========================================================
   LOCAL V2 · Selector directo de los 6 días reservables
   ========================================================= */

@media (max-width: 760px) {
  .visual-calendar::before {
    content: "Elige el día";
    display: block;
    margin: 4px 0 8px;
    font-size: 13px;
    font-weight: 700;
  }

  .calendar-topbar,
  .calendar-weekdays,
  .calendar-help {
    display: none;
  }

  .calendar-grid.compact-date-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    margin: 0;
  }

  .compact-date-button {
    appearance: none;
    min-width: 0;
    min-height: 58px;
    padding: 7px 2px 6px;
    border: 1px solid #334155;
    border-radius: 14px;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
  }

  .compact-date-weekday {
    font-size: 10px;
    line-height: 1;
    text-transform: lowercase;
    opacity: .7;
  }

  .compact-date-day {
    font-size: 18px;
    line-height: 1;
    font-weight: 800;
  }

  .compact-date-button.is-today:not(.is-selected) {
    border-color: #64748b;
  }

  .compact-date-button.is-selected {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
  }

  .compact-date-button.is-selected .compact-date-weekday {
    opacity: .9;
  }

  .availability-head {
    margin-top: 12px;
  }
}

@media (prefers-color-scheme: light) and (max-width: 760px) {
  .compact-date-button {
    background: #fff;
    border-color: #d7e0ea;
    color: #0f172a;
  }

  .compact-date-button.is-selected {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
  }
}

/* LOCAL V3 · Ocultar turnos pasados */
@media (max-width: 760px) {
  .slot.is-past {
    display: none;
  }
}

/* LOCAL V4 · Accessible mobile polish */
@media (max-width: 760px) {

  /* Día: lectura rápida y mejor visibilidad */
  .compact-date-button {
    min-height: 64px;
    padding: 7px 2px 6px;
    gap: 4px;
  }

  .compact-date-weekday {
    font-size: 12px;
    line-height: 1;
    font-weight: 750;
    opacity: .82;
  }

  .compact-date-day {
    font-size: 24px;
    line-height: .95;
    font-weight: 900;
  }

  .compact-date-button.is-selected .compact-date-weekday {
    opacity: 1;
  }

  /* Reserva ocupada: conservar toda la información con menos altura */
  .slot.is-booked {
    gap: 8px;
    padding: 12px 14px;
  }

  .slot.is-booked .slot-info {
    gap: 5px;
  }

  .slot.is-booked .slot-time {
    font-size: 23px;
    line-height: 1.05;
  }

  .slot.is-booked .slot-status {
    margin-top: 1px;
    padding: 5px 10px;
    font-size: 13px;
  }

  .slot.is-booked .slot-home {
    padding-left: 10px;
    font-size: 16px;
    line-height: 1.2;
  }

  .slot.is-booked .slot-cancel {
    min-height: 42px;
    margin-top: 0;
  }

  /* Menos aire entre reservas, privacidad y pie */
  .layout {
    gap: 12px;
    padding-bottom: 7px;
  }

  .compact-privacy {
    padding: 10px 14px;
  }

  .compact-privacy h2 {
    margin-bottom: 3px;
  }

  .compact-privacy p {
    line-height: 1.3;
  }

  .app-footer {
    gap: 5px;
    padding-bottom: 12px;
    line-height: 1.25;
  }
}

/* LOCAL V5 · Theme switch */

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

/* Selector compacto junto al título */
.theme-switch {
  margin-left: auto;
  display: inline-grid;
  grid-template-columns: repeat(3, auto);
  gap: 2px;
  padding: 2px;
  border: 1px solid #334155;
  border-radius: 999px;
  background: rgba(15, 23, 42, .06);
  flex: 0 0 auto;
}

.theme-switch-button {
  width: auto;
  min-width: 0;
  min-height: 28px;
  padding: 0 7px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  background-image: none;
  box-shadow: none;
  color: #64748b;
  font-size: 10px;
  line-height: 1;
  font-weight: 850;
}

.theme-switch-button:hover {
  background: rgba(37, 99, 235, .08);
  background-image: none;
  box-shadow: none;
}

.theme-switch-button.is-active {
  background: #2563eb;
  background-image: none;
  color: #fff;
  box-shadow: none;
}

/* ----------------------------------------------------------
   CLARO forzado aunque el teléfono/sistema esté en oscuro
   ---------------------------------------------------------- */

html[data-theme="light"] body {
  background: #f8fafc;
  color: #0f172a;
}

html[data-theme="light"] .hero {
  background: #fff;
  border-bottom-color: #e2e8f0;
  color: #0f172a;
}

html[data-theme="light"] .hero p {
  color: #475569;
}

html[data-theme="light"] .card {
  background: #fff;
  border-color: #e2e8f0;
  color: #0f172a;
}

html[data-theme="light"] .app-calendar-card {
  background: #fff;
}

html[data-theme="light"] .compact-date-button {
  background: #fff;
  border-color: #d7e0ea;
  color: #0f172a;
}

html[data-theme="light"] .compact-date-button.is-selected {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

html[data-theme="light"] .slot.is-free {
  background: #f4fbf8;
  border-color: #c9e5dc;
}

html[data-theme="light"] .slot.is-selected {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #0f172a;
}

html[data-theme="light"] .slot.is-booked {
  background: #fff7ed;
  border-color: #e7a56a;
  color: #0f172a;
}

html[data-theme="light"] .slot.is-booked .slot-home {
  color: #7c3f12;
  border-left-color: #c47b3a;
}

html[data-theme="light"] .compact-privacy {
  background: #fff;
  color: #64748b;
}

html[data-theme="light"] .theme-switch {
  background: #f1f5f9;
  border-color: #d7e0ea;
}

html[data-theme="light"] .theme-switch-button {
  color: #475569;
}

html[data-theme="light"] .theme-switch-button.is-active {
  color: #fff;
}

/* ----------------------------------------------------------
   OSCURO forzado aunque el teléfono/sistema esté en claro
   ---------------------------------------------------------- */

html[data-theme="dark"] body {
  background: #0b1220;
  color: #f1f5f9;
}

html[data-theme="dark"] .hero {
  background: #0f172a;
  border-bottom-color: #1e293b;
  color: #f1f5f9;
}

html[data-theme="dark"] .hero p {
  color: #cbd5e1;
}

html[data-theme="dark"] .card {
  background: #111827;
  border-color: #334155;
  color: #f1f5f9;
}

html[data-theme="dark"] .app-calendar-card {
  background: #111827;
}

html[data-theme="dark"] .compact-date-button {
  background: #111827;
  border-color: #334155;
  color: #f1f5f9;
}

html[data-theme="dark"] .compact-date-button.is-selected {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

html[data-theme="dark"] .slot.is-free {
  background: #10251f;
  border-color: #28594a;
}

html[data-theme="dark"] .slot.is-selected {
  background: #1e376d;
  border-color: #3b82f6;
  color: #fff;
}

html[data-theme="dark"] .slot.is-booked {
  background: #2a1d10;
  border-color: #925d28;
  color: #fff;
}

html[data-theme="dark"] .slot.is-booked .slot-home {
  color: #ffd7a8;
  border-left-color: #b77942;
}

html[data-theme="dark"] .compact-privacy {
  background: #111827;
  color: #94a3b8;
}

html[data-theme="dark"] .theme-switch {
  background: #0b1220;
  border-color: #334155;
}

html[data-theme="dark"] .theme-switch-button {
  color: #94a3b8;
}

html[data-theme="dark"] .theme-switch-button.is-active {
  color: #fff;
}

@media (max-width: 390px) {
  .theme-switch-button {
    padding-inline: 5px;
    font-size: 9px;
  }
}

/* LOCAL V6 · Hero theme switch */

.hero-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hero-title-row h1 {
  margin: 0;
}

.hero-theme-switch {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 4px;
  padding: 3px;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  flex: 0 0 auto;
}

.hero-theme-switch .theme-switch-button {
  width: auto;
  min-width: 0;
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  background-image: none;
  box-shadow: none;
  color: rgba(255,255,255,.82);
  font-size: 11px;
  line-height: 1;
  font-weight: 850;
  white-space: nowrap;
}

.hero-theme-switch .theme-switch-button:hover {
  background: rgba(255,255,255,.10);
  background-image: none;
  box-shadow: none;
}

.hero-theme-switch .theme-switch-button.is-active {
  background: #2563eb;
  background-image: none;
  color: #fff;
  box-shadow: none;
}

@media (max-width: 760px) {
  .hero-title-row {
    align-items: flex-start;
    gap: 8px;
  }

  .hero-theme-switch {
    margin-top: 1px;
  }

  .hero-theme-switch .theme-switch-button {
    min-height: 28px;
    padding: 0 8px;
    font-size: 10px;
  }
}

/* En la tarjeta interior ya no hace falta el selector */
.app-screen-title .theme-switch,
.theme-switch:not(.hero-theme-switch) {
  display: none !important;
}

/* Claro forzado */
html[data-theme="light"] .hero-theme-switch {
  background: #f1f5f9;
  border-color: #d7e0ea;
}

html[data-theme="light"] .hero-theme-switch .theme-switch-button {
  color: #475569;
}

html[data-theme="light"] .hero-theme-switch .theme-switch-button:hover {
  background: rgba(37, 99, 235, .08);
}

html[data-theme="light"] .hero-theme-switch .theme-switch-button.is-active {
  color: #fff;
}

/* Oscuro forzado */
html[data-theme="dark"] .hero-theme-switch {
  background: rgba(255,255,255,.06);
  border-color: #334155;
}

html[data-theme="dark"] .hero-theme-switch .theme-switch-button {
  color: #cbd5e1;
}

html[data-theme="dark"] .hero-theme-switch .theme-switch-button.is-active {
  color: #fff;
}

/* LOCAL V7 · Visible light theme state */

/* En claro, el selector debe seguir teniendo contraste suficiente */
html[data-theme="light"] .hero-theme-switch {
  background: #eef2f7;
  border-color: #cbd5e1;
}

html[data-theme="light"] .hero-theme-switch .theme-switch-button {
  color: #334155;
}

html[data-theme="light"] .hero-theme-switch .theme-switch-button.is-active {
  background: #2563eb;
  color: #ffffff;
}

/* Auto activo también debe reconocerse claramente */
html:not([data-theme]) .hero-theme-switch .theme-switch-button.is-active {
  background: #2563eb;
  color: #ffffff;
}

/* LOCAL V8 · High contrast light theme */

/*
  El modo Claro explícito debe prevalecer incluso cuando
  el sistema operativo esté configurado en oscuro.
*/

html[data-theme="light"] {
  --text: #0f172a;
  --muted: #475569;
  --line: #cbd5e1;
  color-scheme: light;
}

/* Texto general */
html[data-theme="light"] body,
html[data-theme="light"] .card,
html[data-theme="light"] .app-calendar-card {
  color: #0f172a;
}

/* Hero */
html[data-theme="light"] .hero h1,
html[data-theme="light"] .hero-title-row h1 {
  color: #0f172a;
}

html[data-theme="light"] .hero p,
html[data-theme="light"] .hero p:not(.eyebrow) {
  color: #475569;
  opacity: 1;
}

/* Cabecera de pista */
html[data-theme="light"] .app-screen-title,
html[data-theme="light"] .app-screen-title strong {
  color: #0f172a;
}

html[data-theme="light"] .court-icon.ui-racket-icon {
  filter: none;
}

/* Selector de fecha */
html[data-theme="light"] .visual-calendar::before,
html[data-theme="light"] .calendar-month,
html[data-theme="light"] .compact-date-weekday,
html[data-theme="light"] .compact-date-day {
  color: #0f172a;
}

html[data-theme="light"] .compact-date-weekday {
  opacity: .78;
}

html[data-theme="light"] .compact-date-button.is-selected,
html[data-theme="light"] .compact-date-button.is-selected .compact-date-weekday,
html[data-theme="light"] .compact-date-button.is-selected .compact-date-day {
  color: #ffffff;
  opacity: 1;
}

/* Títulos */
html[data-theme="light"] .availability-head h2,
html[data-theme="light"] h2 {
  color: #0f172a;
}

/* Leyenda: colores sólidos y accesibles */
html[data-theme="light"] .slots-legend {
  color: #0f172a;
}

html[data-theme="light"] .slots-legend-item--free {
  color: #166534;
  background: #dcfce7;
  border-color: #86efac;
}

html[data-theme="light"] .slots-legend-item--selected {
  color: #1e40af;
  background: #dbeafe;
  border-color: #93c5fd;
}

html[data-theme="light"] .slots-legend-item--reserved {
  color: #9a3412;
  background: #ffedd5;
  border-color: #fdba74;
}

/* Horas */
html[data-theme="light"] .slot-time {
  color: #0f172a;
}

/* Estado Libre */
html[data-theme="light"] .slot.is-free .slot-status,
html[data-theme="light"] .slot-status--free {
  color: #166534;
  background: #dcfce7;
}

/* Estado Seleccionado */
html[data-theme="light"] .slot.is-selected .slot-status,
html[data-theme="light"] .slot-status--selected {
  color: #1e40af;
  background: #dbeafe;
}

/* Estado Reservado */
html[data-theme="light"] .slot.is-booked .slot-status,
html[data-theme="light"] .slot-status--reserved {
  color: #9a3412;
  background: #ffedd5;
}

html[data-theme="light"] .slot.is-booked .slot-home {
  color: #78350f;
}

/* Botones principales */
html[data-theme="light"] .slot-cancel:not(.button-danger),
html[data-theme="light"] .button-primary {
  color: #ffffff;
}

/* Botón de cancelar en tarjeta reservada */
html[data-theme="light"] .slot.is-booked .slot-cancel {
  color: #78350f;
  background: #ffffff;
  border-color: #d6a267;
}

html[data-theme="light"] .slot.is-booked .slot-cancel:hover {
  color: #451a03;
  background: #fff7ed;
}

/* Privacidad */
html[data-theme="light"] .compact-privacy,
html[data-theme="light"] .privacy {
  color: #475569;
}

html[data-theme="light"] .compact-privacy h2,
html[data-theme="light"] .privacy h2 {
  color: #334155;
}

html[data-theme="light"] .compact-privacy p,
html[data-theme="light"] .privacy p {
  color: #475569;
}

/* Pie */
html[data-theme="light"] .app-footer,
html[data-theme="light"] .hidden-admin-trigger {
  color: #64748b;
}

html[data-theme="light"] .admin-link,
html[data-theme="light"] .pwa-install-button {
  color: #475569;
}

html[data-theme="light"] .admin-link:hover,
html[data-theme="light"] .pwa-install-button:hover {
  color: #0f172a;
}

/* Versión */
html[data-theme="light"] #app-version {
  color: #64748b !important;
  opacity: .85 !important;
}

/* Selector de tema */
html[data-theme="light"] .hero-theme-switch .theme-switch-button {
  color: #334155;
}

html[data-theme="light"] .hero-theme-switch .theme-switch-button.is-active {
  color: #ffffff;
}
