.ai-assistant-float {
    position: fixed;
    right: 20px;
    bottom: 80px;
    z-index: 9999;
    cursor: pointer;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    animation: ai-float-pulse 2s infinite;
}

.ai-assistant-float:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.ai-assistant-float img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

@keyframes ai-float-pulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(102, 126, 234, 0.7); }
}

.ai-chat-panel {
    position: fixed;
    right: 20px;
    bottom: 150px;
    width: 620px;
    height: 820px;
    max-height: calc(100vh - 200px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.ai-chat-panel.active {
    display: flex;
}

.ai-chat-panel.fullscreen {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
}

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

.ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chat-header-left img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.ai-chat-header-left .ai-title {
    font-size: 16px;
    font-weight: 600;
}

.ai-chat-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-header-right .ai-header-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}

.ai-chat-header-right .ai-header-btn:hover {
    background: rgba(255,255,255,0.35);
}

.ai-chat-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.ai-chat-sidebar {
    width: 0;
    overflow: hidden;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    transition: width 0.3s ease;
    flex-shrink: 0;
}

.ai-chat-sidebar.open {
    width: 200px;
}

.ai-chat-sidebar-inner {
    width: 200px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.ai-sidebar-header {
    padding: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-sidebar-header .ai-new-chat-btn {
    background: #667eea;
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.ai-sidebar-header .ai-new-chat-btn:hover {
    background: #5a6fd6;
}

.ai-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.ai-sidebar-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #495057;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.2s;
    position: relative;
}

.ai-sidebar-item:hover {
    background: #e9ecef;
}

.ai-sidebar-item.active {
    background: #667eea;
    color: #fff;
}

.ai-sidebar-item .ai-sidebar-delete {
    display: none;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
}

.ai-sidebar-item:hover .ai-sidebar-delete {
    display: block;
}

.ai-sidebar-item.active .ai-sidebar-delete {
    color: rgba(255,255,255,0.8);
}

.ai-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

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

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

.ai-msg {
    display: flex;
    margin-bottom: 16px;
    gap: 10px;
}

.ai-msg.user {
    flex-direction: row-reverse;
}

.ai-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #fff;
}

.ai-msg.assistant .ai-msg-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.ai-msg.user .ai-msg-avatar {
    background: #495057;
}

.ai-msg-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.ai-msg.assistant .ai-msg-bubble {
    background: #f1f3f5;
    color: #212529;
    border-top-left-radius: 4px;
}

.ai-msg.user .ai-msg-bubble {
    background: #667eea;
    color: #fff;
    border-top-right-radius: 4px;
}

.ai-msg-bubble img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
}

.ai-msg-bubble a {
    color: #667eea;
    text-decoration: underline;
}

.ai-msg.user .ai-msg-bubble a {
    color: #fff;
}

.ai-chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #868e96;
}

.ai-chat-welcome img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-bottom: 16px;
}

.ai-chat-welcome h3 {
    font-size: 18px;
    color: #495057;
    margin-bottom: 8px;
}

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

.ai-chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e9ecef;
    background: #fff;
    flex-shrink: 0;
}

.ai-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 8px 12px;
    border: 1px solid #e9ecef;
    transition: border-color 0.2s;
}

.ai-chat-input-wrap:focus-within {
    border-color: #667eea;
}

.ai-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 100px;
    min-height: 20px;
    font-family: inherit;
}

.ai-chat-send-btn {
    background: #667eea;
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.ai-chat-send-btn:hover {
    background: #5a6fd6;
}

.ai-chat-send-btn:disabled {
    background: #adb5bd;
    cursor: not-allowed;
}

.ai-chat-send-btn svg {
    width: 16px;
    height: 16px;
}

.ai-chat-upload-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
    color: #868e96;
}

.ai-chat-upload-btn:hover {
    background: #e9ecef;
    color: #667eea;
}

.ai-chat-upload-btn svg {
    width: 18px;
    height: 18px;
}

.ai-chat-upload-preview {
    position: relative;
    display: inline-block;
    margin-bottom: 8px;
}

.ai-chat-upload-preview img {
    max-width: 120px;
    max-height: 80px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    object-fit: cover;
}

.ai-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #dc3545;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    padding: 0;
}

.ai-preview-remove:hover {
    background: #c82333;
}

.ai-msg-user-img {
    max-width: 200px;
    max-height: 150px;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    display: block;
}

.ai-msg-loading {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.ai-msg-loading span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #adb5bd;
    animation: ai-loading-dot 1.4s infinite both;
}

.ai-msg-loading span:nth-child(2) { animation-delay: 0.2s; }
.ai-msg-loading span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-loading-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.ai-msg-loading-text {
    margin-top: 6px;
    font-size: 13px;
    color: #868e96;
    line-height: 1.4;
}

.ai-video-wrap {
    position: relative;
    margin-top: 8px;
    border-radius: 8px;
    overflow: hidden;
    max-width: 100%;
}

.ai-video-wrap video {
    width: 100%;
    display: block;
    border-radius: 8px;
    background: #000;
}

.ai-video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.ai-video-play:hover {
    background: rgba(102, 126, 234, 0.85);
}

.ai-video-play svg {
    width: 24px;
    height: 24px;
    margin-left: 3px;
}

@media (max-width: 768px) {
    .ai-assistant-float {
        right: 12px;
        bottom: 70px;
        width: 48px;
        height: 48px;
    }

    .ai-assistant-float img {
        width: 30px;
        height: 30px;
    }

    .ai-chat-panel {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .ai-chat-sidebar.open {
        width: 160px;
    }

    .ai-chat-sidebar-inner {
        width: 160px;
    }
}
