/* XZoom 视频通话样式文件 */

/* 基本样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    height: 100vh;
    overflow: hidden;
}

.container {
    width: 100%;
    height: 100vh;
    position: relative;
}

/* 屏幕切换 */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.active {
    display: block;
}

/* 登录界面样式 */
#loginScreen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    min-width: 400px;
    backdrop-filter: blur(10px);
}

.login-box h1 {
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5em;
    font-weight: 300;
}

.input-group {
    display: flex;
    margin-bottom: 20px;
    gap: 10px;
}

.input-group input {
    flex: 1;
    padding: 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
    outline: none;
}

.input-group input:focus {
    border-color: #667eea;
}

.input-group button, .button-group button {
    padding: 15px 25px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-weight: 500;
}

.input-group button:hover, .button-group button:hover {
    background: #5a67d8;
}

.button-group {
    margin-bottom: 20px;
}

.button-group button.secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.button-group button.secondary:hover {
    background: #cbd5e0;
}

.status {
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    font-weight: 500;
}

.status.success {
    background: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.status.error {
    background: #fed7d7;
    color: #742a2a;
    border: 1px solid #fc8181;
}

.status.info {
    background: #bee3f8;
    color: #2c5282;
    border: 1px solid #90cdf4;
}

/* 视频界面样式 */
#videoScreen {
    background: #1a202c;
    color: white;
    position: relative;
}

.video-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.video-wrapper {
    flex: 1;
    display: flex;
    position: relative;
    background: #2d3748;
}

/* 本地视频 */
.local-video-container {
    width: 300px;
    height: 200px;
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 2px solid #4a5568;
}

.local-video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 远程视频 */
.remote-video-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a202c;
}

.remote-video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 音频模式样式 */
.remote-video-container.audio-only {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
}

.remote-video-container.audio-only::before {
    content: '🎵';
    font-size: 5rem;
    color: #a0aec0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.local-video-container.audio-only {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

.local-video-container.audio-only::before {
    content: '🎤';
    font-size: 2rem;
    color: #e2e8f0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.video-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
}

.connection-status {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.connection-status.connecting {
    background: rgba(237, 137, 54, 0.9);
}

.connection-status.connected {
    background: rgba(72, 187, 120, 0.9);
}

.connection-status.disconnected, .connection-status.failed {
    background: rgba(245, 101, 101, 0.9);
}

/* 控制面板 */
.controls {
    background: rgba(26, 32, 44, 0.95);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 20;
    min-height: 90px;
}

.room-info {
    color: #a0aec0;
    font-size: 14px;
}

.room-info span {
    margin-right: 20px;
}

.control-buttons {
    display: flex;
    gap: 15px;
}

.control-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #4a5568;
    color: white;
}

.control-btn:hover {
    transform: scale(1.1);
    background: #2d3748;
}

.control-btn.hangup {
    background: #e53e3e;
}

.control-btn.hangup:hover {
    background: #c53030;
}

/* 聊天面板 */
.chat-panel {
    position: absolute;
    bottom: 110px; /* 增加间距，避免与控制按钮重叠 */
    right: 20px;
    width: 300px;
    height: 400px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    transition: all 0.3s;
    z-index: 15;
}

.chat-panel.minimized {
    height: 40px;
    overflow: hidden;
}

/* 移动端聊天面板修复 */
@media (max-width: 768px) {
    .chat-panel.minimized {
        height: 50px; /* 确保最小化时仍然可见 */
        display: flex; /* 保持显示 */
        flex-direction: column;
    }
    
    .chat-panel.minimized .chat-messages,
    .chat-panel.minimized .chat-input-container {
        display: none; /* 隐藏内容但保持头部可见 */
    }
    
    .chat-panel.minimized .chat-header {
        flex-shrink: 0; /* 防止头部被压缩 */
    }
}

.chat-header {
    padding: 15px;
    background: #667eea;
    color: white;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}

.chat-header button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 12px;
    padding: 5px;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    color: #333;
}

.chat-message {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 8px;
    max-width: 80%;
}

.chat-message.me {
    background: #e6fffa;
    border: 1px solid #81e6d9;
    margin-left: auto;
    text-align: right;
}

.chat-message.other {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
}

.message-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #718096;
    margin-bottom: 5px;
}

.message-content {
    font-size: 14px;
    line-height: 1.4;
}

.chat-input-container {
    display: flex;
    padding: 15px;
    border-top: 1px solid #e2e8f0;
    gap: 10px;
}

.chat-input-container input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 14px;
    outline: none;
}

.chat-input-container input:focus {
    border-color: #667eea;
}

.chat-input-container button {
    padding: 8px 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.chat-input-container button:hover {
    background: #5a67d8;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 20px;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content.loading {
    max-width: 300px;
}

.close {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.close:hover {
    color: #000;
}

.modal h3 {
    margin-bottom: 15px;
    color: #333;
}

.modal p {
    margin-bottom: 20px;
    color: #666;
    line-height: 1.5;
}

.modal button {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.modal button:hover {
    background: #5a67d8;
}

/* 加载动画 */
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .login-box {
        min-width: auto;
        width: 90%;
        padding: 30px 20px;
    }
    
    .login-box h1 {
        font-size: 2em;
    }
    
    .input-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .local-video-container {
        width: 150px;
        height: 100px;
        top: 10px;
        right: 10px;
    }
    
    .chat-panel {
        width: calc(100% - 40px);
        right: 20px;
        left: 20px;
        bottom: 120px; /* 为移动端控制面板留出更多空间 */
        max-height: calc(100vh - 200px); /* 限制最大高度，防止超出屏幕 */
    }
    
    .chat-panel .chat-messages {
        max-height: calc(100vh - 320px); /* 确保消息区域不会太高 */
        overflow-y: auto;
    }
    
    .chat-panel .chat-input-container {
        position: relative;
        z-index: 10; /* 确保输入框在最上层 */
        background: white; /* 添加背景色 */
        border-radius: 0 0 10px 10px; /* 保持圆角 */
    }
    
    .controls {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
        min-height: 100px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 30;
    }
    
    .room-info {
        order: 1;
        text-align: center;
        margin-bottom: 10px;
    }
    
    .control-buttons {
        order: 2;
        gap: 15px;
        justify-content: center;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .room-info {
        font-size: 12px;
    }
    
    .room-info span {
        margin-right: 15px;
    }
    
    /* 确保视频容器不被控制面板遮挡 */
    .video-wrapper {
        margin-bottom: 100px;
    }
    
    /* 远程视频容器调整 */
    .remote-video-container {
        height: calc(100vh - 200px);
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 20px 15px;
        margin: 20px;
    }
    
    .login-box h1 {
        font-size: 1.8em;
        margin-bottom: 20px;
    }
    
    .local-video-container {
        width: 120px;
        height: 80px;
    }
    
    .chat-panel {
        bottom: 130px; /* 为小屏幕进一步调整 */
        height: 300px; /* 减小聊天面板高度 */
        max-height: calc(100vh - 250px); /* 防止超出屏幕 */
    }
    
    .chat-panel .chat-messages {
        max-height: calc(100vh - 370px); /* 调整消息区域高度 */
    }
    
    .chat-panel.minimized {
        height: 45px !important; /* 强制设置最小化高度 */
        min-height: 45px; /* 确保最小高度 */
    }
    
    .controls {
        padding: 10px;
        min-height: 110px;
        gap: 8px;
    }
    
    .control-buttons {
        justify-content: center;
        gap: 12px;
    }
    
    .control-btn {
        width: 45px;
        height: 45px;
        font-size: 16px;
    }
    
    .room-info {
        font-size: 11px;
    }
    
    .room-info span {
        display: block;
        margin: 2px 0;
    }
    
    /* 进一步调整视频容器 */
    .video-wrapper {
        margin-bottom: 110px;
    }
    
    .remote-video-container {
        height: calc(100vh - 220px);
    }
    
    /* 连接状态指示器 */
    .connection-status {
        top: 10px;
        left: 10px;
        font-size: 12px;
        padding: 6px 12px;
    }
    
    /* 视频标签 */
    .video-label {
        font-size: 12px;
        padding: 4px 8px;
    }
}

/* 动画效果 */
.video-wrapper {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.chat-message {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* 移动端安全区域适配 */
@supports (padding: max(0px)) {
    @media (max-width: 768px) {
        .controls {
            padding-bottom: max(15px, env(safe-area-inset-bottom));
        }
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .local-video-container {
        width: 100px;
        height: 70px;
        top: 5px;
        right: 5px;
    }
    
    .controls {
        min-height: 80px;
        flex-direction: row;
        gap: 0;
    }
    
    .room-info {
        order: 0;
        margin-bottom: 0;
    }
    
    .control-buttons {
        order: 1;
    }
    
    .chat-panel {
        bottom: 90px;
        height: 250px;
    }
    
    .video-wrapper {
        margin-bottom: 80px;
    }
    
    .remote-video-container {
        height: calc(100vh - 100px);
    }
}

/* 超小屏幕优化 (iPhone SE 等) */
@media (max-width: 375px) and (max-height: 667px) {
    .controls {
        min-height: 95px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .room-info {
        font-size: 10px;
    }
    
    .chat-panel {
        height: 250px;
        max-height: calc(100vh - 200px);
    }
    
    .chat-panel .chat-messages {
        max-height: calc(100vh - 320px);
    }
    
    .chat-panel.minimized {
        height: 40px !important;
        min-height: 40px;
        overflow: visible; /* 确保头部可见 */
    }
    
    .local-video-container {
        width: 100px;
        height: 70px;
    }
}

/* 修复聊天面板在所有移动设备上的显示问题 */
@media (max-width: 768px) {
    .chat-panel {
        position: fixed !important; /* 使用固定定位 */
        z-index: 25; /* 提高层级 */
    }
    
    .chat-panel.minimized {
        display: flex !important; /* 强制显示 */
        visibility: visible !important; /* 确保可见 */
        opacity: 1 !important; /* 确保不透明 */
    }
    
    .chat-panel.minimized .chat-header {
        display: flex !important; /* 确保头部显示 */
        min-height: 40px; /* 最小高度 */
    }
    
    /* 确保输入框不被虚拟键盘遮挡 */
    .chat-input-container {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 15;
    }
    
    .chat-input-container input {
        font-size: 16px; /* 防止iOS缩放 */
    }
}