// 品牌色
$brand-color: #0055AA;
$brand-color-light: #EBF5FF;
$brand-color-hover: #004488;

.chat-room-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fff;
}

// ==================== 加载更多 ====================
.loading-more {
    text-align: center;
    padding: 12px;
    font-size: 13px;
    color: #94a3b8;
}

// ==================== 聊天室头部 ====================
.chat-header {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;

    .header-default {
        h3 {
            margin: 0;
            font-size: 16px;
            font-weight: 600;
            color: #1e293b;
        }
    }
}

// ==================== 消息容器 ====================
.messages-container {
    flex: 1;
    overflow-y: auto;
    background: #f8fafc;
    position: relative;
}

// ==================== Jitsi Meet会议容器 ====================
.meeting-container {
    width: 100%;
    height: 500px;
    margin-bottom: 16px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);

    .meeting-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        font-weight: 500;
        font-size: 14px;
    }

    .close-meeting-btn {
        display: flex;
        align-items: center;
        gap: 4px;
        padding: 6px 12px;
        background: rgba(255, 255, 255, 0.2);
        border: none;
        border-radius: 6px;
        color: white;
        cursor: pointer;
        font-size: 14px;
        transition: all 0.2s;

        &:hover {
            background: rgba(255, 255, 255, 0.3);
        }
    }

    .meeting-iframe {
        width: 100%;
        height: calc(100% - 48px);
        border: none;
    }
}

// 按钮禁用状态
.action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;

    &:hover {
        border-color: #e2e8f0;
        color: #64748b;
        background: transparent;
    }
}

// ==================== 消息列表 ====================
.messages-list {
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px;

    .message-row {
        display: flex;
        gap: 12px;
        margin-bottom: 24px;

        &.is-me {
            flex-direction: row-reverse;

            .message-bubble {
                background: $brand-color;
                color: #fff;
                border-radius: 16px 16px 4px 16px;

                .message-time {
                    text-align: right;
                    color: rgba(255, 255, 255, 0.7);
                }
            }
        }

        &.other {
            .message-bubble {
                background: #fff;
                border: 1px solid #f1f5f9;
                border-radius: 16px 16px 16px 4px;
                box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
            }
        }

        // 系统消息样式（居中显示）
        &.is-system {
            justify-content: center;
            margin-bottom: 32px;

            .system-message-container {
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: 8px;
                max-width: 80%;

                .system-message-text {
                    padding: 8px 16px;
                    background: rgba(148, 163, 184, 0.15);
                    border-radius: 16px;
                    font-size: 13px;
                    color: #64748b;
                    text-align: center;
                }

                .message-time {
                    font-size: 12px;
                    color: #94a3b8;
                    text-align: center;
                }
            }
        }
    }

    .message-avatar {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        flex-shrink: 0;
        overflow: hidden;
        background: $brand-color-light;
        display: flex;
        align-items: center;
        justify-content: center;

        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .avatar-text {
            font-size: 14px;
            font-weight: 600;
            color: $brand-color;
        }
    }

    .sender-name {
        font-size: 12px;
        color: #64748b;
        margin-bottom: 4px;
    }

    .message-content-wrapper {
        max-width: 70%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .message-bubble {
        padding: 12px 16px;

        .message-text {
            font-size: 14px;
            line-height: 1.6;
            white-space: pre-wrap;
            word-wrap: break-word;
            margin: 0;
        }
    }

    .message-files {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 8px;
    }

    .file-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;
        border: 1px solid rgba(255, 255, 255, 0.2);

        &:hover {
            background: rgba(255, 255, 255, 0.2);
        }

        .file-icon {
            width: 32px;
            height: 32px;
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .file-info {
            .file-name {
                font-size: 13px;
                font-weight: 500;
            }
        }
    }

    .other .file-item {
        background: #f8fafc;
        border-color: #e2e8f0;

        &:hover {
            background: #f1f5f9;
        }

        .file-icon {
            background: $brand-color-light;
            color: $brand-color;
        }

        .file-info {
            color: #374151;
        }
    }

    .message-time {
        font-size: 12px;
        color: #94a3b8;
        padding: 0 4px;
    }
}

// ==================== 输入区域 ====================
.input-area {
    padding: 16px 24px 24px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;

    .action-buttons {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 12px;

        .action-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 8px 16px;
            background: transparent;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            color: #64748b;
            cursor: pointer;
            transition: all 0.2s;
            font-size: 14px;

            &:hover {
                border-color: $brand-color;
                color: $brand-color;
                background: $brand-color-light;
            }
        }
    }

    .input-wrapper {
        max-width: 900px;
        margin: 0 auto;
    }

    .input-card {
        background: #f8fafc;
        border-radius: 12px;
        border: 1px solid #e2e8f0;
        overflow: hidden;
        transition: all 0.2s;

        &:focus-within {
            border-color: $brand-color;
            background: #fff;
        }
    }

    .input-row {
        padding: 12px 16px;
    }

    .chat-textarea {
        width: 100%;
        border: none;
        outline: none;
        resize: none;
        font-size: 14px;
        color: #374151;
        background: transparent;
        line-height: 1.5;
        min-height: 60px;
        max-height: 150px;
        font-family: inherit;

        &::placeholder {
            color: #94a3b8;
        }
    }

    .toolbar-row {
        padding: 8px 16px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-top: 1px solid #e2e8f0;
        background: #fff;
    }

    .toolbar-left {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .tool-btn {
        padding: 8px;
        color: #94a3b8;
        background: transparent;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;

        &:hover {
            color: $brand-color;
            background: $brand-color-light;
        }
    }

    .send-btn {
        padding: 8px 16px;
        background: #e2e8f0;
        color: #94a3b8;
        border: none;
        border-radius: 8px;
        cursor: not-allowed;
        transition: all 0.2s;
        font-size: 14px;
        font-weight: 500;
        display: flex;
        align-items: center;
        gap: 6px;

        &.active {
            background: $brand-color;
            color: #fff;
            cursor: pointer;
            box-shadow: 0 2px 8px rgba($brand-color, 0.3);

            &:hover {
                background: $brand-color-hover;
            }
        }
    }
}

// ==================== Markdown样式 ====================
.message-bubble {
    // 粗体
    strong {
        font-weight: 600;
        color: inherit;
    }

    // 斜体
    em {
        font-style: italic;
    }

    // 行内代码
    .inline-code {
        background: rgba(0, 0, 0, 0.05);
        padding: 2px 6px;
        border-radius: 4px;
        font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
        font-size: 13px;
        color: #e53e3e;
    }

    // 代码块
    .code-block {
        background: rgba(0, 0, 0, 0.05);
        padding: 12px;
        border-radius: 8px;
        overflow-x: auto;
        margin: 8px 0;

        code {
            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
            font-size: 13px;
            line-height: 1.5;
            color: #334155;
        }
    }

    // 链接
    .md-link {
        color: $brand-color;
        text-decoration: underline;

        &:hover {
            color: $brand-color-hover;
        }
    }

    // 标题
    .md-h1 {
        font-size: 20px;
        font-weight: 700;
        margin: 12px 0 8px;
        color: inherit;
    }

    .md-h2 {
        font-size: 18px;
        font-weight: 600;
        margin: 10px 0 6px;
        color: inherit;
    }

    .md-h3 {
        font-size: 16px;
        font-weight: 600;
        margin: 8px 0 4px;
        color: inherit;
    }

    // 列表
    .md-ul, .md-ol {
        margin: 8px 0;
        padding-left: 20px;
    }

    .md-li {
        margin: 4px 0;
        line-height: 1.6;
    }
}


// ==================== 视频会议弹窗 ====================
.meeting-modal-mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.meeting-modal {
    width: 90vw;
    max-width: 1200px;
    height: 80vh;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.meeting-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-shrink: 0;
}

.meeting-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
}

.meeting-modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.minimize-btn,
.meeting-modal .close-meeting-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;

    &:hover {
        background: rgba(255, 255, 255, 0.3);
    }
}

.meeting-modal .close-meeting-btn:hover {
    background: rgba(239, 68, 68, 0.8);
}

.meeting-modal-body {
    flex: 1;
    overflow: hidden;

    .meeting-iframe {
        width: 100%;
        height: 100%;
        border: none;
    }
}

// ==================== 最小化悬浮按钮 ====================
.meeting-float-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    z-index: 999;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    animation: floatPulse 2s infinite;

    &:hover {
        transform: scale(1.05);
        box-shadow: 0 6px 24px rgba(102, 126, 234, 0.5);
    }
}

@keyframes floatPulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 4px 30px rgba(102, 126, 234, 0.6);
    }
}
