* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3d3d3d;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --accent-color: #4CAF50;
    --accent-hover: #45a049;
    --border-color: #404040;
    --danger-color: #e53935;
    --control-bar-height: 70px;
    --playback-bar-height: 60px;
    --sidebar-width: 260px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 顶部控制栏 */
.control-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    height: var(--control-bar-height);
    flex-shrink: 0;
}

.control-bar h1 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-right: 20px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 按钮样式 */
.btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-color);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-layout {
    padding: 8px 12px;
    min-width: 40px;
    justify-content: center;
    font-weight: 600;
}

.btn-layout.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.btn-control {
    padding: 10px 16px;
    background: var(--bg-tertiary);
}

.btn-control .icon {
    font-size: 1.1rem;
}

.layout-buttons {
    display: flex;
    gap: 6px;
}

/* 主区域：侧边栏 + 网格 */
.main-area {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s ease;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.list-count {
    color: var(--text-secondary);
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
}

.search-input {
    margin: 10px 12px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    flex-shrink: 0;
}

.search-input:focus {
    border-color: var(--accent-color);
}

.search-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 视频列表 */
.video-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.video-list-empty {
    padding: 20px 12px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    opacity: 0.7;
}

.video-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
    user-select: none;
}

.video-list-item:hover {
    background: var(--bg-tertiary);
}

.video-list-item .item-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.video-list-item .item-name {
    flex: 1;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.video-list-item .item-status {
    flex-shrink: 0;
    color: var(--accent-color);
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 14px;
    text-align: center;
}

/* 已加入网格的视频项 */
.video-list-item.in-grid {
    background: rgba(76, 175, 80, 0.15);
    border-left: 3px solid var(--accent-color);
    padding-left: 7px;
}

.video-list-item.in-grid:hover {
    background: rgba(76, 175, 80, 0.25);
}

.video-list-item.dragging {
    opacity: 0.4;
}

/* 视频网格容器 */
.video-container {
    flex: 1;
    display: grid;
    gap: 10px;
    padding: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* 网格布局 */
.layout-1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

.layout-2 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: 1fr;
}

.layout-3 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr;
}

.layout-4 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.layout-6 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.layout-9 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

/* 视频槽位 */
.video-item {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.video-item:hover {
    border-color: var(--accent-color);
}

.video-item video {
    flex: 1;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    min-height: 0;
}

.video-item .video-label {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

/* 空槽位占位 */
.slot-empty {
    border: 2px dashed var(--border-color);
    align-items: center;
    justify-content: center;
}

.slot-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-align: center;
    gap: 8px;
}

.slot-plus {
    font-size: 2.2rem;
    color: var(--border-color);
    line-height: 1;
}

.slot-hint {
    font-size: 0.8rem;
    opacity: 0.8;
    line-height: 1.4;
}

/* 拖拽悬停状态 */
.video-item.drag-over {
    border-color: var(--accent-color);
    background: rgba(76, 175, 80, 0.12);
}

/* 槽位满时闪烁提示 */
.video-item.flash {
    animation: flash-shake 0.6s ease;
}

@keyframes flash-shake {
    0%, 100% { border-color: var(--danger-color); }
    25%, 75% { transform: translateX(-3px); border-color: var(--danger-color); }
    50% { transform: translateX(3px); }
}

/* 槽位关闭按钮 */
.slot-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: background 0.15s ease;
}

.slot-close:hover {
    background: var(--danger-color);
}

/* 底部播放控制 */
.playback-controls {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    height: var(--playback-bar-height);
    flex-shrink: 0;
}

.slider {
    width: 120px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

#volumeValue {
    color: var(--text-secondary);
    font-size: 0.85rem;
    min-width: 40px;
}

/* 进度控制 */
.progress-control {
    flex: 1;
    max-width: 500px;
    min-width: 160px;
}

.progress-slider {
    width: 100%;
    flex: 1;
}

#progressValue {
    color: var(--text-secondary);
    font-size: 0.85rem;
    min-width: 40px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* 禁用状态的滑块（无视频时） */
.slider:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.slider:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
}

.slider:disabled::-moz-range-thumb {
    cursor: not-allowed;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* 视频信息栏 */
.video-info {
    background: var(--bg-tertiary);
    padding: 8px 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .control-bar {
        flex-direction: column;
        height: auto;
        padding: 12px;
    }

    .control-bar h1 {
        font-size: 1rem;
    }

    .playback-controls {
        flex-direction: column;
        height: auto;
        gap: 12px;
    }

    .layout-buttons {
        flex-wrap: wrap;
    }

    .layout-3,
    .layout-6,
    .layout-9 {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .sidebar {
        position: absolute;
        z-index: 20;
        height: 100%;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.5);
    }

    .main-area {
        position: relative;
    }
}

/* 全屏模式 */
.app-container:fullscreen {
    width: 100%;
    height: 100%;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}
