/* Copilot 浮动AI助手 */

/* ─── 浮动按钮 ─────────────────────────────────── */
#copilot-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b7355, #6b5842);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(139, 115, 85, 0.35);
    z-index: 9998;
    transition: all 0.3s ease;
    user-select: none;
    border: none;
    font-size: 26px;
}

#copilot-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(139, 115, 85, 0.5);
}

#copilot-btn.active {
    background: linear-gradient(135deg, #ff4d4f, #cf1322);
    box-shadow: 0 4px 16px rgba(255, 77, 79, 0.4);
}

/* 呼吸动画 */
#copilot-btn::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    opacity: 0;
    animation: copilot-pulse 3s ease-in-out infinite;
    z-index: -1;
}

@keyframes copilot-pulse {
    0%   { transform: scale(1); opacity: 0.4; }
    50%  { transform: scale(1.3); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

#copilot-btn.active::after {
    animation: none;
}


/* ─── 对话面板 ─────────────────────────────────── */
#copilot-panel {
    position: fixed;
    bottom: 96px;
    right: 28px;
    width: 420px;
    height: 560px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    animation: copilot-slide-up 0.3s ease;
}

#copilot-panel.open {
    display: flex;
}

@keyframes copilot-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* ─── 面板头部 ─────────────────────────────────── */
#copilot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(135deg, #8b7355, #6b5842);
    color: #fff;
    flex-shrink: 0;
}

#copilot-header .copilot-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
}

#copilot-header .copilot-title .avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

#copilot-header .copilot-actions {
    display: flex;
    gap: 6px;
}

#copilot-header .copilot-actions button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#copilot-header .copilot-actions button:hover {
    background: rgba(255,255,255,0.35);
}


/* ─── 消息区域 ─────────────────────────────────── */
#copilot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f7f8fa;
}

#copilot-messages::-webkit-scrollbar {
    width: 4px;
}

#copilot-messages::-webkit-scrollbar-thumb {
    background: #d9d9d9;
    border-radius: 2px;
}

/* 消息气泡 */
.copilot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.6;
    word-break: break-word;
    animation: copilot-msg-in 0.2s ease;
}

@keyframes copilot-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.copilot-msg.bot {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.copilot-msg.user {
    align-self: flex-end;
    background: #8b7355;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.copilot-msg.system {
    align-self: center;
    background: transparent;
    color: #999;
    font-size: 12px;
    padding: 4px 8px;
}

/* 打字指示器 */
.copilot-typing {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

.copilot-typing span {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: copilot-dot 1.4s ease-in-out infinite;
}

.copilot-typing span:nth-child(2) { animation-delay: 0.2s; }
.copilot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes copilot-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* SQL展示区 */
.copilot-sql-block {
    margin-top: 8px;
    background: #f5f5f5;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    padding: 8px 10px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11.5px;
    color: #666;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 120px;
    overflow-y: auto;
}

/* 数据表格 */
.copilot-data-table {
    margin-top: 8px;
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.copilot-data-table th {
    background: #fafafa;
    padding: 4px 8px;
    text-align: left;
    border-bottom: 1px solid #e8e8e8;
    font-weight: 600;
    color: #666;
}

.copilot-data-table td {
    padding: 4px 8px;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
}


/* ─── 快捷操作 ─────────────────────────────────── */
#copilot-quick-actions {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    overflow-x: auto;
    background: #f7f8fa;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

#copilot-quick-actions::-webkit-scrollbar {
    height: 0;
}

#copilot-quick-actions button {
    white-space: nowrap;
    padding: 5px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 16px;
    background: #fff;
    color: #666;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

#copilot-quick-actions button:hover {
    border-color: #8b7355;
    color: #8b7355;
    background: #f8f5f0;
}


/* ─── 输入区域 ─────────────────────────────────── */
#copilot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

#copilot-input {
    flex: 1;
    border: 1px solid #d9d9d9;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s;
}

#copilot-input:focus {
    border-color: #8b7355;
    box-shadow: 0 0 0 2px rgba(139, 115, 85, 0.1);
}

#copilot-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #8b7355;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
}

#copilot-send-btn:hover {
    background: #6b5842;
    transform: scale(1.05);
}

#copilot-send-btn:disabled {
    background: #d9d9d9;
    cursor: not-allowed;
    transform: none;
}


/* ─── 响应式 ─────────────────────────────────── */
@media (max-width: 480px) {
    #copilot-panel {
        width: calc(100vw - 16px);
        height: calc(100vh - 120px);
        right: 8px;
        bottom: 88px;
        border-radius: 12px;
    }

    #copilot-btn {
        bottom: 20px;
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 22px;
    }
}
