/* Paleta y tokens de diseño: fuente única en shared/static/rols-tokens.css
   (servido en /shared/rols-tokens.css). No redefinir aquí. */
@import url("/shared/rols-tokens.css");

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-page);
  color: #2a2a2a;
}
.sidebar { background: var(--bg-sidebar); color: var(--text-sidebar); }
.rols-logo {
  /* Logo oficial: PNG negro sobre transparente. brightness(0) lo deja
     totalmente negro y invert(1) lo pasa a blanco, asi se ve blanco
     sobre el fondo oliva del sidebar. */
  width: 150px; height: auto; display: block;
  filter: brightness(0) invert(1);
}
.sidebar a {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 0.85rem; border-radius: 0.5rem;
  font-size: 0.875rem; color: var(--text-sidebar);
  transition: background 0.15s;
}
.sidebar a:hover { background: var(--bg-sidebar-hover); }
.sidebar a.active { background: var(--bg-sidebar-active); color: var(--text-sidebar-active); font-weight: 500; }
.sidebar a .check {
  width: 16px; height: 16px; border: 1.5px solid #888879; border-radius: 4px;
  display: inline-block; flex-shrink: 0;
}
.sidebar a.active .check { background: var(--accent); border-color: var(--accent); }
.btn-accent {
  background: var(--accent); color: #fff; border-radius: 999px;
  padding: 0.55rem 1.1rem; font-size: 0.875rem; font-weight: 500;
  transition: background 0.15s;
}
.btn-accent:hover { background: var(--accent-hover); }
.btn-outline {
  background: transparent; border: 1px solid #d4cfc0; color: var(--text-sidebar);
  border-radius: 999px; padding: 0.55rem 1.1rem; font-size: 0.875rem;
  transition: background 0.15s;
}
.btn-outline:hover { background: var(--bg-sidebar-hover); }
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 18px; }
.input-line {
  width: 100%; padding: 0.7rem 0.95rem; border-radius: 14px;
  border: 1px solid var(--border); background: #fff; font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-line:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(179,153,98,0.15); }
.step-badge {
  width: 28px; height: 28px; border-radius: 999px;
  background: #D6E7F2; color: #004876;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 600; flex-shrink: 0;
}
.pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 0.95rem; border-radius: 999px;
  font-size: 0.85rem; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); background: #fff;
  transition: all 0.15s;
}
.pill .swatch {
  width: 14px; height: 14px; border-radius: 3px;
  background: linear-gradient(135deg,#005E94 30%, #fff 30% 35%, #005E94 35%);
}
.pill.active { background: var(--accent-soft); border-color: var(--accent); color: #004876; }
.badge-status {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.65rem; border-radius: 999px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.03em;
  text-transform: uppercase;
}
.badge-correcto { background: #d6efd6; color: #1f5d2c; }
.badge-saldo { background: #e8dfc9; color: #6b5b2b; }
.badge-aprestado { background: #ddeaf3; color: #294f6b; }
.badge-anotaciones { background: #f3e5d0; color: #6b4a25; }
.badge-agotado { background: #f3d4d4; color: #6f1f1f; }
.badge-defectuoso { background: #f3d4e2; color: #6f1f45; }
.badge-encurso { background: #f3ecd0; color: #6b5a25; }
.badge-lanzada { background: #d6e4f3; color: #2c4a6b; }
.badge-planif { background: #ede4f3; color: #4a2c6b; }
.badge-correcto .dot, .badge-saldo .dot, .badge-aprestado .dot,
.badge-anotaciones .dot, .badge-agotado .dot,
.badge-defectuoso .dot, .badge-encurso .dot,
.badge-lanzada .dot, .badge-planif .dot {
  width: 6px; height: 6px; border-radius: 999px; background: currentColor;
}
.obs-toggle { cursor: pointer; user-select: none; }
.obs-toggle:hover { filter: brightness(0.92); }
.obs-row td {
  padding: 0 1rem 0.75rem !important;
  border-bottom: 1px solid #EDF2F6;
}
.obs-content {
  background: #EDF2F6; border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 8px;
  padding: 0.75rem 1rem; font-size: 0.85rem; color: #004876; line-height: 1.5;
}
.obs-content > div + div { margin-top: 0.45rem; }
.obs-content strong { color: #323F49; }

/* ---- Badge "Reservas" en la celda de longitud no comprometida ---- */
.libre-cell { display: inline-flex; align-items: center; gap: 0.55rem; }
.res-badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: #EDF2F6; border: 1px solid var(--border);
  color: #004876; font-size: 0.7rem; font-weight: 500;
  padding: 0.18rem 0.55rem; border-radius: 999px;
  cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s;
  font-family: inherit; line-height: 1;
}
.res-badge:hover { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent); }
.res-badge svg { stroke: currentColor; }

/* ---- Fila expandida con el detalle de reservas ---- */
.res-row td {
  padding: 0 1rem 0.75rem !important;
  border-bottom: 1px solid #EDF2F6;
  background: #F7F9FB;
}
.res-content {
  background: #fff; border: 1px solid var(--border);
  border-left: 3px solid #004876; border-radius: 8px;
  padding: 0.85rem 1rem; font-size: 0.82rem; color: #323F49;
}
.res-grid { display: flex; flex-direction: column; gap: 0.9rem; }
.res-section-title {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: #7A7A7A;
  margin-bottom: 0.4rem;
}
.res-section-firme  { color: #294f6b; }
.res-section-manual { color: #6b4a25; }
.res-count {
  display: inline-block; min-width: 1.4em; text-align: center;
  background: var(--accent-soft); color: var(--accent-hover);
  font-size: 0.65rem; padding: 0.05rem 0.45rem; border-radius: 999px;
  letter-spacing: 0;
}
.res-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.res-table thead th {
  text-align: left; font-weight: 600; color: #9a9a9a;
  font-size: 0.65rem; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 0.3rem 0.55rem; border-bottom: 1px solid #EDF2F6;
}
.res-table tbody td {
  padding: 0.35rem 0.55rem;
  border-bottom: 1px solid #F8F5F1;
}
.res-table tbody tr:last-child td { border-bottom: none; }
.res-table .num { font-variant-numeric: tabular-nums; font-weight: 600; color: #2a2a2a; }
.res-table .user-cell { color: #7A7A7A; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.72rem; }
.res-table .cli-code { font-size: 0.7rem; color: #9a9a9a; }
.res-table .obs-cell { color: #6a6a6a; font-style: italic; max-width: 280px; }
/* Ocultar columna de fecha fin fabricacion cuando solo hay stock */
table.no-fab .col-fab { display: none; }
/* Dropdown custom de referencia (reemplaza al datalist nativo) */
.ref-combo { position: relative; }
.ref-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 14px 38px -10px rgba(77,77,77,0.20);
  z-index: 50; max-height: 380px; overflow: hidden;
  display: flex; flex-direction: column;
  animation: refDropdownIn 0.12s ease-out;
}
@keyframes refDropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.ref-dropdown-header {
  padding: 0.55rem 1rem; font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: #7A7A7A; background: #F7F9FB;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ref-dropdown-list { overflow-y: auto; flex: 1; padding: 0.25rem 0; }
.ref-group + .ref-group { border-top: 1px solid #EDF2F6; }
.ref-group-header {
  padding: 0.55rem 1rem 0.45rem; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: #004876;
  /* z-index: 2 garantiza que el header sticky se quede por encima de las
   * .ref-option que scrollean por detras (el thumbnail tiene position:
   * relative, lo que sin z-index lo deja flotando sobre el header). */
  position: sticky; top: 0; z-index: 2;
  background: #fff;
  box-shadow: 0 1px 0 #EDF2F6;
}
.ref-option {
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background 0.08s;
  display: flex; align-items: center; gap: 0.65rem;
}
.ref-option:hover, .ref-option.active {
  background: var(--accent-soft);
}
/* Thumbnail del color (mismas reglas que la calculadora para que la UX
 * sea identica). Si la imagen no existe, el wrap usa el patron diagonal
 * crema para no romper el layout. */
.ref-option-thumb-wrap {
  width: 36px; height: 36px; border-radius: 6px;
  background: #f5efe7;
  box-shadow: 0 0 0 1px rgba(77,77,77,0.08);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.ref-option-thumb-wrap.ref-option-thumb-empty {
  background: repeating-linear-gradient(135deg, #f5efe7, #f5efe7 4px, #ece4d6 4px, #ece4d6 8px);
}
.ref-option-thumb {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.ref-option-text { flex-grow: 1; min-width: 0; }
.ref-option-label {
  font-size: 0.875rem; font-weight: 500; color: #2a2a2a; line-height: 1.25;
}
.ref-option-full {
  font-size: 0.72rem; color: #7A7A7A; margin-top: 0.1rem; line-height: 1.2;
}
.ref-option:hover .ref-option-label,
.ref-option.active .ref-option-label { color: #004876; }
.ref-option:hover .ref-option-full,
.ref-option.active .ref-option-full { color: #323F49; }
.ref-option mark {
  background: rgba(213,179,140,0.35); color: inherit;
  border-radius: 2px; padding: 0 1px;
}
.ref-empty {
  padding: 1.75rem 1rem; text-align: center; color: #7A7A7A;
  font-size: 0.875rem;
}
.row-highlight { background: var(--accent-soft); }
.row-highlight td:first-child { border-left: 3px solid var(--accent); padding-left: calc(1rem - 3px); }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 0.7rem; font-weight: 600;
  color: #7A7A7A; padding: 0.85rem 1rem; letter-spacing: 0.05em; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 0.95rem 1rem; font-size: 0.875rem; color: #2a2a2a;
  border-bottom: 1px solid #EDF2F6;
}
tbody tr:last-child td { border-bottom: none; }
.link-action { color: #004876; font-size: 0.8rem; text-decoration: underline; text-underline-offset: 3px; }
.link-action:hover { color: var(--accent); }
.breadcrumb { font-size: 0.85rem; color: #7A7A7A; }
.breadcrumb a { color: #7A7A7A; }
.breadcrumb a:hover { color: var(--accent); }
.sync-pill {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: #fff; border: 1px solid var(--border);
  padding: 0.4rem 0.85rem; border-radius: 999px; font-size: 0.78rem; color: #7A7A7A;
}
.sync-pill .dot { width: 8px; height: 8px; background: #5cba78; border-radius: 999px; }
.spinner { border: 2px solid #eee; border-top: 2px solid var(--accent); border-radius: 50%; width: 14px; height: 14px; animation: spin 0.6s linear infinite; }

/* Versión "boton" del sync-pill: clickable, con hover, y estados visuales
 * para sincronizando / ok / error. Reutiliza el resto del estilo de .sync-pill. */
.sync-btn {
  cursor: pointer; transition: background 0.12s, border-color 0.12s, color 0.12s;
  font-family: inherit;
}
.sync-btn:hover { background: #F7F9FB; border-color: #005E94; color: #323F49; }
.sync-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sync-btn .sync-sep { color: #C9C2BA; }
.sync-btn .sync-icon { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; }
.sync-btn .sync-icon .spinner { width: 12px; height: 12px; }

/* Estado: sincronizando */
.sync-btn.is-loading { cursor: wait; color: #323F49; }
.sync-btn.is-loading:hover { background: #fff; }

/* Estado: ok (verde discreto, vuelve a normal tras unos segundos) */
.sync-btn.is-ok { background: #E8F3E8; border-color: #b8d8b8; color: #1f5d2c; }
.sync-btn.is-ok .dot { background: #1f5d2c; }

/* Estado: error (rojo suave) */
.sync-btn.is-error { background: #F8E0E0; border-color: #d8b8b8; color: #6f1f1f; }
.sync-btn.is-error .dot { background: #6f1f1f; }
.sync-btn:disabled { cursor: not-allowed; opacity: 0.6; }
@keyframes spin { to { transform: rotate(360deg); } }
.ia-avatar {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 999px;
  background: #D6E7F2; color: #004876; display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em;
}
.ia-bubble {
  background: #fff; border: 1px solid var(--border); border-radius: 18px;
  padding: 1.1rem 1.25rem; font-size: 0.9rem; color: #2a2a2a; line-height: 1.5;
}
.ia-bubble strong { color: #323F49; }
.user-avatar {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 999px;
  background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em;
}
.user-bubble {
  background: var(--accent-soft); border: 1px solid #E2C9A9; border-radius: 18px;
  padding: 1.1rem 1.25rem; font-size: 0.9rem; color: #323F49; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
#search-context {
  position: sticky; top: 1rem; z-index: 5;
}
.search-pill {
  display: inline-flex; align-items: center; gap: 0.65rem;
  background: var(--accent); border: none;
  padding: 0.7rem 1.15rem; border-radius: 14px; font-size: 0.9rem;
  box-shadow: 0 6px 20px -8px rgba(77, 77, 77, 0.35);
  max-width: 100%;
}
.search-pill .icon { color: rgba(255,255,255,0.9); flex-shrink: 0; }
.search-pill .label {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: rgba(255,255,255,0.78); font-weight: 600; flex-shrink: 0;
}
.search-pill .value {
  color: #fff; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.empty-state { text-align: center; color: #7A7A7A; padding: 3rem 1rem; font-size: 0.9rem; }
/* Boton de microfono (dictado por voz) */
.mic-btn {
  position: absolute; right: 0.45rem; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; padding: 0;
  border: none; background: transparent; color: #7A7A7A;
  border-radius: 999px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.mic-btn:hover { background: var(--accent-soft); color: var(--accent); }
.mic-btn.listening {
  color: #fff; background: #C0392B;
  animation: micPulse 1.4s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192,57,43,0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(192,57,43,0); }
}
.mic-btn.unsupported { display: none; }
/* Selector de idioma */
.lang-block {
  padding: 0 0.5rem; margin-bottom: 0.75rem;
}
.lang-block .lang-label {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: rgba(214,212,200,0.55); font-weight: 600;
  margin-bottom: 0.4rem; display: block;
}
.lang-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.3rem; }
.lang-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.35rem;
  padding: 0.38rem 0.3rem;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em;
  border: 1px solid rgba(214,212,200,0.18);
  background: transparent; color: var(--text-sidebar);
  border-radius: 0.45rem; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-align: center;
}
/* Banderas via flag-icons: tamano consistente independiente del SO */
.lang-btn .fi {
  width: 1.15rem; height: 0.85rem; border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.lang-btn .code { line-height: 1; }
.lang-btn:hover { background: var(--bg-sidebar-hover); color: var(--text-sidebar-active); }
.lang-btn.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* (Estilos .chatbot-* ELIMINADOS: el widget chatbot inline se reemplazo
 *  por el widget compartido shared/static/chatbot/. Sus estilos viven
 *  ahora en chatbot.css, prefijados con .rols-chatbot- para no chocar
 *  con clases de la app que lo monta.) */

/* ----- Segmented control de unidad (cm / m) — portado de la calc ----- */
.unit-switch {
  display: inline-flex; background: var(--soft-bg, #EDF2F6);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 2px;
}
.unit-btn {
  padding: 0.25rem 0.7rem; font-size: 0.72rem; font-weight: 600;
  color: #7A7A7A; background: transparent;
  border-radius: 999px; cursor: pointer;
  transition: all 0.12s;
  letter-spacing: 0.02em;
  font-family: inherit; border: none;
}
.unit-btn:hover { color: var(--accent-hover); }
.unit-btn.active {
  background: var(--accent); color: #fff;
  box-shadow: 0 1px 3px rgba(213,179,140,0.4);
}

/* =================================================================
 * Pop-up "Alternativas con stock": cuando la ref consultada no tiene
 * stock suficiente, ofrece las alternativas de su ficha que SÍ tienen
 * piezas que encajan con las medidas pedidas. Click → consulta esa ref.
 * ================================================================= */
.alt-popup-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(42, 42, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: altPopupFade 0.15s ease-out;
}
@keyframes altPopupFade { from { opacity: 0; } to { opacity: 1; } }
.alt-popup-card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #DDE3EA);
  border-radius: 18px;
  max-width: 560px; width: 100%;
  max-height: 82vh; overflow-y: auto;
  padding: 1.3rem 1.5rem 1.4rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
}
.alt-popup-titulo { font-size: 1rem; font-weight: 600; color: #2a2a2a; }
.alt-popup-sub { font-size: 0.82rem; color: #7A7A7A; margin-top: 0.25rem; line-height: 1.45; }
.alt-popup-item {
  display: flex; gap: 0.75rem; align-items: center;
  border: 1px solid var(--border, #DDE3EA); border-radius: 12px;
  padding: 0.6rem 0.75rem; margin-top: 0.55rem;
  cursor: pointer; transition: all 0.12s; background: #fff;
}
.alt-popup-item:hover { border-color: var(--accent, #005E94); background: var(--accent-soft, #D6E7F2); }
.alt-popup-thumb {
  width: 46px; height: 46px; border-radius: 8px; object-fit: cover;
  flex-shrink: 0; background: #f5efe7;
  box-shadow: 0 0 0 1px rgba(77,77,77,0.08);
}
.alt-popup-tier {
  display: inline-block; margin-left: 0.4rem;
  background: var(--accent-soft, #D6E7F2); color: var(--accent-hover, #004876);
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.05em;
  padding: 0.1rem 0.45rem; border-radius: 999px; vertical-align: middle;
}
.alt-popup-cerrar {
  margin-top: 1rem; width: 100%;
  background: transparent; border: 1px solid var(--border, #DDE3EA);
  color: #7A7A7A; border-radius: 999px; padding: 0.5rem;
  font-size: 0.82rem; cursor: pointer; transition: background 0.12s;
}
.alt-popup-cerrar:hover { background: var(--soft-bg, #EDF2F6); }
/* Primera opción del pop-up cuando hay fabricación en curso de la propia
   referencia: borde azul (mismo tono que el badge "Lanzada"). */
.alt-popup-item-fab { border-left: 3px solid #2c4a6b; }
.alt-popup-fab-badge {
  display: inline-block; margin-left: 0.4rem;
  background: #d6e4f3; color: #2c4a6b;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.05em;
  padding: 0.1rem 0.45rem; border-radius: 999px; vertical-align: middle;
  text-transform: uppercase;
}
/* Cabeceras de sección del pop-up (fabricación vs alternativas) y bloque
   de fecha planificada destacada en la tarjeta de fabricación. */
.alt-popup-seccion {
  font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--accent-hover, #004876);
  margin-top: 1rem;
}
.alt-popup-item-fab .alt-popup-seccion { margin-top: 0; }
.alt-popup-fecha {
  flex-shrink: 0; text-align: center;
  background: #d6e4f3; border-radius: 10px;
  padding: 0.35rem 0.65rem;
}
.alt-popup-fecha-label {
  font-size: 0.58rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: #5a7793;
}
.alt-popup-fecha-valor {
  font-size: 0.92rem; font-weight: 700; color: #2c4a6b;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
