/* ============================================================
   H5 页面设计器 · 全局样式 v3.1
   设计语言：轻量卡片 · 柔和阴影 · 清晰层级
   ============================================================ */

/* ── Reset & Base ── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { overflow: hidden; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #F0F2F5;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── 主布局 ── */
.builder-container { display: flex; height: 100vh; width: 100%; overflow: hidden; }

/* ── 左侧面板 ── */
.left-panels { width: 340px; background: #FFF; border-right: 1px solid #E8ECF1; display: flex; flex-direction: column; }
.components-panel, .pages-panel, .recycle-panel { width: 100%; height: 100%; overflow-y: auto; padding: 20px 14px; display: none; scroll-behavior: smooth; }
.components-panel.active, .pages-panel.active { display: block; }

/* ── 面板标签 ── */
.panel-tabs { width: 48px; background: #FAFBFC; border-right: 1px solid #E8ECF1; display: flex; flex-direction: column; padding: 16px 0; gap: 4px; }
.panel-tab { display: flex; flex-direction: column; align-items: center; padding: 14px 0; cursor: pointer; color: #94A3B8; font-size: 11px; border-left: 3px solid transparent; transition: all 0.2s; }
.panel-tab i { font-size: 20px; margin-bottom: 4px; }
.panel-tab.active { color: #3B82F6; border-left-color: #3B82F6; background: linear-gradient(90deg, #EFF6FF 0%, transparent 100%); }
.panel-tab:hover:not(.active) { color: #64748B; }

/* ── 组件分组 ── */
.component-group { margin-bottom: 20px; }
.component-group-title { font-size: 12px; font-weight: 600; color: #94A3B8; margin-bottom: 10px; padding-left: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.component-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.component-item {
    background: #F8FAFC; border-radius: 10px; padding: 12px 6px 10px;
    text-align: center; cursor: pointer; border: 1px solid transparent;
    transition: all 0.2s; position: relative; overflow: hidden;
}
.component-item i { font-size: 22px; color: #3B82F6; margin-bottom: 5px; display: block; transition: all 0.2s; }
.component-item span { font-size: 11px; color: #475569; font-weight: 500; display: block; }
.component-item:hover { background: #3B82F6; border-color: #3B82F6; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(59,130,246,0.25); }
.component-item:hover i, .component-item:hover span { color: #FFF; }

/* ── 预览区域 ── */
.preview-panel { flex: 1; background: #E8ECF1; display: flex; flex-direction: column; overflow: hidden; height: 100vh; }
.preview-toolbar { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 20px; background: #FFF; border-bottom: 1px solid #E8ECF1; flex-shrink: 0; }

/* ── 按钮 ── */
.btn { padding: 7px 18px; border-radius: 8px; border: none; cursor: pointer; font-size: 13px; font-weight: 500; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px; }
.btn i { font-size: 13px; }
.btn-default { background: #F1F5F9; color: #334155; }
.btn-default:hover { background: #E2E8F0; }
.btn-primary { background: #3B82F6; color: #FFF; }
.btn-primary:hover { background: #2563EB; box-shadow: 0 2px 8px rgba(59,130,246,0.3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── 手机模拟器 ── */
.phone-wrapper { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 16px 20px 20px; overflow: hidden; }
.phone-mock {
    width: 375px; background: #FFF; border-radius: 36px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
    overflow: hidden; min-height: 700px; height: 760px;
    max-height: calc(100vh - 130px); position: relative;
    display: flex; flex-direction: column;
}
.phone-status-bar {
    display: flex; justify-content: space-between; padding: 10px 24px;
    background: #FFF; font-size: 13px; font-weight: 600; color: #1E293B;
    border-bottom: 1px solid #F1F5F9; flex-shrink: 0;
}
.phone-content { flex: 1; overflow-y: auto; min-height: 0; background: #F8FAFC; padding: 6px 0; }

/* ── 预览组件卡片 ── */
.preview-component {
    position: relative; margin: 6px 10px;
    background: #FFF; border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    border: 1.5px solid transparent; transition: all 0.2s;
}
.preview-component:hover { border-color: #93C5FD; box-shadow: 0 4px 16px rgba(59,130,246,0.08); }
.preview-component.selected { border-color: #3B82F6; box-shadow: 0 4px 18px rgba(59,130,246,0.12); }

/* ── 组件操作按钮 ── */
.component-actions { position: absolute; top: -10px; right: -10px; display: none; gap: 5px; z-index: 10; }
.preview-component:hover .component-actions,
.bottom-nav-fixed:hover .component-actions { display: flex; }
.component-action {
    width: 28px; height: 28px; background: #FFF; border-radius: 28px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1); cursor: pointer;
    color: #64748B; font-size: 12px; transition: all 0.15s;
}
.component-action:hover { background: #3B82F6; color: #FFF; transform: scale(1.1); }
.component-action[title="复制"]:hover { background: #10B981; }
.component-action[title="删除"]:hover { background: #EF4444; }

/* ── 右侧配置面板 ── */
.config-panel {
    width: 360px; background: #FFF; border-left: 1px solid #E8ECF1;
    overflow-y: auto; padding: 20px 16px; height: 100vh;
}
.config-section { background: #F8FAFC; border-radius: 12px; padding: 16px; margin-bottom: 14px; border: 1px solid #F1F5F9; }
.config-section-title {
    font-weight: 600; margin-bottom: 12px; color: #1E293B; font-size: 13px;
    display: flex; align-items: center; gap: 8px;
}
.config-section-title i { color: #3B82F6; font-size: 14px; width: 18px; text-align: center; }
.config-field { margin-bottom: 12px; }
.config-field:last-child { margin-bottom: 0; }
.config-field label { display: block; font-size: 11px; color: #94A3B8; margin-bottom: 5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; }
.config-field input, .config-field select, .config-field textarea {
    width: 100%; padding: 9px 12px; border: 1px solid #E2E8F0; border-radius: 8px;
    font-size: 13px; background: #FFF; color: #334155; transition: border-color 0.2s;
    font-family: inherit; outline: none;
}
.config-field input:focus, .config-field select:focus, .config-field textarea:focus {
    border-color: #3B82F6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.config-field input[type="color"] { padding: 4px 8px; height: 36px; cursor: pointer; }
.config-field input[type="checkbox"] { width: auto; margin-right: 6px; cursor: pointer; }
.config-row { display: flex; gap: 10px; }
.config-row .config-field { flex: 1; }

/* ── 空状态 ── */
.empty-preview { text-align: center; padding: 80px 20px; color: #CBD5E1; font-size: 13px; }
.empty-preview i { font-size: 36px; display: block; margin-bottom: 12px; }

/* ── 轮播图 ── */
.swiper-container { border-radius: 14px; overflow: hidden; }
.swiper-container img { width: 100%; height: 100%; object-fit: cover; }

/* ── 图标网格 ── */
.grid-icons { display: grid; text-align: center; }
.grid-icon-item i { margin-bottom: 4px; display: block; }

/* ── 配置项子卡片 ── */
.nav-item-config {
    border: 1px solid #E8ECF1; border-radius: 10px; padding: 12px;
    margin-bottom: 8px; background: #FFF;
}
.nav-item-config .config-field { margin-bottom: 8px; }
.nav-item-config .config-field:last-child { margin-bottom: 0; }

/* ── 模态框 ── */
.modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15,23,42,0.5); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.modal.show { display: flex; }
.modal-dialog { max-width: 420px; width: 95%; background: #FFF; border-radius: 16px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid #F1F5F9; display: flex; justify-content: space-between; align-items: center; }
.modal-header h6 { font-size: 15px; font-weight: 600; color: #1E293B; display: flex; align-items: center; gap: 8px; }
.modal-body { padding: 20px; text-align: left; }
.close { background: none; border: none; font-size: 20px; cursor: pointer; color: #94A3B8; padding: 0 4px; }
.close:hover { color: #EF4444; }

/* ── 二维码容器 ── */
.modal-body #qrcodeContainer { display: flex; justify-content: center; align-items: center; margin-bottom: 12px; }
.modal-body #qrcodeContainer img { border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.modal-body .url-text { font-size: 12px; color: #64748B; margin: 10px 0; padding: 10px; background: #F8FAFC; border-radius: 8px; word-break: break-all; text-align: center; }
.modal-body .hint { font-size: 12px; color: #94A3B8; margin-top: 10px; text-align: center; }

/* ── 页面管理 ── */
.pages-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid #3B82F6; font-weight: 600; font-size: 14px; color: #1E293B; }
.btn-icon { background: none; border: none; color: #3B82F6; font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.btn-icon:hover { background: #EFF6FF; }
.page-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; background: #F8FAFC; border-radius: 10px;
    margin-bottom: 6px; cursor: pointer; border: 1px solid transparent; transition: all 0.15s;
}
.page-item:hover { background: #EFF6FF; border-color: #BFDBFE; }
.page-item.active { background: #3B82F6; color: #FFF; }
.page-info { flex: 1; }
.page-name { font-weight: 500; font-size: 13px; }
.page-id { font-size: 11px; opacity: 0.6; margin-top: 2px; }
.page-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.15s; }
.page-item:hover .page-actions { opacity: 1; }
.page-actions i { cursor: pointer; color: #94A3B8; font-size: 14px; padding: 4px; border-radius: 4px; }
.page-actions i:hover { color: #3B82F6; background: rgba(59,130,246,0.1); }
.page-item.active .page-actions i { color: rgba(255,255,255,0.7); }

/* ── 底部导航 ── */
.bottom-nav-fixed {
    position: absolute; bottom: 0; left: 0; right: 0;
    display: flex; justify-content: space-around; align-items: center;
    z-index: 10; cursor: pointer; transition: outline 0.2s;
    background: #FFF; border-top: 1px solid #E8ECF1;
}
.bottom-nav-item { text-align: center; font-size: 11px; color: #94A3B8; flex: 1; padding: 6px 0; transition: color 0.15s; }
.bottom-nav-item.active { color: #3B82F6; }
.bottom-nav-item i { display: block; margin-bottom: 2px; }
.bottom-nav-item img { display: block; margin: 0 auto 2px; }

/* ── 图标选择器 ── */
.icon-picker-btn { background: #F1F5F9; border: none; border-radius: 8px; padding: 4px 10px; cursor: pointer; color: #64748B; font-size: 13px; flex-shrink: 0; transition: all 0.15s; }
.icon-picker-btn:hover { background: #3B82F6; color: #FFF; }
.icon-picker-modal .modal-dialog { max-width: 480px; }
.icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; max-height: 380px; overflow-y: auto; padding: 4px; }
.icon-item { font-size: 24px; text-align: center; padding: 8px 4px; cursor: pointer; border-radius: 8px; background: #F8FAFC; transition: all 0.15s; }
.icon-item:hover { background: #3B82F6; color: #FFF; transform: scale(1.05); }
.icon-upload-area { margin-top: 12px; padding-top: 12px; border-top: 1px solid #E8ECF1; }

/* ── 倒计时 ── */
.cd-block { background: rgba(255,255,255,0.2); border-radius: 8px; padding: 8px 6px; min-width: 48px; text-align: center; }
.cd-num { font-size: 22px; font-weight: 700; letter-spacing: 2px; }
.cd-label { font-size: 10px; opacity: 0.8; margin-top: 2px; }

/* ── 选项卡 ── */
.tab-bar { display: flex; border-bottom: 1px solid #E8ECF1; background: #F8FAFC; border-radius: 8px 8px 0 0; overflow: hidden; }
.tab-item { flex: 1; text-align: center; padding: 8px 4px; cursor: pointer; font-size: 13px; border-bottom: 2px solid transparent; transition: all 0.2s; }
.tab-item.active { font-weight: 600; border-bottom-color: #3B82F6; color: #3B82F6; }

/* ── 滑条美化 ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ── 响应式 ── */
@media (max-width: 1200px) {
    .config-panel { width: 300px; }
    .left-panels { width: 300px; }
}
@media (max-width: 900px) {
    .config-panel { width: 260px; }
    .left-panels { width: 260px; }
}

/* 回收站面板 */
.recycle-panel { padding: 0; }
.recycle-list { max-height: calc(100vh - 200px); overflow-y: auto; }
.recycle-list::-webkit-scrollbar { width: 4px; }
.recycle-list::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 2px; }
