/* Media library styling for Videos and Audios pages */
body[data-media-gallery="video"] {
  background:
    radial-gradient(1200px 1200px at 12% 8%, rgba(107, 133, 126, 0.08), transparent),
    radial-gradient(880px 880px at 86% 18%, rgba(38, 56, 50, 0.06), transparent),
    #f7f9f8;
}

body[data-media-gallery="audio"] {
  background:
    radial-gradient(900px 900px at 12% 10%, rgba(255, 236, 225, 0.8), transparent),
    radial-gradient(1100px 900px at 88% 12%, rgba(193, 210, 255, 0.38), transparent),
    linear-gradient(180deg, #fdf7f4 0%, #f4f0ff 60%, #f6fbff 100%);
}

.container--wide {
  width: min(1200px, 98vw);
  max-width: 100%;
  padding: auto;
  margin-inline: auto;
}

/* Shared shells */
.media-hero {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.media-hero .player-shell {
  background: linear-gradient(135deg, #0f1413, #101b18);
  border: 1px solid #0d1311;
  border-radius: 1.15rem;
  padding: .75rem;
  box-shadow: 0 22px 60px rgba(7, 19, 16, 0.32);
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
}

.video-player-grid {
  display: grid;
  grid-template-columns: 108% 30%;
  gap: .9rem;
  align-items: auto;
  width: 100%;
}

@media (max-width: 900px) {
  .video-player-grid {
    grid-template-columns: 1fr;
  }
  .video-meta-panel {
    width: 100%;
    max-width: 100%;
    margin-top: .5rem;
  }
}

.player-nav {
  position: absolute;
  top: .25rem;
  right: .25rem;
  display: flex;
  gap: .25rem;
}

.nav-btn {
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.12);
  color: #e8f3ef;
  width: 30px;
  height: 30px;
  border-radius: .6rem;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 24px rgba(0,0,0,0.2);
  transition: transform .15s ease, background .15s ease;
}

.nav-btn:hover,
.nav-btn:focus-visible {
  background: rgba(255,255,255,0.14);
  transform: translateY(-1px);
  outline: none;
}

.video-stage-frame,
.audio-stage-wrap {
  background: linear-gradient(145deg, #0d1412, #0c110f);
  border-radius: 1rem;
  border: 1px solid #111b18;
  padding: .5rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.video-stage,
.audio-stage {
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  max-height: 560px;
  background: #000;
  border-radius: .9rem;
  overflow: hidden;
}

.video-stage {
  max-height: min(560px, 72vh);
}

.video-meta-panel {
  background: linear-gradient(135deg, rgba(255,255,255,0.16), rgba(255,255,255,0.06));
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 1rem;
  padding: 1.1rem .95rem .95rem;
  box-shadow: 0 14px 32px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.08);
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  justify-self: stretch;
  width: 100%;
  justify-content: flex-start;
  gap: .35rem;
  position: relative;
  justify-self: end;
  width: 100%;
  max-width: 460px;
}

.video-meta {
  width: 100%;
  max-width: 460px;
  color: #e8f3ef;
}

.video-meta,
.audio-meta {
  color: #d9e6e1;
  margin: 0;
}

.video-meta p,
.audio-meta p {
  margin: 0;
}

.video-meta h3,
.audio-meta h3 {
  margin: 0 0 .15rem;
}

.video-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  align-items: center;
  padding: .85rem .95rem;
  border-radius: 1rem;
  border: 1px solid #e2ebe7;
  background: #fff;
  box-shadow: 0 12px 30px rgba(20, 42, 36, 0.08);
}

.audio-filter-bar {
  display: grid;
  grid-template-columns: minmax(240px, 1.2fr) minmax(260px, 1fr);
  grid-template-areas:
    "search selects"
    "moods moods";
  gap: .65rem;
  align-items: start;
  padding: .85rem .95rem;
  border-radius: 1rem;
  border: 1px solid #e2ebe7;
  background: #fff;
  box-shadow: 0 12px 30px rgba(20, 42, 36, 0.08);
}

.video-toolbar input[type="search"],
.audio-filter-bar input[type="search"] {
  padding: .65rem .8rem;
  border: 1px solid #d9e5df;
  border-radius: .8rem;
  min-width: 240px;
  background: #f7fbf9;
}

.video-toolbar select,
.audio-filter-bar select {
  padding: .6rem .75rem;
  border: 1px solid #d9e5df;
  border-radius: .75rem;
  background: #fff;
}

.video-toolbar__filters,
.audio-filter-bar__selects {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  flex: 1 1 320px;
}

.video-toolbar__search {
  flex: 1 1 240px;
}
.audio-filter-bar__search {
  flex: 1 1 240px;
  grid-area: search;
}
.audio-filter-bar__selects { grid-area: selects; justify-content: flex-end; }
.audio-filter-bar__selects select { justify-self: end; }
.audio-filter-bar .mood-chips { grid-area: moods; justify-content: flex-start; }

/* Rails for videos */
.video-rails.playlist {
  border: 1px solid #e3ece8;
  padding: .75rem;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbf9 100%);
  box-shadow: 0 16px 40px rgba(17, 32, 28, 0.08);
  display: grid;
  gap: .75rem;
  border-radius: 1rem;
  max-height: none;
  overflow: visible;
}

#vid-playlist {
  list-style: none;
  margin: 0;
  padding: 0;
}

#vid-playlist .pl-item.video-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1rem;
  border-radius: 14px;
  border: 1px solid #e0ebe6;
  background: #fff;
  box-shadow: 0 12px 30px rgba(24, 62, 48, 0.06);
  cursor: pointer;
  transition: background-color .16s ease, box-shadow .18s ease, border-color .16s ease;
}

#vid-playlist .pl-item.video-row:hover {
  background: rgba(0, 0, 0, 0.03);
  box-shadow: 0 16px 36px rgba(24, 62, 48, 0.1);
}

#vid-playlist .pl-item.video-row.is-active {
  border-color: #9ebeb1;
  box-shadow: 0 18px 42px rgba(24, 62, 48, 0.14);
  background: #e8f0ed;
}

.video-row__main {
  display: grid;
  gap: .15rem;
  flex: 1 1 auto;
  min-width: 0;
}

.video-row__title {
  margin: 0;
  font-weight: 700;
  color: #1f2b27;
  letter-spacing: .1px;
  word-break: break-word;
}

.video-row__meta {
  margin: 0;
  color: #70837b;
  font-size: .9rem;
}

.video-row__desc {
  margin: 0;
  color: #50635e;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.video-row__actions {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.video-row__play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cddcd5;
  background: linear-gradient(135deg, #f7faf8, #e8f0ed);
  color: #1f2b27;
  padding: .55rem .95rem;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(17, 32, 28, 0.12);
  transition: background-color .15s ease, transform .12s ease;
}

.video-row__play:hover {
  background: #e0ebe6;
  transform: translateY(-1px);
}

.video-row__menu-wrap {
  position: relative;
  display: inline-flex;
}

.video-row__menu-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid #d6e3de;
  background: #f3f8f6;
  color: #3b4b44;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(17, 32, 28, 0.12);
}

.video-row__menu-wrap.is-open .video-row__menu-btn {
  background: #e8f0ed;
  border-color: #c7d8d1;
}

.video-row__menu-btn:focus-visible {
  outline: 2px solid #9ebeb1;
  outline-offset: 2px;
}

.video-row__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 170px;
  background: #fff;
  border: 1px solid #dce7e2;
  border-radius: 12px;
  padding: .35rem;
  box-shadow: 0 18px 34px rgba(24, 62, 48, 0.14);
  z-index: 5;
}

.video-row__menu[hidden] {
  display: none;
}

.video-row__menu-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: .55rem .75rem;
  border-radius: 10px;
  color: #27342f;
  font-weight: 600;
  cursor: pointer;
}

.video-row__menu-item:hover {
  background: #eef3f1;
}

.video-row__menu-item.danger {
  color: #9c4338;
}

.video-row__menu-item.danger:hover {
  background: #f9ece9;
}

.media-rail {
  background: #fff;
  border: 1px solid #e9efec;
  border-radius: 1rem;
  padding: 1rem 1rem 1.1rem;
  box-shadow: 0 16px 40px rgba(17, 32, 28, 0.08);
  display: grid;
  gap: .65rem;
}

.media-rail__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
}

.media-rail__title {
  margin: 0;
  font-size: 1.15rem;
  color: #1f2b27;
}

.media-rail__kicker {
  margin: 0;
  color: #5e726c;
  font-size: .9rem;
  letter-spacing: .3px;
}

.media-rail__nav {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.media-rail__btn {
  border: 1px solid #d8e4de;
  background: #f6faf8;
  color: #1f2b27;
  width: 34px;
  height: 34px;
  border-radius: .65rem;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(17, 32, 28, 0.12);
}

.media-rail__btn:hover {
  background: #e9f5ef;
}

.media-rail__track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(240px, 30%);
  gap: .8rem;
  overflow-x: auto;
  padding-bottom: .25rem;
  scroll-snap-type: x mandatory;
}

.media-rail__track::-webkit-scrollbar {
  height: 8px;
}

.media-rail__track::-webkit-scrollbar-thumb {
  background: #d3e0da;
  border-radius: 999px;
}

.rail-card.pl-item {
  scroll-snap-align: start;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: .55rem;
  padding: .55rem;
  border-radius: .9rem;
  border: 1px solid #e6efea;
  background: linear-gradient(160deg, #ffffff, #f8fbfa);
  box-shadow: 0 14px 36px rgba(17, 32, 28, 0.08);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.rail-card.pl-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 44px rgba(17, 32, 28, 0.14);
  border-color: #d1e2db;
}

.rail-card.pl-item.is-active {
  border-color: #8fb4a7;
  box-shadow: 0 16px 40px rgba(24, 62, 48, 0.16);
}

.rail-thumb.pl-thumb {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  border-radius: .8rem;
  overflow: hidden;
  background: #f3f7f5;
}

.rail-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rail-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,0.45) 100%);
  opacity: .65;
  transition: opacity .18s ease;
}

.rail-card:hover .rail-thumb::after {
  opacity: .15;
}

.rail-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #ffffff;
  font-size: 2.2rem;
  opacity: .22;
  text-shadow: 0 10px 32px rgba(0, 0, 0, 0.4);
}

.rail-card:hover .rail-play {
  opacity: .45;
}

.rail-body .pl-title {
  margin: .1rem 0;
  font-size: 1rem;
  color: #1f2b27;
}

.rail-body .pl-meta {
  color: #5c6f69;
  font-size: .9rem;
}

.rail-actions {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  margin-top: .35rem;
}

.rail-cta {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem .75rem;
  background: #f0f6f3;
  border: 1px solid #d9e5df;
  border-radius: .75rem;
  color: #1f2b27;
  font-weight: 700;
  cursor: pointer;
}

.rail-empty {
  margin-top: .5rem;
  color: #5e726c;
}

/* Audio layout */
.audio-hero .player-shell {
  background: linear-gradient(135deg, rgba(28, 46, 42, 0.78), rgba(10, 15, 25, 0.82));
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 20px 60px rgba(10, 15, 25, 0.32);
  color: #dfe9e5;
}

.audio-hero__shell {
  display: grid;
  gap: .75rem;
}

.audio-now {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.audio-now__cover {
  width: 78px;
  height: 78px;
  border-radius: 20px;
  background: linear-gradient(145deg, #ffe9d9, #f6f0ff);
  box-shadow: 0 12px 30px rgba(0,0,0,0.28);
  overflow: hidden;
  flex-shrink: 0;
}

.audio-now__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.audio-now__meta {
  display: grid;
  gap: .15rem;
}

.audio-now__title {
  margin: 0;
  font-size: 1.15rem;
  color: #f6f8f7;
}

.audio-now__hint {
  margin: 0;
  color: #b7c8c1;
}

.audio-stage {
  max-height: min(420px, 60vh);
  background: linear-gradient(145deg, rgba(255,255,255,0.06), rgba(255,255,255,0.08));
  border: 1px solid rgba(255,255,255,0.1);
}

.audio-meta {
  color: #d9e6e1;
  margin-top: .5rem;
}

.audio-filter-bar {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #e6e8f5;
  box-shadow: 0 16px 42px rgba(64, 76, 96, 0.12);
}

.audio-mood-chips,
.mood-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.audio-mood-chips button,
.mood-chips button {
  border: 1px solid #dfd8f4;
  background: linear-gradient(135deg, #ffffff, #f5f1ff);
  color: #3b3754;
  padding: .45rem .75rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 12px 26px rgba(59, 55, 84, 0.12);
}

.audio-mood-chips button.is-active,
.mood-chips button.is-active {
  background: linear-gradient(135deg, #5b6bff, #4f46e5);
  border-color: #4f46e5;
  color: #fff;
  box-shadow: 0 12px 28px rgba(79, 70, 229, 0.26);
}

/* Media tag chips (comparten estilo con admin) */
.media-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.media-chip {
  border: 1px solid #d9d7f3;
  background: linear-gradient(135deg, #fdfdff, #f5f1ff);
  color: #2e2a44;
  padding: .5rem .85rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 12px 26px rgba(34, 30, 64, 0.14);
  transition: transform .12s ease, box-shadow .16s ease, background .18s ease, border-color .18s ease;
}

.media-chip.is-active {
  background: linear-gradient(135deg, #5b6bff, #4f46e5);
  border-color: #4f46e5;
  color: #fff;
  box-shadow: 0 14px 30px rgba(69, 62, 181, 0.35);
  transform: translateY(-1px);
}

.audio-playlists.playlist {
  background: transparent;
  border: none;
  padding: 0;
  display: grid;
  gap: 1rem;
  box-shadow: none;
  max-height: none;
}

.audio-section {
  background: rgba(255,255,255,0.92);
  border: 1px solid #e5deff;
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: 0 18px 44px rgba(62, 52, 95, 0.12);
  display: grid;
  gap: .6rem;
}

.audio-section__title {
  margin: 0;
  font-size: 1.05rem;
  color: #2b2440;
}

.audio-section__list {
  display: grid;
  gap: .55rem;
}

.audio-card.pl-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: .75rem;
  align-items: center;
  background: linear-gradient(135deg, #ffffff, #f7f3ff);
  border: 1px solid #e6def7;
  border-radius: .95rem;
  padding: .75rem .85rem;
  box-shadow: 0 12px 32px rgba(51, 42, 77, 0.12);
  cursor: pointer;
}

.audio-card.pl-item.is-active {
  border-color: #c8b6ff;
  box-shadow: 0 14px 36px rgba(51, 42, 77, 0.18);
}

.audio-card .pl-title {
  margin: .05rem 0;
  font-size: 1rem;
  color: #241c3a;
}

.audio-card .pl-meta {
  color: #615777;
  font-size: .9rem;
  margin: .05rem 0 0;
}

.audio-card .pl-thumb {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(145deg, #ffe9d9, #f3e8ff);
  display: grid;
  place-items: center;
}

.audio-card .pl-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.audio-card .pill-btn {
  border: none;
  background: linear-gradient(135deg, #2c675d, #1d443d);
  color: #fff;
  padding: .5rem .9rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(28, 79, 69, 0.35);
  font-weight: 700;
}

.audio-card .pill-btn:hover {
  opacity: .92;
}

.audio-admin {
  margin-top: .35rem;
}

.rail-empty,
.audio-empty {
  font-size: .95rem;
}

@media (max-width: 960px) {
  .media-rail__track {
    grid-auto-columns: minmax(220px, 60%);
  }
  .media-rail__head {
    flex-direction: column;
    align-items: flex-start;
  }
  .video-stage {
    max-height: none;
  }
  .audio-stage {
    max-height: none;
  }
  .video-player-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (max-width: 900px) {
  .video-toolbar,
  .audio-filter-bar {
    align-items: stretch;
  }
  .video-toolbar__filters,
  .audio-filter-bar__selects {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  .video-toolbar select,
  .audio-filter-bar select {
    width: 100%;
  }
  .audio-filter-bar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "search"
      "selects"
      "moods";
  }
  .video-meta-panel {
    padding: 1.2rem 1rem 1rem;
  }
}

@media (max-width: 720px) {
  .video-toolbar input[type="search"],
  .audio-filter-bar input[type="search"] {
    min-width: 100%;
  }
  .audio-card.pl-item {
    grid-template-columns: 1fr;
    text-align: left;
  }
  .audio-card .pill-btn {
    width: 100%;
    justify-content: center;
    display: inline-flex;
  }
  #vid-playlist .pl-item.video-row {
    flex-direction: column;
    align-items: stretch;
    gap: .65rem;
    width: 100%;
    box-sizing: border-box;
  }
  .video-row__actions {
    width: 100%;
    justify-content: stretch;
    flex-wrap: wrap;
    display: flex;
    gap: .5rem;
    box-sizing: border-box;
  }
  .video-row__play {
    width: 100%;
    text-align: center;
    justify-content: center;
    display: flex;
    align-items: center;
    margin-bottom: .25rem;
    box-sizing: border-box;
  }
  .video-row__menu-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    box-sizing: border-box;
  }
  .video-row__menu-btn {
    width: 100%;
    min-width: 40px;
    max-width: 120px;
    margin: 0 auto;
    display: block;
  }
  .audio-section {
    padding: .85rem;
  }
  .rail-card.pl-item {
    grid-auto-rows: auto;
  }
  .media-rail__track {
    grid-auto-columns: minmax(220px, 78%);
  }
  .media-hero .player-shell {
    padding: .7rem;
    border-radius: 1rem;
  }
  .video-stage,
  .audio-stage {
    max-height: min(420px, 70vh);
  }
}

@media (max-width: 640px) {
  .container--wide {
    width: 100%;
    max-width: 100%;
    padding-left: 12px;
    padding-right: 12px;
  }
  .media-hero .player-shell {
    padding: .6rem;
    border-radius: 1rem;
  }
  .video-player-grid {
    gap: .65rem;
  }
  .video-meta-panel {
    padding: .9rem .85rem .85rem;
    margin-top: .65rem;
    max-width: 100%;
  }
  .video-toolbar,
  .audio-filter-bar {
    gap: .55rem;
  }
  .mood-chips,
  .audio-mood-chips {
    width: 100%;
    overflow-x: auto;
    padding-bottom: .25rem;
  }
  .mood-chips button,
  .audio-mood-chips button {
    white-space: nowrap;
  }
  .audio-now {
    flex-wrap: wrap;
  }
  .audio-now__cover {
    width: 70px;
    height: 70px;
  }
  .audio-now__meta {
    width: 100%;
  }
  .video-stage,
  .audio-stage {
    max-height: min(360px, 65vh);
  }
}

@media (max-width: 540px) {
  .video-toolbar,
  .audio-filter-bar {
    padding: .75rem .8rem;
  }
  .video-toolbar__filters,
  .audio-filter-bar__selects {
    grid-template-columns: 1fr;
  }
  .video-toolbar__search,
  .audio-filter-bar__search {
    flex-basis: 100%;
  }
  #vid-playlist .pl-item.video-row {
    padding: .85rem .95rem;
  }
  .video-row__meta {
    font-size: .88rem;
  }
  .video-row__actions {
    gap: .45rem;
  }
}
