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

.ai-chat-container {
    display: flex;
    height: 100%;
    background: #f8fafc;
    position: relative;
    overflow: hidden;
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
}

// ==================== 折叠状态的历史栏 ====================
.history-collapsed {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 48px;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    z-index: 10;

    .history-toggle-btn {
        padding: 8px;
        color: #64748b;
        background: transparent;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;
        margin-bottom: 8px;

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

    .history-icons {
        flex: 1;
        overflow-y: auto;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 8px 0;
    }

    .history-icon-btn {
        padding: 8px;
        color: #94a3b8;
        background: transparent;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;

        &:hover {
            color: #64748b;
            background: #f1f5f9;
        }

        &.active {
            color: $brand-color;
            background: $brand-color-light;
        }
    }

    .expand-btn {
        padding: 8px;
        color: #94a3b8;
        background: transparent;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;

        &:hover {
            color: #64748b;
            background: #f1f5f9;
        }
    }
}

// ==================== 展开时的关闭按钮 ====================
.history-close-btn {
    position: absolute;
    left: 256px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: none;
    border-radius: 0 8px 8px 0;
    padding: 8px;
    cursor: pointer;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
    color: #64748b;

    &:hover {
        background: #f8fafc;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
    }
}

// ==================== 历史对话侧边栏 ====================
.history-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    z-index: 10;
    transition: all 0.3s ease;
    overflow: hidden;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.08);

    &.open {
        width: 256px;
    }

    .sidebar-inner {
        width: 256px;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .sidebar-header {
        height: 56px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px;
        border-bottom: 1px solid #f1f5f9;

        .title {
            font-weight: 500;
            color: #1e293b;
        }

        .new-chat-btn {
            padding: 6px;
            color: #64748b;
            background: transparent;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s;

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

    .conversation-list {
        flex: 1;
        overflow-y: auto;
        padding: 8px;

        .empty-tip {
            padding: 16px;
            text-align: center;
            color: #94a3b8;
            font-size: 14px;
        }
    }

    .conversation-item {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        padding: 10px 12px;
        margin-bottom: 4px;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;

        &:hover {
            background: #f8fafc;

            .delete-btn {
                opacity: 1;
            }
        }

        &.active {
            background: $brand-color-light;
            color: $brand-color;
        }

        .conv-icon {
            flex-shrink: 0;
            margin-top: 2px;
        }

        .conv-info {
            flex: 1;
            min-width: 0;
        }

        .conv-title {
            font-size: 14px;
            font-weight: 500;
            color: #374151;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .conv-time {
            font-size: 12px;
            color: #94a3b8;
            margin-top: 2px;
        }

        .delete-btn {
            padding: 4px;
            color: #94a3b8;
            background: transparent;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            opacity: 0;
            transition: all 0.2s;

            &:hover {
                color: #ef4444;
            }
        }
    }
}

// ==================== 主聊天区域 ====================
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: all 0.3s ease;
    margin-left: 48px;

    &.sidebar-open {
        margin-left: 256px;
    }
}

// ==================== 消息容器 ====================
.messages-container {
    flex: 1;
    overflow-y: auto;
}

// ==================== 空状态 ====================
.empty-state {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;

    .empty-content {
        text-align: center;
        max-width: 600px;
    }

    .logo-wrapper {
        width: 80px;
        height: 80px;
        background: linear-gradient(135deg, $brand-color 0%, $brand-color-hover 100%);
        border-radius: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto 24px;
        box-shadow: 0 8px 24px rgba($brand-color, 0.3);

        .logo-icon {
            font-size: 40px;
            color: #fff;
        }
    }

    .title {
        font-size: 24px;
        font-weight: 700;
        color: #1e293b;
        margin: 0 0 8px;
    }

    .desc {
        font-size: 14px;
        color: #64748b;
        margin: 0 0 32px;
        line-height: 1.6;
    }

    .quick-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        max-width: 480px;
        margin: 0 auto;
    }

    .quick-card {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 16px;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        cursor: pointer;
        transition: all 0.2s;
        text-align: left;

        &:hover {
            border-color: $brand-color;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        }

        .quick-icon {
            width: 36px;
            height: 36px;
            background: $brand-color-light;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: $brand-color;
            transition: all 0.2s;
        }

        &:hover .quick-icon {
            background: $brand-color;
            color: #fff;
        }

        .quick-label {
            font-size: 14px;
            font-weight: 500;
            color: #374151;
        }
    }
}

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

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

        &.user {
            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);
                }
            }
        }
    }

    .avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;

        &.user {
            background: $brand-color;
            color: #fff;
        }

        &.assistant {
            background: linear-gradient(135deg, $brand-color 0%, $brand-color-hover 100%);
            color: #fff;
        }
    }

    .message-bubble {
        max-width: 80%;
        padding: 12px 16px;
        border-radius: 16px 16px 16px 4px;
        background: #fff;
        border: 1px solid #f1f5f9;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);

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

        .message-time {
            font-size: 12px;
            color: #94a3b8;
            margin-top: 8px;
        }
    }
}

// ==================== 快捷命令栏 ====================
.quick-bar {
    padding: 8px 16px;
    border-top: 1px solid #f1f5f9;
    background: #fff;

    .quick-bar-inner {
        max-width: 768px;
        margin: 0 auto;
        display: flex;
        gap: 8px;
        overflow-x: auto;

        &::-webkit-scrollbar {
            display: none;
        }
    }

    .quick-pill {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 6px 12px;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 20px;
        font-size: 12px;
        color: #64748b;
        cursor: pointer;
        white-space: nowrap;
        transition: all 0.2s;

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

        .el-icon {
            color: $brand-color;
        }
    }
}

// ==================== 输入区域 ====================
.input-area {
    padding: 24px;
    background: #f8fafc;

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

    .input-card {
        background: #fff;
        border-radius: 16px;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
        border: 1px solid #e2e8f0;
        overflow: hidden;
    }

    .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;
        max-height: 120px;

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

    .toolbar-row {
        padding: 12px 16px;
        display: flex;
        justify-content: flex-end;
        border-top: 1px solid #f8fafc;
    }

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

    .tool-btn {
        padding: 8px;
        color: #94a3b8;
        background: transparent;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;

        &:hover {
            color: #64748b;
            background: #f1f5f9;
        }
    }

    .send-btn {
        padding: 10px;
        background: #e2e8f0;
        color: #94a3b8;
        border: none;
        border-radius: 12px;
        cursor: not-allowed;
        transition: all 0.2s;

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

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

    .disclaimer {
        text-align: center;
        font-size: 12px;
        color: #94a3b8;
        margin: 12px 0 0;
    }
}
