/* ==========================================================================
   AliteCMS HTML 構建器通用樣式（前台渲染 + 後台預覽 + 後台編輯器）
   ========================================================================== */

/* ---------- 前台與預覽共用佈局與元件 (.pb-*) ---------- */
.pb-root {
  width: 100%;
  box-sizing: border-box;
}
.pb-root *,
.pb-root *::before,
.pb-root *::after {
  box-sizing: border-box;
}

.pb-section {
  width: 100%;
  padding: 28px 0;
}

.pb-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.pb-container-full {
  max-width: 100%;
  padding: 0 20px;
}

.pb-grid {
  display: grid;
  gap: 24px;
  align-items: start;
}

.pb-grid-1 { grid-template-columns: 1fr; }
.pb-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pb-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pb-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pb-grid-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.pb-grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.pb-grid-1-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); }
.pb-grid-3-1 { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); }

.pb-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* 文字區塊 */
.pb-text-block {
  line-height: 1.75;
}
.pb-text-block h1,
.pb-text-block h2,
.pb-text-block h3,
.pb-text-block h4 {
  margin: 0 0 10px;
  line-height: 1.35;
}
.pb-text-block p {
  margin: 0 0 12px;
  white-space: pre-line;
}
.pb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  background: #4f46e5;
  color: #fff !important;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: opacity 0.2s, transform 0.15s;
}
.pb-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

/* 富文本區塊 */
.pb-richtext {
  line-height: 1.8;
  color: #1e293b;
  word-break: break-word;
}
.pb-richtext img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}
.pb-richtext blockquote {
  border-left: 4px solid #4f46e5;
  margin: 1em 0;
  padding: 0.6em 1em;
  background: #f8fafc;
  color: #475569;
  border-radius: 0 6px 6px 0;
}
.pb-richtext table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
}
.pb-richtext th,
.pb-richtext td {
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
  text-align: left;
}
.pb-richtext th {
  background: #f1f5f9;
  font-weight: 600;
}

/* 確保 TinyMCE 在 Modal 內的彈出視窗與下拉選單位於最上層 */
.tox-tinymce-aux {
  z-index: 100050 !important;
}

/* 圖片區塊 */
.pb-image-block {
  margin: 0;
}
.pb-image-block img {
  display: block;
  max-width: 100%;
  height: auto;
}
.pb-image-block figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: #64748b;
  text-align: center;
}

/* YouTube 16:9 響應式容器 */
.pb-youtube-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 10px;
  background: #000;
}
.pb-youtube-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* iframe 區塊 */
.pb-iframe-wrap {
  width: 100%;
  overflow: hidden;
}
.pb-iframe-wrap iframe {
  display: block;
  width: 100%;
  border: 0;
}

/* 區塊標題 */
.pb-block-heading {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e2e8f0;
  color: #0f172a;
}

/* 文章清單 - 網格卡片 */
.pb-article-grid {
  display: grid;
  gap: 18px;
}
.pb-article-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pb-article-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pb-article-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.pb-article-card {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  color: inherit;
}
.pb-article-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}
.pb-article-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #f1f5f9;
  display: block;
}
.pb-article-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.pb-article-cat {
  display: inline-block;
  align-self: flex-start;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4f46e5;
}
.pb-article-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  color: #0f172a;
}
.pb-article-title a {
  color: inherit;
  text-decoration: none;
}
.pb-article-title a:hover {
  color: #4f46e5;
}
.pb-article-summary {
  margin: 0;
  font-size: 13.5px;
  color: #475569;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pb-article-meta {
  margin-top: auto;
  padding-top: 8px;
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* 文章清單 - 橫向列表 */
.pb-article-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.pb-article-list-item {
  display: flex;
  gap: 16px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  align-items: center;
}
.pb-article-list-item .pb-article-thumb {
  width: 160px;
  flex-shrink: 0;
  border-radius: 8px;
}

/* 文章清單 - 精簡標題清單 */
.pb-article-compact {
  list-style: none;
  margin: 0;
  padding: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}
.pb-article-compact li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
}
.pb-article-compact li:last-child {
  border-bottom: 0;
}
.pb-article-compact a {
  color: #1e293b;
  text-decoration: none;
  font-weight: 500;
  flex: 1;
}
.pb-article-compact a:hover {
  color: #4f46e5;
}
.pb-article-compact .pb-compact-meta {
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap;
}

/* 分類清單 */
.pb-cat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.pb-cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
}
.pb-cat-pill:hover {
  border-color: #4f46e5;
  color: #4f46e5;
  background: #eef2ff;
}
.pb-cat-count {
  font-size: 11.5px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
}

.pb-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.pb-cat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  text-decoration: none;
  color: #0f172a;
  transition: border-color 0.15s, transform 0.15s;
}
.pb-cat-card:hover {
  border-color: #4f46e5;
  transform: translateY(-2px);
}

.pb-cat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.pb-cat-list li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  text-decoration: none;
}
.pb-cat-list li:last-child a {
  border-bottom: 0;
}
.pb-cat-list li a:hover {
  background: #f8fafc;
  color: #4f46e5;
}

.pb-empty {
  padding: 18px;
  text-align: center;
  color: #94a3b8;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 13.5px;
}

/* ---------- 複合型資料集前台多維度篩選器 (.ds-filter-*) ---------- */
.ds-filter-shell {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 22px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
}
.ds-filter-top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.ds-search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
}
.ds-search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 14px;
}
.ds-search-box input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ds-search-box input:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.ds-filter-groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
}
.ds-filter-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.ds-filter-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #475569;
  min-width: 72px;
  padding-top: 6px;
  flex-shrink: 0;
}
.ds-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  flex: 1;
}
.ds-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.ds-chip:hover {
  border-color: #818cf8;
  color: #4f46e5;
  background: #eef2ff;
}
.ds-chip.active {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #ffffff;
}
.ds-chip-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
}
.ds-chip.active .ds-chip-count {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}
.ds-active-bar {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #e2e8f0;
  font-size: 12.5px;
}
.ds-active-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-weight: 600;
  font-size: 12px;
}
.ds-active-chip button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  line-height: 1;
}
.ds-view-toggle {
  display: inline-flex;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
}
.ds-view-toggle button {
  border: 0;
  background: #fff;
  color: #64748b;
  padding: 8px 11px;
  cursor: pointer;
  font-size: 13px;
}
.ds-view-toggle button.active {
  background: #eef2ff;
  color: #4f46e5;
}

/* RWD 響應式斷點 */
@media (max-width: 900px) {
  .pb-grid-3,
  .pb-grid-4,
  .pb-article-grid.cols-3,
  .pb-article-grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .pb-grid-2,
  .pb-grid-3,
  .pb-grid-4,
  .pb-grid-1-2,
  .pb-grid-2-1,
  .pb-grid-1-3,
  .pb-grid-3-1,
  .pb-article-grid.cols-2,
  .pb-article-grid.cols-3,
  .pb-article-grid.cols-4 {
    grid-template-columns: 1fr;
  }
  .pb-article-list-item {
    flex-direction: column;
    align-items: stretch;
  }
  .pb-article-list-item .pb-article-thumb {
    width: 100%;
  }
}

/* ---------- 後台 HTML 構建器編輯介面專屬樣式 ---------- */
.pb-mode-tabs {
  display: inline-flex;
  background: var(--bg-subtle, #f1f5f9);
  padding: 3px;
  border-radius: 8px;
  gap: 4px;
}
.pb-mode-tab {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary, #475569);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.pb-mode-tab.active {
  background: #fff;
  color: var(--primary, #4f46e5);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.pb-canvas {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 220px;
}

.pb-row-card {
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  overflow: hidden;
}
.pb-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #eef2ff;
  border-bottom: 1px solid #dbeafe;
  flex-wrap: wrap;
}
.pb-row-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #3730a3;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pb-row-body {
  padding: 12px;
}
.pb-cols-preview {
  display: grid;
  gap: 10px;
}

.pb-col-slot {
  background: #fff;
  border: 1.5px dashed #cbd5e1;
  border-radius: 8px;
  padding: 10px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pb-col-slot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: #64748b;
  font-weight: 600;
}

.pb-block-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pb-block-card:hover {
  border-color: #818cf8;
}
.pb-block-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.pb-block-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
}
.pb-block-summary {
  font-size: 11.5px;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pb-block-actions {
  display: flex;
  gap: 3px;
}
.pb-icon-btn {
  border: 0;
  background: transparent;
  color: #64748b;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
}
.pb-icon-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.pb-icon-btn.danger:hover {
  background: #fee2e2;
  color: #dc2626;
}

.pb-widget-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.pb-widget-option {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 14px 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: all 0.15s;
}
.pb-widget-option:hover {
  border-color: var(--primary, #4f46e5);
  background: #eef2ff;
  transform: translateY(-1px);
}
.pb-widget-option i {
  font-size: 18px;
  color: var(--primary, #4f46e5);
}
.pb-widget-option strong {
  font-size: 13.5px;
  color: #0f172a;
}
.pb-widget-option span {
  font-size: 11.5px;
  color: #64748b;
}

.pb-layout-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.pb-layout-option {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.pb-layout-option:hover {
  border-color: var(--primary, #4f46e5);
  background: #eef2ff;
}
.pb-layout-bars {
  display: flex;
  gap: 4px;
  height: 24px;
  margin-bottom: 6px;
}
.pb-layout-bar {
  background: #c7d2fe;
  border-radius: 3px;
}

/* ==================== 資料集前台可設計篩選欄（左側欄 / 頂部欄） ==================== */
.ds-page-layout-sidebar {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.ds-sidebar-panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px 18px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  position: sticky;
  top: 20px;
}
.ds-sidebar-title {
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ds-sb-group {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
}
.ds-sb-group:last-of-type {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 4px;
}
.ds-sb-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 10px;
}
.ds-sb-search-wrap {
  position: relative;
}
.ds-sb-search-wrap input {
  width: 100%;
  padding: 9px 36px 9px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 13.5px;
  color: #0f172a;
  background: #fff;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ds-sb-search-wrap input:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.ds-sb-search-wrap i {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 14px;
  pointer-events: none;
}
.ds-sb-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 13.5px;
  color: #1e293b;
  background: #fff;
  cursor: pointer;
}
.ds-sb-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #64748b;
  flex-wrap: wrap;
}
.ds-sb-mini-btn {
  padding: 3px 9px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  color: #475569;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.ds-sb-mini-btn:hover {
  border-color: #94a3b8;
  color: #0f172a;
  background: #f8fafc;
}
.ds-sb-scroll {
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ds-sb-scroll.expanded {
  max-height: none !important;
}
.ds-sb-check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: #334155;
  cursor: pointer;
  user-select: none;
  line-height: 1.4;
}
.ds-sb-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  accent-color: #4f46e5;
  cursor: pointer;
  flex-shrink: 0;
}
.ds-sb-check-count {
  margin-left: auto;
  font-size: 11.5px;
  color: #94a3b8;
}
.ds-main-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}
.ds-copy-prompt-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.ds-copy-prompt-btn:hover {
  border-color: #4f46e5;
  color: #4f46e5;
  background: #eef2ff;
}
.ds-mobile-filter-toggle {
  display: none;
  width: 100%;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: #1e293b;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
@media (max-width: 900px) {
  .ds-page-layout-sidebar {
    grid-template-columns: 1fr;
  }
  .ds-sidebar-panel {
    position: static;
    display: none;
  }
  .ds-sidebar-panel.mobile-open {
    display: block;
  }
  .ds-mobile-filter-toggle {
    display: inline-flex;
  }
}
