/* ============================================
   灵动图文 · CSS v2.0
   设计哲学：对话驱动 + 画布实时预览
   主题：清新光感（独立主题，不改全局导航栏）
   Phase 5: 布局修复 + 清新色彩
   ============================================ */

/* ----- CSS 变量：清新光感 ----- */
:root {
    /* 品牌色 — 柔和紫蓝 */
    --ld-primary: #7C5CFC;
    --ld-primary-hover: #6B4FE8;
    --ld-primary-light: #F0EBFF;
    --ld-primary-border: #D4C8FF;
    --ld-primary-glow: rgba(124, 92, 252, 0.12);

    /* 辅助色 */
    --ld-accent-green: #34D399;
    --ld-accent-green-light: #ECFDF5;
    --ld-accent-amber: #FBBF24;
    --ld-accent-pink: #F472B6;
    --ld-accent-pink-light: #FDF2F8;

    /* 背景 — 带极淡紫的白 */
    --ld-bg: #F8F6FF;
    --ld-bg-panel: #FFFFFF;
    --ld-bg-canvas: #F2EFF9;
    --ld-bg-hover: #F5F3FF;

    /* 文字 — 深紫黑 */
    --ld-text-primary: #1E1533;
    --ld-text-body: #5B5275;
    --ld-text-muted: #9B95A8;
    --ld-text-placeholder: #B8B3C4;

    /* 边框 — 紫灰 */
    --ld-border: #E8E4F0;
    --ld-border-light: #F0EDF7;

    /* 阴影 */
    --ld-shadow-panel: 0 1px 3px rgba(124, 92, 252, 0.06);
    --ld-shadow-card: 0 2px 8px rgba(124, 92, 252, 0.08);
    --ld-shadow-glow: 0 0 20px rgba(124, 92, 252, 0.15);

    /* 圆角 */
    --ld-radius: 8px;
    --ld-radius-lg: 12px;
    --ld-radius-sm: 6px;

    /* 间距 */
    --ld-gap: 16px;
    --ld-gap-sm: 8px;
}

/* ----- 主题隔离 ----- */
html.ld-light-shell .main-content {
    padding: 0;
    margin: 0;
}

/* ----- 全局布局：Phase 5 修复 calc(100vh - 56px) ----- */
#lingdong-app {
    display: grid;
    grid-template-rows: 52px 1fr auto;
    grid-template-columns: minmax(300px, 340px) 1fr minmax(200px, 240px);
    grid-template-areas:
        "header  header  header"
        "chat    canvas  slides"
        "footer  footer  footer";
    height: calc(100vh - 56px);  /* 减去全局导航栏高度 */
    background: var(--ld-bg);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ----- 顶栏 ----- */
.ld-header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--ld-bg-panel);
    border-bottom: 1px solid var(--ld-border);
    z-index: 10;
}

.ld-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ld-logo-icon {
    font-size: 20px;
    color: var(--ld-primary);
}

.ld-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ld-text-primary);
    margin: 0;
}

.ld-header-center {
    display: flex;
    align-items: center;
}

.ld-slide-count {
    font-size: 13px;
    color: var(--ld-text-body);
    background: var(--ld-primary-light);
    padding: 4px 12px;
    border-radius: 99px;
    border: 1px solid var(--ld-primary-border);
}

.ld-header-right {
    display: flex;
    align-items: center;
}

/* ----- 按钮通用 ----- */
.ld-btn {
    border: none;
    border-radius: var(--ld-radius-sm);
    padding: 8px 18px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.ld-btn-primary {
    background: var(--ld-primary);
    color: #fff;
}

.ld-btn-primary:hover:not(:disabled) {
    background: var(--ld-primary-hover);
    box-shadow: var(--ld-shadow-glow);
}

.ld-btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ----- 对话面板 ----- */
.ld-chat-panel {
    grid-area: chat;
    display: flex;
    flex-direction: column;
    background: var(--ld-bg-panel);
    border-right: 1px solid var(--ld-border);
    overflow: hidden;
}

.ld-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ld-border-light);
    flex-shrink: 0;
}

.ld-chat-head-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ld-text-primary);
}

.ld-chat-clear-btn {
    background: none;
    border: none;
    font-size: 12px;
    color: var(--ld-text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--ld-radius-sm);
}

.ld-chat-clear-btn:hover {
    background: var(--ld-bg-hover);
    color: var(--ld-text-body);
}

.ld-chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 空状态 */
.ld-chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--ld-text-muted);
    text-align: center;
    gap: 8px;
}

.ld-chat-empty-icon {
    font-size: 32px;
    opacity: 0.5;
}

.ld-chat-empty p {
    font-size: 13px;
    margin: 0;
    max-width: 200px;
    line-height: 1.5;
}

/* 对话气泡 */
.ld-bubble {
    max-width: 90%;
    padding: 10px 14px;
    border-radius: var(--ld-radius);
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
}

.ld-bubble--user {
    align-self: flex-end;
    background: var(--ld-primary-light);
    color: var(--ld-text-primary);
    border: 1px solid var(--ld-primary-border);
}

.ld-bubble--ai {
    align-self: flex-start;
    background: var(--ld-bg-panel);
    color: var(--ld-text-body);
    border: 1px solid var(--ld-border);
}

/* 注入画布按钮 */
.ld-inject-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 6px 0;
    background: var(--ld-primary-light);
    border: 1px dashed var(--ld-primary);
    border-radius: var(--ld-radius-sm);
    font-size: 12px;
    color: var(--ld-primary);
    cursor: pointer;
    transition: background 0.15s;
}

.ld-inject-btn:hover {
    background: var(--ld-primary);
    color: #fff;
}

/* 打字指示器 */
.ld-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
}

.ld-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ld-text-muted);
    animation: ld-typing-bounce 1.2s infinite;
}

.ld-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ld-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ld-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ----- 画布 ----- */
.ld-canvas {
    grid-area: canvas;
    background: var(--ld-bg-canvas);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.ld-canvas-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

/* 空状态 */
.ld-canvas-empty {
    text-align: center;
    color: var(--ld-text-muted);
    user-select: none;
}

.ld-canvas-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
    color: var(--ld-primary);
}

.ld-canvas-empty h2 {
    font-size: 22px;
    color: var(--ld-text-primary);
    margin: 0 0 6px 0;
    font-weight: 600;
}

.ld-canvas-empty p {
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 20px 0;
    color: var(--ld-text-body);
}

.ld-canvas-examples {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ld-example-chip {
    background: var(--ld-bg-panel);
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius);
    padding: 10px 16px;
    font-size: 13px;
    color: var(--ld-text-body);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ld-example-chip:hover {
    border-color: var(--ld-primary);
    background: var(--ld-primary-light);
    box-shadow: var(--ld-shadow-panel);
    transform: translateY(-1px);
}

.ld-example-chip:active {
    transform: translateY(0);
}

/* 预览 iframe */
.ld-preview-frame {
    width: 960px;
    height: 540px;
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius);
    background: #fff;
    box-shadow: 0 4px 24px rgba(124, 92, 252, 0.1);
    transform-origin: center center;
}

/* 翻页控制 */
.ld-nav-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.ld-nav-btn {
    background: var(--ld-bg-panel);
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius-sm);
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    color: var(--ld-text-body);
    transition: border-color 0.15s, background 0.15s;
}

.ld-nav-btn:hover:not(:disabled) {
    border-color: var(--ld-primary);
    background: var(--ld-primary-light);
}

.ld-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.ld-nav-indicator {
    font-size: 13px;
    color: var(--ld-text-body);
    min-width: 40px;
    text-align: center;
}

/* ----- 幻灯片面板 ----- */
.ld-slides-panel {
    grid-area: slides;
    display: flex;
    flex-direction: column;
    background: var(--ld-bg-panel);
    border-left: 1px solid var(--ld-border);
    overflow: hidden;
}

.ld-slides-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ld-border-light);
    font-size: 14px;
    font-weight: 600;
    color: var(--ld-text-primary);
    flex-shrink: 0;
}

.ld-slides-add-btn {
    background: none;
    border: 1px solid var(--ld-primary);
    border-radius: var(--ld-radius-sm);
    padding: 3px 10px;
    font-size: 12px;
    color: var(--ld-primary);
    cursor: pointer;
}

.ld-slides-add-btn:hover:not(:disabled) {
    background: var(--ld-primary);
    color: #fff;
}

.ld-slides-add-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ld-slides-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.ld-slides-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--ld-text-muted);
    text-align: center;
}

.ld-slides-empty p {
    margin: 0;
    font-size: 13px;
}

.ld-slides-empty-hint {
    font-size: 12px !important;
    margin-top: 4px !important;
    opacity: 0.7;
}

/* 幻灯片缩略图卡片 */
.ld-slide-card {
    background: var(--ld-bg);
    border: 2px solid var(--ld-border-light);
    border-radius: var(--ld-radius);
    padding: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ld-slide-card:hover {
    border-color: var(--ld-primary-border);
    box-shadow: var(--ld-shadow-panel);
}

.ld-slide-card.ld-active {
    border-color: var(--ld-primary);
    box-shadow: var(--ld-shadow-glow);
}

.ld-slide-card-num {
    font-size: 11px;
    color: var(--ld-text-muted);
    margin-bottom: 4px;
}

.ld-slide-card-preview {
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--ld-bg-canvas);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--ld-text-muted);
    margin-bottom: 6px;
    overflow: hidden;
}

.ld-slide-card-preview iframe {
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: none;
    transform: scale(0.4);
    transform-origin: top left;
}

.ld-slide-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ld-slide-card-title {
    font-size: 12px;
    color: var(--ld-text-body);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ld-slide-card-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    margin-left: 4px;
}

.ld-slide-card-regen {
    background: none;
    border: none;
    font-size: 13px;
    color: var(--ld-text-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

.ld-slide-card-regen:hover {
    background: var(--ld-primary-light);
    color: var(--ld-primary);
}

.ld-slide-card-del {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--ld-text-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1;
}

.ld-slide-card-del:hover {
    background: var(--ld-accent-pink-light);
    color: var(--ld-accent-pink);
}

/* ----- 底栏：Phase 5 修复 auto 高度 ----- */
.ld-footer {
    grid-area: footer;
    background: var(--ld-bg-panel);
    border-top: 1px solid var(--ld-border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    z-index: 10;
}

.ld-footer-inner {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ld-quick-chips {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.ld-chip {
    background: var(--ld-border-light);
    border: 1px solid var(--ld-border);
    border-radius: 99px;
    padding: 4px 12px;
    font-size: 12px;
    color: var(--ld-text-body);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s, background 0.15s;
}

.ld-chip:hover {
    border-color: var(--ld-primary);
    background: var(--ld-primary-light);
}

.ld-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--ld-bg);
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius);
    padding: 6px 8px 6px 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ld-input-wrap:focus-within {
    border-color: var(--ld-primary);
    box-shadow: 0 0 0 3px var(--ld-primary-glow);
}

.ld-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--ld-text-primary);
    resize: none;
    outline: none;
    line-height: 1.5;
    font-family: inherit;
    max-height: 88px;
}

.ld-input::placeholder {
    color: var(--ld-text-placeholder);
}

.ld-send-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ld-primary);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, box-shadow 0.15s;
}

.ld-send-btn:hover:not(:disabled) {
    background: var(--ld-primary-hover);
    box-shadow: var(--ld-shadow-glow);
}

.ld-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ----- 响应式 ----- */
@media (max-width: 1279px) {
    #lingdong-app {
        grid-template-columns: 340px 1fr;
        grid-template-areas:
            "header  header"
            "chat    canvas"
            "footer  footer";
    }
    .ld-slides-panel {
        display: none;
    }
}

@media (max-width: 1023px) {
    #lingdong-app {
        grid-template-columns: 1fr;
        grid-template-rows: 52px 1fr auto;
        grid-template-areas:
            "header"
            "canvas"
            "footer";
    }
    .ld-chat-panel {
        display: none;
    }
    .ld-quick-chips {
        display: none;
    }
}
