/* 悬浮聊天按钮 */
.chat-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e94560 0%, #c73e54 100%);
    box-shadow: 0 4px 20px rgba(233, 69, 96, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: all 0.3s ease;
    border: none;
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(233, 69, 96, 0.5);
}

.chat-fab:active {
    transform: scale(1.05);
}

.chat-fab-icon {
    font-size: 28px;
    color: white;
    user-select: none;
}

.chat-fab-hidden {
    display: none;
}

/* 悬浮聊天窗口 */
.chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 475px;
    height: 750px;
    max-height: calc(100vh - 60px);
    background: #1a1a2e;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    transform: scale(0);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom right;
}

.chat-widget-open {
    transform: scale(1);
    opacity: 1;
}

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

/* 聊天头部 */
.chat-header {
    background: #16213e;
    padding: 16px 20px;
    border-bottom: 1px solid #2d3a5c;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
}

.chat-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #a0a0a0;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* 会话选择器 */
.chat-session-selector {
    background: #16213e;
    border-bottom: 1px solid #2d3a5c;
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    max-height: 120px;
    overflow-y: auto;
}

/* 会话包装器 */
.chat-session-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.chat-session-wrapper:hover .chat-session-actions {
    opacity: 1;
}

/* 会话操作按钮 */
.chat-session-actions {
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
    background: #1a1a2e;
    padding: 2px;
    border-radius: 12px;
    z-index: 10;
}

/* 手机端始终显示操作按钮 */
@media (max-width: 768px) {
    .chat-session-actions {
        opacity: 1;
        position: static;
        transform: none;
        margin-left: 4px;
    }
    
    .chat-session-wrapper {
        display: flex;
        flex-wrap: nowrap;
    }
}

.chat-session-action-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
}

.chat-rename-btn:hover {
    background: rgba(59, 130, 246, 0.3);
}

.chat-delete-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* 手机端操作菜单 */
.chat-action-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.chat-action-menu {
    background: #1a1a2e;
    border-radius: 16px 16px 0 0;
    padding: 12px;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.chat-action-menu-item {
    padding: 16px 20px;
    background: #16213e;
    border: none;
    border-radius: 12px;
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.chat-action-menu-item:active {
    background: #1f4287;
}

.chat-action-delete {
    color: #ef4444;
}

@media (min-width: 769px) {
    .chat-action-overlay {
        display: none !important;
    }
}

/* 会话按钮 */
.chat-session-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #2d3a5c;
    border-radius: 20px;
    color: #a0a0a0;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* 手机端会话按钮调整 */
@media (max-width: 768px) {
    .chat-session-btn {
        max-width: 120px;
        padding: 6px 12px;
        font-size: 12px;
    }
}

.chat-session-btn:hover {
    background: rgba(233, 69, 96, 0.1);
    border-color: #e94560;
    color: #ffffff;
}

.chat-session-btn.active {
    background: #e94560;
    border-color: #e94560;
    color: white;
}

.chat-new-session-btn {
    padding: 8px 16px;
    background: #e94560;
    border: none;
    border-radius: 20px;
    color: white;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-new-session-btn:hover {
    opacity: 0.9;
}

/* 消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

.chat-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #a0a0a0;
}

.chat-welcome p {
    font-size: 14px;
    line-height: 1.6;
}

.chat-message {
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

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

.chat-message-user {
    text-align: right;
}

.chat-message-user .chat-bubble {
    background: #e94560;
    color: white;
    border-radius: 16px 16px 4px 16px;
}

.chat-message-assistant .chat-bubble {
    background: #1f4287;
    color: white;
    border-radius: 16px 16px 16px 4px;
}

.chat-bubble {
    display: inline-block;
    padding: 12px 16px;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
}

.chat-bubble a {
    color: #e94560;
    text-decoration: none;
}

.chat-bubble a:hover {
    text-decoration: underline;
}

/* 输入区域 */
.chat-input-area {
    padding: 16px;
    background: #16213e;
    border-top: 1px solid #2d3a5c;
}

.chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    background: #1a1a2e;
    border: 1px solid #2d3a5c;
    border-radius: 24px;
    color: #ffffff;
    font-size: 14px;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.4;
}

.chat-input:focus {
    outline: none;
    border-color: #e94560;
}

.chat-input::placeholder {
    color: #6b6b6b;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #e94560;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    opacity: 0.9;
    transform: scale(1.05);
}

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

/* Loading 动画 */
.chat-typing {
    display: flex;
    gap: 6px;
    padding: 12px 16px;
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    background: #a0a0a0;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

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

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #3d4a6c;
}

/* 响应式 */
@media (max-width: 480px) {
    .chat-widget {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 10px;
        right: 10px;
        border-radius: 12px;
    }

    .chat-fab {
        bottom: 20px;
        right: 20px;
    }

    .chat-session-btn {
        max-width: 120px;
    }
}
