/* ========== AI 助手侧边栏 ========== */
:root {
    --ai-sidebar-width: 380px;
}

#app-content {
    transition: width 0.3s ease, margin-right 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

body.ai-sidebar-open #app-content {
    width: calc(100vw - var(--ai-sidebar-width) - 24px) !important;
    margin-right: calc(var(--ai-sidebar-width) + 24px) !important;
    overflow-x: hidden;
}

body.ai-sidebar-open .ai-toggle-btn {
    right: calc(var(--ai-sidebar-width) + 30px);
}

.ai-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1001;
    padding: 12px 22px;
    background: linear-gradient(135deg, #d84315, #ff6e40); /* 使用固定的变量替代值或确保变量存在 */
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    box-shadow: 0 4px 15px rgba(216, 67, 21, 0.4);
    transition: all 0.3s ease;
}

.ai-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(216, 67, 21, 0.5);
}

.ai-toggle-btn.active {
    background: #5d4037;
    box-shadow: 0 4px 15px rgba(93, 64, 55, 0.4);
}

.ai-sidebar {
    position: fixed;
    top: 0;
    right: calc(-1 * var(--ai-sidebar-width) - 20px);
    width: var(--ai-sidebar-width);
    height: 100vh;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1002;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.ai-sidebar.open {
    right: 0;
}

.ai-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 2px solid #eee;
    background: linear-gradient(135deg, #fff8e1, #fffaf0);
    flex-shrink: 0;
}

.ai-guide-actions {
    padding: 8px 15px 0;
    display: flex;
    justify-content: flex-end;
    background: #fafafa;
}

#ai-next-step-btn {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 14px;
}

.ai-sidebar-header h3 {
    color: #d84315;
    margin: 0;
    font-size: 1.1em;
}

.ai-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #888;
    padding: 0 5px;
    line-height: 1;
}

.ai-close-btn:hover {
    color: #d84315;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.ai-message p {
    margin: 0;
    white-space: pre-wrap;
}

.ai-bot {
    align-self: flex-start;
    background: #f5f0eb;
    color: #333;
    border-bottom-left-radius: 4px;
}

.ai-user {
    align-self: flex-end;
    background: #d84315;
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-loading p {
    animation: ai-dots 1.5s ease-in-out infinite;
}

.ai-error {
    background: #ffebee !important;
    color: #c62828 !important;
}

.ai-system {
    align-self: center;
    background: #efebe9;
    color: #8d6e63;
    font-size: 13px;
    padding: 4px 16px;
    border-radius: 12px;
    max-width: none;
}

.ai-chat-input {
    display: flex;
    gap: 8px;
    padding: 12px 15px;
    border-top: 1px solid #eee;
    background: #fafafa;
    flex-shrink: 0;
}

.ai-chat-input input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    box-shadow: none;
    text-decoration: none;
    background-image: none;
    appearance: none;
    -webkit-appearance: none;
}

.ai-chat-input input:focus {
    border-color: #d84315;
    box-shadow: 0 0 0 3px rgba(216, 67, 21, 0.14);
    text-decoration: none;
}

.ai-message-content p {
    margin: 0;
    white-space: pre-wrap;
}

.ai-message-content h1,
.ai-message-content h2,
.ai-message-content h3,
.ai-message-content h4 {
    margin: 12px 0 8px 0;
    color: #d84315;
    font-size: 1.1em;
}

.ai-message-content ol,
.ai-message-content ul {
    margin: 8px 0;
    padding-left: 28px;
    list-style-position: outside;
}

.ai-message-content li {
    margin-bottom: 4px;
}

.ai-message-content li:last-child {
    margin-bottom: 0;
}

.ai-message-content blockquote {
    border-left: 4px solid #d84315;
    margin: 8px 0;
    padding: 4px 12px;
    color: #666;
    background: rgba(216, 67, 21, 0.05);
    border-radius: 0 4px 4px 0;
}

.ai-message-content pre {
    background: #fdf6f0;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    border: 1px solid #eee;
    font-size: 13px;
    line-height: 1.4;
}

.ai-message-content pre code {
    background: none;
    padding: 0;
    color: #333;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.ai-message-content code {
    background: #fff3e8;
    color: #9a3b10;
    padding: 1px 4px;
    border-radius: 4px;
}

#ai-send-btn {
    min-width: 72px;
    height: 40px;
    padding: 8px 18px;
    border-radius: 20px;
    border: none;
    outline: none;
    background: linear-gradient(135deg, #d84315, #f4511e);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(216, 67, 21, 0.22);
    transition: all 0.2s ease;
}

#ai-send-btn:hover {
    background: linear-gradient(135deg, #bf360c, #e64a19);
    transform: translateY(-1px);
}

#ai-send-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(216, 67, 21, 0.22), 0 4px 12px rgba(216, 67, 21, 0.22);
}

#ai-send-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.ai-chat-input button {
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 14px;
}

/* ========== 光栅高亮滤镜 ========== */
.ai-highlight-overlay {
    position: fixed;
    z-index: 2000000; /* 提升层级，确保在 Canvas/SVG 上方显示 */
    pointer-events: none;
    background: repeating-linear-gradient(
            45deg,
            rgba(216, 67, 21, 0.13),
            rgba(216, 67, 21, 0.13) 4px,
            transparent 4px,
            transparent 8px
    );
    border: 2.5px solid rgba(216, 67, 21, 0.85);
    border-radius: 6px;
    animation: ai-highlight-pulse 1.5s ease-in-out infinite;
    transition: left 0.3s ease, top 0.3s ease, width 0.3s ease, height 0.3s ease;
}

@keyframes ai-highlight-pulse {
    0%, 100% {
        box-shadow: 0 0 8px 2px rgba(216, 67, 21, 0.35);
    }
    50% {
        box-shadow: 0 0 22px 6px rgba(216, 67, 21, 0.6);
    }
}

@keyframes ai-dots {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

/* ========== 头部操作按钮 ========== */
.ai-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-reset-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ai-reset-btn:hover {
    color: #d84315;
    background: rgba(216, 67, 21, 0.1);
}

/* ========== 重置确认弹窗 ========== */
.ai-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1003;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ai-modal-content {
    background: white;
    padding: 24px;
    border-radius: 12px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: ai-modal-show 0.2s ease;
}

@keyframes ai-modal-show {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ai-modal-content p {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 15px;
    line-height: 1.5;
}

.ai-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.ai-modal-actions .control-btn {
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.ai-modal-actions .btn-danger {
    background: #d84315;
    color: white;
}

.ai-modal-actions .btn-danger:hover {
    background: #bf360c;
}

.ai-modal-actions .btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.ai-modal-actions .btn-secondary:hover {
    background: #bdbdbd;
}

/* ========== 登录按钮样式 ========== */
.ai-login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    background: linear-gradient(135deg, #d84315, #f4511e);
    color: #fff !important;
    text-decoration: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    outline: none;
    box-shadow: 0 4px 14px rgba(216, 67, 21, 0.28);
}

.ai-login-btn:hover {
    background: linear-gradient(135deg, #bf360c, #e64a19);
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(216, 67, 21, 0.34);
}

.ai-login-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(216, 67, 21, 0.26), 0 8px 18px rgba(216, 67, 21, 0.34);
}

.ai-error .ai-login-btn {
    margin-top: 4px;
}

