/**
 * Joyn TV Category 플레이어 페이지 스타일
 * 카테고리 전용 재생창 (재생창 + 재생목록)
 *
 * @package    Joyn_Broadcast
 * @since      1.0.0
 */

.joyn-tv-category-container {
    max-width: 100%;
    margin: 0;
    padding: 0;
    background: #000;
    min-height: 100vh;
    width: 100%;
    box-sizing: border-box;
}

/* WordPress 테마의 기본 스타일 오버라이드 */
body .joyn-tv-category-container {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
}

.joyn-tv-category-tabs-wrapper {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 100; /* 상단 메뉴보다 낮게 설정 */
    background: #1a1a1a;
    border-bottom: 2px solid #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    width: 100%;
    margin: 0;
    padding: 0;
    left: 0;
    right: 0;
}

/* 상단 메뉴와 서브메뉴가 재생창보다 위에 표시되도록 z-index 설정 */
/* 일반 화면에서는 원래 position 유지, z-index만 조정 */
header,
.site-header,
.ast-header-break-point .site-header,
.ast-header-break-point .main-header-bar,
.ast-header-break-point .main-header-bar-wrap {
    z-index: 1001 !important; /* 재생창(z-index: 100)보다 위에 표시 */
}

.main-navigation,
.main-navigation ul,
.main-navigation li,
nav,
nav ul,
nav li,
.site-header .main-navigation,
.site-header .main-navigation ul,
.site-header .main-navigation li,
.ast-header-break-point .main-navigation,
.ast-header-break-point .main-navigation ul,
.ast-header-break-point .main-navigation li {
    z-index: 1001 !important; /* 재생창(z-index: 100)보다 위에 표시 */
}

/* 서브메뉴는 드롭다운이므로 absolute/fixed position 유지하면서 z-index만 조정 */
.main-navigation .sub-menu,
.main-navigation .sub-menu li,
nav .sub-menu,
nav .sub-menu li,
.site-header .main-navigation .sub-menu,
.site-header .main-navigation .sub-menu li,
.ast-header-break-point .main-navigation .sub-menu,
.ast-header-break-point .main-navigation .sub-menu li {
    z-index: 1002 !important; /* 서브메뉴는 메뉴보다 위에 */
}

/* 모바일 메뉴 버튼 */
header .menu-toggle,
header .mobile-menu-toggle,
header .hamburger,
.site-header .menu-toggle,
.site-header .mobile-menu-toggle,
.site-header .hamburger,
.ast-mobile-menu-buttons,
.ast-header-break-point .ast-mobile-menu-buttons,
.ast-button-wrap,
.ast-button-wrap .main-header-menu-toggle,
.main-navigation .menu-toggle,
nav .menu-toggle,
.ast-header-break-point .ast-button-wrap,
.ast-header-break-point .ast-button-wrap .main-header-menu-toggle {
    z-index: 1001 !important; /* 재생창(z-index: 100)보다 위에 표시 */
    position: relative !important; /* 모바일 메뉴 버튼만 relative 유지 */
}

/* 헤더가 고정되어 있을 경우를 대비 */
body.admin-bar .joyn-tv-category-tabs-wrapper {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .joyn-tv-category-tabs-wrapper {
        top: 46px;
    }
}

.joyn-tv-category-tabs {
    display: flex;
    background: #1a1a1a;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #666 #1a1a1a;
    margin: 0;
    padding: 0;
    min-height: 59px;
    box-sizing: border-box;
}

.joyn-tv-category-tabs::-webkit-scrollbar {
    height: 4px;
}

.joyn-tv-category-tabs::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 2px;
}

.joyn-tv-category-tabs::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.joyn-tv-category-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #999;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: max-content;
    flex-shrink: 0;
    min-height: 59px;
    box-sizing: border-box;
}

.joyn-tv-category-tab i {
    font-size: 18px;
    display: none;
}

.joyn-tv-category-tab:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.joyn-tv-category-tab--active {
    color: #fff;
    border-bottom-color: var(--category-color, #667eea);
    background: rgba(255, 255, 255, 0.05);
    font-weight: 500;
}

.joyn-tv-category-tab--active i {
    color: var(--category-color, #667eea);
}

.joyn-tv-category-player-wrapper {
    position: relative;
    width: 100%;
    max-width: 1920px;
    margin: 0 auto;
    background: #000;
    display: flex;
    flex-direction: column;
    gap: 0;
    /* 재생창이 sticky일 때 전체 컨테이너가 올바르게 작동하도록 */
}

.joyn-tv-category-main-content {
    display: flex;
    flex-direction: row;
    gap: 0;
    width: 100%;
}

/* 재생창 영역 */
.joyn-tv-category-player-section {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    order: 1; /* 재생창이 첫 번째 */
    position: -webkit-sticky;
    position: sticky;
    top: 59px; /* 카테고리 탭 높이만큼 아래에 고정 */
    align-self: flex-start; /* sticky가 작동하도록 */
    z-index: 50; /* 상단 메뉴(z-index: 1001)보다 낮게 설정 */
    background: #000; /* 배경색 설정 */
    max-height: calc(100vh - 59px); /* 화면 높이에서 탭 높이 제외 */
    overflow-y: visible; /* 재생창 내용은 스크롤 없음 */
}

/* 헤더가 고정되어 있을 경우 */
body.admin-bar .joyn-tv-category-player-section {
    top: 91px; /* 32px (admin bar) + 59px (tabs) */
    max-height: calc(100vh - 91px);
}

@media screen and (max-width: 782px) {
    body.admin-bar .joyn-tv-category-player-section {
        top: 105px; /* 46px (admin bar) + 59px (tabs) */
        max-height: calc(100vh - 105px);
    }
}

.joyn-tv-category-player-box {
    position: relative;
    width: 100%;
    background: #000;
    flex-shrink: 0; /* sticky 시 크기 고정 */
}

.joyn-tv-category-player-wrapper-inner {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 비율 (기본값) */
    height: 0;
    overflow: hidden;
    background: #000;
    transition: padding-bottom 0.3s ease;
}

/* 숏츠 영상: 9:16 비율 (세로) - 세로 크기 30% 줄임 */
.joyn-tv-category-player-wrapper-inner.joyn-tv-category-shorts-mode,
.joyn-tv-category-player-wrapper-inner[data-shorts-mode="true"] {
    padding-bottom: 140% !important; /* 세로 크기 30% 줄임 (200% * 0.7 = 140%) */
    max-width: 400px !important; /* 숏츠 영상 최대 너비 제한 (세로가 더 길어지도록) */
    margin: 0 auto !important; /* 가운데 정렬 */
    width: 100% !important;
}

/* 숏츠 모드일 때 플레이어 박스와 섹션도 조정 */
.joyn-tv-category-player-box.shorts-mode,
.joyn-tv-category-player-section.shorts-mode {
    max-width: 400px !important;
    margin: 0 auto !important;
}

/* 숏츠 재생 시 재생창 z-index 높이기 */
.joyn-tv-category-player-section.shorts-mode {
    z-index: 100 !important; /* 푸터보다 위에 표시하되 메뉴보다는 낮게 */
}

/* 숏츠 재생 시 푸터가 재생창 밑으로 가도록 */
body.joyn-shorts-mode-active .site-footer,
body.joyn-shorts-mode-active footer,
body.joyn-shorts-mode-active .ast-footer,
body.joyn-shorts-mode-active .footer-widget-area {
    position: relative;
    z-index: 1 !important;
}

.joyn-tv-category-player {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: #000 !important;
    z-index: 1;
}

.joyn-tv-category-player iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1;
}

.joyn-tv-category-player > div {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
}

/* 재생 컨트롤 박스 (영상 제목 아래) */
.joyn-tv-category-controls-box {
    background: #2a2a2a;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
    padding: 14px 25px;
    min-height: 58px;
    width: 100%;
    border-top: 1px solid #333;
    order: 3; /* 영상 제목 아래에 표시 */
}

.joyn-tv-category-player-controls {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

.joyn-tv-category-control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    padding: 7px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 5px;
    min-width: 32px;
    height: 29px;
    position: relative;
}

.joyn-tv-category-control-btn:hover {
    background: rgba(255, 0, 0, 0.2);
    border-color: #ff0000;
    color: #ff0000;
    transform: scale(1.05);
}

.joyn-tv-category-control-btn.active {
    background: rgba(255, 0, 0, 0.3);
    border-color: #ff0000;
    color: #ff0000;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.3);
}

.joyn-tv-category-control-btn i {
    font-size: 14px;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 삭제 버튼 스타일 */
.joyn-tv-category-delete-btn {
    margin-left: auto;
    color: #dc2626;
}

.joyn-tv-category-delete-btn:hover {
    background: rgba(220, 38, 38, 0.3);
    border-color: #dc2626;
    color: #ff4444;
}

.joyn-tv-category-video-title {
    width: 100%;
    padding: 16px 20px;
    background: #1a1a1a;
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
    order: 2; /* 재생창 아래, 컨트롤 박스 위 */
    flex-shrink: 0; /* sticky 시 크기 고정 */
    display: flex;
    align-items: flex-start;
    gap: 8px;
    position: relative;
}

.joyn-tv-category-video-title-text {
    color: #ffffff !important;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.5;
    display: block;
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* 일반 화면에서는 여러 줄로 표시 */
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

/* 영상 제목 텍스트 강제 흰색 적용 */
.joyn-tv-category-video-title,
.joyn-tv-category-video-title *,
.joyn-tv-category-video-title span {
    color: #ffffff !important;
}

/* 재생목록 영역 */
.joyn-tv-category-playlist-section {
    width: 400px;
    background: #1a1a1a;
    border-left: 1px solid #333;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 59px); /* 탭 높이 제외 */
    order: 2; /* 재생목록이 오른쪽(두 번째) */
    overflow-y: auto; /* 재생목록만 스크롤 가능 */
    overflow-x: hidden;
    /* 재생창이 sticky이므로 재생목록은 일반 스크롤 */
}

.joyn-tv-category-playlist-header {
    padding: 20px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.joyn-tv-category-playlist-header h3 {
    margin: 0;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
}

.joyn-tv-category-playlist-count {
    color: #999;
    font-size: 14px;
}

.joyn-tv-category-playlist-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: #666 #1a1a1a;
}

.joyn-tv-category-playlist-content::-webkit-scrollbar {
    width: 6px;
}

.joyn-tv-category-playlist-content::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 3px;
}

.joyn-tv-category-playlist-content::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.joyn-tv-category-playlist-item {
    display: flex;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #2a2a2a;
}

.joyn-tv-category-playlist-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.joyn-tv-category-playlist-item--active {
    background: rgba(102, 126, 234, 0.1);
    border-left: 3px solid var(--category-color, #667eea);
}

.joyn-tv-category-playlist-item-thumbnail {
    position: relative;
    flex-shrink: 0;
    width: 120px;
    height: 68px;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
}

.joyn-tv-category-playlist-item-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.joyn-tv-category-playlist-item-duration {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 2px;
}

.joyn-tv-category-playlist-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.joyn-tv-category-playlist-item-title {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 4px;
    /* 한 줄 말줄임표 처리 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    width: 100%;
}

.joyn-tv-category-playlist-item--active .joyn-tv-category-playlist-item-title {
    color: var(--category-color, #667eea);
}

.joyn-tv-category-playlist-item-views {
    color: #999;
    font-size: 12px;
}

.joyn-tv-category-player-loading {
    padding: 60px 20px;
    text-align: center;
    color: #999;
    font-size: 16px;
}

/* 아이패드 및 태블릿 반응형 (769px ~ 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .joyn-tv-category-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    body .joyn-tv-category-container {
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }
    
    .joyn-tv-category-player-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .joyn-tv-category-main-content {
        flex-direction: column;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* 태블릿에서 재생창 크기 확대 - 좌우 꽉 차게 */
    .joyn-tv-category-player-section {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .joyn-tv-category-player-box {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .joyn-tv-category-player-wrapper-inner {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        padding-bottom: 56.25% !important; /* 16:9 비율 유지 */
    }
    
    .joyn-tv-category-player {
        width: 100% !important;
        height: 100% !important;
    }
    
    .joyn-tv-category-video-title {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding-left: 20px;
        padding-right: 20px;
    }
    
    .joyn-tv-category-playlist-section {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        max-height: 400px;
        border-left: none;
        border-top: 1px solid #333;
        /* 태블릿에서는 재생창 아래에 위치하므로 sticky 영향 없음 */
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    /* joyn-player 컨테이너도 전체 너비로 */
    .joyn-player-wrapper,
    .joyn-player-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* 테마 컨테이너도 전체 너비로 */
    .site-content,
    .content-area,
    .main-content,
    .entry-content,
    .post-content,
    .container,
    .wrap,
    .site-main {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

@media (max-width: 768px) {
    .joyn-tv-category-container {
        margin: 0;
        padding: 0;
        width: 100%;
        max-width: 100%;
    }
    
    body {
        margin: 0;
        padding: 0;
    }
    
    .joyn-tv-category-tabs-wrapper {
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        z-index: 100; /* 상단 메뉴보다 낮게 설정 */
        width: 100%;
        left: 0;
        right: 0;
    }
    
    .joyn-tv-category-tabs {
        margin: 0;
        padding: 0;
        width: 100%;
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: #666 #1a1a1a;
        min-height: 42px;
        box-sizing: border-box;
    }
    
    .joyn-tv-category-tabs::-webkit-scrollbar {
        height: 4px;
    }
    
    .joyn-tv-category-tab {
        padding: 12px 14px;
        font-size: 13px;
        min-width: max-content;
        flex-shrink: 0;
        min-height: 42px;
        box-sizing: border-box;
    }
    
    .joyn-tv-category-tab i {
        display: none;
    }
    
    .joyn-tv-category-tab span {
        white-space: nowrap;
    }
    
    .joyn-tv-category-player-wrapper {
        margin: 0;
        padding: 0;
        width: 100%;
    }
    
    .joyn-tv-category-main-content {
        flex-direction: column;
        width: 100%;
    }
    
    /* 모바일에서 재생창 섹션 전체 너비 사용 */
    .joyn-tv-category-player-section {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 100% !important;
        min-width: 100% !important;
        top: 42px; /* 모바일 탭 높이 */
        max-height: calc(100vh - 42px);
    }
    
    body.admin-bar .joyn-tv-category-player-section {
        top: 88px; /* 46px (admin bar) + 42px (tabs) */
        max-height: calc(100vh - 88px);
    }
    
    /* 모바일에서 재생창 박스 전체 너비 사용 */
    .joyn-tv-category-player-box {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* 모바일에서 플레이어 wrapper-inner 전체 너비 사용 */
    .joyn-tv-category-player-wrapper-inner {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
    }
    
    /* 모바일에서 숏츠 모드일 때도 전체 너비 사용 (일반 재생창은 이미 100%) */
    .joyn-tv-category-player-wrapper-inner.joyn-tv-category-shorts-mode,
    .joyn-tv-category-player-wrapper-inner[data-shorts-mode="true"] {
        max-width: 100% !important; /* 모바일에서는 전체 너비 사용 */
        width: 100% !important;
        padding-bottom: 140% !important; /* 세로 크기 30% 줄임 (200% * 0.7 = 140%) */
    }
    
    /* 모바일에서 숏츠 모드일 때 박스와 섹션도 전체 너비 */
    .joyn-tv-category-player-box.shorts-mode,
    .joyn-tv-category-player-section.shorts-mode {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    .joyn-tv-category-playlist-section {
        width: 100%;
        max-height: 300px;
        border-left: none;
        border-top: 1px solid #333;
    }
    
    .joyn-tv-category-playlist-header {
        padding: 15px;
    }
    
    .joyn-tv-category-playlist-header h3 {
        font-size: 16px;
    }
    
    .joyn-tv-category-playlist-item {
        padding: 10px 15px;
    }
    
    .joyn-tv-category-playlist-item-thumbnail {
        width: 100px;
        height: 56px;
    }
    
    .joyn-tv-category-playlist-item-title {
        font-size: 13px;
        /* 모바일에서 한 줄 말줄임표 처리 */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
        width: 100%;
    }
    
    .joyn-tv-category-video-title {
        padding: 12px 15px;
        display: flex;
        align-items: flex-start;
        gap: 6px;
    }
    
    .joyn-tv-category-video-title-text {
        font-size: 12px;
        color: #ffffff !important;
        display: block;
        flex: 1;
        min-width: 0;
        word-wrap: break-word;
        overflow-wrap: break-word;
        /* 기본 상태: 한 줄로 제한 */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.4;
    }
    
    /* 펼쳐진 상태: 여러 줄로 표시 */
    .joyn-tv-category-video-title.expanded .joyn-tv-category-video-title-text {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }
    
    .joyn-tv-category-title-toggle {
        padding: 2px;
        margin-top: 0;
        flex-shrink: 0;
    }
    
    .joyn-tv-category-title-toggle i {
        font-size: 16px;
    }
    
    /* 모바일에서도 제목 흰색 강제 적용 */
    .joyn-tv-category-video-title,
    .joyn-tv-category-video-title *,
    .joyn-tv-category-video-title span {
        color: #ffffff !important;
    }
    
    .joyn-tv-category-controls-box {
        padding: 10px 15px;
        min-height: 50px;
    }
    
    .joyn-tv-category-player-controls {
        gap: 8px;
    }
    
    .joyn-tv-category-control-btn {
        padding: 6px 8px;
        min-width: 28px;
        height: 26px;
    }
    
    .joyn-tv-category-control-btn i {
        font-size: 12px;
        width: 12px;
        height: 12px;
    }
    
    /* 모바일에서 푸터 숨김 */
    .site-footer,
    footer,
    .ast-footer,
    .footer-widget-area,
    .site-footer-wrap,
    .footer-widgets,
    .footer-bottom {
        display: none !important;
    }
    
}

/* WordPress 테마의 기본 padding/margin 제거 */
.site-content,
.content-area,
.main-content,
.entry-content,
.post-content {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
}

.container,
.wrap,
.site-main {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}
