/**
 * Joyn Broadcast Player Styles
 * 기본 플레이어 스타일
 * 
 * @package Joyn_Broadcast
 * @since 1.0.0
 */

/* ============================================
   플레이어 컨테이너
   ============================================ */

.joyn-playlist-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    background: var(--joyn-bg-primary, #1a1a1a);
    color: var(--joyn-text-primary, #ffffff);
    border-radius: 8px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* 테마 변수 */
.joyn-playlist-container[data-theme="light"] {
    --joyn-bg-primary: #ffffff;
    --joyn-bg-secondary: #f5f5f5;
    --joyn-text-primary: #1a1a1a;
    --joyn-text-secondary: #666666;
    --joyn-border: #e0e0e0;
    --joyn-accent: #ff0000;
}

.joyn-playlist-container[data-theme="dark"] {
    --joyn-bg-primary: #1a1a1a;
    --joyn-bg-secondary: #2a2a2a;
    --joyn-text-primary: #ffffff;
    --joyn-text-secondary: #b3b3b3;
    --joyn-border: #404040;
    --joyn-accent: #ff0000;
}

/* 자동 테마 (시스템 설정 따름) */
@media (prefers-color-scheme: light) {
    .joyn-playlist-container[data-theme="auto"] {
        --joyn-bg-primary: #ffffff;
        --joyn-bg-secondary: #f5f5f5;
        --joyn-text-primary: #1a1a1a;
        --joyn-text-secondary: #666666;
        --joyn-border: #e0e0e0;
        --joyn-accent: #ff0000;
    }
}

@media (prefers-color-scheme: dark) {
    .joyn-playlist-container[data-theme="auto"] {
        --joyn-bg-primary: #1a1a1a;
        --joyn-bg-secondary: #2a2a2a;
        --joyn-text-primary: #ffffff;
        --joyn-text-secondary: #b3b3b3;
        --joyn-border: #404040;
        --joyn-accent: #ff0000;
    }
}

/* ============================================
   플레이어 박스
   ============================================ */

.joyn-player-box {
    position: relative;
    width: 100%;
    background: #000;
}

.joyn-player-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 비율 */
    background: #000;
    overflow: hidden;
}

.joyn-player-wrapper iframe,
.joyn-player-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ============================================
   플레이어 플레이스홀더
   ============================================ */

.joyn-player-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    cursor: pointer;
}

.joyn-video-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.joyn-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.joyn-big-play-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.joyn-big-play-button:hover {
    transform: scale(1.1);
}

.joyn-big-play-button svg {
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.joyn-play-text {
    margin-top: 16px;
    font-size: 16px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.joyn-play-hint {
    margin-top: 8px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ============================================
   비디오 정보
   ============================================ */

.joyn-current-video-info {
    padding: 16px 20px;
    background: var(--joyn-bg-primary);
    border-bottom: 1px solid var(--joyn-border);
}

.joyn-video-title {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 8px 0;
    color: #ffffff !important;
}

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

.joyn-video-description {
    font-size: 14px;
    line-height: 1.6;
    color: var(--joyn-text-secondary);
    margin-top: 8px;
}

.joyn-video-description p {
    margin: 0;
}

/* ============================================
   컨트롤 박스
   ============================================ */

.joyn-controls-box {
    background: var(--joyn-bg-secondary);
    border-bottom: 1px solid var(--joyn-border);
}

.joyn-player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
}

.joyn-control-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--joyn-text-primary);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.joyn-control-btn:hover {
    background: var(--joyn-bg-primary);
}

.joyn-control-btn.active {
    color: var(--joyn-accent);
}

.joyn-control-btn .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* ============================================
   플레이리스트 사이드바
   ============================================ */

.joyn-playlist-sidebar {
    background: var(--joyn-bg-secondary);
    max-height: 400px;
    display: flex;
    flex-direction: column;
}

.joyn-playlist-sidebar.hidden {
    display: none;
}

.joyn-playlist-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--joyn-border);
}

.joyn-playlist-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--joyn-text-primary);
}

.joyn-video-count {
    font-size: 14px;
    font-weight: normal;
    color: var(--joyn-text-secondary);
}

/* ============================================
   플레이리스트 아이템
   ============================================ */

.joyn-playlist-items {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.joyn-playlist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.joyn-playlist-item:hover {
    background: var(--joyn-bg-primary);
}

.joyn-playlist-item.active {
    background: var(--joyn-bg-primary);
    border-left: 3px solid var(--joyn-accent);
}

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

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

.joyn-duration {
    position: absolute;
    bottom: 4px;
    right: 4px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border-radius: 2px;
}

.joyn-item-info {
    flex: 1;
    min-width: 0;
}

.joyn-item-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--joyn-text-primary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.joyn-shorts-badge {
    display: inline-block;
    padding: 2px 6px;
    background: var(--joyn-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 3px;
    margin-right: 4px;
}

.joyn-item-actions {
    flex-shrink: 0;
}

.joyn-play-item-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--joyn-text-primary);
    cursor: pointer;
    transition: background-color 0.2s;
}

.joyn-play-item-btn:hover {
    background: var(--joyn-bg-secondary);
}

.joyn-now-playing {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--joyn-accent);
    font-weight: 600;
}

/* ============================================
   플레이리스트 푸터
   ============================================ */

.joyn-playlist-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--joyn-border);
    background: var(--joyn-bg-secondary);
}

.joyn-progress-bar {
    width: 100%;
    height: 4px;
    background: var(--joyn-border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.joyn-progress-fill {
    height: 100%;
    background: var(--joyn-accent);
    transition: width 0.3s;
}

.joyn-playlist-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--joyn-text-secondary);
}

.joyn-player-info {
    font-weight: 500;
}

/* ============================================
   로딩 & 에러
   ============================================ */

.joyn-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
}

.joyn-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--joyn-accent);
    border-radius: 50%;
    animation: joyn-spin 0.8s linear infinite;
}

@keyframes joyn-spin {
    to {
        transform: rotate(360deg);
    }
}

.joyn-error-message {
    padding: 16px 20px;
    background: #dc3545;
    color: #fff;
    font-size: 14px;
    text-align: center;
}

.joyn-player-error {
    padding: 40px 20px;
    text-align: center;
    background: var(--joyn-bg-primary);
    color: var(--joyn-text-primary);
}

/* ============================================
   스크롤바 스타일
   ============================================ */

.joyn-playlist-items::-webkit-scrollbar {
    width: 8px;
}

.joyn-playlist-items::-webkit-scrollbar-track {
    background: var(--joyn-bg-primary);
}

.joyn-playlist-items::-webkit-scrollbar-thumb {
    background: var(--joyn-border);
    border-radius: 4px;
}

.joyn-playlist-items::-webkit-scrollbar-thumb:hover {
    background: var(--joyn-text-secondary);
}

/* ============================================
   반응형 - 태블릿
   ============================================ */

@media (max-width: 768px) {
    .joyn-playlist-container {
        border-radius: 0;
    }
    
    .joyn-video-title {
        font-size: 16px;
        color: #ffffff !important;
    }
    
    /* 태블릿에서도 제목 흰색 강제 적용 */
    .joyn-video-title,
    .joyn-video-title *,
    .joyn-video-title span {
        color: #ffffff !important;
    }
    
    .joyn-player-controls {
        gap: 4px;
        padding: 8px 12px;
    }
    
    .joyn-control-btn {
        width: 36px;
        height: 36px;
    }
    
    .joyn-item-thumbnail {
        width: 100px;
        height: 56px;
    }
    
    .joyn-item-title {
        font-size: 13px;
    }
}

/* ============================================
   접근성
   ============================================ */

.joyn-control-btn:focus,
.joyn-play-item-btn:focus,
.joyn-big-play-button:focus {
    outline: 2px solid var(--joyn-accent);
    outline-offset: 2px;
}

.joyn-playlist-item:focus {
    outline: 2px solid var(--joyn-accent);
    outline-offset: -2px;
}

/* 키보드 네비게이션 */
.joyn-control-btn:focus-visible,
.joyn-play-item-btn:focus-visible {
    outline: 2px solid var(--joyn-accent);
    outline-offset: 2px;
}

/* ============================================
   애니메이션
   ============================================ */

@keyframes joyn-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.joyn-playlist-item {
    animation: joyn-fade-in 0.3s ease-out;
}

/* ============================================
   유틸리티
   ============================================ */

.joyn-hidden {
    display: none !important;
}

.joyn-invisible {
    visibility: hidden;
}

.joyn-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
