/* 基礎重置和變量 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c5aa0;
    --secondary-color: #4CAF50;
    --text-primary: #333;
    --text-secondary: #666;
    --text-light: #999;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #e0e0e0;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Noto Sans TC', 'Montserrat', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 標題區 */
.header {
    background: var(--bg-white);
    box-shadow: var(--shadow);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.brand h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.brand-info {
    display: flex;
    align-items: center;
}

.brand-name {
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 14px;
}

/* 主內容區 */
.main-content {
    padding: 30px 0;
}

.video-layout {
    display: flex;
    flex-direction: column;
    gap: 30px;
    max-width: 800px;
    margin: 0 auto;
}

/* 主視頻區 */
.main-video-section {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow);
}

.main-video-container {
    margin-bottom: 25px;
}

/* 視頻滑動器 */
.video-slider {
    position: relative;
    width: 100%;
    height: 480px;
    overflow: hidden;
    border-radius: var(--border-radius);
}

.video-slides {
    position: relative;
    width: 100%;
    height: 480px;
    min-height: 480px;
}

.video-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    pointer-events: none;
}

.video-slide.active {
    opacity: 1;
    pointer-events: auto;
}

.video-player {
    position: relative;
    width: 100%;
    height: 400px;
    border-radius: var(--border-radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
}

.video-player:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* 滑動按鈕 */
.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    z-index: 10;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.slider-btn:hover {
    background: rgba(0,0,0,0.7);
}

.prev-btn {
    left: 15px;
}

.next-btn {
    right: 15px;
}

/* 滑動指示點 */
.slider-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.dot.active,
.dot:hover {
    background: var(--primary-color);
}

/* 空白視頻狀態 */
.empty-video-placeholder {
    width: 100%;
    height: 400px;
    background: var(--bg-light);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border-color);
}

.empty-content {
    text-align: center;
    color: var(--text-light);
    font-size: 16px;
}

.video-slide.empty-slide {
    opacity: 1;
}

.video-slide.empty-slide .main-video-title {
    display: none;
}

.video-poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: var(--transition);
}

.video-player:hover .play-button {
    transform: translate(-50%, -50%) scale(1.1);
}

.video-duration {
    position: absolute;
    bottom: 15px;
    left: 15px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
}

.main-video-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 15px;
}

/* 分類導航 */
.category-nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.category-btn {
    background: transparent;
    border: 2px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.category-btn:hover {
    border-color: var(--secondary-color);
    color: var(--secondary-color);
}

.category-btn.active {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
}

/* 視頻列表區 */
.video-sidebar {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow);
}

.video-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.video-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 0;
    border-radius: var(--border-radius);
    transition: var(--transition);
    border: none;
    background: transparent;
}

.video-item:hover {
    background: transparent;
    transform: none;
    box-shadow: none;
}

.video-item:hover .video-thumbnail {
    transform: scale(1.05);
}

.video-thumbnail {
    position: relative;
    width: 100px;
    height: 60px;
    border-radius: var(--border-radius);
    overflow: hidden;
    flex-shrink: 0;
    transition: var(--transition);
}

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

.video-thumbnail .video-duration {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

.play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: var(--transition);
}

.video-item:hover .play-overlay {
    opacity: 1;
}

.video-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: left;
}

/* 模態框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: var(--bg-white);
    margin: 5% auto;
    padding: 0;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.close {
    color: var(--text-light);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 0;
}

#videoContainer {
    width: 100%;
    height: 500px;
}

#videoContainer iframe,
#videoContainer video {
    width: 100%;
    height: 100%;
    border: none;
}

/* 動畫 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* 響應式設計 */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .header .container {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .brand h1 {
        font-size: 24px;
    }
    
    .video-layout {
        gap: 20px;
    }
    
    .main-video-section {
        padding: 15px;
    }
    
    /* 修復視頻滑動器高度 */
    .video-slider {
        height: 300px;
    }
    
    .video-slides {
        height: 300px;
        min-height: 300px;
    }
    
    .video-player {
        height: 250px;
    }
    
    .main-video-title {
        font-size: 18px;
        margin-top: 10px;
    }
    
    .category-nav {
        justify-content: center;
        gap: 8px;
    }
    
    .category-btn {
        padding: 10px 16px;
        font-size: 13px;
        min-height: 44px; /* 增加觸控目標大小 */
    }
    
    .video-sidebar {
        padding: 15px;
    }
    
    .video-item {
        flex-direction: column;
        text-align: center;
        gap: 12px;
        padding: 15px;
    }
    
    .video-thumbnail {
        width: 100%;
        height: 180px;
        align-self: center;
        order: 0;
    }
    
    .video-info {
        text-align: center;
        order: 1;
    }
    
    /* 增大觸控按鈕 */
    .slider-btn {
        width: 50px;
        height: 50px;
        background: rgba(0,0,0,0.7);
    }
    
    .prev-btn {
        left: 8px;
    }
    
    .next-btn {
        right: 8px;
    }
    
    .empty-video-placeholder {
        height: 250px;
    }
    
    /* 優化模態框 */
    .modal-content {
        width: 95%;
        margin: 5% auto;
        max-height: 85vh;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-header h3 {
        font-size: 18px;
    }
    
    #videoContainer {
        height: 280px;
    }
    
    /* 增大指示點觸控區域 */
    .dot {
        width: 16px;
        height: 16px;
        margin: 0 4px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .brand {
        flex-direction: column;
        gap: 8px;
    }
    
    .brand h1 {
        font-size: 18px;
    }
    
    .main-content {
        padding: 20px 0;
    }
    
    .main-video-section {
        padding: 12px;
    }
    
    /* 進一步調整視頻滑動器 */
    .video-slider {
        height: 250px;
    }
    
    .video-slides {
        height: 250px;
        min-height: 250px;
    }
    
    .video-player {
        height: 200px;
    }
    
    .main-video-title {
        font-size: 16px;
        margin-top: 8px;
    }
    
    .category-nav {
        gap: 6px;
        flex-wrap: wrap;
    }
    
    .category-btn {
        padding: 8px 14px;
        font-size: 12px;
        min-height: 40px;
        flex: 1;
        min-width: 80px;
    }
    
    .video-sidebar {
        padding: 12px;
    }
    
    .video-item {
        padding: 12px;
        gap: 10px;
    }
    
    .video-thumbnail {
        height: 140px;
    }
    
    .video-title {
        font-size: 14px;
        line-height: 1.3;
    }
    
    .video-info {
        text-align: center;
    }
    
    /* 小屏幕滑動按鈕 */
    .slider-btn {
        width: 44px;
        height: 44px;
    }
    
    .prev-btn {
        left: 5px;
    }
    
    .next-btn {
        right: 5px;
    }
    
    /* 小屏幕模態框 */
    .modal-content {
        width: 98%;
        margin: 2% auto;
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 12px 15px;
    }
    
    .modal-header h3 {
        font-size: 16px;
    }
    
    .close {
        font-size: 24px;
    }
    
    #videoContainer {
        height: 220px;
    }
    
    .empty-video-placeholder {
        height: 200px;
    }
    
    .empty-content {
        font-size: 14px;
    }
}

/* 觸控優化 */
@media (hover: none) and (pointer: coarse) {
    /* 移動設備觸控優化 */
    .video-item:hover {
        transform: none;
        background: var(--bg-light);
    }
    
    .video-player:hover {
        transform: none;
    }
    
    .play-overlay {
        opacity: 1; /* 在觸控設備上始終顯示播放按鈕 */
    }
    
    .slider-btn {
        opacity: 0.8;
    }
    
    .slider-btn:active {
        opacity: 1;
        transform: translateY(-50%) scale(0.95);
    }
}

/* 防止雙擊縮放 */
.video-player,
.video-item,
.category-btn,
.slider-btn,
.dot {
    touch-action: manipulation;
}

/* 載入動畫 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* 滾動條樣式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}
