/* PlaylisTube - vues : en-tete de chaine, playlists, videos (miniatures et tableau), comparaison. */

/* ---------- Sections ---------- */
.block {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.block-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.block-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
}

/* Petit trait de couleur devant les titres de section */
.block-title::before {
  content: "";
  align-self: center;
  flex: none;
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--accent);
}

.block-count {
  color: var(--text-2);
  font-size: 14px;
  font-weight: 400;
}

/* ---------- En-tete de chaine ---------- */
.channel {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  padding: 24px;
  border: 1px solid var(--card-border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-l);
  background: var(--card);
  box-shadow: var(--shadow-card);
}

.channel-avatar {
  flex: none;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-1);
}

.channel-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.channel-name {
  font-size: 32px;
  line-height: 40px;
  font-weight: 700;
  letter-spacing: -.5px;
  overflow-wrap: anywhere;
}

.channel-meta {
  font-size: 14px;
}

.channel-desc {
  max-width: 860px;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.meta-small {
  font-size: 12px;
}

.channel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.export-status {
  color: var(--text-2);
  font-size: 13px;
}

.export-status.is-error {
  color: var(--danger-fg);
}

/* ---------- Playlists ---------- */
.pl-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pl {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-l);
  background: var(--card);
  box-shadow: var(--shadow-card);
  transition: border-color .15s, box-shadow .15s;
}

.pl:not(.pl-hero):hover {
  border-color: var(--border-strong);
}

/* Playlist ouverte : liseré de couleur a gauche */
.pl.is-open:not(.pl-hero) {
  border-color: var(--border-strong);
  box-shadow: inset 3px 0 0 var(--accent), var(--shadow-card);
}

.pl-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
}

.pl-toggle {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-m);
  background: none;
  color: inherit;
  text-align: left;
}

button.pl-toggle:hover .pl-chevron {
  background: var(--surface-1);
  color: var(--text);
}

.pl-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-m);
  background: var(--surface-1);
}

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

/* "Toutes les videos" : l'avatar de la chaine au centre. */
.pl-thumb-avatar img {
  position: absolute;
  inset: 0;
  width: 38%;
  height: auto;
  aspect-ratio: 1;
  margin: auto;
  border-radius: 50%;
}

.pl-count {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px 1px 4px;
  border-radius: var(--radius-s);
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}

.pl-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding-top: 2px;
}

.pl-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 16px;
  line-height: 22px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.pl-desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
  color: var(--text-2);
  font-size: 13px;
}

.pl-owner {
  color: var(--text);
  font-weight: 500;
}

.pl-owner:hover {
  text-decoration: underline;
}

.pl-chevron {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text-2);
  transition: transform .2s ease, background-color .15s;
}

.pl.is-open .pl-chevron {
  transform: rotate(180deg);
}

.pl-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  flex: none;
}

.pl-status {
  padding: 0 12px 10px;
  color: var(--text-2);
  font-size: 13px;
}

.pl-status.is-error {
  color: var(--danger-fg);
}

.pl-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

/* Playlist ouverte : la description s'affiche en entier. */
.pl.is-open:not(.pl-hero) .pl-desc {
  display: block;
  max-height: 9em;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Playlist seule : grande presentation, comme la page d'une playlist sur YouTube. */
.pl-hero {
  padding: 24px;
  border-top: 3px solid var(--accent);
}

.pl-hero .pl-head {
  padding: 0;
}

.pl-hero .pl-toggle {
  grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
  gap: 24px;
}

.pl-hero .pl-thumb {
  border-radius: var(--radius-l);
}

.pl-hero .pl-info {
  gap: 10px;
}

.pl-hero .pl-title {
  -webkit-line-clamp: 3;
  font-size: 28px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: -.4px;
}

.pl-hero .pl-meta {
  font-size: 14px;
}

.pl-hero .pl-desc {
  -webkit-line-clamp: 3;
  font-size: 14px;
  white-space: pre-wrap;
}

.pl-hero .pl-desc.is-expanded {
  display: block;
}

.pl-hero .pl-actions {
  margin-top: 6px;
}

.pl-hero .pl-status {
  padding: 12px 0 0;
}

.pl-hero .pl-body {
  margin-top: 24px;
  padding: 24px 0 0;
}

/* ---------- Videos ---------- */
.vlist {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.vlist-count,
.vlist-total {
  color: var(--text-2);
  font-size: 13px;
}

.vlist-total::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  margin: 0 8px 0 0;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
  transform: translateY(-2px);
}

.vlist-more {
  display: flex;
  justify-content: center;
}

.vlist-more:empty {
  display: none;
}

.vgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 24px 16px;
}

.vcard {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.vthumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-l);
  background: var(--surface-1);
}

.vthumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .25s ease;
}

a.vthumb:hover img {
  transform: scale(1.03);
}

.vduration,
.vpos {
  position: absolute;
  padding: 0 4px;
  border-radius: var(--radius-s);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}

.vduration {
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, .8);
}

.vpos {
  top: 6px;
  left: 6px;
  min-width: 20px;
  background: rgba(0, 0, 0, .6);
  text-align: center;
}

.vunavailable {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}

.is-unavailable .vthumb img {
  filter: grayscale(1);
  opacity: .55;
}

.vbody {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.vtext {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.vtitle {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin-bottom: 2px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.is-unavailable .vtitle {
  color: var(--text-2);
}

.vchannel {
  max-width: 100%;
  width: fit-content;
  overflow: hidden;
  color: var(--text-2);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.vchannel:hover {
  color: var(--text);
}

.vnote {
  color: var(--text-2);
  font-size: 12px;
  font-style: italic;
}

.vbadges {
  margin-top: 4px;
}

.vdl {
  margin: -4px -8px 0 0;
  color: var(--text-2);
}

.vdl:hover {
  color: var(--text);
}

/* Tableau */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
}

.vtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.vtable th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--subtle);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.vtable td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.vtable tbody tr:last-child td {
  border-bottom: 0;
}

.vtable tbody tr:hover {
  background: var(--surface-1);
}

.vtable .c-pos {
  width: 1%;
  color: var(--text-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.vtable .c-num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.vtable .c-date {
  color: var(--text-2);
  white-space: nowrap;
}

.vtable .c-act {
  width: 1%;
  text-align: right;
}

.vrow {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
}

.vrow .vthumb {
  flex: none;
  width: 96px;
  border-radius: var(--radius-m);
}

.vrow .vunavailable > span {
  display: none;
}

.vrow-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.vrow .vtitle-link {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
}

.vtable .vdl {
  margin: 0;
}

/* ---------- Comparaison ---------- */
.cmp-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  border: 1px solid var(--card-border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-l);
  background: var(--card);
  box-shadow: var(--shadow-card);
}

.cmp-title > .icon {
  color: var(--accent);
}

.cmp-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 28px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: -.4px;
}

.cmp-file {
  font-family: var(--font-mono);
  font-size: 13px;
}

.cmp-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-m);
  font-size: 13px;
  font-weight: 500;
}

.stat::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.stat-removed { color: var(--danger-fg); background: var(--danger-bg); }
.stat-added,
.stat-none { color: var(--ok-fg); background: var(--ok-bg); }
.stat-unavailable { color: var(--warn-fg); background: var(--warn-bg); }
.stat-status { color: var(--info-fg); background: var(--info-bg); }

.cmp-fields {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-l);
  background: var(--card);
  box-shadow: var(--shadow-card);
}

/* Deja dans une carte de playlist : pas d'ombre en plus */
.cmp-pl .cmp-fields {
  box-shadow: none;
}

.cmp-field {
  display: contents;
}

.cmp-field dt,
.cmp-field dd {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.cmp-field:last-child dt,
.cmp-field:last-child dd {
  border-bottom: 0;
}

.cmp-field dt {
  background: var(--subtle);
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
}

.cmp-field dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.cmp-field dd > .icon {
  color: var(--text-3);
}

.cmp-field.is-changed dt {
  color: var(--text);
  font-weight: 500;
}

.cmp-old {
  color: var(--danger-fg);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.cmp-new {
  color: var(--ok-fg);
}

.cmp-old .link,
.cmp-new .link {
  color: inherit;
}

.cmp-pl {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-l);
  background: var(--card);
  box-shadow: var(--shadow-card);
}

.cmp-pl-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cmp-pl-thumb {
  flex: none;
  width: 120px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-m);
  object-fit: cover;
  background: var(--surface-1);
}

.cmp-pl-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.cmp-pl-title {
  font-size: 16px;
  font-weight: 500;
}

.cmp-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cmp-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}

.cmp-group-title .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
}

.cmp-group-removed .dot { background: var(--danger-fg); }
.cmp-group-unavailable .dot { background: var(--warn-fg); }
.cmp-group-added .dot { background: var(--ok-fg); }
.cmp-group-statusChanged .dot { background: var(--info-fg); }

/* ---------- Petits ecrans ---------- */
@media (max-width: 760px) {
  .channel {
    gap: 16px;
    padding: 16px;
  }

  .pl-hero,
  .cmp-head {
    padding: 16px;
  }

  .channel-avatar {
    width: 72px;
    height: 72px;
  }

  .channel-name {
    font-size: 24px;
    line-height: 32px;
  }

  .pl-head {
    flex-direction: column;
    align-items: stretch;
  }

  .pl-toggle {
    grid-template-columns: 128px minmax(0, 1fr) auto;
    gap: 12px;
  }

  .pl-title {
    font-size: 15px;
    line-height: 21px;
  }

  .pl-actions {
    justify-content: flex-end;
  }

  .pl-hero .pl-toggle {
    grid-template-columns: minmax(0, 1fr);
  }

  .pl-hero .pl-title {
    font-size: 22px;
    line-height: 30px;
  }

  .pl-hero .pl-actions {
    justify-content: flex-start;
  }

  .filter-input {
    width: 100%;
  }

  .filter {
    flex: 1 1 180px;
  }

  .cmp-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .cmp-field dt {
    padding-bottom: 0;
    border-bottom: 0;
  }
}
