
/* --- 1. 基础布局 & 拖拽核心样式 --- */
.side-content { display: none !important; }
body { border-top: none !important; }

.survey-antd {
    background-color: #ffffff !important;
    min-height: 100vh;
    position: relative !important;
    margin: 0 auto !important;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

.survey-antd-body { width: 100% !important; max-width: none !important; }
.pe-view { max-width: none !important; }
.answer-sheet { 
    transition: none !important; 
    z-index: 900;
    overflow: visible !important;
}

/* 拖拽手柄样式 - 题目区左右边缘 < | > 样式（细长版） */
.hack-resize-handle {
    position: absolute; 
    top: 350px;
    width: 16px; 
    height: 84px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    cursor: col-resize; 
    z-index: 1000;
    display: flex; 
    flex-direction: row;
    align-items: center; 
    justify-content: center;
    gap: 1px;
    padding: 0 2px;
    border-radius: 3px;
    transition: background 0.2s, border-color 0.2s;
}
.hack-resize-handle:hover { 
    background: #e5e7eb;
    border-color: #d1d5db;
}
.hack-resize-left { left: -18px; }
.hack-resize-right { right: -18px; }

/* < | > 图标内容 - 直接用字符 */
.hack-resize-handle .arrow-left,
.hack-resize-handle .arrow-right {
    font-size: 18px;
    font-weight: bold;
    color: #6b7280;
    line-height: 1;
    font-family: -apple-system, Arial, sans-serif;
    transform: scaleY(1.5);
}
.hack-resize-handle .bars {
    display: flex;
}
.hack-resize-handle .bar {
    width: 2px;
    height: 40px;
    background: #6b7280;
    border-radius: 1px;
}

/* 独立拖动按钮样式 - 四向箭头 */
.hack-drag-btn {
    position: absolute;
    width: 28px; height: 28px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: move;
    z-index: 1001;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    user-select: none;
}
.hack-drag-btn:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

/* 四向箭头图标 - 用 CSS 绘制（细线版） */
.hack-drag-btn .arrow-icon {
    position: relative;
    width: 16px;
    height: 16px;
}
/* 中心十字 */
.hack-drag-btn .arrow-icon::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 1.5px; height: 16px;
    background: #6b7280;
}
.hack-drag-btn .arrow-icon::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 16px; height: 1.5px;
    background: #6b7280;
}
/* 四个箭头（更细） */
.hack-drag-btn .arr-up, 
.hack-drag-btn .arr-down,
.hack-drag-btn .arr-left,
.hack-drag-btn .arr-right {
    position: absolute;
    width: 0; height: 0;
}
.hack-drag-btn .arr-up {
    top: 0; left: 50%;
    transform: translateX(-50%);
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-bottom: 4px solid #6b7280;
}
.hack-drag-btn .arr-down {
    bottom: 0; left: 50%;
    transform: translateX(-50%);
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 4px solid #6b7280;
}
.hack-drag-btn .arr-left {
    left: 0; top: 50%;
    transform: translateY(-50%);
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    border-right: 4px solid #6b7280;
}
.hack-drag-btn .arr-right {
    right: 0; top: 50%;
    transform: translateY(-50%);
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    border-left: 4px solid #6b7280;
}

/* 答题卡拖动按钮位置 - 左边 */
.hack-sheet-drag {
    top: 8px;
    left: -34px;
}

/* AI窗口拖动按钮位置 - 右上角的左边 */
.hack-ai-drag {
    top: 8px;
    right: calc(100% + 6px);
}

/* --- 2. AI 助手样式 (全屏覆盖 + 动效版) --- */
#ai-btn {
    position: fixed; bottom: 50px; right: 30px;
    width: 48px; height: 48px;
    background: #1677ff; border-radius: 50%;
    color: white; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 15px rgba(22, 119, 255, 0.4);
    cursor: pointer; z-index: 9999; font-weight: bold; font-size: 14px;
    transition: transform 0.2s;
}
#ai-btn:hover { transform: scale(1.1); }

#ai-box {
    display: none; position: fixed; bottom: 110px; right: 30px;
    width: 480px;
    max-height: 80vh;
    background: white; border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2); z-index: 9999;
    padding: 20px; border: 1px solid #f0f0f0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex; flex-direction: column; gap: 12px;
    overflow: visible; 
    position: fixed;
    /* 高度变化动画 */
    transition: height 0.3s ease;
}

/* 默认状态下的结果框（显示 Loading/错误信息） */
#ai-result-area {
    margin-top: 10px; padding: 12px;
    background: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0;
    font-size: 13px; line-height: 1.6; color: #334155;
    max-height: 200px; overflow-y: auto;
    word-wrap: break-word;
    transition: all 0.3s ease;
}

/* 关键：展开状态（覆盖全屏） */
#ai-result-area.expanded {
    display: block;
    position: absolute; /* 绝对定位，脱离文档流 */
    top: 0; left: 0; right: 0; bottom: 0; /* 撑满父容器 */
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;

    background: #fff; /* 必须有背景色遮挡底部内容 */
    z-index: 1000;    /* 确保在最上层 */

    padding: 0;       /* 去掉边距，内容贴边 */
    margin: 0;
    border: none;
    border-radius: 12px; /* 匹配父容器圆角 */

    overflow-y: auto; /* 竖向滚动 */
    overflow-x: hidden; /* 横向禁止滚动 */

    /* 动效：从下往上滑入 */
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* 定义滑入动画 */
@keyframes slideUp {
    0% { transform: translateY(100%); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* 返回按钮样式优化：吸顶 Header */
.ai-back-btn {
    position: sticky; top: 0; left: 0;
    width: 100%;
    background: #1677ff;
    color: white;
    border: none;
    padding: 12px 20px;
    text-align: left;
    font-size: 14px; font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 10;
    display: flex; align-items: center;
}
.ai-back-btn:hover { background: #4096ff; }
.ai-back-btn::before { content: '← '; margin-right: 5px; }

/* 输入控件样式 (保持不变) */
.ai-input-group { display: flex; flex-direction: column; gap: 8px; }
.ai-input {
    width: 100%; padding: 8px 12px;
    border: 1px solid #d9d9d9; border-radius: 6px;
    font-size: 14px; outline: none; transition: border 0.2s;
    box-sizing: border-box;
}
.ai-input:focus { border-color: #1677ff; box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1); }
.ai-textarea { min-height: 60px; resize: vertical; }

/* 按钮组 (保持不变) */
.ai-btn-group { display: flex; gap: 10px; justify-content: space-between; margin-top: 5px; }
.ai-action-btn {
    flex: 1; padding: 8px 0; border: none; border-radius: 6px;
    cursor: pointer; font-size: 13px; font-weight: 500;
    transition: background 0.2s; color: white;
}
.btn-delete { background: #ff4d4f; }
.btn-delete:hover { background: #ff7875; }
.btn-ask { background: #1677ff; }
.btn-ask:hover { background: #4096ff; }

/* 消息文字样式 */
#ai-result-area h2 { font-size: 15px; color: #1677ff; margin: 10px 0 5px 0; }
#ai-result-area p { margin-bottom: 8px; }
.success-msg { color: #166534; font-weight: bold; }
.error-msg { color: #dc2626; font-weight: bold; }

/* ========== 3. 手机端适配样式 ========== */
/* 通过 JS 给 body 添加 .hack-mobile-mode 类来标识手机端 */
body.hack-mobile-mode #ai-btn {
    bottom: 10px;  /* 贴近底部 */
    right: 15px;
    width: 44px;
    height: 44px;
    font-size: 13px;
}

body.hack-mobile-mode #ai-box {
    /* 全屏宽度，贴边 */
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0; /* 只有顶部圆角 */
    padding: 16px;
    margin: 0;
    max-height: 60vh; /* 不要太高，留出下一题按钮空间 */
    box-sizing: border-box;
}

/* 手机端隐藏拖动按钮 */
body.hack-mobile-mode .hack-ai-drag {
    display: none !important;
}

/* 手机端 AI 结果全屏覆盖 */
body.hack-mobile-mode #ai-result-area.expanded {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    z-index: 10001 !important;
    background: #fff;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
}

/* 手机端 iframe 内容自适应宽度 */
body.hack-mobile-mode #ai-result-area.expanded iframe {
    width: 100% !important;
    min-height: calc(100vh - 50px) !important;
}

/* 手机端结果关闭按钮 */
body.hack-mobile-mode .ai-result-close-btn {
    width: 36px !important;
    height: 36px !important;
}

/* ========== 4. 简繁切换按钮样式（小方块，放在AI窗口Hi用户名右边） ========== */
#lang-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    color: #666;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    margin-left: 6px;
    vertical-align: middle;
    transition: all 0.2s;
    user-select: none;
    flex-shrink: 0;
}
#lang-toggle-btn:hover {
    background: #e8e8e8;
    border-color: #ccc;
    color: #333;
}
#lang-toggle-btn.is-traditional {
    background: #fff1f0;
    border-color: #ffccc7;
    color: #cf1322;
}
#lang-toggle-btn.is-traditional:hover {
    background: #ffccc7;
    border-color: #ffa39e;
}
/* 转换中状态 */
#lang-toggle-btn.is-loading {
    opacity: 0.6;
    pointer-events: none;
}
