/* ==============================================================
   落地页 AI 编辑器 v2 - 样式
   三栏布局: 左组件库(220px) + 中画布(自适应) + 右属性面板(320px)
   顶部AI栏 + 编辑器工具栏
   ============================================================== */

/* 编辑器全屏容器 */
.le-editor {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #f5f6f8;
    display: flex;
    flex-direction: column;
    z-index: 999;
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ============ 顶部工具栏 ============ */
.le-topbar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e6e8eb;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.le-topbar-left { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.le-topbar-mid { flex: 1; display: flex; justify-content: center; gap: 8px; }
.le-topbar-right { display: flex; gap: 8px; align-items: center; }

.le-brand {
    font-size: 16px; font-weight: 600; color: #1a1d21;
    display: flex; align-items: center; gap: 6px;
}
.le-brand-icon { font-size: 18px; }

.le-title-input {
    padding: 6px 10px;
    border: 1px solid transparent;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: #1a1d21;
    border-radius: 4px;
    width: 220px;
}
.le-title-input:hover { border-color: #dfe1e5; background: #fafafa; }
.le-title-input:focus { border-color: #3b82f6; background: #fff; outline: none; }

.le-btn {
    padding: 7px 14px;
    border: 1px solid #dfe1e5;
    background: #fff;
    color: #1a1d21;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.le-btn:hover { background: #f5f6f8; border-color: #c8ccd1; }
.le-btn-primary { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.le-btn-primary:hover { background: #2563eb; }
.le-btn-success { background: #10b981; color: #fff; border-color: #10b981; }
.le-btn-success:hover { background: #059669; }
.le-btn-ghost { border: none; padding: 6px 10px; color: #6b7280; }
.le-btn-ghost:hover { background: #f5f6f8; }
.le-btn-danger { color: #dc2626; }
.le-btn-danger:hover { background: #fee2e2; }

/* ============ AI 栏 ============ */
.le-ai-bar {
    background: linear-gradient(135deg, #eef2ff 0%, #fdf4ff 100%);
    border-bottom: 1px solid #e6e8eb;
    padding: 10px 16px;
    display: flex;
    gap: 8px;
    align-items: center;
}
.le-ai-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 16px;
    flex-shrink: 0;
}
.le-ai-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}
.le-ai-input:focus { border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,0.1); }

.le-ai-mode {
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.le-ai-status {
    font-size: 12px; color: #6b7280;
    padding: 2px 8px; background: rgba(255,255,255,0.6); border-radius: 4px;
}
.le-ai-status.is-ready { color: #059669; }
.le-ai-status.is-nokey { color: #dc2626; }

/* ============ 三栏主区 ============ */
.le-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ---- 左侧组件面板 ---- */
.le-sidebar-left {
    width: 220px;
    background: #fff;
    border-right: 1px solid #e6e8eb;
    overflow-y: auto;
    flex-shrink: 0;
}
.le-comp-section {
    border-bottom: 1px solid #f1f2f4;
    padding: 12px 12px 8px;
}
.le-comp-title {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-left: 4px;
}
.le-comp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.le-comp-item {
    padding: 10px 6px;
    border: 1px solid #f0f2f4;
    background: #fafbfc;
    border-radius: 6px;
    cursor: grab;
    text-align: center;
    font-size: 12px;
    color: #374151;
    transition: all 0.15s;
    user-select: none;
}
.le-comp-item:hover {
    border-color: #3b82f6;
    background: #eff6ff;
    color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(59,130,246,0.15);
}
.le-comp-item:active { cursor: grabbing; }
.le-comp-icon { font-size: 18px; display: block; margin-bottom: 2px; }

/* ---- 中间画布 ---- */
.le-canvas-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f5f6f8;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}
.le-canvas {
    width: 375px;    /* iPhone 手机尺寸 */
    min-height: 667px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
    overflow: hidden;
    position: relative;
}
.le-canvas-empty {
    padding: 60px 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}
.le-canvas-empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.le-canvas-empty-hint { margin-top: 8px; color: #6b7280; font-size: 12px; }

/* 单个 block 渲染容器 */
.le-block {
    position: relative;
    transition: box-shadow 0.15s;
    cursor: pointer;
}
.le-block.is-selected {
    box-shadow: inset 0 0 0 2px #3b82f6;
}
.le-block:hover:not(.is-selected) {
    box-shadow: inset 0 0 0 1px #d1d5db;
}

/* block 工具条(悬浮时显示) */
.le-block-toolbar {
    position: absolute;
    top: -32px;
    right: 8px;
    background: #1a1d21;
    color: #fff;
    padding: 4px;
    border-radius: 6px;
    display: none;
    gap: 2px;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.le-block.is-selected .le-block-toolbar { display: flex; }
.le-block-toolbar button {
    background: transparent;
    border: none;
    color: #fff;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
}
.le-block-toolbar button:hover { background: rgba(255,255,255,0.15); }
.le-block-toolbar button.danger:hover { background: #dc2626; }

/* SortableJS 拖拽时占位符 */
.le-block-ghost { opacity: 0.4; }
.le-block-chosen { box-shadow: 0 4px 12px rgba(59,130,246,0.25) !important; }
.le-drop-hint {
    height: 3px;
    background: #3b82f6;
    border-radius: 2px;
    margin: 4px 8px;
    display: none;
}

/* ---- 右侧属性面板 ---- */
.le-sidebar-right {
    width: 320px;
    background: #fff;
    border-left: 1px solid #e6e8eb;
    overflow-y: auto;
    flex-shrink: 0;
}
.le-props-empty {
    padding: 60px 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}
.le-props-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e6e8eb;
    background: #f9fafb;
    font-size: 13px;
    font-weight: 600;
    color: #1a1d21;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.le-props-header .type-badge {
    font-size: 11px;
    padding: 2px 6px;
    background: #e0e7ff;
    color: #4338ca;
    border-radius: 4px;
    font-weight: 500;
}
.le-props-body { padding: 12px; }
.le-props-field {
    margin-bottom: 12px;
}
.le-props-label {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
    display: block;
}
.le-props-input, .le-props-select, .le-props-textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 13px;
    outline: none;
    background: #fff;
    box-sizing: border-box;
}
.le-props-input:focus, .le-props-select:focus, .le-props-textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.le-props-textarea { resize: vertical; min-height: 60px; }

.le-props-color {
    width: 40px;
    height: 30px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    cursor: pointer;
    padding: 2px;
}
.le-props-inline {
    display: flex;
    gap: 6px;
    align-items: center;
}

.le-props-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
}

.le-props-ai-btn {
    width: 100%;
    padding: 8px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    margin-top: 8px;
    transition: opacity 0.15s;
}
.le-props-ai-btn:hover { opacity: 0.9; }
.le-props-ai-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ H5 渲染 - block 样式(编辑器 & 前台复用) ============ */
.h5-block-title {
    padding: 16px;
    text-align: center;
}
.h5-block-paragraph {
    padding: 8px 16px;
    line-height: 1.7;
    color: #374151;
    font-size: 14px;
}
.h5-block-image { padding: 0; }
.h5-block-image img { width: 100%; display: block; }
.h5-block-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 12px 16px;
}
.h5-block-video, .h5-block-avatar_video {
    padding: 0;
    background: #000;
    position: relative;
}
.h5-block-video video, .h5-block-avatar_video video {
    width: 100%;
    display: block;
}
.h5-block-form_input, .h5-block-form_textarea, .h5-block-form_radio,
.h5-block-form_checkbox, .h5-block-form_date {
    padding: 8px 16px;
}
.h5-block-form_input label, .h5-block-form_textarea label,
.h5-block-form_radio label, .h5-block-form_checkbox label,
.h5-block-form_date label {
    display: block;
    font-size: 13px;
    color: #374151;
    margin-bottom: 4px;
    font-weight: 500;
}
.h5-block-form_input input, .h5-block-form_textarea textarea,
.h5-block-form_date input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
}
.h5-block-form_radio .opts, .h5-block-form_checkbox .opts {
    display: flex; flex-direction: column; gap: 6px;
}
.h5-block-form_radio .opt, .h5-block-form_checkbox .opt {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.h5-block-button {
    padding: 12px 16px;
}
.h5-block-button button {
    width: 100%;
    padding: 14px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.h5-block-spacer { background: transparent; }
.h5-block-countdown {
    padding: 12px 16px;
    text-align: center;
    background: #fef3c7;
    color: #92400e;
    font-weight: 600;
}
.h5-block-quote_configurator {
    padding: 12px 16px;
    background: #f9fafb;
}
.h5-quote-title {
    font-size: 15px; font-weight: 600; margin-bottom: 8px; color: #1a1d21;
}
.h5-quote-list { display: flex; flex-direction: column; gap: 8px; }
.h5-quote-item {
    display: flex;
    gap: 8px;
    padding: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    align-items: center;
}
.h5-quote-item .img {
    width: 56px; height: 56px;
    background: #f3f4f6;
    border-radius: 6px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #9ca3af; font-size: 20px;
    overflow: hidden;
}
.h5-quote-item .img img { width: 100%; height: 100%; object-fit: cover; }
.h5-quote-item .info { flex: 1; min-width: 0; }
.h5-quote-item .name { font-size: 13px; color: #1a1d21; font-weight: 500; }
.h5-quote-item .desc { font-size: 11px; color: #6b7280; margin-top: 2px; }
.h5-quote-item .price { font-size: 13px; color: #dc2626; font-weight: 600; margin-top: 2px; }
.h5-quote-item .add {
    padding: 4px 10px; background: #3b82f6; color: #fff;
    border: none; border-radius: 999px; font-size: 12px; cursor: pointer;
}
.h5-quote-item .add.selected { background: #10b981; }
.h5-quote-total {
    margin-top: 12px;
    padding: 10px 12px;
    background: #fef2f2;
    border-radius: 8px;
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 600; color: #dc2626;
}

/* ============ 加载/遮罩 ============ */
.le-loading-mask {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.le-loading-mask.is-show { display: flex; }
.le-loading-box {
    background: #fff;
    padding: 24px 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.le-loading-spin {
    width: 40px; height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: le-spin 0.8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes le-spin { to { transform: rotate(360deg); } }
