/* ============================================
   Agent & Settings - 优化版
   ============================================ */

/* 主面板 - 圆角卡片设计 */
.agent-panel {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    border: 1px solid #f0f0f0;
}

/* 头部 - 简洁的蓝色调 */
.agent-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #3b82f6;
    color: #fff;
}

.agent-title {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.agent-title::before {
    content: "🤖";
    font-size: 18px;
}

/* 模型选择下拉框 */
.agent-model-sel {
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    backdrop-filter: blur(8px);
    cursor: pointer;
    transition: all 0.2s;
}

.agent-model-sel:hover {
    background: rgba(255, 255, 255, 0.25);
}

.agent-model-sel option {
    color: #333;
    background: #fff;
}

.agent-header .btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 16px;
    transition: all 0.2s;
}

.agent-header .btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 消息区域 - 柔和渐变背景 */
.agent-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: linear-gradient(180deg, #f8f9fc 0%, #f0f4f8 100%);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* 欢迎卡片 - 玻璃拟态效果 */
.agent-welcome {
    background: linear-gradient(135deg, #fff 0%, #f8faff 100%);
    padding: 28px 32px;
    border-radius: 16px;
    margin: 8px 0 24px;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.1);
    max-width: 600px;
    align-self: center;
    width: 100%;
}

.agent-welcome p {
    margin-bottom: 14px;
    color: #2d3748;
    line-height: 1.7;
    font-size: 15px;
}

.agent-welcome ul {
    margin: 14px 0;
    padding-left: 24px;
    color: #4a5568;
}

.agent-welcome li {
    margin: 10px 0;
    line-height: 1.6;
    position: relative;
}

.agent-welcome li::marker {
    color: #667eea;
}

.agent-tip {
    color: #e53e3e !important;
    font-size: 13px;
    margin-top: 18px;
    padding: 12px 16px;
    background: #fff5f5;
    border-radius: 10px;
    border-left: 3px solid #fc8181;
}

/* 输入区域 - 固定在底部 */
.agent-input-bar {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    align-items: flex-end;
}

.agent-input-bar textarea {
    flex: 1;
    padding: 12px 18px;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
    max-height: 120px;
    background: #f7fafc;
    transition: all 0.2s;
}

.agent-input-bar textarea:focus {
    outline: none;
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.agent-input-bar textarea::placeholder {
    color: #a0aec0;
}

.agent-input-bar .btn {
    padding: 12px 24px;
    height: fit-content;
    align-self: flex-end;
    border-radius: 20px;
    font-weight: 500;
    transition: all 0.2s;
}

.agent-input-bar .btn-primary {
    background: #3b82f6;
    border: none;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.agent-input-bar .btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

/* 消息气泡 - 现代聊天风格 */
.agent-message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
    max-width: 85%;
}

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

.agent-message.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.agent-message.assistant {
    align-self: flex-start;
}

/* 头像 */
.agent-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.agent-message.user .agent-message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.agent-message.assistant .agent-message-avatar {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: #fff;
}

/* 消息包装器 */
.agent-message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

/* 发送者名称 */
.agent-message-sender {
    font-size: 12px;
    color: #718096;
    margin-bottom: 4px;
    padding: 0 4px;
    font-weight: 500;
}

.agent-message.user .agent-message-sender {
    text-align: right;
    color: #667eea;
}

.agent-message.assistant .agent-message-sender {
    text-align: left;
    color: #48bb78;
}

/* 消息内容 - 气泡设计 */
.agent-message-content {
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.65;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.agent-message.user .agent-message-content {
    background: #3b82f6;
    color: #fff;
    border-bottom-right-radius: 6px;
}

.agent-message.assistant .agent-message-content {
    background: #fff;
    color: #2d3748;
    border-bottom-left-radius: 6px;
    border: 1px solid #e2e8f0;
}

/* 代码块样式 */
.agent-message-content pre {
    background: rgba(0, 0, 0, 0.06);
    padding: 14px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 10px 0;
    font-size: 13px;
}

.agent-message.user .agent-message-content pre {
    background: rgba(255, 255, 255, 0.15);
}

.agent-message-content code {
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    padding: 2px 6px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 4px;
    color: #667eea;
}

.agent-message.user .agent-message-content code {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.agent-message-content p {
    margin: 8px 0;
}

.agent-message-content p:first-child {
    margin-top: 0;
}

.agent-message-content p:last-child {
    margin-bottom: 0;
}

.agent-message-content ul,
.agent-message-content ol {
    margin: 10px 0;
    padding-left: 22px;
}

.agent-message-content li {
    margin: 6px 0;
}

/* 表格样式 */
.agent-message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 13px;
    border-radius: 8px;
    overflow: hidden;
}

.agent-message-content th,
.agent-message-content td {
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    text-align: left;
}

.agent-message-content th {
    background: #f7fafc;
    font-weight: 600;
    color: #4a5568;
}

.agent-message-content tr:nth-child(even) {
    background: #fafafa;
}

/* 工具消息 */
.agent-message.tool-msg {
    align-self: flex-start;
    max-width: 90%;
    margin: 8px 0 16px 44px;
}

/* 工具卡片 */
.tool-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    transition: all 0.2s ease;
}

.tool-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.tool-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f7fafc;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.tool-card-header:hover {
    background: #edf2f7;
}

.tool-icon {
    font-size: 16px;
}

.tool-name {
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
}

.tool-summary {
    flex: 1;
    font-size: 12px;
    color: #718096;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 8px;
}

.tool-status {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    background: #edf2f7;
    color: #718096;
}

.tool-card-pending .tool-status {
    background: #fef3c7;
    color: #d97706;
}

.tool-card-done .tool-status {
    background: #d1fae5;
    color: #059669;
}

.tool-toggle {
    font-size: 10px;
    color: #a0aec0;
    transition: transform 0.2s;
}

/* 折叠状态 */
.tool-card.collapsed .tool-card-body {
    display: none;
}

.tool-card.collapsed .tool-toggle {
    transform: rotate(-90deg);
}

/* 展开状态 */
.tool-card.expanded .tool-card-body {
    display: block;
}

.tool-card.expanded .tool-toggle {
    transform: rotate(0deg);
}

.tool-card-body {
    padding: 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

.tool-card-body pre {
    margin: 0 0 12px;
    padding: 12px;
    background: #f7fafc;
    border-radius: 8px;
    font-size: 12px;
    overflow-x: auto;
}

.tool-card-body pre:last-child {
    margin-bottom: 0;
}

.tool-input {
    color: #4a5568;
}

.tool-result {
    color: #059669;
    background: #f0fdf4 !important;
}

.tool-result-error {
    color: #dc2626;
    background: #fef2f2 !important;
}

/* 加载动画 */
.agent-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #718096;
    font-size: 13px;
    padding: 14px 18px;
    background: #fff;
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.agent-loading::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid #e2e8f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* 时间戳 */
.agent-message-time {
    font-size: 11px;
    color: #a0aec0;
    margin-top: 4px;
    padding: 0 4px;
}

.agent-message.user .agent-message-time {
    text-align: right;
}

/* Settings Panel */
.settings-panel {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 24px;
}

.settings-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 16px;
}

.settings-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.settings-tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.settings-tab-btn:hover {
    color: var(--primary-color);
}

.settings-tab-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.settings-sub-panel {
    background: var(--bg-white);
    border-radius: var(--radius);
}

/* 滚动条美化 */
.agent-messages::-webkit-scrollbar {
    width: 6px;
}

.agent-messages::-webkit-scrollbar-track {
    background: transparent;
}

.agent-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.agent-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* 响应式 */
@media (max-width: 768px) {
    .agent-panel {
        height: calc(100vh - 140px);
        border-radius: 0;
    }

    .agent-message {
        max-width: 95%;
    }

    .agent-welcome {
        margin: 4px 0 16px;
        padding: 20px 24px;
    }
}
