/* Fase 10.22 - Grade nova unica oficial
   Objetivo: quando estiver em TV AO VIVO, somente a nova grade lateral aparece.
   Nao altera player/backend. */

body.bz-tv-grid-mode #sidebar {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  transform: none !important;
  width: clamp(560px, 34vw, 660px) !important;
  min-width: clamp(560px, 34vw, 660px) !important;
  max-width: clamp(560px, 34vw, 660px) !important;
  flex: 0 0 clamp(560px, 34vw, 660px) !important;
  overflow: hidden !important;
  background: #0f1528 !important;
  border-right: 1px solid rgba(255,255,255,.10) !important;
}

body.bz-tv-grid-mode #sidebar > *:not(#bz-tv-grid-root) {
  display: none !important;
}

body.bz-tv-grid-mode #bz-tv-grid-root {
  display: grid !important;
  grid-template-columns: minmax(245px, 44%) minmax(300px, 56%);
  height: 100%;
  min-height: 0;
  width: 100%;
  background: #0f1528;
  color: #fff;
  font-family: inherit;
}

#bz-tv-grid-root,
#bz-tv-grid-root * {
  box-sizing: border-box;
}

.bz-tv-folders,
.bz-tv-channels {
  min-height: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  overflow-anchor: none;
  scrollbar-gutter: stable;
  scrollbar-color: #ffcc00 #10162a;
}

.bz-tv-folders {
  padding: 14px 10px 18px;
  background: linear-gradient(180deg,#11182d,#0e1427);
  border-right: 1px solid rgba(255,255,255,.10);
}

.bz-tv-channels {
  padding: 14px 10px 18px;
  background: linear-gradient(180deg,#121a30,#0e1426);
  border-right: 1px solid rgba(255,204,0,.45);
}

.bz-tv-title {
  font-size: 14px;
  line-height: 1.2;
  font-weight: 900;
  color: #fff;
  margin: 2px 4px 10px;
}

.bz-tv-search-wrap {
  position: relative;
  margin: 0 3px 12px;
}

.bz-tv-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #b8c2df;
  font-size: 12px;
  pointer-events: none;
}

#bz-tv-channel-search {
  width: 100%;
  height: 38px;
  border-radius: 10px;
  border: 1px solid #303a5d;
  background: #1b233d;
  color: #fff;
  outline: none;
  padding: 0 34px 0 30px;
  font-size: 12px;
  font-weight: 700;
}

#bz-tv-channel-search:focus {
  border-color: #ffcc00;
  box-shadow: 0 0 0 2px rgba(255,204,0,.18);
}

.bz-tv-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  color: #b8c2df;
  cursor: pointer;
  display: none;
}

.bz-tv-search-clear.is-visible {
  display: grid;
  place-items: center;
}

.bz-tv-folder {
  width: 100%;
  height: 54px;
  min-height: 54px;
  max-height: 54px;
  display: grid;
  grid-template-columns: 26px minmax(0,1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px 9px;
  margin: 7px 0;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 11px;
  background: #172039;
  color: #e8edff;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}

.bz-tv-folder:hover {
  transform: none;
  border-color: rgba(255,204,0,.42);
}

.bz-tv-folder.is-active {
  background: #ffcc00;
  color: #111;
  border-color: #ffcc00;
}

.bz-tv-folder-icon {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: rgba(255,204,0,.12);
  color: #ffcc00;
  font-size: 13px;
}

.bz-tv-folder.is-active .bz-tv-folder-icon {
  background: rgba(0,0,0,.82);
  color: #ffcc00;
}

.bz-tv-folder-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  line-height: 1.15;
  max-height: 2.35em;
}

.bz-tv-folder-count {
  min-width: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(0,0,0,.22);
  color: inherit;
  font-size: 10px;
  font-weight: 900;
  text-align: center;
}

.bz-tv-channel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 4px 10px;
}

.bz-tv-channel-head-title {
  min-width: 0;
}

.bz-tv-channel-head-title strong {
  display: block;
  font-size: 14px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bz-tv-channel-head-title span {
  display: block;
  color: #9ba6c6;
  font-size: 10px;
  line-height: 1.35;
}

.bz-tv-channel-count {
  flex: none;
  color: #111;
  background: #ffcc00;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  padding: 4px 7px;
}

#bz-tv-grid-root .bz-tv-channel-card {
  height: 108px;
  min-height: 108px;
  max-height: 108px;
}

.bz-tv-channel-card {
  width: 100%;
  display: grid;
  grid-template-columns: 40px minmax(0,1fr) 34px;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
  padding: 10px 8px 10px 10px;
  border: 1px solid #2c3659;
  border-left: 4px solid transparent;
  border-radius: 13px;
  background: linear-gradient(180deg,#1b2440,#151d34);
  color: #fff;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}

.bz-tv-channel-card:hover {
  transform: none;
  border-left-color: #ffcc00;
  background: linear-gradient(180deg,#222c4d,#18213c);
}

.bz-tv-channel-card.playing,
.bz-tv-channel-card.is-playing {
  border-left-color: #ffcc00;
  background: linear-gradient(180deg,rgba(255,204,0,.16),#161f39);
  box-shadow: 0 0 0 1px rgba(255,204,0,.22) inset;
}

.bz-tv-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #f5f5f5;
  color: #111;
  font-size: 10px;
  font-weight: 900;
}

.bz-tv-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#bz-tv-grid-root .bz-tv-channel-info {
  height: 80px;
  min-height: 80px;
  max-height: 80px;
}

.bz-tv-channel-info {
  min-width: 0;
  overflow: hidden;
}

.bz-tv-channel-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 900;
  color: #fff;
  margin-bottom: 5px;
}

.bz-tv-channel-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bz-tv-badge-adaptive {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(46,229,139,.16);
  color: #2ee58b;
  border: 1px solid rgba(46,229,139,.45);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .3px;
  line-height: 1.3;
}

.bz-tv-channel-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: #9ba6c6;
  font-size: 10px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#bz-tv-grid-root .bz-tv-channel-card .bz-card-epg {
  height: 33px;
  min-height: 33px;
  max-height: 33px;
}

.bz-tv-channel-card .bz-card-epg {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,.06);
  max-width: 100%;
  overflow: hidden;
  pointer-events: none;
}

.bz-tv-channel-card .bz-card-epg-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 9px;
  line-height: 1.1;
  color: #ffcc00;
  font-weight: 800;
  text-transform: uppercase;
}

.bz-tv-channel-card .bz-card-epg-top em {
  color: rgba(255,255,255,.58);
  font-style: normal;
  font-weight: 700;
  text-transform: none;
}

.bz-tv-channel-card .bz-card-epg-title {
  margin-top: 3px;
  font-size: 10px;
  line-height: 1.15;
  color: rgba(255,255,255,.84);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bz-tv-channel-card .bz-card-epg-bar {
  margin-top: 4px;
  height: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  overflow: hidden;
}

.bz-tv-channel-card .bz-card-epg-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #ffcc00;
}

.bz-tv-channel-card .bz-card-epg-empty .bz-card-epg-top,
.bz-tv-channel-card .bz-card-epg-empty .bz-card-epg-title {
  color: rgba(255,255,255,.48);
}

.bz-tv-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: #2ee58b;
}

.bz-tv-fav {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 9px;
  background: rgba(255,255,255,.04);
  color: #aab4cf;
  cursor: pointer;
  font-size: 16px;
}

.bz-tv-fav.active i {
  color: #ffcc00 !important;
  filter: drop-shadow(0 0 7px rgba(255,204,0,.55));
}


.bz-tv-fav:hover,
.bz-tv-fav.active {
  color: #ffcc00 !important;
  border-color: rgba(255,204,0,.45);
  background: rgba(255,204,0,.10);
}

.bz-tv-empty {
  margin: 14px 4px;
  color: #9ba6c6;
  border: 1px dashed rgba(255,255,255,.16);
  border-radius: 12px;
  padding: 14px;
  font-size: 12px;
  line-height: 1.4;
}

/* Mantem as duas colunas da grade abertas mesmo depois de clicar em canal. */
body.bz-tv-grid-mode.tv-active:not(.mobile-fullscreen) #sidebar,
body.bz-tv-grid-mode:not(.mobile-fullscreen) #sidebar {
  display: block !important;
  visibility: visible !important;
  transform: none !important;
}

body.bz-tv-grid-mode .video-container,
body.bz-tv-grid-mode #player-container,
body.bz-tv-grid-mode .content,
body.bz-tv-grid-mode .main-content {
  min-width: 0 !important;
}

@media (max-width: 1100px) {
  body.bz-tv-grid-mode #sidebar {
    width: clamp(430px, 43vw, 530px) !important;
    min-width: clamp(430px, 43vw, 530px) !important;
    max-width: clamp(430px, 43vw, 530px) !important;
    flex-basis: clamp(430px, 43vw, 530px) !important;
  }
  body.bz-tv-grid-mode #bz-tv-grid-root {
    grid-template-columns: minmax(170px, 40%) minmax(230px, 60%);
  }
}

@media (max-width: 768px) {
  body.bz-tv-grid-mode #sidebar {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    flex-basis: auto !important;
    overflow: visible !important;
  }
  body.bz-tv-grid-mode #bz-tv-grid-root {
    grid-template-columns: 1fr;
    height: auto;
  }
  .bz-tv-folders,
  .bz-tv-channels {
    max-height: 42vh;
  }
}


/* 10.23: fora do modo TV, a raiz da grade nova nunca deve aparecer. */
body:not(.bz-tv-grid-mode) #bz-tv-grid-root {
  display: none !important;
}

/* 10.23: quando a TV abre, a grade antiga fica invisivel desde o primeiro frame. */
body.bz-tv-grid-mode #sidebar .grupo-categoria,
body.bz-tv-grid-mode #sidebar .conteudo-canais,
body.bz-tv-grid-mode #sidebar .btn-categoria {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

@media (max-width: 1100px) {
  body.bz-tv-grid-mode #sidebar {
    width: clamp(500px, 48vw, 610px) !important;
    min-width: clamp(500px, 48vw, 610px) !important;
    max-width: clamp(500px, 48vw, 610px) !important;
    flex-basis: clamp(500px, 48vw, 610px) !important;
  }
  body.bz-tv-grid-mode #bz-tv-grid-root {
    grid-template-columns: minmax(220px, 43%) minmax(270px, 57%) !important;
  }
}


/* ===== FIX VISUAL FINAL: badge Adaptive verde + barra EPG amarela ===== */

/* nome do canal + badge na mesma linha */
#bz-tv-grid-root .bz-tv-channel-name,
.bz-tv-channel-card .bz-tv-channel-name {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

/* nome do canal cortando com ... */
#bz-tv-grid-root .bz-tv-channel-name-text,
.bz-tv-channel-card .bz-tv-channel-name-text {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

/* badge Adaptive verde bonito */
#bz-tv-grid-root .bz-tv-badge-adaptive,
.bz-tv-channel-card .bz-tv-badge-adaptive {
  flex: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 2px 7px !important;
  border-radius: 999px !important;
  background: #22a45a !important;
  color: #ffffff !important;
  border: 0 !important;
  font-size: 9px !important;
  font-weight: 900 !important;
  line-height: 1.4 !important;
  text-transform: uppercase !important;
  letter-spacing: .02em !important;
  white-space: nowrap !important;
}

/* bloco EPG dentro dos cards */
#bz-tv-grid-root .bz-card-epg,
.bz-tv-channel-card .bz-card-epg {
  display: block !important;
  margin-top: 4px !important;
  padding-top: 4px !important;
  height: 39px !important;
  min-height: 39px !important;
  max-height: 39px !important;
  border-top: 1px solid rgba(255,255,255,.06) !important;
  max-width: 100% !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

/* topo da EPG */
#bz-tv-grid-root .bz-card-epg-top,
.bz-tv-channel-card .bz-card-epg-top {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 6px !important;
  font-size: 9px !important;
  line-height: 1.1 !important;
  color: #ffcc00 !important;
  font-weight: 800 !important;
  text-transform: uppercase !important;
}

/* título da programação */
#bz-tv-grid-root .bz-card-epg-title,
.bz-tv-channel-card .bz-card-epg-title {
  margin-top: 3px !important;
  font-size: 10px !important;
  line-height: 1.15 !important;
  color: rgba(255,255,255,.84) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* barra amarela da EPG */
#bz-tv-grid-root .bz-card-epg-bar,
.bz-tv-channel-card .bz-card-epg-bar {
  display: block !important;
  margin-top: 4px !important;
  height: 3px !important;
  min-height: 3px !important;
  border-radius: 999px !important;
  background: rgba(255,255,255,.12) !important;
  overflow: hidden !important;
}

/* preenchimento amarelo da barra */
#bz-tv-grid-root .bz-card-epg-bar i,
.bz-tv-channel-card .bz-card-epg-bar i {
  display: block !important;
  height: 100% !important;
  min-width: 2px !important;
  border-radius: inherit !important;
  background: #ffcc00 !important;
}

/* ===== FIX FINAL: remove badge Adaptive antigo do Player4 e mantém só o novo verde ===== */

/* Esconde o badge antigo criado pelo bz-player4-plus-engine-v11/v12 */
#bz-tv-grid-root .bz-adaptive-badge-live,
.bz-tv-channel-card .bz-adaptive-badge-live {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

/* Mantém o badge correto inline no nome do canal */
#bz-tv-grid-root .bz-tv-channel-name,
.bz-tv-channel-card .bz-tv-channel-name {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

/* Nome com corte em reticências */
#bz-tv-grid-root .bz-tv-channel-name-text,
.bz-tv-channel-card .bz-tv-channel-name-text {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

/* Badge novo: verde, pequeno e elegante */
#bz-tv-grid-root .bz-tv-badge-adaptive,
.bz-tv-channel-card .bz-tv-badge-adaptive {
  flex: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 2px 7px !important;
  border-radius: 999px !important;
  background: #22a45a !important;
  color: #ffffff !important;
  border: 0 !important;
  font-size: 9px !important;
  font-weight: 900 !important;
  line-height: 1.4 !important;
  text-transform: uppercase !important;
  letter-spacing: .02em !important;
  white-space: nowrap !important;
  box-shadow: none !important;
}
