/* fête UI v1: componentes de interfaz. Aprobado 2026-12-02 (artifact 75HUxz5ZfKPjYPTgrJKiv5, Revisión 2).
   Fuente oficial: fete-website/design-system/. Los proyectos (fete-recibos…) usan una COPIA de este archivo.
   Usa los tokens de src/styles/tokens.css (no define colores nuevos, salvo --fete-ui-err, pendiente de aprobar).
   REGLAS: ver README.md. La principal: TODO lo que se toca mide lo mismo (--fete-ctl-h). Mobile first. */
:root {
  --fete-ctl-h: 48px;        /* altura única: campo, lista, fecha, dinero, segmentado, botón, botón de ícono */
  --fete-ctl-r: 8px;         /* esquina de los campos; botones, pastillas y segmentado son redondos */
  --fete-ctl-line: 1.5px;    /* borde de todo control */
  --fete-ui-ok: #0a7a3d;     /* "guardado" (texto). PENDIENTE de aprobar como token */
  --fete-ui-err: #c41d3c;    /* error (borde + mensaje). PENDIENTE de aprobar como token */
}
[hidden] { display: none !important; }

/* Etiquetas */
.fete-lbl { font-size: var(--fs-label); font-weight: var(--fw-bold); letter-spacing: .14em; text-transform: uppercase; color: var(--head); }

/* Campo = etiqueta arriba + control (+ ayuda o error) */
.fete-field { display: grid; gap: 6px; }
.fete-field > span { font-size: 14px; font-weight: 600; }
.fete-field > span i { font-style: normal; color: var(--head); }          /* asterisco de obligatorio */
.fete-field small { font-size: 13px; font-weight: 400; opacity: .75; }

/* Controles de texto: input, select, textarea. 16 px para que el iPhone no haga zoom */
.fete-ctl { height: var(--fete-ctl-h); width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--white);
  border: var(--fete-ctl-line) solid var(--line); border-radius: var(--fete-ctl-r); padding: 0 14px; appearance: none; -webkit-appearance: none; }
textarea.fete-ctl { height: auto; min-height: calc(var(--fete-ctl-h) * 1.75); padding: 12px 14px; line-height: 1.4; resize: vertical; }
select.fete-ctl { padding-right: 36px; background-repeat: no-repeat; background-size: 6px 6px;
  background-image: linear-gradient(45deg, transparent 50%, var(--head) 50%), linear-gradient(135deg, var(--head) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; }
input[type=date].fete-ctl { display: flex; align-items: center; }
.fete-ctl::placeholder { color: var(--text); opacity: .45; }
@media (hover: hover) { .fete-ctl:hover { border-color: color-mix(in srgb, var(--head) 55%, transparent); } }
.fete-ctl:focus { outline: none; border-color: var(--head); box-shadow: 0 0 0 3px color-mix(in srgb, var(--head) 25%, transparent); }
.fete-ctl.is-err { border-color: var(--fete-ui-err); }
.fete-err { font-size: 13px; font-weight: var(--fw-bold); color: var(--fete-ui-err); display: flex; gap: 4px; align-items: center; }
.fete-money { position: relative; }
.fete-money .fete-ctl { padding-left: 28px; }
.fete-money::before { content: "$"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-weight: var(--fw-bold); color: var(--head); }

/* Control segmentado: una opción entre 2 y 4. La pastilla viaja (fete-ui.js) */
.fete-seg { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: var(--fete-ctl-h); padding: 4px;
  border-radius: var(--radius-pill); background: var(--white); border: var(--fete-ctl-line) solid var(--line); width: 100%; }   /* sin fondo azulito (Eduardo 2026-12-02) */
.fete-seg > button { position: relative; z-index: 1; border: 0; background: none; color: var(--head); font: inherit; font-weight: var(--fw-bold); font-size: 15px;
  padding: 0 12px; border-radius: var(--radius-pill); cursor: pointer; white-space: nowrap; }
.fete-seg > button:focus-visible { outline: 2px solid var(--head); outline-offset: 2px; }
.fete-seg > .thumb { position: absolute; inset: 0; z-index: 2; padding: 4px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--head); border-radius: var(--radius-pill); pointer-events: none; clip-path: inset(4px 100% 4px 0 round 999px); }
.fete-seg > .thumb span { display: grid; place-items: center; color: var(--white); font-weight: var(--fw-bold); font-size: 15px; padding: 0 12px; white-space: nowrap; }

/* Botones: mismo alto que los campos */
.fete-btn { min-height: var(--fete-ctl-h); padding: 0 20px; border-radius: var(--radius-pill); border: var(--fete-ctl-line) solid var(--head);
  background: var(--white); color: var(--head); font: inherit; font-weight: 800; font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.fete-btn.pri { background: var(--head); color: var(--white); }
.fete-btn.txt { border-color: transparent; background: none; padding: 0 8px; }
.fete-btn:disabled { opacity: .45; cursor: default; }
.fete-ibtn { width: var(--fete-ctl-h); height: var(--fete-ctl-h); flex: none; border-radius: 50%; border: var(--fete-ctl-line) solid var(--line);
  background: var(--white); color: var(--head); display: inline-grid; place-items: center; cursor: pointer; padding: 0; }
.fete-ibtn.plain { border-color: transparent; background: none; }
.fete-btn:focus-visible, .fete-ibtn:focus-visible { outline: 2px solid var(--head); outline-offset: 2px; }
svg.fete-ic { width: 20px; height: 20px; fill: currentColor; display: block; flex: none; }

/* Fila editable dato / valor / quitar */
.fete-kv { display: grid; grid-template-columns: 1fr 1.3fr var(--fete-ctl-h); gap: 8px; }

/* Sección que se abre (una a la vez). La animación vive en fete-ui.js */
.fete-acc { border-bottom: 1px solid var(--line); }
.fete-acc > button { width: 100%; min-height: calc(var(--fete-ctl-h) + 16px); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px;
  align-items: center; background: none; border: 0; color: var(--text); text-align: left; cursor: pointer; padding: 8px 0; font: inherit; }
.fete-acc > button b { display: block; font-size: 16px; }
.fete-acc > button .sum { display: block; font-size: 14px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fete-acc > button .chev { display: inline-block; color: var(--head); }
.fete-acc.is-open > button .chev { transform: rotate(180deg); }
.fete-acc > .body { display: grid; gap: 14px; padding: 4px 0 20px; }
.fete-dot { width: 24px; height: 24px; border-radius: 50%; border: var(--fete-ctl-line) solid var(--line); display: grid; place-items: center;
  font-size: 12px; font-weight: 800; color: var(--head); }
.fete-dot.done { background: var(--head); border-color: var(--head); color: var(--white); }

/* Barra fija abajo, siempre al alcance del pulgar */
.fete-bar { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line); background: var(--white); z-index: 5; }
.fete-bar .fete-btn { flex: 1; }

/* Estado visible: cápsula con fondo tenue del color del estado; se anima (fete-ui.js: status()) cada vez que cambia.
   Eduardo 2026-12-02: "una cápsula con fondo tenue animada cada vez que se guarde" */
.fete-status { display: inline-flex; gap: 6px; align-items: center; min-height: 32px; padding: 0 12px 0 10px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: var(--fw-bold); white-space: nowrap;
  color: var(--fete-ui-ok); background: color-mix(in srgb, var(--fete-ui-ok) 12%, var(--white)); }
.fete-status.is-muted { color: color-mix(in srgb, var(--text) 70%, var(--white)); background: color-mix(in srgb, var(--text) 6%, var(--white)); }
.fete-status.is-err { color: var(--fete-ui-err); background: color-mix(in srgb, var(--fete-ui-err) 10%, var(--white)); }

/* Tarjeta de historial */
.fete-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 14px 0; width: 100%; text-align: left;
  border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text); font: inherit; cursor: pointer; align-items: center; }
.fete-card b { font-size: 16px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fete-card small { font-size: 13px; opacity: .75; }
.fete-card .amt { font-weight: var(--fw-black); font-stretch: var(--wide); color: var(--head); font-size: 18px; text-align: right; display: block; }
.fete-card > :last-child { text-align: right; }   /* monto y saldo/pagado siempre a la derecha */
.fete-empty { padding: 32px 0; text-align: center; display: grid; gap: 8px; justify-items: center; opacity: .8; }

/* Fecha: un botón con forma de campo que abre el calendario de fête (no el del navegador:
   en la compu se veía diminuto y a veces no se cerraba al elegir un día) */
.fete-date { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; }
.fete-date .ph { opacity: .45; }
.fete-date svg.fete-ic { color: var(--head); }

/* Hoja que sube desde abajo (celular) o tarjeta al centro (compu) */
.fete-sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(4, 6, 30, .55); }   /* oscurece el fondo (Eduardo 2026-12-02) */
.fete-sheet { position: fixed; z-index: 51; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--white);
  border-radius: 28px; padding: 8px 16px 16px; display: grid; gap: 8px; max-height: calc(100vh - 24px); overflow: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 40, .25); }   /* flota: se ve el fondo a los lados (Eduardo 2026-12-02) */
.fete-sheet::before { content: ""; justify-self: center; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin-bottom: 4px; }
/* Dos mitades (tablet, compu, plegable abierto): la ventana flotante vive en la mitad IZQUIERDA, donde está lo que la abrió;
   nunca centrada en toda la pantalla (en un plegable caería sobre la bisagra y no se podría operar). Eduardo 2026-12-02 */
@media (min-width: 600px), (horizontal-viewport-segments: 2) {
  .fete-sheet { left: 25%; right: auto; bottom: auto; top: 50%; width: min(400px, calc(50vw - 32px)); border-radius: var(--radius-md); translate: -50% -50%; padding: 16px; }
  .fete-sheet::before { display: none; }
}
@media (horizontal-viewport-segments: 2) {
  .fete-sheet { left: calc(env(viewport-segment-right 0 0) / 2); width: min(400px, calc(env(viewport-segment-width 0 0) - 32px)); }
}

/* Calendario */
.fete-cal-head { display: grid; grid-template-columns: var(--fete-ctl-h) 1fr var(--fete-ctl-h); align-items: center; text-align: center; }
.fete-cal-head b { font-size: 17px; font-weight: 800; text-transform: capitalize; }
.fete-cal-wd, .fete-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.fete-cal-wd span { text-align: center; font-size: var(--fs-label); font-weight: var(--fw-bold); letter-spacing: .1em; color: var(--head); padding: 4px 0; }
.fete-cal-grid { row-gap: 2px; }
.fete-cal-grid button { justify-self: center; width: var(--fete-ctl-h); height: var(--fete-ctl-h); border-radius: 50%; border: var(--fete-ctl-line) solid transparent;
  background: none; color: var(--text); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; padding: 0; }
.fete-cal-grid button.hoy { border-color: var(--head); color: var(--head); }
.fete-cal-grid button[aria-pressed="true"] { background: var(--head); border-color: var(--head); color: var(--white); }
.fete-cal-grid button:focus-visible { outline: 2px solid var(--head); outline-offset: 2px; }
.fete-cal-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 4px; }

/* Búsqueda: campo con lupa a la izquierda y botón para borrar a la derecha (mismo alto que todo) */
.fete-search { position: relative; }
.fete-search .fete-ctl { padding-left: 44px; padding-right: var(--fete-ctl-h); }
.fete-search > svg.fete-ic { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--head); pointer-events: none; }
.fete-search > .fete-ibtn { position: absolute; right: 0; top: 0; }
.fete-search input::-webkit-search-cancel-button { display: none; }

/* Chips: varias opciones que se pueden combinar (o ninguna). Mismo alto que todo */
.fete-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fete-chip { min-height: var(--fete-ctl-h); padding: 0 16px; border-radius: var(--radius-pill); border: var(--fete-ctl-line) solid var(--line);
  background: var(--white); color: var(--head); font: inherit; font-weight: var(--fw-bold); font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; }
.fete-chip svg.fete-ic { width: 18px; height: 18px; margin-left: -4px; }
.fete-chip[aria-pressed="true"] { background: var(--head); border-color: var(--head); color: var(--white); }
.fete-chip:focus-visible { outline: 2px solid var(--head); outline-offset: 2px; }

/* Botón de acción destructiva (borrar). Usa --fete-ui-err, PENDIENTE de aprobar como token */
.fete-btn.danger { border-color: var(--fete-ui-err); color: var(--fete-ui-err); }
.fete-btn.danger.pri { background: var(--fete-ui-err); color: var(--white); }
.fete-btn.danger.txt { border-color: transparent; }

/* Barra flotante: sin fondo ni línea; el botón flota con sombra (p. ej. "Nuevo recibo") */
.fete-bar.is-flotante { background: transparent; border: 0; pointer-events: none; }
.fete-bar.is-flotante .fete-btn { pointer-events: auto; box-shadow: 0 8px 24px color-mix(in srgb, var(--blue-500) 35%, transparent), 0 2px 6px rgba(0, 0, 40, .12); }

/* Confirmación: misma hoja flotante que el calendario */
.fete-confirm h2 { font-size: 19px; font-weight: 800; margin: 4px 4px 0; }
.fete-confirm p { font-size: 15px; margin: 0 4px 8px; opacity: .85; }
.fete-confirm .acc { display: flex; gap: 10px; } .fete-confirm .acc .fete-btn { flex: 1; }

/* Deslizar para una acción (p. ej. "Borrar" en el historial). El botón vive DETRÁS de la tarjeta;
   al deslizar a la izquierda se descubre. fete-ui.js: el gesto, el resorte y el evento "fete:swipe". */
.fete-swipe { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); --fete-swipe-w: 104px; }
.fete-swipe > .fete-card { position: relative; z-index: 1; background: var(--white); border-bottom: 0; touch-action: pan-y; }
.fete-swipe-accion { position: absolute; top: 0; right: 0; bottom: 0; width: var(--fete-swipe-w); border: 0; cursor: pointer;
  background: var(--fete-ui-err); color: var(--white); font: inherit; font-weight: 800; font-size: 15px; }
.fete-swipe-accion:focus-visible { outline: 3px solid var(--text); outline-offset: -6px; }
