/* đặt cùng file CSS của live */
#remoteVideos {
  display: grid;
  gap: 12px;
  justify-content: center; /* căn giữa ngang */
  align-content: center;   /* căn giữa dọc toàn bộ grid */
  height: 100%;            /* phải có height cố định / kế thừa flex cha */
  padding: 15px;
  overflow-y: auto;
  min-height: 0;
}



#remoteVideos[data-count="1"] { 
  grid-template-columns: repeat(1, 1fr); 
  max-width: 600px;
  margin: 0 auto;
}
#remoteVideos[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
#remoteVideos[data-count="3"],
#remoteVideos[data-count="4"] { grid-template-columns: repeat(3, 1fr); }
#remoteVideos[data-count="5"],
#remoteVideos[data-count="6"],
#remoteVideos[data-count="7"],
#remoteVideos[data-count="8"] { grid-template-columns: repeat(4, 1fr); }

.video-wrapper{
  position:relative;
  width:100%;
  border-radius:8px;
  overflow:hidden;
}
.video-wrapper video{
  width:100%;
  aspect-ratio:16/9; /* tránh bóp méo */
  display:block;
  background:#000;
}

div#live-room-ui {
    padding: 15px;
}

button#btn-leave-live {
    margin: 0;
}
.livestream-chat {
    flex: 1;
}

.live-room {
  display: flex;
  flex-direction: column;
  height: 100vh;           /* hoặc 100%, tuỳ khung cha */
  border-radius: 8px;
  overflow: hidden;
}

.select-to-chat:not(.fullscreen) .body-livestream{ 
  height: 60vh;  
}
.select-to-chat.fullscreen .body-livestream {
  height: calc(100vh - 120px); /* trừ phần header livestream */
}
 
.body-livestream {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;           /* tránh double scroll */
}

.render-livestream-chat {
  flex: 1;
  overflow-y: auto;
  min-height: 0;              /* ⚡ cực quan trọng để flex con co được */
}

.live-controls {
    padding: 10px 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    border-radius: 12px;
    border: 1px solid #8e8e8e4f;
    max-width: 800px;
    margin: 0 auto;
    
}

.live-controls {
  padding-left: 15px;
  padding-right: 15px;
  box-sizing: border-box;  /* Đảm bảo padding được tính trong chiều rộng */
  width: 100%;
  max-width: calc(100% - 30px); /* Đảm bảo không vượt quá 100% - 30px (15px mỗi bên) */
}

.btn-live {
  background: rgba(255,255,255,0.1);
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  color: black;
}
.select-to-chat.fullscreen .btn-live {
  /*color: white;*/
}

.btn-live:hover {
  background: rgba(255,255,255,0.25);
}

.video-tile {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #8e8e8e4f;
    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1);  
}
.select-to-chat.fullscreen .livestream-chat {
  /*background-color: #171717;*/
  /*color: tan;*/
}

.sc-chat-main.chat-expanded {
  max-width: 500px;
  transition: max-width 0.3s ease;
}

/* khung xám mờ khi đang load livestream */
.livestream-loading-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  height: 100%;
  min-height: 400px; /* cho có chiều cao cố định */
}
.livestream-loading-placeholder {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  padding: 30px;
}

.live-placeholder-tile {
  border-radius: 8px;
  padding: 24px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid #8e8e8e4f;
}

.ph-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(90deg,#eee 25%,#f8f8f8 37%,#eee 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
}

.ph-name-placeholder,
.ph-subtext-placeholder {
  background: linear-gradient(90deg,#eee 25%,#f8f8f8 37%,#eee 63%)!important;
  width: 100px;
  height: 12px;
  border-radius: 4px;
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
}

.ph-name, .ph-subtext {
  height: 12px;
  border-radius: 4px;
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
}
.ph-subtext { width: 100px; opacity: 0.7; }
.ph-name { max-width: 150px; }

@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.video-tile .pip-camera {
  position: absolute;
  width: 160px;
  height: 90px;
  right: 12px;
  top: 12px; /* hoặc bottom:12px */
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.7);
  box-shadow: 0 0 10px rgba(0,0,0,0.4);
  z-index: 10;
}

:fullscreen .pip-camera,
:-webkit-full-screen .pip-camera {
  position: fixed !important;
  right: 24px !important;
  top: 24px !important;
  width: 240px !important;
  height: 135px !important;
  z-index: 99999 !important;
}

.video-tile.audio-only .stream-placeholder {
  opacity: 1;
}
.video-tile.audio-only button i.fa-volume-high {
  transition: 0.2s;
}
.video-tile.audio-only button:hover i.fa-volume-high {
  color: #4ade80; /* xanh khi hover */
}

.remote-videos {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.video-wrapper {
  position: relative;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;   /* ✅ giữ khung cố định, không bị co giãn */
  /* Nếu browser cũ không hỗ trợ aspect-ratio, fallback: */
  height: 0;
  padding-top: 56.25%;   /* 16:9 */
}

/* --- Video bên trong --- */
.livekit-video,
.video-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* PIP camera */
.pip-camera {
  position: absolute;
  width: 160px;
  height: 90px;
  right: 12px;
  top: 12px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.7);
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  z-index: 10;
  background: #000;
  pointer-events: none;
}

/* Volume controls */
.volume-button {
  position: absolute;
  right: 10px;
  bottom: 8px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  z-index: 20;
  padding: 0;
  margin: 0;  
}

.volume-slider {
  position: absolute;
  right: 50px;
  bottom: 15px;
  width: 70px;
  display: none;
  z-index: 20;
}

.volume-slider.show {
  display: block;
}

/* Quality badge */
.quality-badge {
  position: absolute;
  right: 8px;
  top: 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Participant name */
.participant-name {
  position: absolute;
  left: 8px;
  top: 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Fullscreen */
.fullscreen-btn {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 25px;
}

.video-tile video.livekit-video { 
object-fit: contain;
/*position: relative;*/
 }
 
.live-avatar-container {
  width: 30px;  /* Kích thước của avatar */
  height: 30px;
  display: inline-block;
  margin-right: 8px;
}

 

button#btn-join-live {
    margin: 10px auto;
    padding: 16px 25px;
}

.reset-livestream {
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Thay đổi từ center thành flex-start để cho phép các phần tử con hiển thị thành hàng */
    height: 90%;
    flex-direction: column;
    overflow-y: auto; /* Cho phép cuộn nếu có quá nhiều người tham gia */
}

#voice-channel-users {
    display: flex;
    flex-wrap: wrap; /* Các phần tử sẽ xuống dòng khi không đủ chỗ */
    gap: 15px; /* Khoảng cách giữa các avatar */
    justify-content: center;
    width: 100%; /* Đảm bảo chiếm toàn bộ chiều rộng */
}

.voice-channel-user {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #8e8e8e4f;
    border-radius: 8px;
    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin: 5px;
    width: 150px; /* Đặt chiều rộng cho mỗi khối user */
    text-align: center;
}

.voice-channel-user img.avatar-list-chat {
    border-radius: 50%;
    width: 70px;
    height: 70px;
    object-fit: cover;
}

.voice-channel-user .user-name {
    margin-left: 10px;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: none; /* Ẩn toast mặc định */
}

.toast-message {
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 15px;
  border-radius: 5px;
  font-size: 16px;
  max-width: 350px;
  text-align: center;
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
  animation: toast 3s ease-out;
}

@keyframes toast {
  0% { opacity: 0; transform: translateY(50px); }
  50% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(50px); }
}

.stream-placeholder {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;

  display: flex;
  align-items: center;
  justify-content: center;
  background-size: 20px 20px;
  background-position: top left;  
}

.select-to-chat.fullscreen .stream-placeholder {
    /*background-image: linear-gradient(to right, rgb(175 175 175 / 5%) 1px, #00000000 1px), linear-gradient(to bottom, rgb(175 175 175 / 0%) 1px, #00000070 1px);*/
}

.ph-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* Avatar có ảnh */
.ph-avatar-img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

/* Avatar chỉ có chữ */
.ph-avatar-initials {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  color: #fff;
}

.ph-name {
  font-weight: 500;
  font-size: 14px;
}

.ph-wait {
  opacity: .7;
  font-size: 14px;
}
.volume-slider {
    display: none;
}

.volume-slider.show {
    display: block;
}