/* ============================================
   叩门 - 对话页面样式
   ============================================ */

/* 对话页面容器 */
.chat-container {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    background: linear-gradient(180deg, #F5F0E8 0%, #EDE8E0 100%);
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ============================================
   顶部栏
   ============================================ */
.chat-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px var(--shadow-color);
}

.back-btn {
    font-size: 28px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0 8px;
    transition: color 0.3s ease;
}

.back-btn:hover {
    color: var(--accent-red);
}

.mentor-info-header {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.mentor-avatar-small {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.mentor-meta {
    display: flex;
    flex-direction: column;
}

.mentor-name-header {
    font-family: var(--font-calligraphy);
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--text-primary);
    margin: 0;
}

.mentor-status {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 开始新对话按钮 */
.new-chat-btn {
    width: 36px;
    height: 36px;
    background: rgba(196, 30, 58, 0.1);
    border: 1px solid rgba(196, 30, 58, 0.2);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: var(--accent-red);
}

.new-chat-btn:hover {
    background: rgba(196, 30, 58, 0.15);
    transform: rotate(45deg);
}

.new-chat-icon {
    font-size: 1.3rem;
    line-height: 1;
}

/* 沉浸式对话开关 */
.immersive-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 6px 10px;
    background: rgba(196, 30, 58, 0.08);
    border-radius: 10px;
    border: 1px solid rgba(196, 30, 58, 0.15);
}

.toggle-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    font-weight: 500;
}

.toggle-switch {
    width: 44px;
    height: 24px;
    background: #D4C4B0;
    border-radius: 12px;
    position: relative;
    transition: background 0.3s ease;
    border: 1px solid rgba(0,0,0,0.1);
}

.toggle-switch.active {
    background: var(--accent-red);
}

.toggle-knob {
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 1px;
    left: 2px;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}

.toggle-switch.active .toggle-knob {
    transform: translateX(20px);
}

/* ============================================
   PGC 标识
   ============================================ */
.pgc-badge {
    position: absolute;
    top: 70px;
    right: 16px;
    background: linear-gradient(135deg, var(--accent-red) 0%, #A01830 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(196, 30, 58, 0.3);
}

/* ============================================
   聊天消息区
   ============================================ */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    padding-bottom: 200px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 900px;
    margin: 0 auto;
}

/* 消息通用样式 */
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out;
}

.message-mentor {
    align-self: flex-start;
}

.message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* 头像 */
.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--border-color);
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-user .message-avatar {
    background: var(--accent-red);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
}

/* 消息内容区 */
.message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-user .message-content {
    align-items: flex-end;
}

/* 消息气泡 */
.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 100%;
    word-wrap: break-word;
    line-height: 1.7;
}

.message-mentor .message-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
}

.message-user .message-bubble {
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    border-bottom-right-radius: 4px;
    color: var(--text-primary);
}

.message-bubble p {
    margin: 0;
    font-size: 0.95rem;
}

/* 时间戳 */
.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* 打字中动画 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ============================================
   生成赠言按钮（浮动）
   ============================================ */
.generate-dedication-btn {
    position: fixed;
    right: 16px;
    bottom: 160px;
    background: linear-gradient(135deg, var(--accent-red) 0%, #A01830 100%);
    color: white;
    border: none;
    padding: 12px 18px;
    border-radius: 24px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(196, 30, 58, 0.4), 0 0 0 2px rgba(255,255,255,0.3);
    transition: all 0.3s ease;
    z-index: 50;
}

.generate-dedication-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(196, 30, 58, 0.5), 0 0 0 2px rgba(255,255,255,0.4);
}

.generate-dedication-btn span:first-child {
    font-size: 1.2rem;
}

/* ============================================
   底部输入区
   ============================================ */
.chat-input-area {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1200px;
    background: linear-gradient(180deg, #FAF8F4 0%, #F5F0E8 100%);
    border-top: 1px solid #D4C4B0;
    padding: 12px 16px;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}

/* 人格模拟指令面板 */
.persona-panel {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: background 0.3s ease;
}

.panel-header:hover {
    background: rgba(0,0,0,0.02);
}

.panel-arrow {
    transition: transform 0.3s ease;
}

.persona-panel.expanded .panel-arrow {
    transform: rotate(180deg);
}

.panel-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.persona-panel.expanded .panel-content {
    max-height: 300px;
}

.panel-section {
    padding: 12px 14px;
    border-top: 1px solid var(--border-color);
}

.panel-section h4 {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.panel-section p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* 输入框包装 */
.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

/* 消息输入框 */
.message-input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 10px 16px;
    font-family: var(--font-serif);
    font-size: 0.95rem;
    color: var(--text-primary);
    resize: none;
    outline: none;
    transition: border-color 0.3s ease;
    max-height: 120px;
    min-height: 44px;
}

.message-input:focus {
    border-color: var(--accent-red);
}

.message-input::placeholder {
    color: var(--text-muted);
}

/* 发送按钮 */
.send-btn {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-red) 0%, #A01830 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(196, 30, 58, 0.35);
}

.send-btn:hover {
    background: linear-gradient(135deg, #D42040 0%, #8B1538 100%);
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(196, 30, 58, 0.45);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn span {
    font-size: 1.3rem;
    margin-left: 2px;
}

/* ============================================
   赠言弹窗
   ============================================ */
.dedication-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.dedication-modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.dedication-modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-family: var(--font-calligraphy);
    font-size: 1.5rem;
    font-weight: 400;
    margin: 0;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px 20px;
    text-align: center;
}

.dedication-card {
    background: linear-gradient(135deg, #FFF9F0 0%, #FFF5E6 100%);
    border: 2px solid var(--accent-red);
    border-radius: var(--radius-md);
    padding: 32px 28px;
    margin-bottom: 16px;
    position: relative;
    box-shadow: 0 4px 20px rgba(196, 30, 58, 0.1);
}

.dedication-card::before {
    content: '"';
    position: absolute;
    top: 8px;
    left: 14px;
    font-family: var(--font-serif);
    font-size: 3.5rem;
    color: var(--accent-red);
    opacity: 0.25;
    line-height: 1;
}

.dedication-quote {
    font-family: var(--font-calligraphy);
    font-size: 1.6rem;
    color: #2C2C2C;
    line-height: 2;
    margin-bottom: 16px;
    font-weight: 400;
    letter-spacing: 0.05em;
}

.dedication-author {
    font-size: 1rem;
    color: var(--accent-red);
    font-weight: 500;
    letter-spacing: 0.08em;
}

.dedication-context {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.modal-footer button {
    flex: 1;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-serif);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-primary {
    background: var(--accent-red);
    border: none;
    color: white;
}

.btn-primary:hover {
    background: var(--accent-red-hover);
}

/* ============================================
   响应式适配
   ============================================ */
@media (max-width: 380px) {
    .chat-header {
        padding: 10px 12px;
    }
    
    .mentor-avatar-small {
        width: 38px;
        height: 38px;
    }
    
    .mentor-name-header {
        font-size: 1rem;
    }
    
    .toggle-label {
        font-size: 0.6rem;
    }
    
    .message {
        max-width: 90%;
    }
    
    .generate-dedication-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* ============================================
   动画效果
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 消息流式输出动画 */
.message-stream {
    animation: streamIn 0.5s ease-out;
}

@keyframes streamIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
