/* Piezas comunes (comun/ui.js): modales, campos de fecha y hora, y el
 * selector de cuenta. Solo tokens de tokens.css, asi que funcionan de dia y
 * de noche sin reglas aparte. Prefijo `tf-` para no chocar con las hojas de
 * cada frontal. */

/* ============================================================ modal */
.tf-modal {
  border: 0; padding: 0;
  border-radius: 16px;
  width: min(30rem, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  background: var(--bg-card); color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
  font-family: var(--font-body);
}
.tf-modal::backdrop { background: rgba(10, 20, 30, .55); backdrop-filter: blur(2px); }
.tf-modal[open] { animation: tf-entra .16s ease-out; }
@keyframes tf-entra { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .tf-modal[open] { animation: none; } }

.tf-modal-form { display: flex; flex-direction: column; padding: 22px 22px 18px; gap: 4px; }
.tf-modal-titulo {
  font-family: var(--font-display); font-weight: 600; font-size: 19px;
  margin: 0 0 6px; line-height: 1.3;
}
.tf-modal-texto { margin: 0 0 8px; font-size: 15px; line-height: 1.5; color: var(--ink-soft); white-space: pre-line; }
.tf-modal-error {
  margin: 8px 0 0; padding: 8px 10px; border-radius: 8px;
  font-size: 14px; color: var(--arcilla-texto);
  background: var(--bg-panel); border-left: 3px solid var(--arcilla);
}
.tf-modal-botones { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.tf-campo { margin-top: 8px; }
.tf-campo label { display: block; font-size: 13px; color: var(--ink-soft); margin: 0 0 5px; }
.tf-campo input, .tf-campo select {
  width: 100%; box-sizing: border-box;
  font: inherit; font-size: 16px; padding: 10px 12px;
  border: 1px solid var(--line-input); border-radius: 10px;
  background: var(--bg-card); color: var(--ink);
}
.tf-campo input:focus, .tf-campo select:focus { outline: 2px solid var(--azulejo); outline-offset: 1px; }
.tf-campo-ayuda { margin: 5px 0 0; font-size: 12.5px; color: var(--ink-soft); line-height: 1.4; }
/* F5: casillas en el modal. La casilla va delante del texto y toda la fila
 * se puede pulsar (dedo en el movil). */
.tf-casilla label, .tf-casilla-op {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 15px; color: var(--ink); margin: 0; padding: 8px 0; cursor: pointer;
}
.tf-campo .tf-casilla-op, .tf-campo.tf-casilla label { display: flex; color: var(--ink); font-size: 15px; margin: 0; }
.tf-casilla input, .tf-casilla-op input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--azulejo); }
.tf-casilla-op small { display: block; font-size: 12.5px; color: var(--ink-soft); }
.tf-casillas { border: 0; padding: 0; margin: 8px 0 0; }
.tf-casillas legend { font-size: 13px; color: var(--ink-soft); padding: 0; margin-bottom: 2px; }

.tf-btn {
  font: inherit; font-size: 15px; font-weight: 600;
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; min-height: 44px;
}
.tf-btn:focus-visible { outline: 2px solid var(--azulejo); outline-offset: 2px; }
.tf-btn-primario { background: var(--azulejo); color: var(--sobre-azulejo); }
.tf-btn-primario:hover { background: var(--azulejo-deep); }
.tf-btn-peligro { background: var(--arcilla-texto); color: var(--sobre-arcilla); }
.tf-btn-secundario { background: transparent; color: var(--ink); border-color: var(--line-input); }
.tf-btn-secundario:hover { background: var(--bg-panel); }

/* ================================================== fecha y hora */
.tf-fecha-envoltorio { position: relative; display: flex; align-items: stretch; gap: 6px; }
.tf-fecha-envoltorio > input { flex: 1 1 auto; min-width: 0; }
.tf-fecha-boton {
  flex: 0 0 auto; width: 44px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-input); background: var(--bg-panel); font-size: 18px; line-height: 1;
}
.tf-fecha-boton:focus-visible { outline: 2px solid var(--azulejo); outline-offset: 1px; }
input.tf-fecha, input.tf-hora { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
/* La variante de texto: un borde que dice "esto esta mal" necesita 3:1. */
input.tf-invalido { border-color: var(--arcilla-texto) !important; outline-color: var(--arcilla-texto) !important; }

.tf-calendario {
  position: absolute; z-index: 50; top: calc(100% + 6px); right: 0;
  width: 17.5rem; padding: 12px;
  background: var(--bg-card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .22);
}
.tf-cal-cab { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.tf-cal-mes { font-family: var(--font-display); font-weight: 600; text-transform: capitalize; }
.tf-cal-nav {
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-panel); color: var(--ink); font-size: 18px;
}
.tf-cal-rejilla { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.tf-cal-dsem { font-size: 12px; color: var(--ink-soft); padding: 4px 0; }
.tf-cal-dia {
  height: 34px; border-radius: 8px; cursor: pointer;
  border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.tf-cal-dia:hover { background: var(--bg-panel); }
.tf-cal-dia.hoy { box-shadow: inset 0 0 0 1px var(--ocre); }
.tf-cal-dia.elegido { background: var(--azulejo); color: var(--sobre-azulejo); }
.tf-cal-dia:focus-visible { outline: 2px solid var(--azulejo); outline-offset: 1px; }

/* ================================================= selector de cuenta */
.tf-cuenta { position: relative; display: inline-flex; }
.tf-cuenta-boton {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 14rem; min-height: 38px; padding: 6px 12px;
  border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-input); background: var(--bg-panel); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 500;
}
.tf-cuenta-boton:focus-visible { outline: 2px solid var(--azulejo); outline-offset: 2px; }
.tf-cuenta-donde { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tf-cuenta-flecha { font-size: 11px; color: var(--ink-soft); }
.tf-cuenta-menu {
  position: absolute; z-index: 60; top: calc(100% + 6px); right: 0;
  width: max-content; min-width: 15rem; max-width: min(22rem, calc(100vw - 24px));
  padding: 6px; border-radius: 14px;
  background: var(--bg-card); border: 1px solid var(--line);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .22);
}
.tf-cuenta-grupo {
  padding: 8px 10px 4px; font-size: 12px; font-weight: 600;
  color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em;
}
.tf-cuenta-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 10px 10px; border-radius: 10px; cursor: pointer;
  border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 15px; text-align: left;
}
.tf-cuenta-item:hover, .tf-cuenta-item:focus-visible { background: var(--bg-panel); outline: none; }
.tf-cuenta-item.actual { font-weight: 600; color: var(--azulejo-texto); }
.tf-cuenta-item.actual::after { content: '✓'; color: var(--salvia-texto); }
.tf-cuenta-rol { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

/* ============================================================ marca */
/* El logo del kit de marca (comun/marca/). Dos versiones y se ensena la del
 * tema: la de noche es la misma con el texto y el trazo oscuro en crema,
 * porque el azul petroleo sobre el fondo de noche no se lee. */
.marca .logo { display: block; height: 52px; width: auto; max-width: 100%; }
.marca .logo-noche { display: none; }
[data-theme="noche"] .marca .logo-dia { display: none; }
[data-theme="noche"] .marca .logo-noche { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .marca .logo-dia { display: none; }
  :root:not([data-theme]) .marca .logo-noche { display: block; }
}
.marca-mini img { display: block; width: 38px; height: 38px; border-radius: 10px; }
