/* ========================================
   AI 聊天助手小部件样式 - Chat Widget Styles
   ======================================== */

/* 聊天小部件容器 */
.chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* 聊天切换按钮 */
.chat-toggle-btn {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(139, 92, 246, 0.6);
}

.chat-toggle-btn:active {
    transform: scale(0.95);
}

.chat-toggle-btn i {
    font-size: 1.5rem;
    color: white;
}

.chat-toggle-btn.hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* 悬停提示 */
.chat-tooltip {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--text-dark);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
}

.chat-tooltip::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid #1a1a2e;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

.chat-toggle-btn:hover .chat-tooltip {
    opacity: 1;
    right: 75px;
}

/* 聊天窗口 */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: min(380px, calc(100vw - 60px));
    height: min(550px, calc(100vh - 120px));
    background: var(--bg-white);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.chat-window.active {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* 聊天头部 */
.chat-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header .chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.chat-header .chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-title h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.chat-status {
    font-size: 0.75rem;
    opacity: 0.9;
}

.chat-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 聊天消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: var(--bg-dark);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* 消息样式 */
.chat-message {
    margin-bottom: 1rem;
    animation: slideIn 0.3s ease-out;
}

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

.chat-message-content {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.chat-message .chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.chat-message .chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-bubble {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    max-width: 85%;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* AI 消息 */
.chat-message-ai .chat-bubble {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
}

.chat-message-ai .chat-bubble p {
    margin-bottom: 0.5rem;
}

.chat-message-ai .chat-bubble p:last-child {
    margin-bottom: 0;
}

.chat-message-ai .chat-bubble ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.chat-message-ai .chat-bubble li {
    margin-bottom: 0.25rem;
}

/* Markdown 样式 */
.chat-message-ai .chat-bubble h1,
.chat-message-ai .chat-bubble h2,
.chat-message-ai .chat-bubble h3,
.chat-message-ai .chat-bubble h4,
.chat-message-ai .chat-bubble h5,
.chat-message-ai .chat-bubble h6 {
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.chat-message-ai .chat-bubble h1 { font-size: 1.5rem; }
.chat-message-ai .chat-bubble h2 { font-size: 1.3rem; }
.chat-message-ai .chat-bubble h3 { font-size: 1.15rem; }
.chat-message-ai .chat-bubble h4 { font-size: 1.05rem; }
.chat-message-ai .chat-bubble h5 { font-size: 0.95rem; }
.chat-message-ai .chat-bubble h6 { font-size: 0.9rem; }

.chat-message-ai .chat-bubble h1:first-child,
.chat-message-ai .chat-bubble h2:first-child,
.chat-message-ai .chat-bubble h3:first-child {
    margin-top: 0;
}

.chat-message-ai .chat-bubble code {
    background: rgba(0, 0, 0, 0.06);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85em;
    color: #e83e8c;
}

.chat-message-ai .chat-bubble pre {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 0.75rem;
    margin: 0.5rem 0;
    overflow-x: auto;
}

.chat-message-ai .chat-bubble pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.chat-message-ai .chat-bubble strong {
    font-weight: 600;
}

.chat-message-ai .chat-bubble em {
    font-style: italic;
}

.chat-message-ai .chat-bubble del {
    text-decoration: line-through;
    opacity: 0.7;
}

.chat-message-ai .chat-bubble a {
    color: #c4b5fd;
    text-decoration: none;
}

.chat-message-ai .chat-bubble a:hover {
    text-shadow: 0 0 8px rgba(139, 92, 246, 0.5);
    text-decoration: underline;
}

.chat-message-ai .chat-bubble blockquote {
    border-left: 3px solid var(--primary-color);
    padding-left: 0.75rem;
    margin: 0.5rem 0;
    color: var(--text-light);
    font-style: italic;
}

.chat-message-ai .chat-bubble hr {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin: 0.75rem 0;
}

.chat-message-ai .chat-bubble img {
    max-width: 100%;
    border-radius: 8px;
    margin: 0.5rem 0;
}

.chat-message-ai .chat-bubble ol {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

/* 用户消息 */
.chat-message-user {
    flex-direction: row-reverse;
}

.chat-message-user .chat-avatar {
    background: #0ea5e9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.chat-message-user .chat-avatar::before {
    content: '';
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
}

.chat-message-user .chat-avatar::after {
    content: '';
    width: 14px;
    height: 7px;
    background: white;
    border-radius: 14px 14px 0 0;
}

.chat-message-user .chat-avatar img {
    display: none;
}

.chat-message-user .chat-bubble {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-top-right-radius: 4px;
}

/* 打字指示器 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.5rem 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-light);
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

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

/* 输入区域 */
.chat-input-area {
    padding: 1rem 1.25rem;
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
}

.chat-input-container {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
}

.chat-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.5);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

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

/* 静音按钮 */
.chat-mute-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-mute-btn:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--primary-color);
}

.chat-mute-btn:active {
    transform: scale(0.95);
}

.chat-mute-btn.muted {
    background: var(--text-light);
    color: white;
    border-color: var(--text-light);
}

.chat-mute-btn.muted:hover {
    background: var(--text-dark);
    border-color: var(--text-dark);
}

/* 响应式 - 使用 min() 已处理大部分情况，这里只需调整小屏细节 */
@media (max-width: 600px) {
    .chat-widget {
        bottom: 15px;
        right: 15px;
    }

    .chat-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 150px);
        max-height: 550px;
        bottom: 70px;
        border-radius: 16px;
    }

    .chat-toggle-btn {
        width: 50px;
        height: 50px;
    }

    .chat-toggle-btn i {
        font-size: 1.25rem;
    }

    .chat-tooltip {
        display: none;
    }
}

@media (max-width: 360px) {
    .chat-widget {
        bottom: 10px;
        right: 10px;
    }

    .chat-header .chat-avatar {
        width: 36px;
        height: 36px;
    }

    .chat-bubble {
        font-size: 0.85rem;
    }
}

/* ========================================
   消息操作按钮样式
   ======================================== */

.chat-message-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 0.75rem;
}

.chat-action-btn:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.chat-action-btn:active {
    transform: scale(0.95);
}

.chat-action-btn.copied {
    background: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
    color: #22c55e;
}

.chat-action-btn.playing {
    background: rgba(14, 165, 233, 0.15);
    border-color: var(--primary-color);
    color: var(--primary-color);
}
