/* ========== 基础样式 ========== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', sans-serif;
    background: #1a1a1a;
    min-height: 100vh;
    color: #ffffff;
    overflow: hidden;
}

/* 页面容器 */
.page {
    display: none;
    width: 100%;
    height: 100vh;
    position: relative;
}

.page.active {
    display: flex;
}

/* ========== 密钥输入页面 ========== */
#loginPage {
    background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.login-content {
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
}

.input-field {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: all 0.2s;
}

.input-field:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: #07C160;
}

.input-field::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.join-btn {
    width: 100%;
    height: 52px;
    background: #07C160;
    border: none;
    border-radius: 26px;
    color: #fff;
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.join-btn:hover {
    background: #06AD56;
}

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

.join-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.hint-text {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.hint-icon {
    width: 14px;
    height: 14px;
}

/* ========== 视频通话页面 ========== */
#callPage {
    background: linear-gradient(180deg, #3a3a3a 0%, #1a1a1a 100%);
    flex-direction: column;
}

/* 远端视频（全屏背景） */
.remote-video-container {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
}

#remoteVideo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remote-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: rgba(255, 255, 255, 0.3);
    z-index: 1;
}

.remote-placeholder svg,
.remote-icon {
    width: 80px;
    height: 80px;
}

/* 顶部栏（保留用于安全区域间距） */
.top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 20px;
    z-index: 10;
}

/* 本地视频预览（右上角小窗） */
.local-video-container {
    position: absolute;
    top: 30px;
    right: 15px;
    width: 100px;
    height: 140px;
    background: linear-gradient(180deg, #4a4a4a 0%, #2a2a2a 100%);
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.local-video-container.hidden {
    display: none;
}

#localVideo {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 100px;
    min-height: 140px;
    max-width: 140px;
    max-height: 200px;
    object-fit: cover;
    transform: scaleX(-1);
}

.local-placeholder {
    color: rgba(255, 255, 255, 0.4);
    padding: 30px 40px;
}

.local-placeholder svg,
.local-icon {
    width: 36px;
    height: 36px;
}

/* 本地视频关闭按钮 */
.local-close-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s;
}

.local-close-btn svg {
    width: 12px;
    height: 12px;
}

.local-video-container:hover .local-close-btn {
    opacity: 1;
}

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

/* 底部控制栏 */
.bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 150px;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.5) 0%, transparent 100%);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 20px 30px 50px;
    z-index: 10;
    transition: opacity 0.3s, transform 0.3s;
}

.bottom-bar.hidden {
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
}

.local-video-container.auto-hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    color: #fff;
    min-width: 50px;
}

.control-btn .icon {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.control-btn .icon svg,
.control-btn .icon i {
    width: 22px;
    height: 22px;
}

.control-btn.hangup .icon {
    background: #F44336;
}

.control-btn.active .icon {
    background: #07C160;
}

.control-btn .label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
}

.control-btn:hover .icon {
    transform: scale(1.05);
}

.control-btn .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 16px;
    height: 16px;
    background: #F44336;
    border-radius: 8px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.control-btn .icon-wrapper {
    position: relative;
}

/* ========== 悬浮评论区 ========== */
.floating-comments {
    position: absolute;
    left: 0;
    bottom: 150px;
    width: 300px;
    max-height: 280px;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 8px;
    z-index: 5;
    overflow: hidden;
}

.floating-comment {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 20px;
    padding: 6px 12px 6px 8px;
    animation: slideIn 0.3s ease;
}

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

.floating-comment .avatar {
    width: 24px;
    height: 24px;
    background: #4a4a4a;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.floating-comment .avatar.self {
    background: #07C160;
}

.floating-comment .avatar svg,
.floating-comment .avatar i {
    width: 14px;
    height: 14px;
    color: rgba(255, 255, 255, 0.6);
}

.floating-comment .text {
    font-size: 13px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 底部输入区（评论模式） */
.comment-input-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 40px;
    z-index: 15;
    display: none;
}

.comment-input-bar.show {
    display: flex;
}

.comment-input-bar .input-wrap {
    flex: 1;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 22px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
}

.comment-input-bar .input-wrap svg,
.input-icon {
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.6);
    flex-shrink: 0;
}

.comment-input-bar input {
    flex: 1;
    background: none;
    border: none;
    color: #fff;
    font-size: 14px;
    outline: none;
}

.comment-input-bar input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.comment-input-bar .send-btn {
    width: 40px;
    height: 40px;
    background: #07C160;
    border: none;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
}

.comment-input-bar .send-btn svg {
    width: 18px;
    height: 18px;
}

.comment-input-bar .close-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
}

.comment-input-bar .close-btn svg {
    width: 18px;
    height: 18px;
}

/* ========== 设置面板 ========== */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.settings-overlay.show {
    display: block;
    opacity: 1;
}

.settings-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #2a2a2a;
    border-radius: 24px 24px 0 0;
    z-index: 101;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    padding: 20px 0 40px;
}

.settings-panel.show {
    transform: translateY(0);
}

.settings-handle {
    width: 40px;
    height: 4px;
    background: #555;
    border-radius: 2px;
    margin: 0 auto 20px;
}

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

.settings-title {
    font-size: 16px;
    font-weight: 500;
}

.settings-close {
    width: 32px;
    height: 32px;
    background: #404040;
    border: none;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
}

.settings-close svg {
    width: 16px;
    height: 16px;
}

.settings-content {
    padding: 16px 20px;
    max-height: 400px;
    overflow-y: auto;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item-label {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-item-label svg,
.settings-item-label i {
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.6);
}

.settings-item-label span {
    font-size: 14px;
}

.settings-select {
    padding: 8px 12px;
    background: #404040;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    min-width: 120px;
}

.settings-select option {
    background: #2a2a2a;
}

.settings-toggle-btn {
    padding: 8px 16px;
    background: #07C160;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.settings-toggle-btn:hover {
    background: #06AD56;
}

.settings-toggle-btn:disabled {
    background: #555;
    cursor: not-allowed;
}

/* ========== 加载动画 ========== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s linear infinite;
}

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

/* ========== 响应式 ========== */
@media (min-width: 768px) {
    .local-video-container {
        width: 140px;
        height: 200px;
    }

    #localVideo {
        min-width: 140px;
        min-height: 200px;
        max-width: 180px;
        max-height: 260px;
    }

    .floating-comments {
        width: 350px;
    }
}
