/* ===============================
   YouTube 플레이어 컨테이너
================================= */
#youtube-player-container {
    margin: 20px 0;
    padding: 20px 10px 10px 10px;
    background: #f4f9f9;
    border-radius: 8px;
    box-sizing: border-box;
    overflow: hidden;  /* ✅ 음수 마진 처리 */
}

/* 플레이어 영역 */
#youtube-player {
    width: 100%;
    height: 456px;
    border-radius: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    border: none;
    display: block;
    line-height: 0;
    vertical-align: bottom;
    transition: height 0.3s ease;
}

/* iframe 자체 여백 제거 */
#youtube-player iframe {
    display: block;
    border: none;
    margin: 0;
    padding: 0;
    vertical-align: bottom;
}

/* 모바일용 (가로 768px 이하) */
@media (max-width: 768px) {
    #youtube-player {
        height: calc(100vw * 9 / 16);
        margin-bottom: 0;  /* ✅ 0으로 변경 */
    }
}

/* 모바일용 (가로 480px 이하) */
@media (max-width: 480px) {
    #youtube-player {
        height: calc(100vw * 9 / 16);
        margin-bottom: 0;  /* ✅ 0으로 변경 */
    }
}

/* ===============================
   컨트롤 버튼
================================= */
.yt-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.yt-ctrl-btn {
    padding: 9px 0px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    width: 51px;
    text-align: center;
}

.yt-ctrl-btn:hover {
    background: #f0f0f0;
}

.yt-ctrl-btn.play {
    background: #ff0000;
    color: white;
    border-color: #ff0000;
}

.yt-ctrl-btn.play:hover {
    background: #cc0000;
}

/* ===============================
   플레이리스트
================================= */
#youtube-playlist {
    background: #fcfefe;
    border-radius: 8px;
    padding: 15px 8px;
    box-sizing: border-box;
}

/* 플레이리스트 헤더: 좌/우 배치 + 모바일 한 줄 */
.yt-playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0 10px;
    box-sizing: border-box;
    margin-bottom: 0px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.yt-playlist-header h4 {
    margin: 0;
    font-size: 1.2em;
    white-space: nowrap;
    color: #333;
}

.yt-playlist-header h4 i {
    color: #ff0000;
    margin-right: 8px;
}

.yt-count {
    font-size: 0.9em;
    white-space: nowrap;
    margin-left: 8px;
    color: #666;
}

/* ===============================
   선택 전체 행
================================= */
.yt-select-all-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.yt-select-all-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.yt-select-all-row label {
    cursor: pointer;
    font-size: 14px;
    color: #666;
    user-select: none;
}

.yt-drag-info {
    margin-left: auto;
    font-size: 13px;
    color: #999;
    font-style: italic;
}

/* ===============================
   플레이리스트 아이템
================================= */
.yt-playlist-items {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
}

.yt-playlist-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
    background: #ffffff;
    transition: all 0.3s ease;
    overflow: visible;
}

.yt-playlist-item:hover {
    background: #f8f9fa;
}

.yt-playlist-item.playing::before {
    content: '';
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: 0;
    width: 3px;
    background-color: #ff0000;
    z-index: 1;
}

/* 모바일용 보정 */
@media (max-width: 768px) {
    .yt-playlist-item.playing::before {
        top: 5px;
        bottom: 5px;
        left: 0;
        width: 3px;
    }
}

/* 체크박스 */
.yt-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}

/* 선택된 항목 */
.yt-playlist-item.selected {
    opacity: 1;
}

.yt-playlist-item:not(.selected) .yt-item-title {
    text-decoration: line-through;
    color: #999;
}

/* 번호 */
.yt-item-num {
    font-size: 14px;
    color: #999;
    min-width: 25px;
    text-align: center;
    font-weight: 500;
    flex-shrink: 0;
}

/* 제목 */
.yt-item-title {
    flex: 1;
    font-size: 14px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 컨트롤 버튼 영역 */
.yt-item-controls {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* 이동 버튼 */
.yt-btn-move {
    padding: 6px 10px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.yt-btn-move:hover:not(:disabled) {
    background: #e0e0e0;
}

.yt-btn-move:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.yt-btn-move i {
    font-size: 10px;
}

/* 재생 버튼 */
.yt-item-play {
    padding: 4px 12px 7px 12px;
    background: #ff0000;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.2s;
    width: 32px;
}

.yt-item-play:hover {
    background: #cc0000;
}

.yt-item-play:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.4;
}

.yt-item-play i {
    font-size: 13px;
}

/* ===============================
   빈 플레이리스트
================================= */
.yt-empty {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.yt-empty i {
    font-size: 48px;
    color: #ddd;
    margin-bottom: 15px;
}

.yt-empty p {
    margin: 0;
    line-height: 1.6;
}

/* ===============================
   다크 모드 (ink_board 스타일)
================================= */
body.color_scheme_dark #youtube-player-container {
    background: #1a1d23;
    border-radius: 8px;
}

body.color_scheme_dark #youtube-playlist {
    background: #22262e;
    border-radius: 8px;
}

body.color_scheme_dark .yt-playlist-header {
    border-bottom-color: #2d323c;
}

body.color_scheme_dark .yt-playlist-header h4 {
    color: #e4e6eb;
}

body.color_scheme_dark .yt-count {
    color: #9ca3af;
}

body.color_scheme_dark .yt-select-all-row {
    background: #1a1d23;
    border-bottom-color: #2d323c;
}

body.color_scheme_dark .yt-select-all-row label {
    color: #9ca3af;
}

body.color_scheme_dark .yt-drag-info {
    color: #6b7280;
}

body.color_scheme_dark .yt-playlist-item {
    background: #22262e;
    border-bottom-color: #2d323c;
}

body.color_scheme_dark .yt-playlist-item:hover {
    background: #2a2f3a;
}

body.color_scheme_dark .yt-item-title {
    color: #e4e6eb;
}

body.color_scheme_dark .yt-item-num {
    color: #6b7280;
}

body.color_scheme_dark .yt-ctrl-btn {
    background: #2a2f3a;
    border-color: #3a404c;
    color: #e4e6eb;
}

body.color_scheme_dark .yt-ctrl-btn:hover {
    background: #333842;
}

body.color_scheme_dark .yt-ctrl-btn.play {
    background: #ff0000;
    border-color: #ff0000;
    color: white;
}

body.color_scheme_dark .yt-ctrl-btn.play:hover {
    background: #cc0000;
}

body.color_scheme_dark .yt-btn-move {
    background: #2a2f3a;
    border-color: #3a404c;
    color: #e4e6eb;
}

body.color_scheme_dark .yt-btn-move:hover:not(:disabled) {
    background: #333842;
}

body.color_scheme_dark .yt-btn-move:disabled {
    opacity: 0.3;
}

body.color_scheme_dark .yt-empty {
    color: #6b7280;
}

body.color_scheme_dark .yt-empty i {
    color: #374151;
}

/* ===============================
   모바일 최적화
================================= */
@media (max-width: 768px) {
    #youtube-player-container { 
        padding: 10px; 
        margin: 15px 0; 
    }
    #youtube-now-playing {
        font-size: 13px;
        padding: 8px 12px;
        margin: -4px 0 10px 0;  /* ✅ 모바일도 -4px */
        height: 36px;
    }
    .yt-playlist-header {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        padding-left: 7px;
        padding-right: 7px;
    }
    
    .yt-select-all-row {
        padding: 10px 6px;
    }
    
    .yt-item-controls {
        gap: 2px;
    }
    
    .yt-playlist-items {
        max-height: 310px;
        overflow-y: auto;
    }
    
    .yt-playlist-header h4 { 
        font-size: 14px; 
    }
    
    .yt-count { 
        font-size: 0.9em; 
        margin-left: 8px; 
    }
    
    .yt-playlist-item { 
        padding: 4px 6px; 
        font-size: 13px; 
        gap: 6px; 
    }
    
    .yt-item-title { 
        font-size: 13px; 
    }
    
    .yt-item-num {
        min-width: 12px;
        font-size: 12px;
        flex: 0 0 auto;
        display: flex;
        justify-content: center;
        align-items: center;
        text-align: center;
    }
    
    .yt-item-play { 
        padding: 0;
        width: 26px;
        height: 26px;
    }
    
    .yt-controls { 
        gap: 8px; 
    }
    
    .yt-ctrl-btn { 
        width: 43px; 
        font-size: 14px; 
        text-align: center; 
    }
    
    .yt-drag-info {
        font-size: 13px;
    }
    
    .yt-btn-move { 
        padding: 5px 8px; 
    }
}