/* ============================================================
   后台产品编辑：图片画廊 + 富文本编辑器
   依赖 admin.css 中的 CSS 变量
   ============================================================ */

/* ---------- 图片数量徽标 ---------- */
.count-badge {
    display: inline-block; margin-left: 8px; padding: 2px 9px;
    background: #E8F0FF; color: #165DFF; border-radius: 20px;
    font-size: 12px; font-weight: 600; vertical-align: middle;
}

/* ---------- 拖拽上传区 ---------- */
.upload-drop {
    position: relative; border: 2px dashed #C9D6EA; border-radius: 10px;
    background: #F7FAFF; padding: 26px 18px; text-align: center;
    transition: all .2s; cursor: pointer;
}
.upload-drop:hover, .upload-drop.dragover {
    border-color: #165DFF; background: #EEF4FF;
}
.upload-drop input[type=file] {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
}
.upload-drop-inner { pointer-events: none; }
.upload-drop-ico { font-size: 30px; line-height: 1; margin-bottom: 8px; }
.upload-drop-inner p { margin: 0 0 6px; color: #1d2129; font-size: 14px; }
.upload-drop-inner span { color: #86909c; font-size: 12px; }
.upload-drop-inner b { color: #165DFF; }

/* ---------- 图片列表 ---------- */
.gallery-head {
    display: flex; align-items: center; justify-content: space-between;
    margin: 22px 0 10px; gap: 12px; flex-wrap: wrap;
}
.gallery-head label { font-size: 13px; font-weight: 600; color: #1d2129; }
.gallery-list {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 12px; list-style: none; margin: 0; padding: 0;
}
.gallery-item {
    position: relative; aspect-ratio: 1 / 1; border-radius: 8px; overflow: hidden;
    border: 1px solid #E3E9F2; background: #F2F5FA; cursor: grab;
}
.gallery-item.dragging { opacity: .45; }
.gallery-item.drag-over { outline: 2px dashed #165DFF; outline-offset: -3px; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-order {
    position: absolute; left: 6px; top: 6px; min-width: 18px; height: 18px; padding: 0 4px;
    background: rgba(0, 0, 0, .55); color: #fff; border-radius: 4px;
    font-size: 11px; line-height: 18px; text-align: center;
}
.cover-tag {
    position: absolute; left: 6px; bottom: 6px; padding: 2px 7px;
    background: #165DFF; color: #fff; border-radius: 4px; font-size: 11px;
}
.gallery-del {
    position: absolute; right: 6px; top: 6px; width: 22px; height: 22px;
    border: 0; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff;
    font-size: 15px; line-height: 20px; cursor: pointer; opacity: 0; transition: opacity .18s;
}
.gallery-item:hover .gallery-del { opacity: 1; }
.gallery-del:hover { background: #F53F3F; }
.gallery-empty { color: #86909c; font-size: 13px; margin: 6px 0 0; }

/* ---------- 富文本编辑器 ---------- */
.editor-wrap { border: 1px solid #DCE3EE; border-radius: 10px; overflow: hidden; background: #fff; }
.editor-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
    padding: 8px 10px; background: #F7F9FC; border-bottom: 1px solid #E8EDF5;
    position: sticky; top: 0; z-index: 5;
}
.tb-group { display: flex; align-items: center; gap: 4px; }
.tb-sep { width: 1px; height: 20px; background: #DFE5EE; margin: 0 6px; }
.tb-label { font-size: 12px; color: #6B7785; }
.tb-btn {
    min-width: 30px; height: 30px; padding: 0 8px;
    border: 1px solid #DCE3EE; border-radius: 6px; background: #fff;
    color: #1d2129; font-size: 13px; cursor: pointer; transition: all .15s;
    display: inline-flex; align-items: center; justify-content: center;
}
.tb-btn:hover { border-color: #165DFF; color: #165DFF; background: #F2F7FF; }
.tb-btn.active { background: #165DFF; border-color: #165DFF; color: #fff; }
.tb-select {
    height: 30px; padding: 0 6px; border: 1px solid #DCE3EE; border-radius: 6px;
    background: #fff; font-size: 13px; color: #1d2129; cursor: pointer;
}
.tb-size-num {
    width: 72px; height: 30px; padding: 0 8px; border: 1px solid #DCE3EE;
    border-radius: 6px; font-size: 13px; text-align: center;
}
.tb-color {
    width: 34px; height: 30px; padding: 0; border: 1px solid #DCE3EE;
    border-radius: 6px; background: #fff; cursor: pointer;
}
.tb-insert-img { color: #165DFF; border-color: #B8CEFF; }

.editor-body {
    min-height: 280px; max-height: 720px; overflow-y: auto;
    padding: 18px 20px; font-size: 15px; line-height: 1.8; color: #1d2129;
    outline: none; word-break: break-word;
}
.editor-body:empty::before {
    content: attr(data-placeholder); color: #A9B3C1; pointer-events: none;
}
.editor-body p { margin: 0 0 10px; }
.editor-body h1, .editor-body h2, .editor-body h3, .editor-body h4 {
    margin: 16px 0 10px; line-height: 1.4; color: #0E1A33;
}
.editor-body ul, .editor-body ol { margin: 0 0 12px; padding-left: 24px; }
.editor-body img { max-width: 100%; height: auto; border-radius: 6px; }
.editor-body table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.editor-body table td, .editor-body table th {
    border: 1px solid #DCE3EE; padding: 8px 10px; font-size: 14px;
}
.editor-body table th { background: #F5F8FD; }
.editor-source {
    width: 100%; min-height: 280px; border: 0; padding: 16px 18px;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px; line-height: 1.7; color: #24304a; resize: vertical; outline: none;
}

/* 前台详情页富文本样式（产品详情正文） */
.detail-content h1, .detail-content h2, .detail-content h3, .detail-content h4 {
    margin: 18px 0 10px; line-height: 1.4; color: #0E1A33;
}
.detail-content p { margin: 0 0 12px; }
.detail-content ul, .detail-content ol { margin: 0 0 14px; padding-inline-start: 24px; }
.detail-content img { max-width: 100%; height: auto; border-radius: 8px; }
.detail-content table { border-collapse: collapse; width: 100%; margin: 14px 0; }
.detail-content table td, .detail-content table th {
    border: 1px solid #E3E9F2; padding: 10px 12px; font-size: 14px;
}
.detail-content table th { background: #F5F8FD; }

@media (max-width: 760px) {
    .editor-toolbar { position: static; }
    .editor-body { padding: 14px; min-height: 220px; }
    .gallery-list { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
    .tb-size-num { width: 60px; }
}
