/* ══════════════════════════════════════════════════════════
   COLECCIÓN — Layout responsivo
   ══════════════════════════════════════════════════════════ */
:root {
  --sp-w: 320px;
  --radius: 14px;
  --blue: #611232;
  --blue-dark: #310214;
  --border: #e3e6ef;
}


/* ── Layout general ─────────────────────────────────────── */
.col-layout {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 1rem 1.5rem 2rem;
  /* Evita que hijos desborden el viewport */
  min-width: 0;
  max-width: 100%;
  width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}
.col-main {
  flex: 1;
  min-width: 0;       /* Clave: permite que flex item se encoja */
  max-width: 100%;
  overflow-x: hidden; /* Corta cualquier desbordamiento horizontal */
  box-sizing: border-box;
}

/* Elementos media embebidos nunca superan el ancho del padre */
.col-main video,
.col-main iframe,
.col-main embed,
.col-main object,
.col-main img {
  max-width: 100%;
  height: auto;
}
/* Iframes de aspecto fijo mantienen su ratio pero no desbordan */
.col-main iframe[style*="aspect-ratio"],
.media-preview iframe {
  width: 100% !important;
  max-width: 100%;
}
/* Contenido HTML embebido (contenido.contenido|safe) */
.contenido_contenido {
  overflow-x: auto;   /* scroll interno si hay tablas anchas */
  word-break: break-word;
}
.contenido_contenido table {
  width: 100%;
  table-layout: fixed;
  word-break: break-word;
}

.col-aside  {
  width: var(--sp-w);
  flex-shrink: 0;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  border-radius: var(--radius);
  background: #1a1a2e;
  scrollbar-width: thin;
  scrollbar-color: #333 #111;
}
.col-aside::-webkit-scrollbar       { width: 4px; }
.col-aside::-webkit-scrollbar-track { background: #111; }
.col-aside::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

/* ── Header de la colección ─────────────────────────────── */
.col-header {
  background: linear-gradient(135deg, #0a1628 0%, #0033aa 100%);
  border-radius: var(--radius);
  padding: 2rem;
  color: #fff;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}
/* Overlay oscuro sobre la portada para mantener legibilidad */
.col-header::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(
    135deg,
    rgba(10, 22, 40, 0.88) 0%,
    rgba(0, 51, 170, 0.78) 100%
  );
  border-radius: var(--radius);
  z-index: 0;
}
.col-header::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C%3C/g%3E%3C/g%3E%3C/svg%3E");
  z-index: 0;
}
/* Todo el contenido del header por encima de los overlays */
.col-header > * { position: relative; z-index: 1; }
.col-header__tipo {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: rgba(255,255,255,.7);
  margin-bottom: .5rem;
}
.col-header__title {
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 800; line-height: 1.2;
  margin: 0 0 1rem;
  text-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.col-header__meta {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin-bottom: 1rem;
}
.col-meta-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px; padding: .25rem .75rem;
  font-size: .78rem; color: rgba(255,255,255,.9);
  backdrop-filter: blur(4px);
}
.col-header__actions {
  display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem;
}

/* ── Vista previa de medios ─────────────────────────────── */
.media-preview {
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
}
.media-preview video,
.media-preview iframe { display: block; width: 100%; }
.media-preview iframe { aspect-ratio: 16/9; border: none; }
#preview-video { display: none; }
#preview       { margin-top: 1rem; }

/* ── Cuerpo del contenido ───────────────────────────────── */
.col-body-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.col-body-card .contenido_contenido p { margin-top: revert; }
.col-body-card .contenido_contenido >div { padding-right: revert; padding-left: revert; }

/* Etiquetas */
.tags-wrap { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }
.tags-wrap .badge {
  font-size: .72rem; padding: .3rem .65rem;
  border-radius: 20px; text-decoration: none;
}

/* Valoración */
.valoracion-row {
  display: flex; align-items: center; gap: .5rem;
  font-size: .85rem; color: #555; padding: .6rem 0;
  border-top: 1px solid var(--border);
}

/* Navegación prev/next */
.col-nav {
  display: flex; justify-content: space-between;
  gap: 1rem; margin: 1rem 0;
}
.col-nav .btn { min-width: 110px; }

/* ── Panel lateral ──────────────────────────────────────── */
.aside-toggle {
  display: flex; margin: .75rem;
  background: #111; border-radius: 30px; overflow: hidden;
}
.aside-toggle button {
  flex: 1; border: none; background: transparent;
  color: rgba(255,255,255,.6); font-size: .8rem;
  font-weight: 600; padding: .5rem; cursor: pointer;
  border-radius: 30px; transition: background .2s, color .2s;
}
.aside-toggle button.active {
  background: var(--blue); color: #fff;
}

.aside-section { padding: .75rem; }
.aside-title {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: rgba(255,255,255,.4);
  margin: 1rem 0 .5rem; padding: 0 .25rem;
}

/* Tarjeta de recurso en panel lateral */
.aside-rec-card {
  display: flex; align-items: center; gap: .65rem;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px; padding: .6rem .75rem;
  margin-bottom: .5rem; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.aside-rec-card:hover,
.aside-rec-card.selected {
  background: rgba(0,51,170,.35);
  border-color: rgba(0,51,170,.6);
}
.aside-rec-card__cover {
  width: 52px; height: 40px; flex-shrink: 0;
  border-radius: 6px; object-fit: cover;
  background: #2a2a3e;
}
.aside-rec-card__cover-ph {
  width: 52px; height: 40px; flex-shrink: 0;
  border-radius: 6px;
  background: linear-gradient(135deg,#1e3a6e,#0033aa);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.aside-rec-card__info { flex: 1; min-width: 0; }
.aside-rec-card__name {
  font-size: .8rem; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aside-rec-card__fmt {
  font-size: .68rem; color: rgba(255,255,255,.45);
  text-transform: uppercase; letter-spacing: .05em;
}
.aside-rec-card__actions {
  display: flex; gap: .3rem; flex-shrink: 0;
}
.aside-rec-card__actions .btn { padding: .2rem .45rem; font-size: .75rem; }

/* Tarjeta relacionados en panel lateral */
.aside-rel-card {
  display: flex; gap: .6rem; align-items: flex-start;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px; padding: .65rem;
  margin-bottom: .5rem; text-decoration: none; color: #fff;
  transition: background .15s;
}
.aside-rel-card:hover { background: rgba(255,255,255,.1); color: #fff; }
.aside-rel-card img {
  width: 56px; height: 42px; object-fit: cover;
  border-radius: 6px; flex-shrink: 0;
}
.aside-rel-card__body { flex: 1; min-width: 0; }
.aside-rel-card__name {
  font-size: .8rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aside-rel-card__tipo { font-size: .68rem; color: rgba(255,255,255,.4); }

/* ── Listado de recursos (sección principal) ────────────── */
.recursos-section-title {
  font-size: 1rem; font-weight: 700; color: #1a1a2e;
  display: flex; align-items: center; gap: .5rem;
  margin: 1.5rem 0 .75rem;
  padding-bottom: .5rem; border-bottom: 2px solid var(--border);
}
.recursos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: .75rem;
}
.recurso-card {
  display: flex; align-items: flex-start; gap: .75rem;
  background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: .75rem 1rem;
  transition: box-shadow .15s, transform .12s, border-color .15s;
  cursor: pointer;
}
.recurso-card:hover {
  box-shadow: 0 4px 16px rgba(0,51,170,.12);
  transform: translateY(-2px); border-color: #0033aa44;
}
.recurso-card.selected { border-color: var(--blue); background: #f0f4ff; }
.recurso-card__icon  { font-size: 1.7rem; flex-shrink: 0; line-height: 1; }
.recurso-card__body  { flex: 1; min-width: 0; }
.recurso-card__nombre {
  font-weight: 600; font-size: .88rem; line-height: 1.3;
  color: #1a1a2e; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.recurso-card__tipo {
  font-size: .7rem; color: #6c757d;
  text-transform: uppercase; letter-spacing: .04em; margin-top: .1rem;
}
.recurso-card__actions {
  display: flex; align-items: center; gap: .35rem; flex-shrink: 0;
}
.recurso-card__link { color: var(--blue); font-size: .95rem; }
.recurso-card__link:hover { color: var(--blue-dark); }

/* ── Botón panel lateral móvil ──────────────────────────── */
.aside-toggle-btn {
  display: none;
  position: fixed; bottom: 5rem; right: 1rem; z-index: 1000;
  background: #1a1a2e; color: #fff; border: none;
  border-radius: 50%; width: 46px; height: 46px;
  font-size: 1.2rem; box-shadow: 0 4px 14px rgba(0,0,0,.3);
  cursor: pointer;
}

/* ── Responsivo ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .col-layout { flex-direction: column; padding: .75rem 1rem 2rem; }
  .col-aside {
    width: 100%; position: static; max-height: none;
    border-radius: var(--radius);
  }
  .aside-toggle-btn { display: flex; align-items: center; justify-content: center; }
  .col-aside-wrap { display: none; }
  .col-aside-wrap.open { display: block; }
}
@media (max-width: 576px) {
  body, html { overflow-x: hidden; }
  .col-layout {
    padding: .5rem .75rem 2rem;
    flex-direction: column;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  .col-header { padding: 1.25rem; }
  .col-header__title { font-size: 1.4rem; }
  .col-body-card { padding: 1rem; }
  .col-main {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    word-break: break-word;
  }
  .recursos-grid { grid-template-columns: 1fr; }
  .col-nav .btn { font-size: .82rem; padding: .4rem .75rem; min-width: 90px; }
}

object { width: 100%; max-width: 100%; height: 90vh; }
embed  { width: 100%; max-width: 100%; height: 90vh; }
.picture-in-picture { position: relative; }
.picture-in-picture button { top: 0; right: 0; position: absolute; }
