/* =========================================================================
   rambla.app — hoja de estilos compartida por todos los módulos
   Fuente: canvas "Rambla® app — Rediseño sistematizado de módulos"
   (Rambla® Design System + capa de interfaz rambla-app.css + UI kit).
   Un solo lugar para cada patrón: los módulos lo usan, no lo copian.
   Cargar DESPUÉS del CSS propio del módulo para que los tokens ganen.
   ========================================================================= */
/* Va DESPUÉS de /compartido/rambla-header.css (tokens, header, menús, pestañas): cada página
   linkea los dos. Antes era un @import con ?v= fijo y el navegador se quedaba con la versión vieja. */

body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
html body { background-color: #FFFFFF; }  /* fijo: hojas viejas de los módulos redefinen --bg en gris */
.tnum { font-variant-numeric: tabular-nums; }


/* Ruta (solo en pantallas de detalle) */
.crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-70); min-height: 32px; }
.crumb a { color: var(--ink-70); text-decoration: none; }
.crumb a:hover { color: var(--ink); text-decoration: underline; }

/* ---------- Layout de página ---------- */
.app-page { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.app-main { width: 100%; max-width: 1440px; margin: 0 auto; box-sizing: border-box; padding: 28px 40px 56px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.page-meta { margin: 10px 0 0; font-size: var(--fs-body-sm); line-height: 1.4; color: var(--ui-text-2); }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Botones ---------- */
.ui-btn { appearance: none; border: none; cursor: pointer; font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: var(--r-pill); text-decoration: none; white-space: nowrap; transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); box-sizing: border-box; }
.ui-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.ui-btn:disabled { opacity: .5; cursor: default; }
.ui-btn-primary { background: var(--blue); color: #FFFFFF; }
.ui-btn-primary:hover:not(:disabled) { background: var(--blue-s2); }
.ui-btn-dark { background: var(--ink); color: #FFFFFF; }
.ui-btn-dark:hover:not(:disabled) { background: var(--ink-90); }
.ui-btn-secondary { background: var(--ui-fill); color: var(--ink); }
.ui-btn-secondary:hover:not(:disabled) { background: var(--ui-fill-hover); }
.ui-btn-ghost { background: transparent; color: var(--ui-text-2); padding: 0 8px; min-height: 36px; font-weight: 500; }
.ui-btn-ghost:hover:not(:disabled) { color: var(--ink); }
.ui-btn-block { width: 100%; }


/* Mostrar más: siempre texto + flecha, con aria-expanded */
.more { appearance: none; border: none; background: transparent; cursor: pointer; font: inherit; font-family: var(--font-sans); font-size: 13px; font-weight: 500; color: var(--ui-text-2); min-height: 36px; padding: 0 4px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: var(--r-2); white-space: nowrap; }
.more:hover { color: var(--ink); }
.more:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.more svg { transition: transform var(--dur-fast) var(--ease); }
.more[aria-expanded="true"] svg { transform: rotate(180deg); }

/* ---------- Campos ---------- */
.search { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 16px; border-radius: var(--ui-radius-control);
  background: var(--ui-fill); color: var(--ui-text-2); min-width: 300px; box-sizing: border-box; }
.search:hover { background: var(--ui-fill-hover); }
.search:focus-within { background: var(--ui-fill-hover); outline: 2px solid var(--blue); outline-offset: 1px; }
.search input { border: none; background: transparent; outline: none; font: inherit; font-family: var(--font-sans); font-size: var(--fs-body-sm); color: var(--ink); width: 100%; min-width: 0; }
.search input::placeholder { color: var(--ui-text-3); }

/* Campo de formulario/filtro: vacío el nombre ocupa el campo; con valor pasa chico arriba */
.filter-field { display: flex; flex-direction: column; justify-content: center; gap: 1px; border: 1px solid transparent; border-radius: var(--ui-radius-control);
  background: var(--ui-fill); padding: 4px 12px; min-height: 40px; box-sizing: border-box; position: relative; min-width: 0; font-family: var(--font-sans);
  transition: background var(--dur-fast) var(--ease); }
.filter-field.has-caret { padding-right: 28px; }
.filter-field:hover { background: var(--ui-fill-hover); }
.filter-field:focus-within { background: var(--ui-fill-hover); outline: 2px solid var(--blue); outline-offset: 1px; }
.filter-label { font-size: var(--fs-eyebrow); line-height: 1; font-weight: 500; color: var(--ink-70); }
.filter-value { font-family: var(--font-sans); font-size: var(--fs-body-sm); line-height: 1.25; color: var(--ink); border: none; background: transparent; padding: 0; margin: 0; outline: none; width: 100%; min-width: 0; }
.filter-value::placeholder { color: var(--ui-text-3); }
select.filter-value { appearance: none; cursor: pointer; }
.filter-caret { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--ui-text-2); display: inline-flex; pointer-events: none; }
/* Vacío y sin foco: el nombre ocupa el campo (el input sigue ahí, invisible; al hacer click en el
   <label> toma el foco y el nombre pasa chico arriba). Fechas vacías = :invalid (llevan required). */
.filter-field:not(:focus-within):has(> input.filter-value:placeholder-shown) > .filter-label,
.filter-field:not(:focus-within):has(> input[type="date"].filter-value:invalid) > .filter-label { font-size: var(--fs-body-sm); line-height: 1.25; font-weight: 400; color: var(--ui-text-3); }
.filter-field:not(:focus-within) > input.filter-value:placeholder-shown,
.filter-field:not(:focus-within) > input[type="date"].filter-value:invalid { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.filter-field > input.filter-value::placeholder { color: transparent; }
/* Desplegable sin elegir (opción value=""): igual que vacío, solo el nombre y la flecha. El <select>
   queda encima, invisible, así el click lo abre; al tomar foco o elegir algo el nombre sube. */
.filter-field:not(:focus-within):has(> select.filter-value option[value=""]:checked) > .filter-label { font-size: var(--fs-body-sm); line-height: 1.25; font-weight: 400; color: var(--ui-text-3); }
.filter-field:not(:focus-within):has(> select.filter-value option[value=""]:checked) > select.filter-value { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.filter-field .filter-value:focus, .filter-field .filter-value:focus-visible { outline: none !important; box-shadow: none !important; border: none !important; }

/* Casilla: gris claro inactiva, contorno azul en hover, azul con tilde blanco activa */
.ui-check { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; line-height: 1.2; color: var(--ink); cursor: pointer; white-space: nowrap; min-height: 18px; }
.ui-check input { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 13px; height: 13px; margin: 0; border: none; border-radius: 3px; background: var(--ink-t8); cursor: pointer; transition: background var(--dur-fast) var(--ease); }
.ui-check input:hover { box-shadow: inset 0 0 0 1.5px var(--blue); }
.ui-check input:checked { background: var(--blue); box-shadow: none; }
.ui-check input:checked::before, .ui-check input:checked::after { content: ""; position: absolute; left: 4.85px; width: 1.6px; border-radius: 1px; background: #FFFFFF; transform-origin: 50% calc(100% - 0.8px); }
.ui-check input:checked::before { top: 5.35px; height: 4.4px; transform: rotate(-45deg); }
.ui-check input:checked::after { top: 2.35px; height: 7.4px; transform: rotate(40deg); }
.ui-check input[type="radio"] { border-radius: 50%; }
.ui-check input[type="radio"]:checked::before, .ui-check input[type="radio"]:checked::after { content: none; }
.ui-check input[type="radio"]:checked { box-shadow: inset 0 0 0 3.5px var(--blue); background: #FFFFFF; }
.ui-check input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.ui-check input:disabled { opacity: .5; cursor: default; }

/* Filtros rápidos (pills con estado + conteo) y selector segmentado */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pipe { appearance: none; border: 1px solid var(--ui-line); background: #FFFFFF; border-radius: var(--r-pill); min-height: 36px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px; font: inherit; font-family: var(--font-sans); font-size: 13px; color: var(--ink); cursor: pointer; white-space: nowrap; }
.pipe:hover { border-color: var(--ink-t7); }
.pipe:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.pipe .n { color: var(--ink-70); font-variant-numeric: tabular-nums; }
.pipe.is-active { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.pipe.is-active .n { color: var(--ink-t7); }
.pipe.is-active .status { color: #FFFFFF; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-pill); background: var(--ui-fill); flex: none; }
.seg-btn { appearance: none; border: none; background: transparent; border-radius: var(--r-pill); min-height: 38px; padding: 0 14px; font: inherit; font-family: var(--font-sans); font-size: 13px; font-weight: 500; color: var(--ink-70); cursor: pointer; white-space: nowrap; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-on { background: #FFFFFF; color: var(--ink); }
.seg-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.seg .icon-btn { width: 38px; height: 38px; }
.seg .icon-btn:hover { background: transparent; }
.seg .icon-btn.is-on { background: #FFFFFF; color: var(--ink); }

/* ---------- Superficies ---------- */
.panel { background: #FFFFFF; border: 1px solid var(--ui-line); border-radius: var(--ui-radius-card); }
.panel-pad { padding: 20px; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.filters-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.eyebrow { font-size: 12px; font-weight: 500; color: var(--ui-text-3); }

/* Panel lateral (edición, Claude): 400–440 px a la derecha, por encima del contenido */
.side-panel { position: fixed; inset: 0; z-index: 200; display: none; }
.side-panel.open { display: block; }
.side-panel-backdrop { position: absolute; inset: 0; background: rgba(32, 33, 36, .24); }
.side-panel-box { position: absolute; right: 0; top: 0; bottom: 0; width: 440px; max-width: 100vw; background: #FFFFFF; border-left: 1px solid var(--ink-t8);
  box-shadow: -12px 0 32px rgba(32, 33, 36, .08); display: flex; flex-direction: column; font-family: var(--font-sans); color: var(--ink); }
.side-panel-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 12px 16px 24px; border-bottom: 1px solid var(--ui-line); }
.side-panel-title { margin: 4px 0 0; font-size: 20px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
.side-panel-body { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 28px; }
.side-panel-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--ui-line); }
.form-section { display: flex; flex-direction: column; gap: 10px; }
.form-section-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); }

/* ---------- Tabla de datos (única para todos los módulos) ---------- */
.dt-wrap { overflow-x: auto; }
.dt { width: 100%; border-collapse: collapse; font-size: var(--fs-body-sm); color: var(--ink); }
.dt th { text-align: left; font-size: 12px; font-weight: 500; color: var(--ui-text-3); padding: 12px 16px; white-space: nowrap; border-bottom: 1px solid var(--ui-line-strong); background: #FFFFFF; }
.dt td { padding: 14px 16px; border-bottom: 1px solid var(--ui-line); vertical-align: middle; }
.dt tbody tr:hover td { background: var(--ui-row-hover); }
.dt tbody tr:last-child td { border-bottom: none; }
.dt .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dt .strong { font-weight: 600; }
.dt .muted { color: var(--ui-text-2); }
.dt .child td { background: #FAFAFA; color: var(--ui-text-2); }
.dt .child td:first-child { padding-left: 44px; }
.dt .is-open td { background: var(--blue-t9); }
.dt-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--ui-line); font-size: var(--fs-body-sm); color: var(--ui-text-2); }

/* ---------- Átomos que se repiten entre módulos ---------- */
/* Código / SKU / N° de OP */
.code { font-variant-numeric: tabular-nums; font-weight: 500; font-size: 13px; color: var(--ui-text-2); letter-spacing: 0.01em; white-space: nowrap; }
/* Estado: punto + texto, nunca color solo */
.status { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-body-sm); white-space: nowrap; color: var(--ink); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-t6); flex: none; }
.status.t-green::before { background: var(--green); }
.status.t-yellow::before { background: var(--yellow); }
.status.t-orange::before { background: var(--orange); }
.status.t-blue::before { background: var(--blue); }
.status.t-gray::before { background: var(--ink-t5); }
.status.t-danger::before { background: var(--danger); }
/* Tag: clasificación neutra; azul para conteos; con punto para tecnología */
.tag { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-pill); background: var(--ui-fill); font-size: 12px; font-weight: 500; color: var(--ink); white-space: nowrap; }
.tag-blue { background: var(--blue-t9); color: var(--blue-s4); }
.tag-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-dot.t-orange::before { background: var(--orange); }
.tag-dot.t-yellow::before { background: var(--yellow); }
.tag-dot.t-green::before { background: var(--green); }
.tag-dot.t-blue::before { background: var(--blue); }
/* Muestra de color de producto */
.swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; box-shadow: inset 0 0 0 1px rgba(32,33,36,.18); }
.color-cell { display: inline-flex; align-items: center; gap: 8px; }
.person { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
/* Miniatura de producto */
.thumb { width: 44px; height: 44px; border-radius: var(--r-2); background: var(--ui-fill); flex: none; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-t5); overflow: hidden; }

/* Link de texto (dominios, mails, teléfonos) */
.ui-link { color: var(--blue-s3); text-decoration: none; }
.ui-link:hover { text-decoration: underline; }

@media (max-width: 760px) {
  .mh-inner { padding: 0 16px; }
  .mh-role { display: none; }
  .app-main { padding: 20px 16px 40px; }
  .search { min-width: 0; width: 100%; }
  .page-actions { width: 100%; }
}

/* ---------- Toast: tarjeta tinta + punto de estado (nunca color solo) ---------- */
.ui-toast { display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 400px; padding: 12px 16px; border-radius: var(--ui-radius-card);
  background: var(--ink); color: #FFFFFF; box-shadow: var(--ui-shadow-pop); font-family: var(--font-sans); font-size: 14px; line-height: 1.4;
  animation: uiToastIn var(--dur-base) var(--ease-out); }
.ui-toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex: none; }
.ui-toast-success::before { background: var(--green); }
.ui-toast-error { background: var(--danger); }
.ui-toast-error::before { background: #FFFFFF; }
.ui-toast-warning::before { background: var(--yellow); }
.ui-toast.removing { opacity: 0; transform: translateY(8px); transition: opacity .25s ease, transform .25s ease; }
@keyframes uiToastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
