/* ============================================================
   layout-v39.css — 编辑狗写作工具台 v39 布局样式
   加载顺序: style.css → layout-v39.css
   说明: 两栏布局（中间内容区 + 右侧预览区），顶部横版功能菜单
   ============================================================ */

/* ========== 主区域包裹 ========== */
.main-shell {
  display: flex;
  flex-direction: row;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ========== 中间内容区 ========== */
.content-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  width: 50%;
  position: relative;
  background: #fff;
}

/* ========== 横版功能菜单（顶部，与预览header对齐） ========== */
.panel-nav-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 12px;
  height: 48px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
}
.panel-nav-bar::-webkit-scrollbar { height: 0; }

.panel-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 13px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s ease;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.4;
  position: relative;
}
.panel-nav-item:hover {
  color: #28b894;
  font-weight: 680;
}
.panel-nav-item:hover::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: #28b894;
  border-radius: 1px;
}
.panel-nav-item.active {
  background: #f0fdf4;
  color: #059669;
  font-weight: 600;
}
.panel-nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ========== 视图容器 ========== */
.panel-views {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.panel-view {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  overflow: hidden;
}
.panel-view.active {
  display: block;
}

/* iframe 视图 */
.panel-view iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ========== 编辑器视图 ========== */
#view-editor {
  display: none;
  flex-direction: column;
}
#view-editor.active {
  display: flex;
}
#view-editor .editor {
  flex: 1;
  width: 100%;
  border: none;
  resize: none;
  outline: none;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
  font-size: 14px;
  line-height: 1.8;
  padding: 16px;
  overflow-y: auto;
}

/* ========== 快捷面板视图 ========== */
#view-quick {
  display: none;
  overflow-y: auto;
}
#view-quick.active {
  display: block;
}
#view-quick .quick-panel {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #f8fafc;
}
.quick-panel-header {
  text-align: center;
  margin-bottom: 24px;
}
.quick-panel-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 6px;
}
.quick-panel-header p {
  font-size: 13px;
  color: #6b7280;
  margin: 0;
}
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 720px;
  width: 100%;
}
.quick-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: #374151;
}
.quick-card:hover {
  border-color: #059669;
  box-shadow: 0 2px 12px rgba(5, 150, 105, 0.12);
  transform: translateY(-1px);
}
.quick-card svg {
  width: 28px;
  height: 28px;
  color: #059669;
  margin-bottom: 6px;
}
.quick-card .quick-card-label {
  font-size: 12px;
  font-weight: 500;
}
.quick-card .quick-card-desc {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 2px;
}

/* ========== 右侧预览面板 ========== */
.preview-panel-v39 {
  flex: 1;
  width: 50%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  border-left: 1px solid #e5e7eb;
  position: relative;
}
.preview-panel-v39 .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
  gap: 8px;
  flex-wrap: wrap;
}
.preview-panel-v39 .panel-title {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}
.preview-panel-v39 .panel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.preview-panel-v39 .preview-scroll {
  flex: 1;
  overflow-y: auto;
  background: #eef0f2;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
}
.preview-panel-v39 .preview-content {
  max-width: 960px;
  margin: 0 auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  min-height: 200px;
  padding: 1px 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.preview-panel-v39 .preview-content .empty-state {
  padding: 60px 20px;
  text-align: center;
  color: #9ca3af;
}
.preview-panel-v39 .preview-content .empty-state .empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}
.preview-panel-v39 .preview-content .empty-state p {
  margin: 0;
  font-size: 14px;
}
.preview-panel-v39 .preview-content .empty-sub {
  font-size: 12px;
  color: #b0b7c3;
  margin-top: 6px;
}
.preview-scroll.mobile-mode .preview-content {
  max-width: 375px;
}

/* ========== 底部操作栏 v39 ========== */
.action-bar-v39 {
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
}
.action-bar-v39 .action-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.action-bar-v39 .action-center {
  display: flex;
  align-items: center;
  gap: 6px;
}
.action-bar-v39 .action-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 粘贴按钮（移到预览区 header） */
.btn-paste-sm {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  border: 1px solid #059669;
  border-radius: 5px;
  background: #f0fdf4;
  color: #059669;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-paste-sm:hover {
  background: #059669;
  color: #fff;
}
.btn-paste-sm svg {
  width: 14px;
  height: 14px;
}

/* 设置面板 v39（紧凑版，默认折叠） */
.settings-bar-v39 {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 6px 14px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  gap: 10px;
  font-size: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.settings-bar-v39.collapsed {
  display: none;
}
.settings-bar-v39 .setting-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.settings-bar-v39 .setting-group.toggles {
  gap: 10px;
}
.settings-bar-v39 .setting-group.toggles label {
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font-size: 11px;
}
.settings-bar-v39 input[type="text"] {
  width: 80px;
  padding: 3px 6px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 11px;
}
.settings-bar-v39 .theme-select {
  padding: 3px 6px;
  border: 1.5px solid #059669;
  border-radius: 4px;
  font-size: 11px;
}
.settings-bar-v39 .color-picker {
  width: 24px;
  height: 22px;
  border: none;
  cursor: pointer;
}
.settings-bar-v39 .btn-text {
  padding: 3px 8px;
  font-size: 11px;
  border: none;
  background: none;
  color: #6b7280;
  cursor: pointer;
  border-radius: 4px;
}
.settings-bar-v39 .btn-text:hover {
  background: #e5e7eb;
  color: #374151;
}
.btn-settings-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border: none;
  background: none;
  color: #6b7280;
  font-size: 11px;
  cursor: pointer;
  border-radius: 4px;
}
.btn-settings-toggle:hover {
  background: #e5e7eb;
  color: #374151;
}
.btn-settings-toggle svg {
  width: 14px;
  height: 14px;
}

/* ========== 左侧导航栏收起状态 ========== */
.content-panel.collapsed {
  width: 0 !important;
  min-width: 0;
  flex: 0 !important;
  overflow: hidden;
}
.content-panel.collapsed .panel-nav-bar,
.content-panel.collapsed .panel-views {
  display: none;
}
/* 收起时预览区左移并留出展开按钮的空间 */
.content-panel.collapsed ~ .preview-panel-v39 .preview-scroll {
  padding-left: 44px;
}
/* 收起时编辑框最大宽度调整为 768px */
.content-panel.collapsed ~ .preview-panel-v39 .preview-content {
  max-width: 768px;
}

/* ========== 响应式 ========== */
@media (max-width: 640px) {
  /* 解锁 body/html，允许页面整体滚动 */
  html, body {
    overflow: visible;
    height: auto;
  }
  .main-shell {
    flex-direction: column;
    overflow-y: auto;
    min-height: 100vh;
  }
  .content-panel {
    width: 100%;
    flex: none;
    flex-shrink: 0;
    height: 110vh;
  }
  .preview-panel-v39 {
    width: 100%;
    flex: none;
    flex-shrink: 0;
    height: 90vh;
    border-left: none;
    border-top: 1px solid #e5e7eb;
  }
  .panel-nav-bar {
    padding: 0 8px;
    gap: 1px;
  }
  .panel-nav-item {
    padding: 5px 8px;
    font-size: 12px;
  }
  .panel-nav-item svg {
    width: 14px;
    height: 14px;
  }
  .quick-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .settings-bar-v39 {
    justify-content: flex-start;
  }
}
