/* 
 * AI客服插件样式 - 现代紫色渐变风格
 * 版本: 1.3.0
 * 字体: 微软雅黑
 */

/* 基础样式 */
.ai-service-window {
    position: fixed;
    z-index: 99999;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

/* 位置样式 */
.ai-position-bottom-right {
    right: 20px;
    bottom: 20px;
}

.ai-position-bottom-left {
    left: 20px;
    bottom: 20px;
}

.ai-position-top-right {
    right: 20px;
    top: 20px;
}

.ai-position-top-left {
    left: 20px;
    top: 20px;
}

/* 客服按钮 */
.ai-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 28px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.ai-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.5);
}

.ai-btn:active {
    transform: translateY(0);
}

/* 客服窗口 */
.ai-box {
    width: 380px;
    height: 580px;
    background: #ffffff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    position: fixed;
    display: none;
    flex-direction: column;
    animation: ai-box-fade-in 0.3s ease-out;
}

@keyframes ai-box-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 根据父容器位置设置窗口位置 */
.ai-position-bottom-right .ai-box {
    right: 20px;
    bottom: 90px;
}

.ai-position-bottom-left .ai-box {
    left: 20px;
    bottom: 90px;
}

.ai-position-top-right .ai-box {
    right: 20px;
    top: 90px;
}

.ai-position-top-left .ai-box {
    left: 20px;
    top: 90px;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .ai-box {
        width: calc(100vw - 40px) !important;
        height: 70vh !important;
        max-height: 580px !important;
    }
    
    .ai-position-bottom-right .ai-box,
    .ai-position-bottom-left .ai-box {
        right: 20px !important;
        left: 20px !important;
        bottom: 90px !important;
        top: auto !important;
    }
    
    .ai-position-top-right .ai-box,
    .ai-position-top-left .ai-box {
        right: 20px !important;
        left: 20px !important;
        top: 90px !important;
        bottom: auto !important;
    }
}

/* 窗口头部 */
.ai-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    padding: 20px 24px;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.2);
}

.ai-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ffffff;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-title::before {
    content: '💬';
    font-size: 22px;
}

.ai-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}

.ai-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.ai-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
    font-weight: 300;
}

.ai-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 聊天区域 */
.ai-chat-area {
    flex: 1;
    background: #f7f8fc;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* 自定义滚动条 */
.ai-chat-area::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-area::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-area::-webkit-scrollbar-thumb {
    background: #d1d5e8;
    border-radius: 10px;
}

.ai-chat-area::-webkit-scrollbar-thumb:hover {
    background: #b8bdd8;
}

/* 消息样式 */
.ai-message {
    max-width: 75%;
    word-wrap: break-word;
    animation: ai-message-fade-in 0.3s ease-out;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

@keyframes ai-message-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-bot-message {
    background: #ffffff;
    color: #2d3748;
    padding: 14px 18px;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    align-self: flex-start;
    position: relative;
}

.ai-bot-message .ai-message-content {
    font-size: 14px;
    line-height: 1.6;
    color: #2d3748;
}

.ai-user-message {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    padding: 14px 18px;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    align-self: flex-end;
    position: relative;
}

.ai-user-message .ai-message-content {
    font-size: 14px;
    line-height: 1.6;
    color: #ffffff;
}

.ai-welcome-message {
    background: linear-gradient(135deg, #e0e7ff 0%, #f3e8ff 100%);
    color: #5b21b6;
    text-align: center;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

/* 输入区域 */
.ai-input-area {
    display: flex;
    border-top: 1px solid #e8eaf6;
    background: #ffffff;
    padding: 16px 20px;
    gap: 12px;
    align-items: center;
}

.ai-input {
    flex: 1;
    border: 1px solid #e8eaf6;
    border-radius: 24px;
    padding: 12px 20px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    background: #f7f8fc;
    color: #2d3748;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-input:focus {
    border-color: #667eea;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-input::placeholder {
    color: #a0aec0;
}

.ai-send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border: none;
    border-radius: 24px;
    padding: 12px 28px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.ai-send:active {
    transform: translateY(0);
}

.ai-send:disabled {
    background: #cbd5e0;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 错误消息 */
.ai-error-message {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
}

/* 时间戳 */
.ai-timestamp {
    font-size: 11px;
    color: #a0aec0;
    margin-top: 6px;
    opacity: 0.8;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}
.ai-typing-indicator {
    display: flex;
    gap: 6px;
    padding: 12px 18px;
    background: #ffffff;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    align-self: flex-start;
}

.ai-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    opacity: 0.6;
    animation: ai-typing 1.4s infinite ease-in-out;
}

.ai-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.ai-typing-dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes ai-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* 错误消息 */
.ai-error-message {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
}

/* 时间戳 */
.ai-timestamp {
    font-size: 11px;
    color: #a0aec0;
    margin-top: 6px;
    opacity: 0.8;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

/* 工单弹窗样式 */
.ai-ticket-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-ticket-modal.ai-modal-show {
    opacity: 1;
    visibility: visible;
}

.ai-ticket-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.ai-ticket-modal-content {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.ai-modal-show .ai-ticket-modal-content {
    transform: scale(1);
}

.ai-ticket-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-ticket-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #ffffff;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-ticket-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    font-size: 28px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
    font-weight: 300;
    padding: 0;
}

.ai-ticket-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.ai-ticket-modal-body {
    padding: 30px 24px;
    max-height: calc(90vh - 80px);
    overflow-y: auto;
}

.ai-ticket-modal-desc {
    margin: 0 0 24px 0;
    font-size: 14px;
    color: #666;
    text-align: center;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-form-group {
    margin-bottom: 15px;
}

.ai-form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: #2d3748;
    font-weight: 500;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-form-group .required {
    color: #e53e3e;
}

.ai-form-input,
.ai-form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e8eaf6;
    border-radius: 8px;
    font-size: 14px;
    color: #2d3748;
    background: #f7f8fc;
    transition: all 0.2s;
    box-sizing: border-box;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-form-input:focus,
.ai-form-textarea:focus {
    outline: none;
    border-color: #667eea;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-form-textarea {
    resize: vertical;
    min-height: 80px;
}

.ai-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.ai-form-submit,
.ai-form-cancel {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-form-submit {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ai-form-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.ai-form-submit:active {
    transform: translateY(0);
}

.ai-form-submit:disabled {
    background: #cbd5e0;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ai-form-cancel {
    background: #f7f8fc;
    color: #666;
    border: 1px solid #e8eaf6;
}

.ai-form-cancel:hover {
    background: #e8eaf6;
    color: #333;
}

/* 工单按钮样式 - 已移除独立按钮 */

/* 工单列表样式 */
.ai-ticket-items {
    max-height: 500px;
    overflow-y: auto;
}

.ai-ticket-item {
    background: #f7f8fc;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    border-left: 4px solid #667eea;
    transition: all 0.2s;
}

.ai-ticket-item:hover {
    background: #eef0f8;
    transform: translateX(2px);
}

.ai-ticket-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e8eaf6;
}

.ai-ticket-status {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-ticket-status.status-pending {
    background: #fff3cd;
    color: #856404;
}

.ai-ticket-status.status-replied {
    background: #d4edda;
    color: #155724;
}

.ai-ticket-status.status-closed {
    background: #e2e3e5;
    color: #383d41;
}

.ai-ticket-time {
    font-size: 12px;
    color: #999;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-ticket-item-content {
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-ticket-message {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #2d3748;
    line-height: 1.6;
}

.ai-ticket-reply {
    background: #e7f3e7;
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
    border-left: 3px solid #5cb85c;
}

.ai-ticket-reply strong {
    color: #5cb85c;
    font-size: 13px;
    display: block;
    margin-bottom: 6px;
}

.ai-ticket-reply p {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #2d3748;
    line-height: 1.6;
}

.ai-reply-time {
    font-size: 12px;
    color: #666;
}

.ai-loading {
    color: #667eea;
    font-size: 14px;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

/* 工单号样式 */
.ai-ticket-number {
    font-size: 13px;
    font-weight: 600;
    color: #667eea;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

/* 已完成状态样式 */
.ai-ticket-status.status-completed {
    background: #d1ecf1;
    color: #0c5460;
}

/* 多轮回复容器 */
.ai-ticket-replies {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e8eaf6;
}

.ai-replies-header {
    font-size: 13px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 10px;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-ticket-reply {
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

/* 管理员回复样式 */
.ai-admin-reply {
    background: #e7f3e7;
    border-left: 3px solid #5cb85c;
}

/* 用户回复样式 */
.ai-user-reply {
    background: #e3f2fd;
    border-left: 3px solid #2196f3;
}

.ai-reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.ai-admin-reply .ai-reply-header strong {
    color: #5cb85c;
    font-size: 13px;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-user-reply .ai-reply-header strong {
    color: #2196f3;
    font-size: 13px;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-ticket-reply p {
    margin: 0;
    font-size: 14px;
    color: #2d3748;
    line-height: 1.6;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-reply-time {
    font-size: 12px;
    color: #666;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.ai-no-reply {
    color: #999;
    font-size: 13px;
    margin-top: 10px;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

/* 用户回复表单 */
.ai-ticket-reply-form {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e8eaf6;
}

.ai-reply-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
    resize: vertical;
}

.ai-reply-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.ai-submit-reply-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
    transition: all 0.2s;
}

.ai-submit-reply-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ai-submit-reply-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 展开/收起按钮 */
.ai-toggle-replies-btn {
    background: #667eea;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
    transition: all 0.2s;
}

.ai-toggle-replies-btn:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

/* 回复容器 */
.ai-replies-container {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

/* 分页按钮 */
.ai-replies-pagination {
    margin-top: 10px;
    text-align: center;
}

.ai-page-btn {
    margin: 0 3px;
    padding: 4px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
    transition: all 0.2s;
}

.ai-page-btn:hover {
    border-color: #667eea;
    transform: translateY(-1px);
}
