/* Garantiza que los elementos ocultos por JavaScript no sean mostrados
   por otras reglas CSS (p. ej. .state-card { display: grid; }). */
[hidden] {
  display: none !important;
}

:root {
  --endoalba-blue: #2A2C9F;
  --endoalba-blue-dark: #23258A;
  --bg: #eef5ff;
  --surface: #ffffff;
  --surface-soft: #f4f8ff;
  --text: #1f2937;
  --muted: #64748b;
  --line: #d5e2f3;
  --line-strong: #b9cce5;
  --primary: #1677d2;
  --primary-dark: #0d5fae;
  --primary-soft: #e9f4ff;
  --danger-soft: #fff1f2;
  --danger: #be123c;
  --shadow: 0 12px 32px rgba(23, 93, 156, .09);
  --radius: 14px;
  --radius-sm: 9px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}
button, input { font: inherit; }
button { cursor: pointer; }
.shell {
  width: min(1500px, calc(100% - 32px));
  margin-inline: auto;
}

.app-header {
  background: linear-gradient(135deg, #ffffff 0%, #edf7ff 58%, #dceeff 100%);
  border-bottom: 1px solid #c9def3;
  box-shadow: 0 4px 18px rgba(22, 119, 210, .06);
  padding: 28px 0 24px;
}
.eyebrow, .section-kicker {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: .75rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2.6vw, 2.25rem);
  letter-spacing: -.025em;
  line-height: 1.12;
}
.subtitle {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 1rem;
}
.app-layout {
  display: grid;
  grid-template-columns: minmax(270px, 320px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  padding-block: 24px;
}

.filter-panel, .content-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.filter-panel {
  border-top: 3px solid #70b8ef;
}
.content-panel {
  border-top: 3px solid var(--primary);
}
.filter-panel {
  padding: 20px;
  position: sticky;
  top: 16px;
}
.panel-heading, .toolbar, .table-footer, .result-line {
  display: flex;
  align-items: center;
}
.panel-heading, .toolbar, .table-footer {
  justify-content: space-between;
  gap: 14px;
}
.panel-heading h2 {
  margin: 0;
  font-size: 1.35rem;
}
.content-panel { min-width: 0; overflow: hidden; }
.toolbar {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.result-line { gap: 9px; flex-wrap: wrap; }
#resultCount { font-size: 1.05rem; }
#activeFilterText {
  color: var(--muted);
  font-size: .88rem;
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 8px 11px;
  font-weight: 650;
}
.btn-secondary {
  color: #0f5f9f;
  background: #eef7ff;
  border: 1px solid #c9e1f6;
}
.btn-secondary:hover:not(:disabled) {
  background: #dceeff;
  border-color: #9dc9ed;
}
.btn:disabled { opacity: .45; cursor: default; }

.filter-group {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.filter-label {
  display: block;
  margin-bottom: 8px;
  font-size: .9rem;
  font-weight: 700;
}
.multi-select { position: relative; }
.select-button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.select-button:hover { border-color: #94a3b8; }
.select-button:focus-visible,
.search-box input:focus-visible,
input[type="range"]:focus-visible {
  outline: 3px solid rgba(37,99,235,.17);
  outline-offset: 1px;
}
.select-button-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.select-menu {
  position: absolute;
  z-index: 30;
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: 0 16px 38px rgba(15, 23, 42, .16);
}
.select-menu-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  padding: 1px 2px 7px;
  border-bottom: 1px solid var(--line);
}
.select-menu-actions button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: .78rem;
  font-weight: 700;
}
.select-options {
  max-height: 260px;
  overflow-y: auto;
  padding-top: 5px;
}
.select-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 6px;
  border-radius: 7px;
  font-size: .88rem;
}
.select-option:hover { background: var(--surface-soft); }
.select-option input { accent-color: var(--primary); }

.range-group {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.range-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}
.range-title { font-size: .9rem; font-weight: 700; }
.range-values { color: var(--primary-dark); font-size: .82rem; font-weight: 700; white-space: nowrap; }
.dual-range {
  position: relative;
  height: 34px;
  margin: 3px 0 1px;
}
.range-track {
  position: absolute;
  inset: 15px 0 auto;
  height: 4px;
  border-radius: 99px;
  background: #e2e8f0;
}
.range-fill {
  position: absolute;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}
.dual-range input[type="range"] {
  position: absolute;
  left: 0;
  top: 4px;
  width: 100%;
  margin: 0;
  pointer-events: none;
  appearance: none;
  background: transparent;
}
.dual-range input[type="range"]::-webkit-slider-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px #94a3b8, 0 2px 5px rgba(15,23,42,.18);
  background: var(--primary);
  appearance: none;
  pointer-events: auto;
}
.dual-range input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px #94a3b8, 0 2px 5px rgba(15,23,42,.18);
  background: var(--primary);
  pointer-events: auto;
}
.range-minmax {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: .72rem;
}

.units-note {
  margin-top: 20px;
  padding: 13px 14px;
  background: var(--surface-soft);
  border-radius: 10px;
  color: var(--muted);
  font-size: .79rem;
}
.units-note h3 { margin: 0 0 5px; color: var(--text); font-size: .85rem; }
.units-note p { margin: 0; }

.search-box {
  min-width: min(310px, 100%);
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 0 10px;
  background: var(--surface);
}
.search-box svg {
  width: 18px; height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}
.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  padding: 9px 0;
  background: transparent;
  color: var(--text);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.table-scroll { overflow: auto; max-height: 70vh; }
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .82rem;
  white-space: nowrap;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #eaf4ff;
  color: #475569;
  border-bottom: 1px solid var(--line);
  padding: 10px 11px;
  text-align: left;
  font-size: .75rem;
  letter-spacing: .015em;
}
tbody td {
  padding: 9px 11px;
  border-bottom: 1px solid #e5edf6;
  color: #334155;
  background: transparent !important;
}
tbody tr:nth-child(odd) {
  background-color: #ffffff !important;
}
tbody tr:nth-child(even) {
  background-color: #dfeefb !important;
}
tbody tr:nth-child(odd) td,
tbody tr:nth-child(even) td {
  background-color: inherit !important;
}
tbody tr:hover,
tbody tr:hover td {
  background-color: #cfe5f8 !important;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--primary); }
.sort-indicator { color: #94a3b8; padding-left: 4px; }
th.sorted .sort-indicator { color: var(--primary); }

.table-footer {
  padding: 13px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .82rem;
}
.pagination { display: flex; align-items: center; gap: 8px; }
#pageInfo { min-width: 80px; text-align: center; }

.state-card {
  min-height: 230px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: var(--muted);
  padding: 30px;
  text-align: center;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid #dbeafe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.state-card.error { background: var(--danger-soft); color: var(--danger); }
.state-card.error h3, .state-card.error p { margin: 0; }

.disclaimer {
  margin-bottom: 28px;
  padding: 15px 17px;
  border: 1px solid #fde68a;
  border-radius: 11px;
  background: #fffbeb;
  color: #713f12;
  font-size: .82rem;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media (max-width: 900px) {
  .shell { width: min(100% - 22px, 1500px); }
  .app-layout { grid-template-columns: 1fr; gap: 14px; padding-block: 14px; }
  .filter-panel { position: static; }
  .table-scroll { max-height: none; }
}
@media (max-width: 600px) {
  .app-header { padding: 20px 0 18px; }
  .filter-panel, .content-panel { border-radius: 11px; }
  .filter-panel { padding: 16px; }
  .toolbar { padding: 15px; align-items: stretch; }
  .search-box { min-width: 100%; }
  .table-footer { align-items: flex-start; flex-direction: column; }
  table { font-size: .79rem; }
  thead th, tbody td { padding: 9px 9px; }
}


/* --- Ajustes tabla v4: filas alternas y primera columna fija --- */

/* Zebra striping aplicado directamente a las celdas */
#resultsTable tbody tr:nth-child(odd) > td {
  background-color: #ffffff !important;
}
#resultsTable tbody tr:nth-child(even) > td {
  background-color: #dfeefb !important;
}
#resultsTable tbody tr:hover > td {
  background-color: #cfe5f8 !important;
}

/* Primera columna fija al hacer scroll horizontal */
#resultsTable th:first-child,
#resultsTable td:first-child {
  position: sticky;
  left: 0;
}

/* Cabecera de la primera columna por encima del resto */
#resultsTable th:first-child {
  z-index: 25;
  background-color: #eaf4ff !important;
}

/* Mantener el zebra striping también en la primera columna fija */
#resultsTable tbody tr:nth-child(odd) > td:first-child {
  background-color: #ffffff !important;
}
#resultsTable tbody tr:nth-child(even) > td:first-child {
  background-color: #dfeefb !important;
}
#resultsTable tbody tr:hover > td:first-child {
  background-color: #cfe5f8 !important;
}

/* Sombra sutil para marcar el límite de la columna fija */
#resultsTable th:first-child,
#resultsTable td:first-child {
  box-shadow: 3px 0 6px rgba(15, 23, 42, .08);
}


/* --- Ajuste v5: contraste visible entre filas --- */
#resultsTable > tbody > tr:nth-child(odd) > td {
  background: #ffffff !important;
}
#resultsTable > tbody > tr:nth-child(even) > td {
  background: #dfeefb !important;
}
#resultsTable > tbody > tr:hover > td {
  background: #cfe5f8 !important;
}

/* La primera columna fija conserva exactamente el fondo de su fila */
#resultsTable > tbody > tr:nth-child(odd) > td:first-child {
  background: #ffffff !important;
}
#resultsTable > tbody > tr:nth-child(even) > td:first-child {
  background: #dfeefb !important;
}
#resultsTable > tbody > tr:hover > td:first-child {
  background: #cfe5f8 !important;
}


/* --- v6: cabecera Endoalba y ficha modal --- */
.site-brand-bar {
  background: var(--endoalba-blue);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(4, 60, 112, .18);
}
.site-brand-inner {
  min-height: 104px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding-block: 18px;
}
.site-logo-link {
  flex: 0 0 auto;
  display: block;
  line-height: 0;
}
.site-logo {
  width: 92px;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,.16);
}
.site-brand-title {
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  font-weight: 760;
  letter-spacing: -.02em;
  line-height: 1.08;
}
.site-brand-subtitle {
  margin-top: 7px;
  max-width: 960px;
  font-size: .93rem;
  line-height: 1.38;
  color: rgba(255,255,255,.9);
}
.app-header {
  background: linear-gradient(135deg, #ffffff 0%, #edf7ff 58%, #dceeff 100%);
  border-bottom: 1px solid #c9def3;
  box-shadow: 0 4px 18px rgba(22, 119, 210, .06);
  padding: 25px 0 22px;
}

#resultsTable tbody tr {
  cursor: pointer;
}
#resultsTable tbody tr:focus-visible > td {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.btn-primary {
  color: #ffffff;
  background: var(--primary);
  border: 1px solid var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(15, 23, 42, .52);
  backdrop-filter: blur(2px);
}
.modal-backdrop[hidden] {
  display: none !important;
}
.product-modal {
  width: min(760px, 100%);
  max-height: min(84vh, 850px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #cbddee;
  border-radius: 16px;
  box-shadow: 0 24px 65px rgba(15, 23, 42, .28);
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 21px 22px 17px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #ffffff 0%, #edf7ff 100%);
}
.modal-header h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.18;
}
.modal-close-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #cbddee;
  border-radius: 9px;
  background: #ffffff;
  color: #475569;
  font-size: 1.55rem;
  line-height: 1;
}
.modal-close-icon:hover {
  color: var(--primary-dark);
  background: #eef7ff;
}
.product-details {
  overflow: auto;
  padding: 8px 22px 12px;
}
.product-detail-row {
  display: grid;
  grid-template-columns: minmax(150px, 34%) 1fr;
  gap: 16px;
  padding: 10px 2px;
  border-bottom: 1px solid #e8eef5;
}
.product-detail-label {
  color: #526477;
  font-size: .84rem;
  font-weight: 700;
}
.product-detail-value {
  color: #1f2937;
  font-size: .9rem;
  overflow-wrap: anywhere;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line);
  background: #f8fbff;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  .site-brand-inner {
    min-height: auto;
    align-items: flex-start;
    gap: 13px;
    padding-block: 14px;
  }
  .site-logo {
    width: 68px;
    height: auto;
    border-radius: 3px;
  }
  .site-brand-title {
    font-size: 1.18rem;
  }
  .site-brand-subtitle {
    font-size: .78rem;
  }
  .modal-backdrop {
    padding: 10px;
    align-items: flex-end;
  }
  .product-modal {
    max-height: 90vh;
    border-radius: 15px 15px 8px 8px;
  }
  .product-detail-row {
    grid-template-columns: 1fr;
    gap: 3px;
    padding: 9px 1px;
  }
}


/* --- v7: identidad Endoalba enlazada --- */
.site-brand-link {
  color: inherit;
  text-decoration: none;
}
.site-brand-link:hover,
.site-brand-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.site-logo-link:focus-visible {
  outline: 3px solid rgba(255,255,255,.8);
  outline-offset: 4px;
  border-radius: 5px;
}


/* --- v8: ajuste fiel de cabecera según endoalba.org.es --- */
.site-brand-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
}
.site-brand-title {
  display: block;
  margin: 0;
  color: #ffffff;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0;
}
.site-brand-subtitle {
  display: block;
  margin: 0;
  color: #ffffff;
  font-size: .86rem;
  font-weight: 400;
  line-height: 1.25;
}
.site-brand-title:hover,
.site-brand-subtitle:hover {
  color: #ffffff;
}
