/* 分类标签样式 */
.category-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

.category-tag.quick-start {
    background: rgba(34, 197, 94, 0.15);
    color: #15803d;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.category-tag.advanced {
    background: rgba(59, 130, 246, 0.15);
    color: #1d4ed8;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* 分类区域样式 */
.category-section {
    margin-bottom: 48px;
}

.category-title {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 24px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f3f4f6;
}

/* 中文注释：功能名称【后台教程分类标签样式】，用法：在后台教程页顶部提供“全部/幻象COS/花生国风”切换按钮 */
.admin .actions-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin .tabbar { display: inline-flex; gap: 8px; align-items: center; }
.admin .tabbar .tab {
  appearance: none;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #374151;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
}
.admin .tabbar .tab.active {
  background: #111827;
  color: #ffffff;
  border-color: #111827;
}
.admin .quick-create { display: inline-flex; gap: 8px; align-items: center; }

.admin-sidebar-toggle {
    display: none;
}

@media (max-width: 960px) {
    .admin-topbar {
        position: sticky;
        top: 0;
        z-index: 60;
    }
    .admin-sidebar-toggle {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 10px 16px;
        border-radius: 999px;
        background: rgba(15, 23, 42, 0.08);
        border: none;
        cursor: pointer;
    }
}
/* === Force show '编辑' button in compare list === */
.actions-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.actions-inline .btn.ghost {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}
.actions-inline form {
  display: inline-block;
  margin: 0;
}
/* 修复编辑按钮不可见问题 */
.btn.ghost {
  color: #333 !important;      /* 深色文字 */
  border: 1px solid #ccc;      /* 灰色边框 */
  background: #fff;            /* 白底 */
  opacity: 1 !important;       /* 禁止透明 */
}
.btn.ghost:hover {
  color: #000;
  border-color: #888;
  background: #f5f5f5;
}
/* 竖排表单 */
.form-vertical .form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.form-vertical input[type="text"],
.form-vertical input[type="url"],
.form-vertical select,
.form-vertical textarea { width: 520px; max-width: 100%; }

.form-actions { display: flex; gap: 12px; margin-top: 12px; }

/* 小按钮 */
.btn.sm { height: 36px; line-height: 36px; padding: 0 14px; font-size: 14px; }

/* 模板区域 */
.tpl-row { display: flex; gap: 12px; align-items: center; margin: 6px 0; }
.tpl-row input[type="text"] { width: 260px; }
.hint { color: #6b7280; font-size: 12px; }

/* 预览缩略图 */
.tpl-preview img, .thumb img {
  width: 240px;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.08);
}
/* 布局：左表单 + 右预览；窄屏自动单列 */
.editor-grid {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) 340px;
  gap: 24px;
}
@media (max-width: 1200px) {
  .editor-grid { grid-template-columns: 1fr; }
}

/* 竖排表单基线 */
.form-vertical .form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.form-vertical input[type="text"],
.form-vertical input[type="url"],
.form-vertical select,
.form-vertical textarea { width: 560px; max-width: 100%; }

.form-actions { display: flex; gap: 12px; margin-top: 8px; }
.btn.sm { height: 36px; line-height: 36px; padding: 0 14px; font-size: 14px; }

/* 模板输入行 */
.tpl-row { display: flex; gap: 12px; align-items: center; margin: 6px 0; }
.tpl-row input[type="text"] { width: 260px; }
.hint { color: #6b7280; font-size: 12px; }

/* 右侧预览卡片 */
.editor-preview h3 { margin: 2px 0 10px; }
.cover-mock {
  position: relative;
  width: 100%;
  max-width: 320px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0,0,0,.08);
}
.cover-mock img { display: block; width: 100%; height: auto; }

/* 文案叠加：与后端生成逻辑的居中方案一致 */
.cover-mock .t1,
.cover-mock .t2 {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  text-align: center;
  width: 86%;
  white-space: normal;
  text-shadow: 0 2px 8px rgba(0,0,0,.22);
  font-family: "PingFang SC","Noto Sans SC","Microsoft YaHei",sans-serif;
}
.cover-mock .t1 {
  top: 42%;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
}
.cover-mock .t2 {
  top: 62%;
  font-size: 16px;
  font-weight: 600;
  opacity: .95;
}

.preview-hint { color: #6b7280; font-size: 12px; margin-top: 10px; }
.mt8 { margin-top: 8px; }
.thumb img {
  width: 240px; height: auto; border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
}
/* 3列：左表单(两列栅格) + 右预览；窄屏自动一列 */
.editor-grid-3cols{
  display:grid;
  grid-template-columns:minmax(720px,1fr) 360px;
  gap:28px;
}
@media (max-width:1280px){
  .editor-grid-3cols{ grid-template-columns:1fr; }
}

/* 表单两列 */
.editor-form .fields-grid-2{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px 24px;
}
@media (max-width:900px){
  .editor-form .fields-grid-2{ grid-template-columns:1fr; }
}

.form-group{ display:flex; flex-direction:column; gap:8px; margin-bottom:14px; }
.editor-form input[type="text"],
.editor-form input[type="url"],
.editor-form select,
.editor-form textarea{ max-width:100%; }

.tpl-row{ display:flex; gap:12px; align-items:center; margin:6px 0; }
.tpl-row input[type="text"]{ width:260px; }
.hint{ color:#6b7280; font-size:12px; }
.form-actions{ display:flex; gap:12px; margin-top:8px; }
.btn.sm{ height:36px; line-height:36px; padding:0 14px; font-size:14px; }

.editor-preview h3{ margin:2px 0 10px; }
.cover-mock{ position:relative; width:100%; max-width:320px; border-radius:16px; overflow:hidden; box-shadow:0 6px 20px rgba(0,0,0,.08); }
.cover-mock img{ width:100%; display:block; }

/* 预览文字：左对齐版（与后端生成保持一致） */
.cover-mock .t1, .cover-mock .t2{
  position:absolute; color:#fff; width:78%; text-shadow:0 2px 8px rgba(0,0,0,.22);
  font-family:"PingFang SC","Noto Sans SC","Microsoft YaHei",sans-serif;
}
.cover-mock .left{ left:10%; text-align:left; } /* 关键：靠左 */
.cover-mock .t1{ top:42%; font-size:26px; font-weight:800; line-height:1.15; }
.cover-mock .t2{ top:62%; font-size:16px; font-weight:600; opacity:.95; }

.thumb img{ width:240px; height:auto; border-radius:12px; box-shadow:0 4px 14px rgba(0,0,0,.06); }
.mt8{ margin-top:8px; }
.preview-hint{ color:#6b7280; font-size:12px; margin-top:10px; }
/* === 教程编辑页布局 === */
.editor-grid-3cols{
  display:grid;
  grid-template-columns: 1fr 360px;   /* 左：表单   右：预览 */
  gap:24px;
  align-items:start;
}

.editor-form .fields-grid-2{
  display:grid;
  grid-template-columns: 1fr 1fr;     /* 左列：名称/分类；右列：简介/上传 */
  gap:16px 24px;
}

.editor-form .col .form-group + .form-group{ margin-top:12px; }

.form-group label{ display:block; font-weight:600; margin-bottom:8px; }
.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="file"],
.form-group textarea,
.editor-form select{
  width:100%;
  height:40px;
  padding:8px 12px;
  border:1px solid #e5e7eb;
  border-radius:10px;
  background:#fff;
  outline:none;
}
.form-group textarea{ height:auto; min-height:96px; resize:vertical; }

/* 上传后的缩略图 */
.thumb{ margin-top:8px; }
.thumb img{ max-width:220px; border-radius:12px; display:block; }

/* 模板行 */
.tpl-row{ display:flex; gap:12px; align-items:center; margin-top:8px; }
.tpl-row .hint{ color:#6b7280; font-size:12px; }

/* 底部按钮行 */
.form-actions{ margin-top:16px; display:flex; gap:10px; }
.btn.sm{ padding:8px 14px; border-radius:10px; }

/* === 右侧封面预览（与生成 SVG 保持一致） === */
.editor-preview h3{ margin:0 0 10px; font-size:16px; font-weight:700; }
.editor-preview{ width:360px; margin-left:auto; }

.cover-mock{
  position:relative;
  width:100%;
  aspect-ratio:16/9;
  border-radius:24px;
  overflow:hidden;
  box-shadow:0 8px 24px rgba(0,0,0,.08);
  background:#eef3f7;
}
.cover-mock img{
  position:absolute; inset:0;
  width:100%; height:100%;
  object-fit:cover;
}

/* 预览文字：靠左 12%；与 app.py 的 LEFT_X/TITLE_Y/SUBTITLE_Y 一致 */
.cover-mock .t1,
.cover-mock .t2{
  position:absolute;
  left:12%;
  color:#fff;
  pointer-events:none;
  text-shadow:0 2px 6px rgba(0,0,0,.15);
  font-family:"PingFang SC","Noto Sans SC",sans-serif;
  white-space:nowrap;
  max-width:76%;
  overflow:hidden;
  text-overflow:ellipsis;
}
.cover-mock .t1{ top:45%; transform:translateY(-100%); font-size:28px; font-weight:800; }
.cover-mock .t2{ top:62%; transform:translateY(-100%); font-size:16px; font-weight:600; opacity:.95; }

.preview-hint{ color:#6b7280; font-size:12px; margin-top:10px; }

/* 产品预览样式 */
.product-preview {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e5e7eb;
}

.product-preview .product-info h4 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

.product-preview .product-info .tagline {
    margin: 0 0 12px;
    font-size: 14px;
    color: var(--primary);
    font-weight: 600;
}

.product-preview .product-info .description {
    margin: 0 0 16px;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
}

.product-preview .product-image img {
    width: 100%;
    max-width: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.product-image-placeholder {
    width: 100%;
    height: 180px;
    background: #e5e7eb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 14px;
    border: 2px dashed #d1d5db;
}

/* 后台管理表单样式 */
.admin-form-container {
    max-width: 1000px;
    margin: 0 auto;
}

.admin-form {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.form-section {
    margin-bottom: 32px;
}

.form-section:last-of-type {
    margin-bottom: 24px;
}

.form-section h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    border-bottom: 2px solid #f3f4f6;
    padding-bottom: 8px;
}

/* 网格布局 - 自适应多列 */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* 单行布局 */
.form-row {
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 全宽字段（如文件上传） */
.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-help {
    color: #6b7280;
    font-size: 12px;
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 12px;
    padding-top: 24px;
    border-top: 1px solid #f3f4f6;
}

/* 紧凑按钮样式 */
.btn.compact {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
}

.current-image {
    margin-top: 8px;
}

.current-image img {
    max-width: 300px;
    height: auto;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .admin-form {
        padding: 20px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1025px) {
    .form-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 后台表格样式 */
.admin-table-wrapper {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table thead {
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
}

.admin-table th {
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-table td {
    padding: 16px 12px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: top;
}

.admin-table tbody tr:hover {
    background: #f9fafb;
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

/* 横幅预览样式 */
.banner-preview {
    width: 120px;
    height: 68px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.banner-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 横幅链接样式 */
.banner-link {
    margin-top: 4px;
}

.banner-link small {
    color: #6b7280;
    font-size: 12px;
}

/* 横幅副标题样式 */
.banner-subtitle {
    color: #374151;
    font-size: 13px;
    line-height: 1.4;
}

/* 状态标签样式 */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.active {
    background: rgba(34, 197, 94, 0.15);
    color: #15803d;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-badge.inactive {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* 排序相关样式 */
.sort-order {
    display: inline-block;
    margin-right: 8px;
    font-weight: 600;
    color: #6b7280;
}

.drag-handle {
    display: inline-block;
    cursor: grab;
    color: #9ca3af;
    font-size: 16px;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.sortable-item {
    transition: opacity 0.2s ease;
}

.sortable-item:hover .drag-handle {
    color: #6b7280;
}

/* 操作按钮样式 */
.actions-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.actions-inline .btn {
    white-space: nowrap;
}

/* 空状态样式 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.empty-state p {
    font-size: 16px;
    margin: 0;
}

.empty-state a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
}

.empty-state a:hover {
    text-decoration: underline;
}
