/* themes/default/css/modules.css - V47.0 雅致 UI 修复版 */

/* === 1. 围炉夜话 (Fireside Chat) === */
.ai-fab { 
    position: fixed; bottom: 30px; right: 20px; 
    width: 56px; height: 56px; border-radius: 50%; 
    background: linear-gradient(135deg, #2B6E75 0%, #1F2D30 100%); 
    box-shadow: 0 4px 15px rgba(43,110,117,0.3); 
    display: flex; align-items: center; justify-content: center; 
    color: #fff; font-size: 28px; cursor: pointer; z-index: 90; 
    transition: transform 0.3s, opacity 0.3s; 
}
.ai-fab:active { transform: scale(0.9); }
.ai-fab.hide { opacity: 0; pointer-events: none; transform: translateY(20px); }

/* 对话框容器 */
.chat-modal { 
    position: fixed; bottom: -100%; left: 0; width: 100%; height: 75vh; 
    background: #fff; border-radius: 20px 20px 0 0; 
    z-index: 1001; transition: 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); 
    display: flex; flex-direction: column; 
    box-shadow: 0 -10px 40px rgba(0,0,0,0.15); 
}
.chat-modal.show { bottom: 0; }

/* === 核心修复：标题栏 === */
.chat-header { 
    padding: 16px 20px; 
    /* 与作者页同款渐变 */
    background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-secondary) 100%);
    color: #fff;
    display: flex; justify-content: center; /* 标题居中 */
    align-items: center; 
    position: relative; /* 为关闭按钮定位 */
    border-radius: 20px 20px 0 0;
    box-shadow: 0 2px 10px rgba(43, 110, 117, 0.1);
}

.chat-header strong {
    font-size: 1.1rem; letter-spacing: 1px;
    display: flex; align-items: center; gap: 8px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* 关闭按钮：绝对定位 */
.chat-close-btn {
    position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
    font-size: 24px; color: rgba(255,255,255,0.8); cursor: pointer;
    transition: 0.3s;
}
.chat-close-btn:hover { color: #fff; transform: translateY(-50%) rotate(90deg); }

/* 内容区 */
.chat-body { 
    flex: 1; overflow-y: auto; padding: 20px; 
    display: flex; flex-direction: column; gap: 20px;
    background: #F4F9F9; /* 淡青灰底色 */
}

/* 消息气泡 */
.chat-msg-row { display: flex; gap: 10px; align-items: flex-start; width: 100%; }
.chat-msg-row.user { flex-direction: row-reverse; }
.chat-msg-row.system { justify-content: center; width: 100%; }

.msg-avatar { 
    width: 36px; height: 36px; border-radius: 50%; 
    display: flex; align-items: center; justify-content: center; 
    flex-shrink: 0; font-size: 18px; border: 1px solid rgba(0,0,0,0.05);
}
/* AI 头像：白底青标 */
.ai .msg-avatar { background: #fff; color: var(--c-primary); }
/* 用户头像：青底白标 */
.user .msg-avatar { background: var(--c-primary); color: #fff; }

.msg-bubble { 
    max-width: 75%; padding: 10px 15px; 
    border-radius: 12px; font-size: 15px; line-height: 1.6; position: relative;
    word-break: break-word; box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
/* AI 气泡 */
.ai .msg-bubble { 
    background: #fff; color: #333; 
    border-top-left-radius: 2px; /* 气泡角标 */
}
/* 用户气泡 */
.user .msg-bubble { 
    background: #CDE8E5; /* 极淡的青绿色，比纯绿更雅 */
    color: #1F2D30; 
    border-top-right-radius: 2px;
}

/* 系统提示卡片 */
.chat-system-card {
    background: #fff; padding: 15px; border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    text-align: center; max-width: 85%; margin: 0 auto;
}
.sys-btn {
    background: linear-gradient(135deg, #D4AF37, #C5A028); /* 泥金色 */
    color: #fff; border: none; padding: 6px 16px; border-radius: 20px;
    font-size: 13px; cursor: pointer; transition: 0.2s;
    box-shadow: 0 2px 6px rgba(212, 175, 55, 0.3);
}

/* 底部输入栏 */
.chat-footer { 
    padding: 12px 15px; background: #fff; border-top: 1px solid #eee; 
    display: flex; gap: 10px; align-items: center; 
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.chat-input { 
    flex: 1; padding: 10px 15px; border: 1px solid #eee; border-radius: 20px; 
    outline: none; background: #f9f9f9; font-size: 15px; height: 40px; 
    transition: 0.3s;
}
.chat-input:focus { background: #fff; border-color: var(--c-primary); }
.chat-send { 
    width: 40px; height: 40px; border-radius: 50%; border: none; 
    background: var(--c-primary); color: #fff; font-size: 18px; 
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: 0.2s;
}
.chat-send:active { transform: scale(0.9); }

/* === 2. 诗笺工坊 (保持 V46 修复版) === */
/* 为了确保全量覆盖不丢失，这里重复粘贴 V46 的诗笺样式 */
.card-builder-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #e0e5e5; z-index: 2000; display: flex; flex-direction: column; transform: translateY(100%); transition: transform 0.3s; }
.modal-overlay.show .card-builder-modal { transform: translateY(0); }
.cb-header { height: 44px; background: #fff; border-bottom: 1px solid #eee; display: flex; justify-content: center; align-items: center; position: relative; }
.cb-title { font-weight: bold; color: var(--c-primary); font-size: 16px; }
.cb-close { position: absolute; right: 15px; font-size: 24px; color: #999; cursor: pointer; }
.cb-body { flex: 1; display: flex; justify-content: center; align-items: center; overflow: hidden; padding: 40px; position: relative; background-color: #E0E5E5; }
.cb-preview-box { display: block; width: 360px; height: 600px; background: #fff; box-shadow: 0 20px 60px rgba(0,0,0,0.2); transition: 0.3s; transform-origin: center center; position: relative; }
.cb-preview-box.loading::after { content: "正在绘制..."; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.95); color: #999; display: flex; justify-content: center; align-items: center; z-index: 10; }
.cb-preview-box iframe { position: relative; z-index: 1; background: #fff; }
.cb-controls { flex-shrink: 0; background: #fff; border-top: 1px solid #eee; height: 300px; display: flex; flex-direction: column; box-shadow: 0 -4px 20px rgba(0,0,0,0.05); }
.cb-tabs { display: flex; border-bottom: 1px solid #f5f5f5; height: 40px; }
.cb-tab { flex: 1; text-align: center; padding: 10px 0; font-size: 14px; color: #999; cursor: pointer; }
.cb-tab.active { color: var(--c-primary); font-weight: bold; background: rgba(43,110,117,0.05); border-bottom: 2px solid var(--c-primary); }
.cb-panel { flex: 1; padding: 20px; overflow-y: auto; display: none; }
.cb-panel.active { display: block; }
.opt-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 15px; }
.opt-btn { padding: 8px 0; border: 1px solid #eee; border-radius: 6px; text-align: center; font-size: 13px; cursor: pointer; color: #666; background: #fff; }
.opt-btn.active { border-color: var(--c-primary); background: var(--c-primary); color: #fff; }
.cb-actions { padding: 10px 20px; display: flex; justify-content: center; border-top: 1px solid #f9f9f9; padding-bottom: 25px; }
.btn-save { width: 100%; max-width: 300px; padding: 10px; border-radius: 30px; border: none; background: linear-gradient(135deg, var(--c-primary), var(--c-secondary)); color: #fff; font-size: 16px; font-weight: bold; cursor: pointer; }
@media (min-width: 768px) {
    .chat-modal { width: 400px; left: auto; right: 20px; bottom: 20px; height: 600px; border-radius: 12px; transform: translateY(120%); }
    .chat-modal.show { transform: translateY(0); bottom: 20px; }
    .card-builder-modal { width: 900px; height: 85vh; margin: auto; border-radius: 16px; transform: scale(0.95); opacity: 0; pointer-events: none; }
    .modal-overlay.show .card-builder-modal { transform: scale(1); opacity: 1; pointer-events: auto; }
    .cb-header { display: none; } .cb-body { width: 65%; height: 100%; border-right: 1px solid #eee; } .cb-controls { width: 35%; height: 100%; }
}