/* ============================================
   预览模式专属样式 (Preview Mode)
   ============================================ */

/* 1. 半透明遮罩层 (极淡黑) */
.preview-overlay {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.15) !important;
    z-index: 10000 !important;
    cursor: pointer;
}

/* 2. 退出按钮 & 打字机开关 (右上角) */
.preview-controls {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 10050;
    display: flex;
    align-items: center;
    gap: 12px;
}

.preview-exit-btn {
    background: var(--bg-panel);
    color: var(--text-main);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}
.preview-exit-btn:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.typewriter-toggle {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-sub);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}
.toggle-switch {
    width: 32px;
    height: 18px;
    background: var(--border-deep);
    border-radius: 9px;
    position: relative;
    transition: background 0.3s;
}
.toggle-switch.on { background: var(--primary); }
.toggle-switch .toggle-knob {
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle-switch.on .toggle-knob { transform: translateX(14px); }

/* 3. 日志面板 (卡片流布局) */
.log-panel {
    position: fixed;
    width: 320px;
    height: 50vh;
    z-index: 10010;
    pointer-events: none;
}

.log-combined-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    height: 100%;
    pointer-events: auto;
    overflow: hidden;
}

.log-header-status {
    padding: 12px 16px;
    background: var(--bg-body);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: grab;
    user-select: none;
}
.log-header-status:active {
    cursor: grabbing;
}

.status-path {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.condition-row {
    display: flex;
    gap: 16px;
}
.condition-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-sub);
    font-weight: 600;
}
.condition-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.condition-dot.green { background: #22c55e; }
.condition-dot.red { background: var(--danger); }
.timer-remaining {
    font-family: monospace;
    color: var(--danger);
    font-size: 11px;
    margin-left: 2px;
}

/* 日志流容器 */
.log-stream-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
}

/* 单条日志卡片 */
.log-entry-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-sub);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: logSlideIn 0.3s ease;
    pointer-events: auto;
}

.log-entry-card.t-green { border-left: 3px solid #22c55e; }
.log-entry-card.t-blue { border-left: 3px solid #3b82f6; }
.log-entry-card.t-purple { border-left: 3px solid #a855f7; }
.log-entry-card.t-gray { border-left: 3px solid #64748b; }
.log-entry-card.t-orange { border-left: 3px solid #f97316; }

.log-entry-header { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text-main); }
.log-entry-detail { font-size: 11px; padding-left: 20px; line-height: 1.4; color: var(--text-sub); }

/* 4. 对话框 (底部便当盒) */
.dialogue-box {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    max-width: 800px;
    min-width: 500px;
    z-index: 10010;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-box);
    padding: 24px 32px;
    box-shadow: var(--shadow-md);
    text-align: center;
    transition: all 0.3s ease;
}

.dialogue-box.signal-flash {
    animation: borderFlash 0.4s ease;
}

.dialogue-speaker {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2px;
}

.dialogue-title-divider {
    font-size: 13px;
    color: #bca068;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}
.dialogue-title-divider::before,
.dialogue-title-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-deep);
}

.dialogue-text {
    font-size: 16px;
    color: var(--text-sub);
    line-height: 1.6;
    min-height: 52px;
    font-weight: 500;
}

.cursor-blink {
    display: inline-block;
    color: var(--primary);
    animation: blink 530ms step-end infinite;
    margin-left: 2px;
}

.advance-indicator {
    margin-top: 12px;
    color: var(--primary);
    font-size: 14px;
    animation: bounceArrow 1.5s ease-in-out infinite;
}

/* 5. 选项卡 & 检定按钮 (右侧) */
.choices-panel {
    position: fixed;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10010;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: flex-end;
}
.check-title {
    font-size: 13px;
    font-weight: 600;
    color: #a855f7;
    background: var(--bg-panel);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid #a855f7;
    margin-bottom: 8px;
    box-shadow: 0 0 10px rgba(168,85,247,0.2);
}
.choice-btn {
    background: var(--bg-panel);
    border: 1px solid var(--border-deep);
    padding: 12px 32px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.choice-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(99,102,241,0.3);
}
.choice-btn:active {
    transform: scale(0.95);
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

/* 6. 蓝图预览联动特效 (Phase 5) */
.preview-active-node {
    border: 2px solid var(--primary) !important;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4) !important;
    z-index: 10 !important;
}
.preview-active-dialogue {
    animation: breatheLight 2s infinite ease-in-out;
    background: rgba(99, 102, 241, 0.1);
    border-left: 2px solid var(--primary);
}

@keyframes breatheLight {
    0%, 100% { box-shadow: 0 0 5px rgba(99,102,241,0.2) inset; }
    50% { box-shadow: 0 0 15px rgba(99,102,241,0.5) inset; }
}

.preview-edge-flash {
    stroke: var(--primary) !important;
    stroke-width: 4 !important;
    stroke-dasharray: 10 10;
    animation: flowEdge 0.8s linear forwards;
}

@keyframes flowEdge {
    from { stroke-dashoffset: 100; opacity: 1; }
    to { stroke-dashoffset: 0; opacity: 0.6; }
}

.signal-flash {
    animation: flashBorder 0.4s ease-out;
}

@keyframes flashBorder {
    0% { border-color: rgba(255, 255, 255, 0.8); box-shadow: 0 0 20px rgba(255, 255, 255, 0.6); }
    100% { border-color: var(--border-light); box-shadow: 0 4px 20px rgba(0,0,0,0.3); }
}

.finished-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(30, 30, 35, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    z-index: 1005;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.finish-title {
    font-size: 20px;
    font-weight: 600;
    color: white;
}
.finish-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.choices-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

.choices-group-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-sub);
    margin-bottom: 4px;
    background: var(--bg-hover);
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
}

.choice-btn {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    min-width: 180px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: breatheGlow 2.5s ease-in-out infinite, slideInRight 0.3s ease backwards;
}

.choice-btn:hover {
    background: var(--bg-focus);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateX(-4px);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.15);
}
.choice-btn:active { transform: scale(0.97); }

.choice-icon { color: var(--border-deep); }
.choice-btn:hover .choice-icon { color: var(--primary); }

/* 动画关键帧 */
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes bounceArrow { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(4px); } }
@keyframes breatheGlow { 0%, 100% { box-shadow: var(--shadow-sm); } 50% { box-shadow: 0 4px 16px rgba(79,70,229,0.15); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes logSlideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes borderFlash {
    0% { border-color: var(--border-light); box-shadow: var(--shadow-md); }
    50% { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2); }
    100% { border-color: var(--border-light); box-shadow: var(--shadow-md); }
}
