/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow-x: hidden;
}

/* 应用容器 */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 0;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-size: 1.8rem;
    font-weight: bold;
    color: #5d4e75;
    margin: 0;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-weight: 500;
}

.room-id {
    color: #666;
}

.viewer-count {
    color: #4a90e2;
}

.user-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 主要内容区域 */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* 媒体播放区域 */
.media-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.media-container {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.media-placeholder {
    aspect-ratio: 16/9;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(45deg, #2c3e50, #34495e);
    color: white;
}

.placeholder-content {
    text-align: center;
}

.placeholder-content h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.placeholder-content p {
    font-size: 1.1rem;
    opacity: 0.8;
}

/* 媒体元素样式 */
#mediaPlayer {
    width: 100%;
    height: auto;
    display: block;
}

#imageViewer {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    display: block;
}

/* Video.js 播放器样式 */
.video-js-container {
    width: 100%;
    position: relative;
}

.video-js {
    width: 100% !important;
    height: auto !important;
}

.video-js .vjs-control-bar {
    background: rgba(0, 0, 0, 0.7) !important;
}

.video-js .vjs-big-play-button {
    background: rgba(0, 0, 0, 0.7) !important;
    border: none !important;
    border-radius: 50% !important;
    width: 80px !important;
    height: 80px !important;
    line-height: 80px !important;
    margin-left: -40px !important;
    margin-top: -40px !important;
}

.video-js .vjs-big-play-button:before {
    font-size: 32px !important;
}

/* YouTube播放器容器样式 */
#youtube-player-container {
    width: 100%;
    background: #000;
    position: relative;
}

/* 降级播放器样式 */
#fallback-player {
    width: 100%;
    height: auto;
    background: #000;
}

/* 加载状态样式 */
.player-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 16px;
    z-index: 10;
}

/* 错误状态样式 */
.player-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ff6b6b;
    font-size: 16px;
    text-align: center;
    z-index: 10;
}

/* 媒体控制条 */
.media-controls {
    background: rgba(0, 0, 0, 0.8);
    border-radius: 10px;
    padding: 1rem;
    margin-top: 1rem;
    color: white;
}

.control-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.control-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.2s;
    color: white;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.progress-bar::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: #4a90e2;
    border-radius: 50%;
    cursor: pointer;
}

.time-display {
    font-family: monospace;
    font-size: 0.9rem;
    white-space: nowrap;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.volume-slider {
    width: 80px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    outline: none;
}

/* 媒体输入区域 */
.media-input-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid rgba(0, 0, 0, 0.1);
}

/* 选项卡样式 */
.input-tabs {
    display: flex;
    margin-bottom: 1rem;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-btn.active {
    color: #4a90e2;
    border-bottom-color: #4a90e2;
    background: rgba(74, 144, 226, 0.05);
}

.tab-btn:hover:not(.active) {
    color: #333;
    background: rgba(0, 0, 0, 0.05);
}

/* 选项卡内容 */
.tab-content {
    min-height: 200px;
}

.tab-content.hidden {
    display: none;
}

/* 文件上传区域 */
.upload-area {
    margin-bottom: 1rem;
}

.upload-zone {
    border: 3px dashed #ccc;
    border-radius: 15px;
    padding: 3rem 2rem;
    text-align: center;
    background: rgba(248, 249, 250, 0.8);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.upload-zone:hover {
    border-color: #4a90e2;
    background: rgba(74, 144, 226, 0.05);
}

.upload-zone.drag-over {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.1);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.upload-text h3 {
    margin: 0 0 0.5rem 0;
    color: #333;
    font-size: 1.2rem;
}

.upload-text p {
    margin: 0.25rem 0;
    color: #666;
    font-size: 0.9rem;
}

.upload-link {
    color: #4a90e2;
    text-decoration: underline;
    cursor: pointer;
}

.upload-link:hover {
    color: #357abd;
}

/* 上传进度 */
.upload-progress {
    background: rgba(74, 144, 226, 0.05);
    border: 2px solid rgba(74, 144, 226, 0.2);
    border-radius: 10px;
    padding: 1rem;
    margin-top: 1rem;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(135deg, #4a90e2, #28a745);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

/* 媒体库 */
.media-library {
    min-height: 300px;
}

.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.library-header h4 {
    margin: 0;
    color: #333;
    font-size: 1.1rem;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.library-item {
    background: white;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.library-item:hover {
    border-color: #4a90e2;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.2);
    transform: translateY(-2px);
}

.library-item.selected {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.05);
}

.library-thumbnail {
    width: 100%;
    height: 80px;
    background: #f8f9fa;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.library-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.library-info {
    font-size: 0.8rem;
}

.library-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-size {
    color: #666;
}

.library-type {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
}

.library-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    color: #666;
    padding: 2rem;
}

.library-placeholder p {
    margin: 0.5rem 0;
}

/* 删除按钮 */
.library-item .delete-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #dc3545;
    color: white;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.library-item:hover .delete-btn {
    display: flex;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.media-examples {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: #666;
}

.example-link {
    color: #4a90e2;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid #4a90e2;
    transition: all 0.2s;
}

.example-link:hover {
    background: #4a90e2;
    color: white;
}

/* 聊天区域 */
.chat-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 200px);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

.chat-header h3 {
    margin: 0;
    color: #5d4e75;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
    min-height: 300px;
    max-height: 500px;
    padding-right: 0.5rem;
}

.chat-message {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border-radius: 12px;
    background: rgba(116, 75, 162, 0.1);
    border-left: 4px solid #764ba2;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

.message-username {
    font-weight: bold;
    color: #5d4e75;
}

.message-timestamp {
    color: #999;
    font-size: 0.75rem;
}

.message-content {
    color: #333;
    line-height: 1.4;
    word-wrap: break-word;
}

.system-message {
    background: rgba(74, 144, 226, 0.1);
    border-left-color: #4a90e2;
    font-style: italic;
    text-align: center;
}

.chat-input-group {
    display: flex;
    gap: 0.5rem;
}

/* 表单控件样式 */
input[type="text"],
input[type="url"] {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: rgba(255, 255, 255, 0.9);
}

input[type="text"]:focus,
input[type="url"]:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* 按钮样式 */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #4a90e2, #357abd);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #357abd, #2868a3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #28a745, #1e7e34);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #1e7e34, #155724);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* 连接状态指示器 */
.connection-status {
    position: fixed;
    top: 50%;
    right: 2rem;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    backdrop-filter: blur(10px);
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-indicator.online {
    background: #28a745;
}

.status-indicator.offline {
    background: #dc3545;
}

.status-indicator.connecting {
    background: #ffc107;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* 模态框样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.modal {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    animation: modalShow 0.3s ease-out forwards;
}

@keyframes modalShow {
    to {
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    padding: 0.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #333;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* 通知样式 */
.notifications {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notification {
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border-left: 4px solid #4a90e2;
    animation: slideIn 0.3s ease-out;
    max-width: 400px;
}

.notification.success {
    border-left-color: #28a745;
}

.notification.error {
    border-left-color: #dc3545;
}

.notification.warning {
    border-left-color: #ffc107;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
    
    .header-content {
        padding: 0 1rem;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .room-info {
        order: -1;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .control-buttons {
        justify-content: center;
    }
    
    .progress-container {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .notifications {
        top: 1rem;
        right: 1rem;
        left: 1rem;
    }
    
    .modal {
        margin: 1rem;
        width: calc(100% - 2rem);
    }
}

/* ==================== 性能优化样式 ==================== */

/* 懒加载样式 */
.lazy-loading {
    opacity: 0.5;
    filter: blur(5px);
    transition: opacity 0.3s, filter 0.3s;
}

.lazy-loaded {
    opacity: 1;
    filter: blur(0);
}

.lazy-error {
    opacity: 0.3;
    background: #f0f0f0;
}

/* 无限滚动加载器 */
.infinite-scroll-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 1rem;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(74, 144, 226, 0.2);
    border-top-color: #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loader-text {
    color: #666;
    font-size: 0.9rem;
}

/* 虚拟滚动容器 */
.virtual-scroll-container {
    position: relative;
    overflow: auto;
    height: 100%;
}

.virtual-scroll-item {
    position: absolute;
    left: 0;
    right: 0;
}