/* ตัวแปรธีมมืดสีม่วงฟ้า */
:root {
    --primary-dark: #1a1a2e;
    --secondary-dark: #16213e;
    --accent-purple: #9d4edd;
    --accent-blue: #7b2cbf;
    --accent-light-purple: #c77dff;
    --text-light: #e2e2e2;
    --text-dim: #a0a0a0;
    --gradient-purple-blue: linear-gradient(135deg, #7b2cbf 0%, #3a0ca3 50%, #4361ee 100%);
    --card-bg: rgba(26, 26, 46, 0.7);
    --glass-effect: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 15px rgba(123, 44, 191, 0.5);
}

/* สไตล์สำหรับหน้าวิดีโอและวิดีโอเพลเยอร์ */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    margin-top: 2rem;
}

.video-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    transition: all 0.4s ease;
    position: relative;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
}

.video-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    transition: left 0.7s ease;
    z-index: 1;
    pointer-events: none;
}

.video-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3), 0 0 20px rgba(123, 44, 191, 0.4);
}

.video-card:hover::before {
    left: 100%;
}

.video-thumbnail {
    position: relative;
    overflow: hidden;
    width: 100%;
    padding-bottom: 56.25%; /* อัตราส่วน 16:9 */
}

.video-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease, filter 0.3s ease;
    filter: brightness(0.9);
}

.video-card:hover .video-thumbnail img {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: var(--gradient-purple-blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3), 0 0 10px rgba(123, 44, 191, 0.5);
    opacity: 0.9;
    z-index: 2;
}

.play-button svg {
    width: 30px;
    height: 30px;
    fill: white;
    transition: transform 0.3s ease;
}

.video-card:hover .play-button {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4), 0 0 15px rgba(123, 44, 191, 0.7);
}

.video-card:hover .play-button svg {
    transform: scale(1.1);
}

.video-info {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 2;
    transition: all 0.3s ease;
    background: linear-gradient(to top, var(--card-bg) 80%, transparent);
}

.video-info h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--text-light);
    position: relative;
    display: inline-block;
}

.video-info h3::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 40px;
    height: 2px;
    background: var(--accent-purple);
    transition: width 0.3s ease;
}

.video-card:hover .video-info h3::after {
    width: 100%;
}

.video-info p {
    color: var(--text-dim);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* วิดีโอเพลเยอร์แบบกำหนดเอง */
.custom-video-player {
    position: relative;
    width: 100%;
    background-color: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3), 0 0 20px rgba(123, 44, 191, 0.4);
    margin-bottom: 30px;
}

.custom-video-player video {
    width: 100%;
    display: block;
}

.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 15px;
    display: flex;
    align-items: center;
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    transform: translateY(10px);
}

.custom-video-player:hover .video-controls {
    opacity: 1;
    transform: translateY(0);
}

.play-pause-btn, .mute-btn, .fullscreen-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin: 0 5px;
    transition: all 0.3s ease;
}

.play-pause-btn:hover, .mute-btn:hover, .fullscreen-btn:hover {
    background: var(--accent-purple);
    transform: scale(1.1);
}

.time-display {
    color: white;
    margin: 0 15px;
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 100px;
    text-align: center;
}

.progress-bar {
    flex-grow: 1;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    cursor: pointer;
    margin: 0 15px;
    position: relative;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: var(--gradient-purple-blue);
    border-radius: 30px;
    width: 0;
    position: relative;
    transition: width 0.1s linear;
}

.progress::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background-color: white;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.progress-bar:hover .progress::after {
    opacity: 1;
}

.volume-control {
    display: flex;
    align-items: center;
    width: 100px;
    margin: 0 10px;
}

.volume-slider {
    width: 60px;
    height: 5px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    cursor: pointer;
    margin-left: 8px;
    position: relative;
    overflow: hidden;
}

.volume-level {
    height: 100%;
    background: var(--gradient-purple-blue);
    border-radius: 30px;
    width: 100%;
}

/* รายการเล่นวิดีโอ */
.playlist {
    margin-top: 2rem;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
    background-color: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.playlist-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.playlist-item:last-child {
    border-bottom: none;
}

.playlist-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    transform: translateX(5px);
}

.playlist-item.active {
    background: linear-gradient(90deg, 
        rgba(123, 44, 191, 0.2), 
        rgba(67, 97, 238, 0.1), 
        transparent
    );
    border-left: 4px solid var(--accent-purple);
}

.playlist-thumbnail {
    width: 120px;
    height: 70px;
    margin-right: 15px;
    overflow: hidden;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.playlist-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.playlist-item:hover .playlist-thumbnail img {
    transform: scale(1.05);
}

.playlist-info {
    flex-grow: 1;
}

.playlist-info h4 {
    margin-bottom: 5px;
    font-size: 1rem;
    color: var(--text-light);
}

.playlist-info p {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.playlist-duration {
    font-size: 0.9rem;
    color: var(--accent-light-purple);
    font-weight: 500;
    margin-left: 10px;
}

/* หมวดหมู่วิดีโอ */
.video-categories {
    display: flex;
    overflow-x: auto;
    gap: 15px;
    padding-bottom: 15px;
    margin-bottom: 2rem;
}

.category-btn {
    padding: 0.7rem 1.5rem;
    border: 1px solid var(--glass-border);
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
    border-radius: 30px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.category-btn:hover {
    background-color: rgba(157, 78, 221, 0.3);
    border-color: var(--accent-purple);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(123, 44, 191, 0.3);
    color: white;
}

.category-btn.active {
    background: var(--gradient-purple-blue);
    color: white;
    border: none;
    box-shadow: 0 5px 15px rgba(123, 44, 191, 0.5);
}

/* ป้ายกำกับคุณภาพวิดีโอ */
.quality-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--gradient-purple-blue);
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    z-index: 2;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* ความยาววิดีโอ */
.video-duration {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    z-index: 2;
}

/* ปุ่มดาวน์โหลดวิดีโอ */
.download-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    z-index: 2;
}

.video-card:hover .download-btn {
    opacity: 1;
}

.download-btn:hover {
    background-color: var(--accent-purple);
    transform: scale(1.1);
}

/* ข้อมูลผู้อัปโหลด */
.uploader-info {
    display: flex;
    align-items: center;
    margin-top: 10px;
}

.uploader-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 10px;
}

.uploader-name {
    font-size: 0.85rem;
    color: var(--text-dim);
}

/* แถบความคืบหน้าการโหลดวิดีโอ */
.loading-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--gradient-purple-blue);
    width: 0%;
    transition: width 0.3s ease;
    z-index: 3;
}

/* เอฟเฟกต์การคลิก */
.ripple-effect {
    position: relative;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

@keyframes ripple {
    to { transform: scale(2.5); opacity: 0; }
}

/* ปุ่มควบคุมวิดีโอเพิ่มเติม */
.more-actions {
    position: relative;
}

.more-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.more-btn:hover {
    background: var(--accent-purple);
}

.actions-menu {
    position: absolute;
    bottom: 45px;
    right: 0;
    background-color: var(--secondary-dark);
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    padding: 10px 0;
    min-width: 150px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 10;
    border: 1px solid var(--glass-border);
}

.more-actions:hover .actions-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.action-item {
    padding: 8px 15px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-light);
}

.action-item:hover {
    background-color: rgba(157, 78, 221, 0.2);
}

.action-item i {
    margin-right: 10px;
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

/* สถานะการโหลดวิดีโอ */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent-purple);
    animation: spin 1s infinite linear;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* แถบด้านบนของเพลเยอร์ */
.video-player-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(rgba(0, 0, 0, 0.8), transparent);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
}

.custom-video-player:hover .video-player-header {
    opacity: 1;
}

.video-title {
    color: white;
    font-size: 1.1rem;
    font-weight: 500;
}

.player-actions {
    display: flex;
    gap: 10px;
}

.player-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.player-btn:hover {
    background: var(--accent-purple);
}

/* เอฟเฟกต์ Hover การ์ดที่ดูแล้ว */
.video-card.watched .video-thumbnail::after {
    content: 'ดูแล้ว';
    position: absolute;
    bottom: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* แถบความคืบหน้าที่ดูแล้ว */
.watched-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.2);
    z-index: 2;
}

.watched-amount {
    height: 100%;
    background: var(--gradient-purple-blue);
    width: 0%; /* จะถูกกำหนดโดย JavaScript */
}

/* การแสดงคำบรรยาย (Subtitles) */
.subtitles-container {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 80%;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    border-radius: 4px;
    color: white;
    text-align: center;
    font-size: 1rem;
    line-height: 1.4;
    z-index: 5;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.subtitles-active .subtitles-container {
    opacity: 1;
}

/* คำแนะนำวิดีโอที่เกี่ยวข้อง */
.related-videos {
    margin-top: 2rem;
}

.related-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-light);
    position: relative;
    display: inline-block;
}

.related-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--accent-purple);
}

/* รองรับการตอบสนอง (Responsive) */
@media screen and (max-width: 768px) {
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    
    .video-controls {
        padding: 10px;
    }
    
    .time-display {
        font-size: 0.8rem;
        min-width: 80px;
    }
    
    .play-pause-btn, .mute-btn, .fullscreen-btn {
        font-size: 1rem;
        width: 32px;
        height: 32px;
    }
    
    .playlist-item {
        flex-direction: row; /* เปลี่ยนกลับมาเป็นแนวนอน */
        align-items: center;
    }
    
    .playlist-thumbnail {
        width: 100px;
        flex-shrink: 0;
    }
    
    .volume-control {
        display: none; /* ซ่อนตัวปรับเสียงบนมือถือ */
    }
    
    .video-categories {
        padding-bottom: 10px;
    }
    
    .category-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .quality-badge, .video-duration {
        font-size: 0.7rem;
        padding: 3px 6px;
    }
}

@media screen and (max-width: 576px) {
    .video-grid {
        grid-template-columns: 1fr;
    }
    
    .playlist-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .playlist-thumbnail {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .progress-bar {
        height: 4px;
    }
    
    .time-display {
        min-width: 70px;
        font-size: 0.75rem;
    }
    
    .video-player-header {
        padding: 10px;
    }
    
    .video-title {
        font-size: 0.9rem;
    }
    
    .player-btn {
        width: 30px;
        height: 30px;
    }
}

/* สำหรับจอขนาดใหญ่ */
@media screen and (min-width: 1200px) {
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }
    
    .custom-video-player {
        max-width: 1000px;
        margin: 0 auto 30px;
    }
}