/**
 * AI 聊天组件 - 前端样式
 */

/* 聊天按钮 */
.ry-chat-trigger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 99998;
}

.ry-chat-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.5);
}

.ry-chat-trigger svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

.ry-chat-trigger.bottom-left {
    right: auto;
    left: 20px;
}

/* 聊天窗口 */
.ry-chat-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    animation: slideUp 0.3s ease;
}

.ry-chat-widget.bottom-left {
    right: auto;
    left: 20px;
}

.ry-chat-widget.active {
    display: flex;
}

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

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

.ry-chat-header .title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
}

.ry-chat-header .title svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

.ry-chat-header .status {
    font-size: 12px;
    opacity: 0.8;
}

.ry-chat-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.ry-chat-close:hover {
    opacity: 1;
}

.ry-chat-close svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* 消息区域 */
.ry-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

.ry-chat-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

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

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

.ry-chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #667eea;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ry-chat-avatar svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

.ry-chat-message.user .ry-chat-avatar {
    background: #e0e0e0;
}

.ry-chat-message.user .ry-chat-avatar svg {
    fill: #666;
}

.ry-chat-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.ry-chat-message.assistant .ry-chat-bubble {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

/* 消息中的链接样式 */
.ry-chat-bubble a {
    color: #0056b3;
    text-decoration: underline;
    transition: color 0.2s;
}

.ry-chat-bubble a:hover {
    color: #003d82;
}

.ry-chat-message.user .ry-chat-bubble a {
    color: #b3d4fc;
}

.ry-chat-message.user .ry-chat-bubble a:hover {
    color: #fff;
}

/* 消息中的粗体 */
.ry-chat-bubble strong {
    font-weight: 600;
}

/* 加载动画 */
.ry-chat-message.loading .ry-chat-bubble {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* 输入区域 */
.ry-chat-input-area {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ry-chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
}

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

.ry-chat-input::placeholder {
    color: #999;
}

.ry-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.ry-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ry-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.ry-chat-send svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

/* 响应式 */
@media (max-width: 480px) {
    .ry-chat-widget {
        width: calc(100% - 20px);
        height: calc(100% - 100px);
        bottom: 80px;
        right: 10px;
        left: 10px;
        border-radius: 12px;
    }
    
    .ry-chat-widget.bottom-left {
        left: 10px;
        right: 10px;
    }
    
    .ry-chat-trigger {
        width: 54px;
        height: 54px;
    }
}

/* 卡片列表样式 */
.widget-card-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.widget-card-item {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #eee;
    transition: box-shadow 0.2s;
}

.widget-card-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.widget-card-thumb {
    width: 80px;
    max-width: 80px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.widget-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.widget-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.widget-card-title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.widget-card-title a {
    color: #333 !important;
    text-decoration: none !important;
}

.widget-card-title a:hover {
    color: #555 !important;
    text-decoration: none !important;
}

.widget-card-excerpt {
    font-size: 12px;
    color: #888;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.widget-card-link {
    margin-top: 2px;
}

.widget-card-link a {
    font-size: 12px;
    color: #667eea !important;
    text-decoration: none !important;
}

.widget-card-link a:hover {
    text-decoration: underline !important;
}

/* 详情卡片样式 */
.widget-detail-card {
    margin-top: 8px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #eee;
    background: #f8f9fa;
}

.widget-detail-thumb {
    width: 100%;
    max-height: 160px;
    overflow: hidden;
}

.widget-detail-thumb img {
    width: 100%;
    height: auto;
    display: block;
}

.widget-detail-body {
    padding: 10px 12px;
}

.widget-detail-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.widget-detail-text {
    font-size: 12px;
    color: #666;
    line-height: 1.5;
    max-height: 80px;
    overflow: hidden;
}

.widget-detail-link {
    margin-top: 6px;
}

.widget-detail-link a {
    font-size: 12px;
    color: #667eea !important;
    text-decoration: none !important;
}

.widget-detail-link a:hover {
    text-decoration: underline !important;
}
