/* Página Empresa → Calidad (/empresa/calidad/): tarjetas de documentos PDF con
   miniatura y visor a pantalla completa. Se apoya en los estilos generales de las
   subpáginas de empresa (main.css: .info-layout, .info-hero…). */

.calidad-docs { display: grid; gap: 16px; }

.calidad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.calidad-card {
  display: flex;
  flex-direction: column;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e3eaf5);
  border-radius: 18px;
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.calidad-card:hover {
  border-color: color-mix(in srgb, var(--primary, #003471) 30%, var(--border, #e3eaf5));
  box-shadow: 0 16px 36px -22px rgba(15, 51, 108, 0.45);
}

/* Miniatura: la primera página del PDF sobre un fondo suave */
.calidad-thumb {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  height: 236px;
  padding: 22px 28px 0;
  overflow: hidden;
  border: 0;
  border-bottom: 1px solid var(--border, #e3eaf5);
  background: var(--card-alt, #f0f5ff);
  cursor: zoom-in;
}
.calidad-thumb:focus-visible { outline: 3px solid var(--accent, #ffb703); outline-offset: -3px; }
.calidad-thumb-page {
  display: block;
  width: min(100%, 220px);
  aspect-ratio: 210 / 297;
  background: #fff;
  border-radius: 6px 6px 0 0;
  box-shadow: 0 10px 28px -12px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  transform-origin: 50% 0;
  transition: transform 0.25s ease;
}
.calidad-thumb-page canvas { display: block; width: 100%; height: auto; }
.calidad-card:hover .calidad-thumb-page { transform: translateY(-4px); }
.calidad-thumb-skeleton {
  display: block;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.65), transparent) -200px 0 / 200px 100% no-repeat,
    linear-gradient(#e8edf5 0 0) 14% 12% / 60% 7px no-repeat,
    linear-gradient(#eef2f8 0 0) 14% 22% / 72% 5px no-repeat,
    linear-gradient(#eef2f8 0 0) 14% 27% / 66% 5px no-repeat,
    linear-gradient(#eef2f8 0 0) 14% 32% / 70% 5px no-repeat,
    #fff;
  animation: calidad-shimmer 1.3s linear infinite;
}
.calidad-thumb-page.is-failed {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c2410c;
  font-size: 54px;
}
.calidad-thumb-badge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.calidad-thumb:hover .calidad-thumb-badge,
.calidad-thumb:focus-visible .calidad-thumb-badge { opacity: 1; transform: scale(1); }

@keyframes calidad-shimmer { to { background-position: calc(100% + 200px) 0, 14% 12%, 14% 22%, 14% 27%, 14% 32%, 0 0; } }

.calidad-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  padding: 18px 20px 20px;
}
.calidad-card-title {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.35;
  color: var(--primary, #003471);
}
.calidad-card-text { margin: 0; color: var(--text, #0f172a); font-size: 14px; line-height: 1.6; }
.calidad-card-meta {
  margin: 0;
  color: var(--muted, #516072);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.calidad-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.calidad-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.calidad-btn:focus-visible { outline: 3px solid var(--accent, #ffb703); outline-offset: 2px; }
.calidad-btn--primary { background: var(--primary, #003471); color: #fff; }
.calidad-btn--primary:hover { background: color-mix(in srgb, var(--primary, #003471) 86%, #000); color: #fff; }
.calidad-btn--ghost { background: transparent; color: var(--primary, #003471); border-color: var(--border, #e3eaf5); }
.calidad-btn--ghost:hover { border-color: var(--primary, #003471); color: var(--primary, #003471); }
.calidad-btn--icon { justify-content: center; width: 40px; height: 40px; padding: 0; font-size: 16px; }

.calidad-empty { margin: 0; padding: 28px; text-align: center; color: var(--muted, #516072); background: var(--card, #fff); border: 1px dashed var(--border, #e3eaf5); border-radius: 18px; }
.calidad-admin-bar { display: flex; justify-content: flex-end; }
.calidad-noscript { margin: 0; padding-left: 1.2em; line-height: 1.8; }

/* ── Visor a pantalla completa ── */
html.calidad-viewer-open { overflow: hidden; }

.calidad-viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #2b2f36;
  color: #f1f5f9;
  display: none;
  flex-direction: column;
}
.calidad-viewer[open] { display: flex; }
.calidad-viewer::backdrop { background: rgba(15, 23, 42, 0.6); }

.calidad-viewer-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 12px 8px 18px;
  background: #1f2329;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.calidad-viewer-heading { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.calidad-viewer-heading > i { color: #f87171; font-size: 20px; flex-shrink: 0; }
.calidad-viewer-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calidad-viewer-tools { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.calidad-viewer-counter {
  min-width: 56px;
  margin-right: 6px;
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: #cbd5e1;
}
.calidad-viewer-zoom {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}
.calidad-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #e2e8f0;
  font-size: 17px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.calidad-icon-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.calidad-icon-btn:focus-visible { outline: 2px solid #7dd3fc; outline-offset: 1px; }
.calidad-viewer-fit.is-active { color: #7dd3fc; }
.calidad-viewer-close { margin-left: 4px; background: rgba(255, 255, 255, 0.08); }

.calidad-viewer-scroll {
  position: relative;
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
  outline: none;
  -webkit-overflow-scrolling: touch;
}
.calidad-viewer-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: max-content;
  min-width: 100%;
  margin: 0 auto;
  padding: 24px 24px 48px;
  box-sizing: border-box;
}
.calidad-viewer-page {
  flex-shrink: 0;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.calidad-viewer-page:not(.is-ready) {
  background: linear-gradient(90deg, #f8fafc, #eef2f7, #f8fafc) 0 0 / 200% 100%;
  animation: calidad-page-loading 1.4s ease infinite;
}
.calidad-viewer-page canvas { display: block; width: 100%; height: 100%; }
@keyframes calidad-page-loading { to { background-position: -200% 0; } }

.calidad-viewer-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 0;
  padding: 18vh 24px 0;
  text-align: center;
  color: #cbd5e1;
}
.calidad-viewer-status[hidden] { display: none; }
.calidad-spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: #7dd3fc;
  animation: calidad-spin 0.8s linear infinite;
}
@keyframes calidad-spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .calidad-grid { grid-template-columns: 1fr; gap: 16px; }
  .calidad-thumb { height: 210px; }
  .calidad-viewer-bar { padding: 6px 6px 6px 12px; gap: 6px; }
  .calidad-viewer-heading > i { display: none; }
  .calidad-viewer-title { font-size: 14px; }
  .calidad-viewer-counter { min-width: 44px; margin-right: 0; font-size: 12px; }
  .calidad-viewer-newtab, .calidad-viewer-fit { display: none; }
  .calidad-icon-btn { width: 36px; height: 36px; }
  .calidad-viewer-pages { padding: 12px 8px 32px; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .calidad-card, .calidad-thumb-page, .calidad-thumb-badge { transition: none; }
  .calidad-thumb-skeleton, .calidad-viewer-page:not(.is-ready), .calidad-spinner { animation: none; }
}

/* Tema oscuro del sitio */
:root[data-theme="dark"] .calidad-card:hover { box-shadow: 0 16px 36px -22px rgba(0, 0, 0, 0.8); }
:root[data-theme="dark"] .calidad-thumb-page { box-shadow: 0 10px 28px -12px rgba(0, 0, 0, 0.8); }
:root[data-theme="dark"] .calidad-card-title { color: var(--text); }
:root[data-theme="dark"] .calidad-btn--primary { color: #0b1220; }
:root[data-theme="dark"] .calidad-btn--primary:hover { color: #0b1220; background: color-mix(in srgb, var(--primary) 85%, #fff); }
:root[data-theme="dark"] .calidad-btn--ghost { color: var(--text); }
:root[data-theme="dark"] .calidad-btn--ghost:hover { color: var(--primary); }
