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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* 首页样式 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    text-align: center;
    margin-bottom: 3rem;
    color: white;
}

.title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 300;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
}

.card {
    background: white;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(10px);
}

.card h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: #333;
    font-weight: 600;
}

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

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

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.btn {
    flex: 1;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #e1e5e9;
}

.btn-secondary:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    width: 100%;
    max-width: 800px;
}

.feature {
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    color: white;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature h3 {
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.feature p {
    opacity: 0.9;
    font-weight: 300;
}

.footer {
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 2rem;
}

/* 房间页面样式 */
.room-body {
    background: #1a1a1a;
    color: white;
    overflow: hidden;
}

.room-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

.video-container {
    flex: 1;
    padding: 1rem;
    overflow: hidden;
}

.video-grid {
    display: grid;
    gap: 1rem;
    height: 100%;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    grid-auto-rows: minmax(200px, 1fr);
}

.video-wrapper {
    position: relative;
    background: #2a2a2a;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

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

.video-label {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    background: rgba(0,0,0,0.7);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.local-video {
    border: 2px solid #667eea;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
}

.control-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.control-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

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

.control-btn.active {
    background: #667eea;
}

.control-btn.muted {
    background: #dc3545;
}

.leave-btn {
    background: #dc3545;
}

.leave-btn:hover {
    background: #c82333;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.1);
    padding: 0.5rem 1rem;
    border-radius: 25px;
}

.copy-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 5px;
    transition: background 0.3s ease;
}

.copy-btn:hover {
    background: rgba(255,255,255,0.1);
}

/* 聊天面板 */
.chat-panel {
    position: fixed;
    right: -350px;
    top: 0;
    width: 350px;
    height: 100vh;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(10px);
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.chat-panel.open {
    right: 0;
}

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

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(255,255,255,0.1);
}

.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-message {
    background: rgba(255,255,255,0.1);
    padding: 0.75rem;
    border-radius: 10px;
    word-wrap: break-word;
}

.chat-message .sender {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 0.25rem;
}

.chat-message .timestamp {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 0.25rem;
}

.chat-input-container {
    display: flex;
    padding: 1rem;
    gap: 0.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.chat-input-container input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 25px;
    background: rgba(255,255,255,0.1);
    color: white;
    outline: none;
}

.chat-input-container input::placeholder {
    color: rgba(255,255,255,0.5);
}

.chat-input-container button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 25px;
    background: #667eea;
    color: white;
    cursor: pointer;
    font-weight: 500;
}

/* 加载和错误提示 */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 权限请求界面 */
.permission-request {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.permission-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.permission-content h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 24px;
}

.permission-content p {
    color: #666;
    margin-bottom: 20px;
    font-size: 16px;
}

.permission-tips {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    text-align: left;
}

.permission-tips h4 {
    color: #007bff;
    margin-bottom: 10px;
    font-size: 16px;
}

.permission-tips ul {
    margin: 0;
    padding-left: 20px;
}

.permission-tips li {
    color: #555;
    margin-bottom: 5px;
    font-size: 14px;
}

.permission-content .btn {
    margin: 10px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.permission-content .btn-primary {
    background: #007bff;
    color: white;
}

.permission-content .btn-primary:hover {
    background: #0056b3;
    transform: translateY(-2px);
}

.permission-content .btn-secondary {
    background: #6c757d;
    color: white;
}

.permission-content .btn-secondary:hover {
    background: #545b62;
    transform: translateY(-2px);
}

.error-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.error-modal.show {
    display: flex;
}

.error-content {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    color: #333;
}

.error-content h3 {
    margin-bottom: 1rem;
    color: #dc3545;
}

.error-content p {
    margin-bottom: 2rem;
}

/* 音频指示器 */
.audio-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.audio-indicator i {
    font-size: 48px;
    color: #007bff;
}

.audio-indicator span {
    font-size: 16px;
    font-weight: bold;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .title {
        font-size: 2rem;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .features {
        grid-template-columns: 1fr;
    }
    
    .video-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .video-wrapper {
        min-height: 200px;
    }
    
    .controls {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.75rem;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0,0,0,0.95);
    }
    
    .control-btn {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
        /* 增加触摸目标大小 */
        min-width: 44px;
        min-height: 44px;
    }
    
    .chat-panel {
        width: 100%;
        right: -100%;
    }
    
    .room-info {
        order: 3;
        width: 100%;
        justify-content: center;
        font-size: 0.9rem;
    }
    
    .audio-indicator {
        padding: 15px;
    }
    
    .audio-indicator i {
        font-size: 36px;
    }
    
    .audio-indicator span {
        font-size: 14px;
    }
    
    /* 为底部控制栏留出空间 */
    .video-container {
        padding-bottom: 80px;
    }
    
    /* 改善权限请求界面在移动端的显示 */
    .permission-content {
        margin: 1rem;
        padding: 1.5rem;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .permission-content .btn {
        display: block;
        width: 100%;
        margin: 0.5rem 0;
    }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    .control-group {
        gap: 0.5rem;
    }
    
    .room-info {
        font-size: 0.8rem;
        padding: 0.25rem 0.75rem;
    }
    
    .copy-btn {
        font-size: 0.9rem;
    }
    
    .video-label {
        font-size: 0.8rem;
        padding: 0.25rem 0.75rem;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .control-btn:hover {
        transform: none;
    }
    
    .control-btn:active {
        transform: scale(0.95);
        background: rgba(255,255,255,0.3);
    }
    
    .btn:hover {
        transform: none;
    }
    
    .btn:active {
        transform: scale(0.98);
    }
}