/* ==========================================================================
   Base — reset mínimo + estilos globales compartidos por todas las páginas.
   Se carga en todas las páginas, después de tokens.css.
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 100%;
  color-scheme: light;
}

body {
  font-family: var(--font-base);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

input,
button,
select,
textarea {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--color-primary);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

img {
  display: block;
  max-width: 100%;
}

/* Salto de contenido: primer elemento focuseable de las páginas del admin,
   para no obligar a tabular por todo el sidebar antes de llegar al formulario. */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  background-color: var(--color-primary);
  color: var(--color-surface);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: var(--space-4);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Campos de formulario — compartidos por todas las páginas (login, admin).
   ========================================================================== */

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-regular);
  color: var(--color-text);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.form-required {
  color: var(--color-error);
}

.form-input,
.form-select,
.form-textarea {
  height: 36px;
  padding: 0 var(--space-3);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
  width: 100%;
}

/* Variante grande: solo para los inputs del login, que van junto al botón .btn-primary--lg */
.form-input--lg {
  height: 52px;
  padding: 0 var(--space-4);
}

.form-textarea {
  height: auto;
  min-height: 120px;
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
  resize: vertical;
}

.form-select {
  /* appearance:none para poder dibujar una flecha propia y que se vea igual en todos los navegadores */
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%237a6b73' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 7.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  background-size: 16px; /* sin esto el SVG usa su tamaño intrínseco ambiguo y se ve gigante */
  padding-right: var(--space-7);
  font-size: var(--font-size-sm); /* el texto elegido/placeholder del select, igual que el resto de los placeholders */
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-placeholder);
  font-size: var(--font-size-sm);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.form-input[aria-invalid="true"],
.form-select[aria-invalid="true"],
.form-textarea[aria-invalid="true"] {
  border-color: var(--color-error);
}

/* Campos de dinero (estilo Mercado Pago): signo $ fijo a la izquierda —dibujado
   como fondo SVG, igual que la flecha del <select>— y dígitos de ancho parejo
   (tabular) para que el número no "baile" al tipear miles/millones. */
.money-input {
  padding-left: var(--space-6);
  font-variant-numeric: tabular-nums;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='14' viewBox='0 0 9 14'%3E%3Ctext x='0' y='11.5' font-family='sans-serif' font-size='13' fill='%237a6b73'%3E$%3C/text%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left var(--space-3) center;
}
/* Variante USD (dólares): mismo trato pero el prefijo dice "US$". */
.money-input--usd {
  padding-left: var(--space-7);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='14' viewBox='0 0 20 14'%3E%3Ctext x='0' y='11' font-family='sans-serif' font-size='11' fill='%237a6b73'%3EUS$%3C/text%3E%3C/svg%3E");
}

.form-error {
  font-size: var(--font-size-xs);
  color: var(--color-error);
  min-height: 1em; /* reserva el espacio para que el layout no salte cuando aparece el mensaje */
}

.form-error:empty {
  display: none;
}

/* ==========================================================================
   Botones — compartidos.
   ========================================================================== */

.btn-primary {
  /* inline-flex + center: para que rindan igual como <button> o como <a> (los
     <a> ignoran height y no centran el texto solos). text-decoration:none saca
     el subrayado por defecto del navegador cuando la clase va sobre un link. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 var(--space-3);
  background-color: var(--color-primary);
  color: var(--color-surface);
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  transition: background-color 0.15s ease;
}

/* Variante grande: solo para el submit del login, que va a full-width junto a inputs de 52px */
.btn-primary--lg {
  height: 52px;
  padding: 0 var(--space-5);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
}

.btn-primary:active {
  background-color: var(--color-primary-active);
}

.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-focus-ring-strong);
}

.btn-primary:disabled {
  background-color: var(--color-border);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 var(--space-3);
  background-color: transparent;
  color: var(--color-text);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-secondary:hover {
  background-color: var(--color-bg);
  border-color: var(--color-text-muted);
}

.btn-secondary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

/* ==========================================================================
   Layout del admin autenticado — sidebar + contenedor de página.
   El sidebar se renderiza con JS (assets/js/sidebar.js) dentro de un
   <div id="sidebar-root">, así no se duplica el markup en cada página.
   ========================================================================== */

.admin-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* El sidebar real (.admin-sidebar) se inyecta con JS adentro de este div.
   Sin display:flex acá, #sidebar-root se estira bien (es el flex item de
   .admin-shell) pero su hijo .admin-sidebar no hereda esa altura solo —
   un div normal no llena la altura del padre a menos que se lo digas. */
#sidebar-root {
  display: flex;
}

.admin-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-5) var(--space-4);
  border-right: var(--border-width) solid var(--color-border);
  background-color: var(--color-surface);
}

.admin-sidebar-logo {
  display: inline-flex;
  padding: 0 var(--space-2);
}

.admin-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
}

.admin-sidebar-footer {
  border-top: var(--border-width) solid var(--color-border);
  padding-top: var(--space-4);
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 44px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
}

.admin-nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.admin-nav-link:hover {
  background-color: var(--color-bg);
  color: var(--color-text);
}

.admin-nav-link.is-active {
  background-color: var(--color-bg);
  color: var(--color-primary);
}

.admin-nav-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.admin-content {
  flex: 1;
  min-width: 0; /* evita que el flex item se desborde si algún día hay tablas anchas adentro */
}

/* Es el destino del skip-link (ver .skip-link): sin esto el foco iría a un
   contenedor gigante y se vería un recuadro de foco alrededor de toda la página. */
.admin-content:focus-visible {
  outline: none;
}

.admin-page {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) calc(96px + var(--space-6)); /* el padding-bottom deja lugar a la barra de acciones fija */
}

@media (max-width: 768px) {
  .admin-shell {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border-right: none;
    border-bottom: var(--border-width) solid var(--color-border);
  }

  .admin-sidebar-nav {
    flex-direction: row;
  }

  .admin-sidebar-footer {
    border-top: none;
    padding-top: 0;
  }

  .sticky-actions {
    left: 0;
  }
}

.page-breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  margin-bottom: var(--space-3);
}

.page-breadcrumb:hover {
  color: var(--color-text);
}

.page-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-6);
}

/* Título + acción principal en la misma fila (ej. "Productos" + botón "Agregar producto") */
.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.page-header-row .page-title {
  margin-bottom: 0;
}

/* ==========================================================================
   Estado vacío — cuando un listado todavía no tiene contenido.
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-7) var(--space-5);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
}

/* Sin esto, `hidden` no alcanza para ocultar el elemento: un estilo propio con
   `display` siempre le gana al `display:none` que trae `[hidden]` por defecto
   del navegador, sin importar el orden en que se declaren. */
.empty-state[hidden] {
  display: none;
}

.empty-state svg {
  width: 36px;
  height: 36px;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.empty-state-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
}

.empty-state-description {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  max-width: 40ch;
}

.empty-state .btn-primary {
  margin-top: var(--space-3);
}

/* ==========================================================================
   Secciones de formulario (título afuera + campos adentro).
   ========================================================================== */

.form-section {
  margin-bottom: var(--space-7);
}

.form-section-header {
  margin-bottom: var(--space-4);
}

.form-section-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
}

.form-section-description {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* Default: sin card, sin borde — los campos separan entre sí solo con espaciado.
   Uso: adentro del side sheet (ver .sheet-body). */
.form-section-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* Variante con card blanca + borde — disponible para una futura pantalla de
   página completa lo bastante ancha como para justificar el patrón tipo Clerk,
   pero sin uso hoy (el side sheet usa .form-section-body). */
.form-card {
  background-color: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.form-card-row {
  padding-top: var(--space-5);
  border-top: var(--border-width) solid var(--color-border);
}

.form-card-row:first-child {
  padding-top: 0;
  border-top: none;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}

@media (min-width: 640px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* ==========================================================================
   Chips — selección múltiple (ej. tipo de piel, rutina).
   ========================================================================== */

.chip-group {
  border: none;
  padding: 0;
  margin: 0;
}

.chip-group legend {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  padding: 0;
  margin-bottom: var(--space-2);
}

.chip-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 var(--space-3);
  border: var(--border-width) solid var(--color-border);
  border-radius: 999px;
  font-size: var(--font-size-xs);
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* El checkbox real queda invisible pero ocupa toda la pastilla: sigue siendo
   focuseable por teclado y mantiene el estado accesible (checked/unchecked)
   para lectores de pantalla — solo se le saca la apariencia nativa. */
.chip input[type="checkbox"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--color-text-muted);
}

.chip:has(input:checked) {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-surface);
}

.chip:has(input:focus-visible) {
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

/* ==========================================================================
   Carga de fotos: cuadrado para agregar + miniaturas al lado, en la misma fila.
   ========================================================================== */

.photo-uploader {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.dropzone {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--color-primary);
  background-color: var(--color-bg);
}

.dropzone:has(input:focus-visible) {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.dropzone svg {
  width: 24px;
  height: 24px;
}

.dropzone-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted); /* --color-placeholder da ~2.5:1 acá, no pasa WCAG AA para texto real (esa variable es para ::placeholder, que está exceptuado) */
  margin-top: var(--space-2);
}

.photo-preview-grid {
  display: contents; /* las miniaturas son flex items directos de .photo-uploader, al lado del cuadrado */
}

.photo-preview-item {
  position: relative;
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: var(--border-width) solid var(--color-border);
}

.photo-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview-remove {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: rgba(31, 18, 25, 0.6);
  color: var(--color-surface);
}

/* Amplía el área táctil a ~44px sin agrandar el círculo visible
   (la miniatura es chica, un botón de 44px visible se comería la foto). */
.photo-preview-remove::before {
  content: "";
  position: absolute;
  inset: -10px;
}

.photo-preview-remove:focus-visible {
  outline: 2px solid var(--color-surface);
  outline-offset: 2px;
}

.photo-preview-remove svg {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   Barra de acciones fija — se usa en formularios largos (crear/editar) para
   que Guardar/Cancelar estén siempre a mano sin tener que scrollear al fondo.
   ========================================================================== */

.sticky-actions {
  position: fixed;
  left: var(--sidebar-width); /* arranca después del sidebar en desktop; en mobile se pisa a 0 (ver media query abajo) */
  right: 0;
  bottom: 0;
  background-color: var(--color-surface);
  border-top: var(--border-width) solid var(--color-border);
  z-index: 10;
}

.sticky-actions-inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ==========================================================================
   Side sheet — panel que desliza desde la derecha, altura completa, para
   acciones como "Agregar producto" sin salir de la página. Se controla con JS
   (ver patrón en assets/js/productos.js): abrir/cerrar, Escape, foco atrapado
   adentro con el atributo `inert` (nativo del navegador, sin JS de más).
   ========================================================================== */

.no-scroll {
  overflow: hidden;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(31, 18, 25, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 40;
}

.sheet-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 480px; /* a propósito angosto: los campos van en una sola columna, no dispara el grid de 2 columnas de .form-row */
  display: flex;
  flex-direction: column;
  background-color: var(--color-surface);
  border-left: var(--border-width) solid var(--color-border);
  transform: translateX(100%);
  transition: transform 0.25s ease-out;
  z-index: 41;
}

.sheet-backdrop.is-open .sheet {
  transform: translateX(0);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: var(--border-width) solid var(--color-border);
  flex-shrink: 0;
}

.sheet-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}

.sheet-close {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* Amplía el área de click a ~44px sin agrandar el botón visible */
.sheet-close::before {
  content: "";
  position: absolute;
  inset: -6px;
}

.sheet-close:hover {
  background-color: var(--color-bg);
  color: var(--color-text);
}

.sheet-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.sheet-close svg {
  width: 20px;
  height: 20px;
}

.sheet-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}

.sheet-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: var(--border-width) solid var(--color-border);
  flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
  .sheet-backdrop,
  .sheet {
    transition: none;
  }
}

/* ==========================================================================
   Tabla de datos — listados (productos, y a futuro pedidos, clientes, etc.)
   ========================================================================== */

.data-table-wrapper {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  overflow-x: auto; /* si la tabla no entra en mobile, scrollea ella sola en vez de desbordar la página */
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  border-bottom: var(--border-width) solid var(--color-border);
  white-space: nowrap;
}

.data-table th {
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  background-color: var(--color-bg);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table-thumb,
.data-table-thumb-placeholder {
  width: 62px;
  height: 62px;
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--color-border);
}

.data-table-thumb {
  object-fit: cover;
  display: block;
}

.data-table-thumb-placeholder {
  background-color: var(--color-bg);
  border-style: dashed;
}

/* Chips de solo lectura para mostrar valores multi-selección en una tabla
   (ej. tipo de piel, rutina) — versión estática de .chip, sin checkbox. */
.table-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  white-space: normal; /* .data-table pone nowrap por default, acá sí queremos que los chips bajen de línea */
}

.table-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 var(--space-2);
  border-radius: 999px;
  background-color: var(--color-bg);
  color: var(--color-text-muted);
  border: var(--border-width) solid var(--color-border);
  font-size: var(--font-size-xs);
  white-space: nowrap;
}

/* --- Mobile: la tabla pasa de filas/columnas a una lista de tarjetas ---
   Cada <tr> se convierte en una card; cada <td> se convierte en una fila
   "label: valor" usando el atributo data-label que pone productos.js al
   armar las celdas (mismo texto que el <th> de esa columna). */
@media (max-width: 768px) {
  .data-table-wrapper {
    border: none;
    overflow-x: visible;
  }

  .data-table thead {
    display: none;
  }

  .data-table,
  .data-table tbody,
  .data-table tr {
    display: block;
    width: 100%;
  }

  .data-table tr {
    margin-bottom: var(--space-4);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
  }

  .data-table tr:last-child {
    margin-bottom: 0;
  }

  .data-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    white-space: normal;
  }

  .data-table tr td:last-child {
    border-bottom: none;
  }

  .data-table td::before {
    content: attr(data-label);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-muted);
    flex-shrink: 0;
  }

  /* La imagen va sola arriba de la card, sin label al lado */
  .data-table td[data-label="Imagen"] {
    justify-content: flex-start;
    background-color: var(--color-bg);
  }

  .data-table td[data-label="Imagen"]::before {
    display: none;
  }
}

/* ==========================================================================
   Toast — confirmación breve de una acción completada (ej. "Producto agregado").
   ========================================================================== */

.toast {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 50;
  padding: var(--space-3) var(--space-4);
  background-color: var(--color-text);
  color: var(--color-surface);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}

/* ==========================================================================
   Pestañas (usadas en Configuración: Precios / Administradores / Mi cuenta).
   ========================================================================== */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
  /* Permitimos scroll horizontal si hay muchas pestañas (mobile), pero ocultamos
     la barra: con overflow-x:auto el navegador fuerza overflow-y:auto y, sumado
     al margin-bottom:-1px de cada .tab, aparecía una barra de scroll espuria. */
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
}
.tabs::-webkit-scrollbar {
  display: none; /* Chrome / Edge / Safari */
}

.tab {
  background: none;
  border: none;
  padding: var(--space-3) var(--space-4);
  font: inherit;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--color-text);
}

.tab.is-active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Formulario angosto de página (no en sheet), p.ej. cambiar contraseña. */
.narrow-form {
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Título de sección dentro de un sheet (ej. "Ítems", "Desglose"). */
.sheet-section-title {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
}

/* Texto de ayuda debajo de un campo de formulario. */
.form-hint {
  margin: var(--space-1) 0 0;
  font-size: var(--font-size-xs);
  line-height: 1.4;
  color: var(--color-text-muted);
}

/* Párrafo introductorio bajo el título de una página (texto secundario). */
.page-intro {
  margin: calc(-1 * var(--space-3)) 0 var(--space-5);
  max-width: 640px;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

/* ==========================================================================
   Estado (badge) + acciones de fila. Compartido por las tablas de catálogo
   (marcas, categorías, rutinas, tipos de piel) y por el listado de productos.
   ========================================================================== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1.5;
  background: var(--color-focus-ring);
  color: var(--color-primary);
}

.badge--off {
  background: var(--color-border);
  color: var(--color-text-muted);
}

/* Acciones por fila (Editar / Desactivar): botones con apariencia de link. */
.row-actions {
  display: flex;
  gap: var(--space-4);
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--color-primary);
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.link-btn--danger {
  color: var(--color-error);
}

/* ==========================================================================
   Paginación de tablas (Anterior / Siguiente + contador). Componente
   reutilizable: va debajo de un .data-table-wrapper. Se oculta con [hidden]
   cuando hay una sola página.
   ========================================================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.pagination[hidden] {
  display: none;
}
.pagination-info {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
.pagination-controls {
  display: flex;
  gap: var(--space-2);
}
.pagination-controls .btn-secondary[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==========================================================================
   Barra de filtros de un listado (buscador + selects + rango de fechas).
   Reutilizable: va arriba de un .data-table-wrapper. Cada control pega a la API.
   ========================================================================== */
.filters-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.filters-toolbar .form-input,
.filters-toolbar .form-select {
  width: auto;
  min-width: 160px;
}
.filters-toolbar input[type="date"] {
  min-width: 150px;
}
/* Rango de fechas: "Del [desde] al [hasta]" como una sola unidad que no se parte. */
.filter-daterange {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.filter-daterange-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* ===== Adjuntos (documentos privados) — componente compartido =====
   Lo arma assets/js/attachments.js: una lista de documentos (tipo + "Ver" +
   "Quitar") y, si es editable, un control para adjuntar (selector de tipo +
   botón). Lo usa Compras y queda listo para Gastos/Ventas. */
.attachments-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.attachment-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}
/* El tipo (Factura, Remito…) ocupa el espacio; las acciones quedan a la derecha. */
.attachment-kind {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--color-text);
}
.attachment-adder {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
/* El selector de tipo ocupa el espacio; el botón queda a su lado (no debajo). */
.attachment-adder .form-select {
  flex: 1;
  min-width: 0;
}
/* El botón "+ Adjuntar" es un <label> (envuelve un input file oculto). Sin
   display:inline-flex, al ser un <label> inline ignora el height:36px de
   .btn-secondary y queda como texto con un borde finito, desalineado del select. */
.attachment-add-btn {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  white-space: nowrap;
}

/* ===== Grilla de tasas (métodos de pago) =====
   Cada fila: plazo + cuotas + tasa% en línea, con "Quitar" al final. */
.rate-row {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
  margin-bottom: var(--space-2);
}
.rate-row .form-field {
  flex: 1;
  min-width: 0;
}
.rate-row .rate-remove {
  flex: 0 0 auto;
  padding-bottom: var(--space-2);
}
