/*
 * Clay Design System — Capa de convivencia con Materialize y main.css
 * ---------------------------------------------------------------
 * TEMPORAL. Se carga DESPUÉS de /css/main.css y de clay-controls.css.
 * Se borra entera cuando salga Materialize (M8) y se limpien las reglas de
 * elemento y atributo de main.css (M9). No agrega diseño: no define ningún
 * valor nuevo, solo fija cada propiedad a la variable que ya calcula
 * clay-controls.css.
 *
 * Por qué existe (spike DX-512): main.css aplica !important sobre selectores
 * de elemento y atributo (input:focus, textarea, .input-field input,
 * .tem-form input[type=…], input[type=text]:not(.browser-default):focus:not([readonly])
 * que pesa 0,4,1) y Materialize oculta el checkbox y el radio nativos. Sin
 * !important nada les gana, y meter ese CSS en @layer lo empeora.
 *
 * Cómo:
 *  - `:not(#_)` sube la especificidad al nivel de un id sin depender de un
 *    contenedor (sirve en modales y pantallas sin sesión).
 *  - !important solo en las propiedades que el CSS heredado fuerza.
 *  - Nunca `display` con !important, para que .hide() / style.display sigan funcionando.
 */

/* Materialize cambia el tamaño raíz (html { font-size: 14px–15px } según el ancho),
   así que los tokens en rem del DS (--space-*, --radius-*) se achican. Dentro de los
   componentes Clay se fijan a su equivalente en px documentado en tokens.css.
   Sin Materialize la raíz vuelve a 16px y esta regla deja de hacer falta. */
.clay-btn, .clay-field, .clay-label, .clay-label__help, .clay-input, .clay-textarea, .clay-select,
.clay-hint, .clay-error-text, .clay-check, .clay-checkbox, .clay-radio, .clay-btn-group, .clay-switch {
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px;
  --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px;
  --clay-control-radius: 8px; /* se resolvió en :root con el rem de Materialize */
}

/* Botón: Materialize pinta `button:focus` (0,1,1) y main.css `body a:link` (0,1,2) */
.clay-btn:not(#_) {
  background-color: var(--_bg) !important;
  color: var(--_fg) !important;
  border-color: var(--_bd) !important;
  box-shadow: var(--_shadow) !important;
  text-decoration-line: var(--_decoration) !important;
  text-transform: none !important;
  height: var(--_h) !important;
}

/* Input, textarea y select */
.clay-input:not(#_),
.clay-textarea:not(#_),
.clay-select:not(#_) {
  box-sizing: border-box !important;
  width: 100% !important;
  height: var(--_h) !important;
  min-height: var(--_minh) !important;
  max-height: none !important;
  margin: 0 !important;
  padding: var(--_pad) !important;
  border: var(--clay-control-border) solid var(--_bc) !important;
  border-radius: var(--clay-control-radius) !important;
  background-image: var(--_arrow) !important;   /* main.css pone el PNG de iconfinder con !important */
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 12px 12px !important;
  background-color: var(--_bg) !important;
  color: var(--_fg) !important;
  box-shadow: var(--_shadow) !important;
  font: inherit !important;   /* `.input-field input` fuerza font-size 14px !important */
}
/* Switch (DX-532): Materialize (.switch label .lever, hasta 0,4,2) y main.css 1668-1684,
   que pintan la pista y la perilla con !important */
.clay-switch:not(#_) .lever {
  width: 34px;
  height: 20px;
  margin: 0 8px !important;                           /* main.css: span.lever { margin: 0 10px !important } */
  border-radius: 9999px;
  background-color: var(--_track) !important;         /* main.css pinta la pista checked y disabled con !important */
  box-shadow: var(--_shadow);
  transition: background-color .2s cubic-bezier(0, 0, .2, 1), box-shadow .15s ease;   /* Materialize: background .3s */
}
.clay-switch:not(#_) .lever::before { content: none; }
.clay-switch:not(#_) .lever::after {
  top: 2px;
  left: var(--_knob-x);
  width: 16px;
  height: 16px;
  background-color: var(--color-neutral-0) !important; /* main.css pinta la perilla checked con var(--clay) !important */
  box-shadow: none;
  transition: left .2s cubic-bezier(0, 0, .2, 1);   /* Materialize: left y background .3s, box-shadow y transform .1s */
}
.clay-switch:not(#_) input[type="checkbox"]:disabled + .lever { cursor: not-allowed; }   /* Materialize: cursor: default */
/* Disabled: main.css pinta fondo #bdccd4 y color #2b4758 con !important, Materialize pone cursor default */
.clay-input:not(#_):disabled,
.clay-textarea:not(#_):disabled,
.clay-select:not(#_):disabled {
  opacity: 1 !important;
  cursor: not-allowed !important;
}
/* Materialize oculta todos los select (`select { display: none }`): sin !important */
.clay-select:not(#_) { display: block; }
.clay-select:not(#_) { -webkit-appearance: none !important; appearance: none !important; }

/* Label: `.input-field label` lo deja absoluto, flotante y con color !important */
.clay-label:not(#_) {
  position: static !important;
  top: auto !important;
  left: auto !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
  font: inherit !important;
  color: var(--_fg) !important;
  pointer-events: auto !important;
}

/* Ícono de ayuda del label: main.css pinta `body a:link` y Materialize `button:focus` */
.clay-label__help:not(#_) {
  color: var(--_fg) !important;
  background: none !important;
  box-shadow: var(--_shadow) !important;
  text-decoration: none !important;
}

/* Checkbox y radio: Materialize los oculta (position absolute, opacity 0)
   y main.css fuerza alto 40px, borde y margen en .tem-form input[type=radio] */
.clay-checkbox:not(#_),
.clay-radio:not(#_) {
  position: relative !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  width: 16px !important;
  height: 16px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: var(--clay-control-border) solid var(--_bc) !important;
  background-image: none !important;
  background-color: var(--_bg) !important;
  box-shadow: var(--_shadow) !important;
}
.clay-checkbox:not(#_) { border-radius: 3px !important; }
.clay-radio:not(#_)    { border-radius: 50% !important; }

.clay-checkbox:not(#_) + label,
.clay-radio:not(#_) + label {
  position: static !important;
  height: auto !important;
  padding: 0 !important;
  font: inherit !important;
  color: var(--color-text-primary) !important;
}
.clay-checkbox:not(#_) + label::before,
.clay-checkbox:not(#_) + label::after,
.clay-radio:not(#_) + label::before,
.clay-radio:not(#_) + label::after {
  content: none !important;
  display: none !important;
}

/* =========================================================================
   BLOQUE PARA clay-compat-materialize.css — tablas (DX-533)
   Va AL FINAL del archivo (después de main.css). Temporal: se borra en M8/M9.
   No declara tipografía: la cabecera conserva lo que hoy fuerza main.css:12612
   (mayúsculas, 12px, peso 500) hasta que se decida la escala en M7.
   Cubre tablas que conservan `.cashflow` (el piloto la mantiene) y `thead td`
   (73 de 119 tablas) además de `thead th`.
   Especificidad: `:not(#_)` suma un id; `!important` solo donde main.css lo fuerza.
   ========================================================================= */

/* Padding de celdas (gana a td,th de Materialize, .cashflow tr td y la cabecera de main.css:12612) */
.clay-table:not(#_) :is(thead, tbody) :is(td, th) { padding: 12px 14px; }
/* main.css:17035 fuerza padding en <=600px con !important */
@media (max-width: 600px) {
  .clay-table:not(#_) tbody td { padding: 12px 14px !important; }
}

/* Cabecera: fondo, color, borde y alineación */
.clay-table:not(#_) thead :is(td, th) {
  background: var(--table-header-bg) !important;      /* main.css:12612 y .blue-grey.lighten-2 usan !important */
  color: var(--table-header-fg);
  border: 0; border-bottom: 1px solid var(--table-border);
  border-radius: 0 !important;                        /* main.css:12607 / 10006 fuerzan 5px con !important */
  text-align: left; white-space: nowrap;
}
.clay-table:not(#_) thead :is(td, th).num { text-align: right; }

/* Cuerpo: borde entre filas, alineación y números */
.clay-table:not(#_) tbody td {
  border: 0; border-bottom: 1px solid var(--table-border);
  text-align: left; vertical-align: middle;
}
.clay-table:not(#_) tbody td.num { text-align: right; white-space: nowrap; }
.clay-table:not(#_) tbody tr:last-child td { border-bottom: 0; }

/* Zebra y hover.
   Zebra: el DS la pide por clase (.clay-table--zebra). Las reglas viejas pintan el <tr>:
   se neutralizan y los colores salen de las celdas.
   Hover: en TODAS las filas del cuerpo, como hoy (main.css:12629), pero con el color del DS y
   sin pintar subtotal, total, contexto, título de sección ni estado vacío. El cursor de mano
   solo en las filas marcadas con .hoverable (las que se pueden clicar). */
.clay-table:not(#_) > tbody > tr { background: transparent; }                 /* main.css:6301, Materialize table.striped */
.clay-table:not(#_) tr:hover { background: transparent !important; }          /* main.css:12629 es global y !important */
.clay-table:not(#_) tbody tr:not(:where(.subtotal, .total, .meta, .section-title, .clay-table__empty)):hover td { background: var(--table-row-hover); }
.clay-table:not(#_) tbody tr.hoverable:hover td { cursor: pointer; }
