/**
 * DOUBAOAI 聊天界面样式
 */

.doubaoai-chat-container {
    width: 100%;
    max-width: 100%;
    height: 100vh; /* 填充整个视口高度 */
    display: flex;
    flex-direction: column;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.doubaoai-chat-container[data-theme="dark"] {
    background: #1a1a1a;
    border-color: #333;
    color: #fff;
}

/* 聊天头部 */
.doubaoai-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.doubaoai-chat-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.doubaoai-chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.doubaoai-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 消息区域 */
.doubaoai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0px 8px;
    background: #f8f9fa;
    min-height: 200px;
    max-height: calc(100vh - 200px);
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-chat-messages {
    background: #2a2a2a;
}

.doubaoai-welcome-message {
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-welcome-message {
    color: #999;
}

/* 消息气泡 */
.doubaoai-message {
    display: flex;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease-in;
}

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

.doubaoai-message.user {
    justify-content: flex-end;
}

.doubaoai-message-wrapper {
    display: inline-flex;
    flex-direction: column;
    max-width: 70%;
    min-width: 100px;
}

.doubaoai-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.doubaoai-message.user .doubaoai-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.doubaoai-message.assistant .doubaoai-message-content {
    background: #fff;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-message.assistant .doubaoai-message-content {
    background: #333;
    color: #fff;
    border-color: #444;
}

/* 消息中的图片 */
.doubaoai-message-image {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
}

/* 消息时间 */
.doubaoai-message-time {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
    padding: 0 4px;
}

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

.doubaoai-message.assistant .doubaoai-message-time {
    text-align: left;
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-message-time {
    color: #666;
}

/* 历史对话分隔线 */
.doubaoai-history-divider {
    text-align: center;
    color: #999;
    font-size: 12px;
    margin: 20px 0;
    position: relative;
}

.doubaoai-history-divider::before,
.doubaoai-history-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: #e0e0e0;
}

.doubaoai-history-divider::before {
    left: 0;
}

.doubaoai-history-divider::after {
    right: 0;
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-history-divider {
    color: #666;
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-history-divider::before,
.doubaoai-chat-container[data-theme="dark"] .doubaoai-history-divider::after {
    background: #333;
}

/* 输入区域 */
.doubaoai-chat-input-wrapper {
    border-top: 1px solid #e0e0e0;
    background: #fff;
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-chat-input-wrapper {
    background: #1a1a1a;
    border-color: #333;
}

.doubaoai-image-preview {
    padding: 12px 16px;
    width: 180px;
    position: relative;
    display: flex;
    align-items: flex-start;
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-image-preview {
    border-color: #333;
}

.doubaoai-image-preview img {
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 2px solid #e0e0e0;
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-image-preview img {
    border-color: #444;
}

.doubaoai-remove-image {
    position: absolute;
    top: 0px;
    left: 6px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.doubaoai-remove-image:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.doubaoai-chat-input-container {
    display: flex;
    align-items: flex-end;
    padding: 12px 16px;
    gap: 8px;
}

.doubaoai-upload-btn,
.doubaoai-send-btn {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    min-height: 42px;
}

.doubaoai-upload-btn > i,
.doubaoai-send-btn > i {
    font-size: 32px;
}

.doubaoai-upload-btn:hover,
.doubaoai-send-btn:hover {
    background: #f0f0f0;
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-upload-btn:hover,
.doubaoai-chat-container[data-theme="dark"] .doubaoai-send-btn:hover {
    background: #333;
}

.doubaoai-chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    color: #353333 !important;
    resize: none;
    outline: none;
    max-height: 120px;
    font-family: inherit;
    transition: border-color 0.2s;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.doubaoai-chat-input::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

.doubaoai-chat-input:focus {
    border-color: #667eea;
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-chat-input {
    background: #2a2a2a;
    border-color: #444;
    color: #fff !important;
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-chat-input::placeholder {
    color: #888 !important;
}

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

/* 加载动画 */
.doubaoai-loading {
    position: absolute;
    bottom: 106px;
    left: 45%;
    background: #fff;
    padding: 12px 20px;
    border-radius: 18px;
    border: 1px solid #e0e0e0;
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-loading {
    background: #333;
    border-color: #444;
}

.doubaoai-loading-dots {
    display: flex;
    gap: 4px;
}

.doubaoai-loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: bounce 1.4s infinite ease-in-out both;
}

.doubaoai-loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.doubaoai-loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* 登录提示 */
.doubaoai-login-prompt {
    text-align: center;
    padding: 40px 20px;
    margin: 20px;
}

.doubaoai-login-prompt p {
    font-size: 16px;
    color: #999;
    margin: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .doubaoai-message-content {
        max-width: 85%;
    }
    
    .doubaoai-chat-input-container {
        padding: 8px 12px;
    }
}

/* 滚动条样式 */
.doubaoai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.doubaoai-chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.doubaoai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 积分显示 */
.doubaoai-points-display {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.doubaoai-points-display svg {
    color: #ffd700;
}

.doubaoai-points-display .points-value {
    color: #fff;
}

/* 积分不足对话框 */
.doubaoai-points-dialog {
    text-align: center;
    padding: 20px;
}

.doubaoai-points-dialog .points-dialog-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.doubaoai-points-dialog .points-dialog-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 16px;
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-points-dialog .points-dialog-title {
    color: #fff;
}

.doubaoai-points-dialog .points-dialog-content {
    margin-bottom: 20px;
    color: #666;
}

.doubaoai-chat-container[data-theme="dark"] .doubaoai-points-dialog .points-dialog-content {
    color: #999;
}

.doubaoai-points-dialog .points-dialog-content p {
    margin: 8px 0;
    font-size: 16px;
}

.doubaoai-points-dialog .points-dialog-content strong {
    color: #667eea;
    font-size: 18px;
}

.doubaoai-points-dialog .points-dialog-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.doubaoai-points-dialog .points-dialog-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.doubaoai-points-dialog .points-dialog-cancel {
    background: #f0f0f0;
    color: #666;
}

.doubaoai-points-dialog .points-dialog-cancel:hover {
    background: #e0e0e0;
}

.doubaoai-points-dialog .points-dialog-buy {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.doubaoai-points-dialog .points-dialog-buy:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
