/* ===== BEXIE DOCUMENTATION — Vista agrupada por producto ===== */

.bexie-doc-wrap{
  --bexie-teal:#078586;
  --bexie-blue:#1A3967;
  margin:40px 0;
  font-family:inherit;
}

/* Toolbar / buscador */
.bexie-doc-toolbar{ margin-bottom:18px; }
.bexie-doc-search input{
  width:100%;
  padding:13px 16px;
  border-radius:10px;
  border:1px solid #e2e8f0;
  font-size:15px;
  outline:none;
  box-sizing:border-box;
  transition:border-color .2s, box-shadow .2s;
}
.bexie-doc-search input:focus{
  border-color:var(--bexie-teal);
  box-shadow:0 0 0 3px rgba(7,133,134,.12);
}

/* Chips de filtro */
.bexie-doc-chips{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom:24px; }
.bexie-chip{
  font-size:13px;
  padding:7px 16px;
  border-radius:100px;
  border:1px solid #d7dde3;
  background:#fff;
  color:#475569;
  cursor:pointer;
  transition:all .18s;
}
.bexie-chip:hover{ border-color:var(--bexie-teal); color:var(--bexie-teal); }
.bexie-chip.is-active{
  background:var(--bexie-teal);
  border-color:var(--bexie-teal);
  color:#fff;
}

/* Grupos (producto) */
.bexie-doc-group{
  background:#fff;
  border:1px solid #eef1f4;
  border-radius:14px;
  margin-bottom:14px;
  box-shadow:0 2px 10px rgba(26,57,103,.04);
  overflow:hidden;
}
.bexie-group-head{
  width:100%;
  display:flex;
  align-items:center;
  gap:14px;
  padding:18px 22px;
  background:transparent;
  border:none;
  cursor:pointer;
  text-align:left;
}
.bexie-group-title{
  font-size:17px;
  font-weight:600;
  color:var(--bexie-blue);
  flex:1;
}
.bexie-group-meta{
  font-size:13px;
  color:#94a3b8;
  white-space:nowrap;
}
.bexie-group-arrow{
  width:10px; height:10px;
  border-right:2px solid #94a3b8;
  border-bottom:2px solid #94a3b8;
  transform:rotate(45deg);
  transition:transform .25s;
  flex-shrink:0;
}
.bexie-doc-group.open .bexie-group-arrow{ transform:rotate(-135deg); }

/* Cuerpo plegable */
.bexie-group-body{
  max-height:0;
  overflow:hidden;
  transition:max-height .3s ease;
}
.bexie-doc-group.open .bexie-group-body{ max-height:3000px; }

/* Tabla de documentos */
.bexie-doc-table{
  width:100%;
  border-collapse:collapse !important;
  border-spacing:0 !important;
  font-size:14px;
  border:0 !important;
}
/* Reset agresivo: el tema mete border + border-radius por celda. Lo anulamos. */
.bexie-doc-table tr,
.bexie-doc-table td,
.bexie-doc-table th,
.bexie-doc-table tbody,
.bexie-doc-table thead{
  border:0 !important;
  border-radius:0 !important;
  background-image:none !important;
  box-shadow:none !important;
}
.bexie-doc-table thead th{
  text-align:left;
  font-weight:600;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.04em;
  color:#94a3b8;
  padding:10px 22px;
  background:#fafbfc;
}
.bexie-doc-table th.col-act,
.bexie-doc-table td.col-act{ text-align:right; white-space:nowrap; }
.bexie-doc-table th.col-type,
.bexie-doc-table td.col-type{ width:150px; }
/* Una sola línea fina separando filas */
.bexie-doc-table tbody tr{ border-top:1px solid #eef1f4 !important; }
.bexie-doc-table tbody tr:hover{ background:#fafdfd; }
.bexie-doc-table tbody td{
  padding:13px 22px;
  vertical-align:middle;
  color:#334155;
}
.bexie-doc-table td.col-doc{ display:flex; align-items:center; gap:10px; }
.bexie-doc-ico{ width:22px; height:22px; flex-shrink:0; }

/* Tags de tipo */
.bexie-type-tag{
  display:inline-block;
  font-size:12px;
  font-weight:500;
  padding:4px 11px;
  border-radius:7px;
  white-space:nowrap;
}
.type-manual    { background:#e6f1fb; color:#185fa5; }
.type-guia      { background:#e1f5ee; color:#0f6e56; }
.type-cert      { background:#faeeda; color:#854f0b; }
.type-datasheet { background:#eeedfe; color:#3c3489; }
.type-garantia  { background:#fbeaf0; color:#993556; }
.type-otros     { background:#f1f0eb; color:#5f5e5a; }

/* Acciones */
.col-act a{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:34px; height:34px;
  border-radius:8px;
  margin-left:6px;
  text-decoration:none;
  border:1px solid #e2e8f0;
  color:#64748b;
  transition:all .18s;
}
.col-act a svg{ display:block; }
.col-act a.doc-preview:hover{ border-color:var(--bexie-teal); color:var(--bexie-teal); }
.col-act a.doc-download{
  background:var(--bexie-teal);
  border-color:var(--bexie-teal);
  color:#fff;
}
.col-act a.doc-download:hover{ background:#066a6b; }

/* Estados vacíos */
.bexie-doc-empty,
.bexie-doc-noresults{
  text-align:center;
  color:#94a3b8;
  padding:40px 20px;
  font-size:15px;
}

/* Modal previsualización */
.doc-modal{
  display:none;
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.7);
  z-index:99999;
  align-items:center;
  justify-content:center;
  padding:30px;
}
.doc-modal-content{
  position:relative;
  width:min(900px,92vw);
  height:min(85vh,800px);
  background:#fff;
  border-radius:14px;
  overflow:hidden;
}
.doc-modal-content iframe{ width:100%; height:100%; border:0; }
.doc-close{
  position:absolute;
  top:10px; right:14px;
  width:36px; height:36px;
  border-radius:50%;
  border:none;
  background:rgba(0,0,0,.55);
  color:#fff;
  font-size:22px;
  line-height:1;
  cursor:pointer;
  z-index:2;
}


/* Contenedor PDF.js dentro del modal */
#doc-pdf-wrap{
  width:100%;
  height:100%;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  background:#525659;
  padding:8px;
  box-sizing:border-box;
}
.doc-pdf-page{ display:block; width:100%; height:auto; margin:0 auto 8px; box-shadow:0 1px 6px rgba(0,0,0,.4); }
.doc-pdf-msg{ color:#fff; text-align:center; padding:24px; font-size:14px; }
.doc-pdf-msg a{ color:var(--bexie-teal); text-decoration:underline; }

/* Modal responsive en móvil */
@media (max-width:768px){
  .doc-modal-content{
    width:100%; max-width:100%; height:90vh;
    margin:0; border-radius:0; box-sizing:border-box;
  }
  .doc-modal-content iframe{ height:100%; }
}
/* Responsive */
@media(max-width:640px){
  .bexie-group-head{ padding:15px 16px; }
  .bexie-doc-table thead{ display:none; }
  .bexie-doc-table td{ padding:10px 16px; }
  .bexie-doc-table td.col-type{ width:auto; }
}
.bexie-group-head:hover{ background:#cfeeee; }


@media (max-width: 768px) {
  /* Fila: icono+texto a la izquierda | acciones a la derecha */
  .bexie-doc-item {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 12px;
    padding: 14px 16px;
  }

  .bexie-doc-item td { display: contents; }

  /* Bloque izquierdo: icono + (nombre encima del tag) */
  .bexie-doc-item .col-doc {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-columns: auto 1fr;   /* icono | nombre */
    align-items: center;
    column-gap: 10px;
    min-width: 0;
  }
  .bexie-doc-item .bexie-doc-ico {
    width: 28px;
    height: 28px;
    grid-row: 1 / span 2;              /* el icono ocupa nombre+tag (centrado) */
    align-self: center;
    flex: 0 0 auto;
  }
  .bexie-doc-item .col-doc span {
    font-size: 14px;
    font-weight: 600;
    color: #1A3967;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }

  /* El tag, justo debajo del nombre y alineado con él (no con el icono) */
  .bexie-doc-item .col-type {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
    margin-left: 38px;                /* 28px icono + 10px gap = alinea con el nombre */
    margin-top: 3px;
  }
  .bexie-doc-item .bexie-type-tag {
    font-size: 11px;
    padding: 2px 10px;
  }

  /* Acciones a la derecha, centradas en vertical respecto a todo el bloque */
  .bexie-doc-item .col-act {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
  }
  .bexie-doc-item .doc-preview,
  .bexie-doc-item .doc-download {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    flex: 0 0 auto;
  }
}

@media (max-width: 768px) {
  .bexie-doc-item {
    display: grid;
    grid-template-columns: 1fr auto;   /* texto | acciones */
    align-items: center;
    column-gap: 12px;
    padding: 14px 16px;
  }
  .bexie-doc-item td { display: contents; }

  /* Bloque izquierdo: icono + (nombre sobre tag) */
  .bexie-doc-item .col-doc {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
  }
  .bexie-doc-item .bexie-doc-ico { width: 32px; height: 32px; flex: 0 0 auto; }

  .bexie-doc-item .bexie-doc-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;   /* tag justo bajo el nombre, sin márgenes mágicos */
    gap: 4px;
    min-width: 0;
  }
  .bexie-doc-item .bexie-doc-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--bexie-blue);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
  .bexie-doc-item .bexie-type-tag { font-size: 11px; padding: 2px 10px; }

  /* La columna de tipo ya no se usa en móvil (el tag está dentro de col-doc) */
  .bexie-doc-item .col-type { display: none; }

  .bexie-doc-item .col-act {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
  }
  .bexie-doc-item .doc-preview,
  .bexie-doc-item .doc-download {
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9px; flex: 0 0 auto;
    margin-left: 0;   /* anula el margin-left:6px del .col-act a base */
  }
}