.page-wrapper {
  max-width: 100%;
  margin: 16px 0 10px;
  padding: 0 16px;
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 450px;
  gap: 24px;
  align-items: flex-start;
  padding: 0 10px 20px 10px;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 900px) {
  .page-grid {
    grid-template-columns: 1fr;
  }

  .video-wrapper {
    border-radius: 0;
  }
}

@media (max-width: 600px) {

  /* video ชิดขอบแบบ YouTube */
  .page-wrapper {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .video-wrapper {
    border-radius: 0 !important;
  }
}

/* =====================================================
   SIDEBAR / BRANCH LIST
   ===================================================== */
.branch-scroll {
  height: calc(80vh - 220px);
  overflow-y: auto;
}

.branch-list {
  display: block;
}

.branch-item {
  display: block;
  padding: 12px 14px;
  margin-bottom: 6px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: #fff;
  font-size: 16px;
}

.branch-item.active {
  background: var(--accent-soft);
  border-left: 5px solid var(--led-blue);
  font-weight: 600;
}

/* iPad → 2 columns */
@media (min-width: 768px) and (max-width: 1024px) {
  .branch-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .branch-item {
    margin-bottom: 0;
  }
}

/* =====================================================
   OFFLINE MODE (16:9 LIKE LIVE)
   ===================================================== */
.offline-body {
  width: 95%;
  aspect-ratio: 16 / 9;
  max-width: calc(100vh * (16 / 9));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: linear-gradient(
    180deg,
    #F2F2F2 0%,
    #EEF2FF 100%
);
}

* =====================================================
   OFFLINE IMAGE SIZE FIX
   ===================================================== */

/* คุมขนาดรูป OFFLINE ไม่ให้ใหญ่เกิน */
.offline-body img {
  max-width: 200px;   /* ขนาดมาตรฐาน */
  width: 100%;
  height: auto;
  margin-bottom: 20px;
}

/* จอใหญ่มาก (TV / Monitor) */
@media (min-width: 1400px) {
  .offline-body img {
    max-width: 220px;
  }
}

/* Tablet */
@media (max-width: 1024px) {
  .offline-body img {
    max-width: 180px;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .offline-body img {
    max-width: 150px;
  }
}


/* =====================================================
   MULTI SCREEN LAYOUT (SUPPORT UP TO 4 SCREENS)
   ===================================================== */

/* ================= LEFT : MAIN SCREEN ================= */
.screen-main {
  display: flex;
}

.screen-main .video-wrapper {
  width: 100%;
  height: 100%;
}

/* ================= RIGHT : SUB SCREENS ================= */
.screen-side {
  display: grid;
  grid-template-rows: repeat(auto-fit, minmax(0, 1fr));
  gap: 0;
}

/* แต่ละจอด้านขวา */
.screen-sub {
  display: flex;
}

.screen-sub .video-wrapper {
  width: 100%;
  height: 100%;
}


.branch-multi-screen {
	position: relative;
  display: grid;
  grid-template-columns: 2.4fr 1.07fr; /* จอหลักซ้าย / จอรองขวา */
  gap: 0;
  align-items: start;
  background:#000;
}
/* ===== 16:9 RATIO (ทุกจอ) ===== */
.video-wrapper {
  display: grid;
  grid-template-columns: 1fr; 
  gap: 16px;
  align-items: start;
  background:#000;
}

/* video / iframe / video.js */
.video-wrapper video,
.video-wrapper iframe,
.video-js {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;   /* ❗ ไม่ยืด ไม่ crop */
}

/* ===== SOUND / LOADING OVERLAY SAFE ===== */
.video-wrapper .sound-overlay,
.video-wrapper .video-loading {
  position: absolute;
  inset: 0;
  z-index: 50;
}


/* =====================================================
   RESPONSIVE – TABLET / MOBILE
   ===================================================== */
@media (max-width: 900px) {

  /* เรียงลงล่างทั้งหมด */
  .branch-multi-screen {
    grid-template-columns: 1fr;
  }

  .screen-side {
    grid-template-rows: none;
    grid-auto-rows: auto;
	grid-template-columns: 1fr;
  }

  .screen-main,
  .screen-sub {
    width: 100%;
	margin-bottom: 12px;
  }
}

/* =====================================================
   📱 MOBILE – MOVE SCREEN 2 3 4 TO BOTTOM (LEFT → RIGHT)
   ===================================================== */
@media (max-width: 600px) {

  /* โครงรวม */
  .branch-multi-screen {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* จอหลักอยู่บน */
  .screen-main {
    grid-column: 1 / -1;
  }

  /* กลุ่มจอรอง = เรียงแนวนอน */
  .screen-side {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 2-3-4 ซ้าย→ขวา */
    gap: 6px;
  }

  /* กันจอยืด */
  .screen-sub {
    width: 100%;
  }

  /* video รักษา 16:9 */
  .screen-sub .video-wrapper {
    aspect-ratio: 16 / 9;
  }
}

@media (max-width: 480px) {

  /* เรียงลงล่างทั้งหมด */
  .branch-multi-screen {
    grid-template-columns: 1fr;
  }

  .screen-side {
    grid-template-rows: none;
    grid-auto-rows: auto;
  }

  .screen-main,
  .screen-sub {
    width: 100%;
  }
}


/* =========================================
   📱 MOBILE LANDSCAPE – LOCK 16:9 (No crop)
   ========================================= */
@media (max-width: 900px) and (orientation: landscape) {

  /* กล่องรวม Live (4 จอ) ให้ล็อกเป็น 16:9 */
  .branch-multi-screen{
    width: 100vw;
    max-width: 100vw;

    aspect-ratio: 16 / 9;     /* ✅ ล็อก 16:9 */
    height: auto;

    /* ✅ จัดให้อยู่กลางหน้าจอ */
    margin: auto;
    display: grid;

    /* ให้เห็นขอบดำบน/ล่างสำหรับจอ 16:10 */
    background: #000;
  }

  /* ให้ body / container ช่วยจัดกลาง */
  body{
    background: #000;
  }

  /* ✅ จัดกลางแนวตั้งจริง ๆ */
  .container, .container-fluid, .main, .wrapper, .content {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    min-height: 100vh;
    min-height: 100dvh;
  }
  

  /* ทุกจอเต็มช่อง */
  .branch-multi-screen .screen-main,
  .branch-multi-screen .screen-sub,
  .branch-multi-screen .screen-side,
  .branch-multi-screen .video-wrapper{
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: #000;
  }

  /* video/iframe ไม่ crop */
  .branch-multi-screen video,
  .branch-multi-screen iframe,
  .branch-multi-screen .video-js{
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    background: #000;
  }
}

/* ถ้ามีจอที่ 4 (city-video4)*/
.branch-multi-screen:has(#city-video4)
  .screen-main .video-wrapper {
  aspect-ratio: 4 / 3;
}

/* การแสดงผลของ video จอหลัก */
.branch-multi-screen:has(#city-video4)
  .screen-main .video-wrapper video,
.branch-multi-screen:has(#city-video4)
  .screen-main .video-wrapper iframe,
.branch-multi-screen:has(#city-video4)
  .screen-main .video-wrapper .video-js {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}

/* จอรอง (2–4) ยังเป็น 16:9 */
.branch-multi-screen:has(#city-video4)
  .screen-sub .video-wrapper {
  aspect-ratio: 16 / 9;
}

/* ---------- ✅ Footer overlay เฉพาะตอน fullscreen ---------- */
.branch-multi-screen:fullscreen ~ .live-footer,
.branch-multi-screen:-webkit-full-screen ~ .live-footer{
  display:flex !important;

  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;

  padding: 12px 14px !important;
  margin: 0 !important;

  background: linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,0));
  color: #fff;

  z-index: 999999;
}

/* ปรับสี link ตอน overlay */
.branch-multi-screen:fullscreen ~ .live-footer a,
.branch-multi-screen:-webkit-full-screen ~ .live-footer a{
  color:#fff;
  text-decoration:none;
}

/* ---------- ✅ Fullscreen 4 จอ (mobile landscape) ---------- */
@media (max-width: 900px) and (orientation: landscape) {

  .branch-multi-screen:fullscreen,
  .branch-multi-screen:-webkit-full-screen{

    width: 100vw;
    height: 100vh;    /* fallback */
    height: 100dvh;   /* ✅ safe */

    display: grid;

    /* ✅ 1 ซ้ายใหญ่ / 3 จอขวาเรียงตั้ง */
    grid-template-columns: 2.4fr 1fr;
    gap: 0;

    background: #000;
    overflow: hidden;
  }

  /* ซ้าย */
  .branch-multi-screen:fullscreen .screen-main,
  .branch-multi-screen:-webkit-full-screen .screen-main{
    grid-column: 1 / 2;
    width:100%;
    height:100%;
    overflow:hidden;
    display:flex;
  }

  /* ขวา: 3 จอเรียงแนวตั้ง */
  .branch-multi-screen:fullscreen .screen-side,
  .branch-multi-screen:-webkit-full-screen .screen-side{
    grid-column: 2 / 3;

    display:grid;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 0;

    width:100%;
    height:100%;
    overflow:hidden;
  }

  /* ทุกจอ */
  .branch-multi-screen:fullscreen .screen-sub,
  .branch-multi-screen:-webkit-full-screen .screen-sub{
    overflow:hidden;
    min-width:0;
    min-height:0;
  }

  /* video wrapper */
  .branch-multi-screen:fullscreen .video-wrapper,
  .branch-multi-screen:-webkit-full-screen .video-wrapper{
    width: 100%;
    height: 100%;
    overflow: hidden;
    background:#000;
  }

  /* video/iframe/videojs */
  .branch-multi-screen:fullscreen video,
  .branch-multi-screen:fullscreen iframe,
  .branch-multi-screen:fullscreen .video-js,
  .branch-multi-screen:-webkit-full-screen video,
  .branch-multi-screen:-webkit-full-screen iframe,
  .branch-multi-screen:-webkit-full-screen .video-js{
    width:100% !important;
    height:100% !important;
    object-fit: contain;
    background:#000;
  }

  /* ✅ กัน footer overlay บัง content (เผื่ออยากเลื่อน) */
  body{
    padding-bottom: 54px;
  }
}

/* ตอนมือถือแนวนอน ป้องกัน layout เพี้ยน */
@media (max-width: 1024px) and (orientation: landscape) {

  #live-container{
    width: 100vw !important;
    height: calc(var(--vh) * 100) !important;
    overflow: hidden !important;
    background:#000;
  }

  /* บังคับ player เต็มกรอบ */
  .video-js,
  .video-js video{
    width: 100% !important;
    height: 100% !important;
	object-fit: contain !important;
  }
}

.video-tab{
  bottom:16px;
  right:16px;
  left:auto;
  top:auto;
  transform:none;
}

/* ==========================================================
   🔥 MOBILE LANDSCAPE = CONTROL ROOM MODE (REAL AUCTION)
   ========================================================== */
@media (max-width:900px) and (orientation:landscape){

  body{
    background:#000 !important;
    overflow:hidden;
  }

  /* ซ่อนส่วนเกิน */
  .led-header,
  .led-nav,
  .live-footer,
  .video-info-row{
    display:none !important;
  }

  /* live container เต็มจอ */
  #live-container{
    position:fixed !important;
    inset:0 !important;
    width:100vw !important;
    height:100vh !important;
    background:#000 !important;
    z-index:999;
  }

  /* wrapper เต็ม */
  #live-container .page-wrapper{
    padding:0 !important;
    margin:0 !important;
    max-width:100% !important;
    width:100% !important;
    height:100% !important;
  }

  /* 4 กล้อง layout control room */
  .branch-multi-screen{
    width:100vw !important;
    height:100vh !important;

    display:grid !important;
    grid-template-columns: 2.4fr 1fr !important;
    grid-template-rows: 1fr !important;

    gap:0 !important;
    background:#000;
  }

  /* ซ้ายใหญ่ */
  .screen-main{
    width:100%;
    height:100%;
    overflow:hidden;
  }

  /* ขวา 3 จอเรียง */
  .screen-side{
    display:grid !important;
    grid-template-rows:1fr 1fr 1fr !important;
    gap:0 !important;
    height:100%;
  }

  .screen-sub{
    width:100%;
    height:100%;
    overflow:hidden;
  }

  /* video เต็ม */
  .video-wrapper{
    width:100% !important;
    height:100% !important;
    aspect-ratio:auto !important;
    background:#000;
  }

  .video-wrapper video,
  .video-wrapper iframe,
  .video-js{
    width:100% !important;
    height:100% !important;
    object-fit:contain !important;
    background:#000;
  }

  /* control popup */
	.video-tab{
	  bottom:16px;
	  right:16px;
	  left:auto;
	  top:auto;
	  transform:none;
	}
}

/* ซ่อน volume video.js เดิม */
.vjs-volume-panel{
  display:none !important;
}

