/* Controles propios (desplegable y hora). Solo tokens de tokens.css. */

/* El nativo sigue en el DOM pero no se ve ni se enfoca. */
.ctl-nativo { display: none !important; }

.ctl-boton {
  font: inherit;
  font-size: 16px; /* evita el zoom en iOS */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--esp-2);
  width: 100%;
  min-height: 48px;
  padding: 0 var(--esp-3);
  color: var(--texto);
  background: var(--vidrio-tinte);
  border: 1px solid var(--vidrio-borde-item);
  border-radius: var(--radio-control);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.ctl-boton:hover:not(:disabled) { border-color: var(--acento); }
.ctl-boton:focus-visible { outline: 2px solid var(--acento); outline-offset: 1px; }
.ctl-boton[aria-expanded="true"] { border-color: var(--acento); }
.ctl-boton:disabled { opacity: .55; cursor: not-allowed; }
.ctl-boton svg { flex: none; color: var(--texto-suave); transition: transform .15s; }
.ctl-boton[aria-expanded="true"] svg { color: var(--acento); }
.ctl-select[aria-expanded="true"] svg { transform: rotate(180deg); }
.ctl-texto { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctl-time .ctl-texto { font-variant-numeric: lining-nums tabular-nums; }
.ctl-vacio { color: var(--texto-suave); }

/* Popover */
.ctl-pop {
  position: fixed;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  color: var(--texto);
  font-family: var(--fuente-cuerpo);
  font-size: 16px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .14s ease, transform .14s ease;
}
.ctl-pop.ctl-arriba { transform: translateY(4px); }
.ctl-pop.ctl-visible { opacity: 1; transform: none; }

/* Lista (select) */
.ctl-lista {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: var(--esp-1);
  outline: none;
}
.ctl-op {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--esp-3);
  border-radius: var(--radio-s);
  cursor: pointer;
  line-height: 1.3;
}
.ctl-op.ctl-activa { background: var(--vidrio-tinte-fuerte); }
.ctl-op.ctl-sel {
  background: var(--acento);
  color: var(--acento-texto);
  font-weight: 600;
}
.ctl-op.ctl-des { color: var(--texto-suave); opacity: .5; cursor: not-allowed; }
.ctl-grupo-titulo {
  padding: var(--esp-3) var(--esp-3) var(--esp-1);
  color: var(--texto-suave);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.ctl-lista:focus-visible .ctl-op.ctl-activa:not(.ctl-sel) { outline: 2px solid var(--acento); outline-offset: -2px; }

/* Hora */
.ctl-pop-time { padding: var(--esp-3); gap: var(--esp-3); }
.ctl-columnas {
  --ctl-item: 44px;
  --ctl-alto: 220px;
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: var(--esp-2);
  height: var(--ctl-alto);
}
.ctl-banda {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% - var(--ctl-item) / 2);
  height: var(--ctl-item);
  border-radius: var(--radio-s);
  background: var(--vidrio-tinte-fuerte);
  border: 1px solid var(--acento);
  pointer-events: none;
}
.ctl-columna {
  position: relative;
  flex: 1;
  max-width: 96px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  padding-block: calc((var(--ctl-alto) - var(--ctl-item)) / 2);
  scrollbar-width: none;
  outline: none;
  border-radius: var(--radio-s);
}
.ctl-columna::-webkit-scrollbar { display: none; }
.ctl-columna:focus-visible { outline: 2px solid var(--acento); outline-offset: 1px; }
.ctl-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--ctl-item);
  scroll-snap-align: center;
  font-family: var(--fuente-cuerpo);
  font-size: 1.3rem;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--texto-suave);
  cursor: pointer;
  user-select: none;
}
.ctl-item.ctl-sel { color: var(--texto); font-weight: 700; }
.ctl-dospuntos {
  position: relative;
  display: flex;
  align-items: center;
  font-family: var(--fuente-cuerpo);
  font-size: 1.3rem;
  color: var(--texto-suave);
}
.ctl-listo {
  font: inherit;
  font-weight: 600;
  min-height: 48px;
  color: var(--acento-texto);
  background: var(--acento);
  border: 0;
  border-radius: var(--radio-s);
  cursor: pointer;
}
.ctl-listo:focus-visible { outline: 2px solid var(--texto); outline-offset: 2px; }

/* Variantes por módulo: el botón imita el aspecto de los campos de cada módulo. */
.mod-descanso .time-field .ctl-boton { height: 52px; margin-top: 6px; border-radius: var(--radio-control); font-size: 1.1rem; padding: 0 14px; }
.mod-descanso .anchor-display .ctl-boton {
  width: auto;
  min-height: 0;
  padding: 0;
  gap: var(--esp-3);
  border: 0;
  background: transparent;
  font-family: var(--fuente-titulo);
  font-size: 1.8rem;
}
.mod-descanso .anchor-display .ctl-boton svg { width: 26px; height: 26px; }
.mod-alimentacion .ctl-boton { min-height: 44px; border-width: 1.5px; border-radius: var(--radio-control); padding: 8px 10px; }
.mod-entorno .ctl-boton { min-height: 0; border-width: 1.5px; border-radius: var(--radio-control); padding: 8px 10px; }
.mod-contribucion .ctl-boton { border-radius: var(--radio-control); padding: var(--esp-3) var(--esp-4); min-height: 0; margin-bottom: var(--esp-4); }
/* Pastilla de área de planificación: hereda las clases del nativo (area, set). */
.mod-planificacion .ctl-boton.area {
  width: auto;
  max-width: 150px;
  min-height: 0;
  flex-shrink: 0;
  margin-bottom: 5px;
  padding: 5px 8px 5px 10px;
  gap: 6px;
  border-width: 1.5px;
  border-radius: 20px;
  color: var(--texto-suave);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .6px;
}
.mod-planificacion .ctl-boton.area svg { width: 14px; height: 14px; color: var(--oro); }
.mod-planificacion .ctl-boton.area.set { border-color: var(--oro); color: var(--pl-oro-texto); background-color: var(--pl-oro-suave); }

/* Calendario */
.ctl-pop-date { padding: var(--esp-3); gap: var(--esp-2); overflow-y: auto; }
.ctl-cal-cab { display: flex; align-items: center; justify-content: space-between; gap: var(--esp-2); }
.ctl-cal-titulo {
  flex: 1;
  text-align: center;
  font-family: var(--fuente-titulo);
  font-size: 1.25rem;
  font-weight: 600;
  text-transform: capitalize;
}
.ctl-cal-nav, .ctl-cal-celda, .ctl-cal-hoy {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ctl-cal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radio-s);
  color: var(--texto-suave);
}
.ctl-cal-nav:hover:not(:disabled) { background: var(--vidrio-tinte-fuerte); color: var(--texto); }
.ctl-cal-nav:disabled, .ctl-cal-celda:disabled { opacity: .35; cursor: not-allowed; }
.ctl-cal-semana, .ctl-cal-fila { display: grid; grid-template-columns: repeat(7, 1fr); }
.ctl-cal-dia-nombre {
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--texto-suave);
  padding: var(--esp-1) 0;
}
.ctl-cal-rejilla { display: flex; flex-direction: column; gap: 2px; }
.ctl-cal-celda {
  height: 40px;
  min-width: 0;
  padding: 0;
  border-radius: var(--radio-s);
  font-size: .95rem;
  font-variant-numeric: lining-nums tabular-nums;
}
.ctl-cal-celda:hover:not(:disabled):not(.ctl-sel) { background: var(--vidrio-tinte-fuerte); }
.ctl-cal-otro { color: var(--texto-suave); opacity: .6; }
.ctl-cal-hoy-marca { box-shadow: inset 0 0 0 1.5px var(--acento); font-weight: 600; }
.ctl-cal-celda.ctl-sel { background: var(--acento); color: var(--acento-texto); font-weight: 700; opacity: 1; }
.ctl-cal-celda:focus-visible { outline: 2px solid var(--texto); outline-offset: -2px; }
.ctl-cal-nav:focus-visible, .ctl-cal-hoy:focus-visible { outline: 2px solid var(--acento); outline-offset: 1px; }
.ctl-cal-pie { display: flex; justify-content: center; }
.ctl-cal-hoy {
  min-height: 40px;
  padding: 0 var(--esp-4);
  border-radius: var(--radio-s);
  font-weight: 600;
  color: var(--texto);
}
.ctl-cal-hoy:hover:not(:disabled) { background: var(--vidrio-tinte-fuerte); }
.ctl-cal-hoy:disabled { opacity: .35; cursor: not-allowed; }

/* Móvil: hoja inferior con fondo oscurecido */
.ctl-fondo {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--navy);
  opacity: 0;
  transition: opacity .2s ease;
}
.ctl-fondo.ctl-visible { opacity: .6; }
.ctl-pop.ctl-hoja {
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  width: auto;
  max-height: 70vh;
  border-radius: var(--radio-contenedor) var(--radio-contenedor) 0 0;
  border-bottom: 0;
  padding-bottom: max(var(--esp-3), env(safe-area-inset-bottom));
  transform: translateY(100%);
  opacity: 1;
  transition: transform .22s ease;
}
.ctl-pop.ctl-hoja.ctl-visible { transform: none; }
.ctl-pop.ctl-hoja::before {
  content: "";
  flex: none;
  align-self: center;
  width: 40px;
  height: 4px;
  margin: var(--esp-2) 0 var(--esp-1);
  border-radius: 2px;
  background: var(--vidrio-borde-item);
}

@media (prefers-reduced-motion: reduce) {
  .ctl-pop, .ctl-fondo, .ctl-boton, .ctl-boton svg { transition: none; }
  .ctl-lista { scroll-behavior: auto; }
}
