/* ===== 仓库管理系统 warehouse.css ===== */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --bg: #f5f6fa;
    --border: #e8eaed;
    --text: #1f2937;
    --muted: #6b7280;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ---- 顶栏 ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 58px;
    padding: 0 1.25rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
}
.topbar .brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}
.topbar .search-box {
    flex: 1;
    max-width: 460px;
    position: relative;
}
.topbar .search-box i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}
.topbar .search-box input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: none;
    font-size: 0.9rem;
}
.topbar .search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }

/* ---- 布局 ---- */
.layout {
    display: flex;
    align-items: flex-start;
    height: calc(100vh - 58px);
}
.sidebar {
    width: 280px;
    flex-shrink: 0;
    height: 100%;
    overflow-y: auto;
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 1rem 0.75rem;
}
.main {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
}

/* ---- 分类树 ---- */
.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.5rem 0.75rem;
}
.sidebar-head .title { font-weight: 700; font-size: 0.95rem; }
.cat-tree { list-style: none; margin: 0; padding: 0; }
.cat-node { list-style: none; }
.cat-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    user-select: none;
}
.cat-row:hover { background: #f3f4f6; }
.cat-row.active { background: #ede9fe; color: var(--primary-dark); font-weight: 600; }
.cat-caret {
    width: 16px;
    flex-shrink: 0;
    text-align: center;
    color: #9ca3af;
    transition: transform .15s;
}
.cat-caret.open { transform: rotate(90deg); }
.cat-caret.leaf { visibility: hidden; }
.cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { font-size: 0.7rem; color: #9ca3af; }
.cat-children { list-style: none; margin: 0; padding-left: 1.1rem; border-left: 1px solid #eef0f3; margin-left: 0.6rem; }
.cat-children.collapsed { display: none; }

/* ---- 商品列表 ---- */
.main-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.main-head .count { color: var(--muted); font-size: 0.85rem; }
.product-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
.product-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.9rem;
    display: grid;
    grid-template-columns: 150px 1fr;
    grid-template-areas: "media body" "plat plat";
    gap: 0.9rem;
}
.pc-media { grid-area: media; }
.pc-cover {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 10px;
    background: #f3f4f6;
    cursor: zoom-in;
    display: block;
}
.pc-cover.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c7cad1;
    font-size: 2rem;
}
.pc-thumbs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.pc-thumbs img {
    width: 34px; height: 34px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
}
.pc-thumbs img.is-cover { border-color: var(--primary); }

.pc-body { grid-area: body; min-width: 0; }
.pc-sku {
    display: inline-block;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.72rem;
    background: #eef2ff;
    color: var(--primary-dark);
    padding: 2px 8px;
    border-radius: 6px;
    margin-bottom: 0.35rem;
}
.pc-title { font-weight: 600; font-size: 1rem; margin-bottom: 0.45rem; word-break: break-all; }
.pc-meta { display: flex; flex-wrap: wrap; gap: 0.9rem; align-items: center; margin-bottom: 0.7rem; font-size: 0.85rem; color: var(--muted); }
.pc-price { color: #e11d48; font-weight: 700; font-size: 1.05rem; }
.pc-meta .out { color: #dc2626; }
.pc-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.pc-actions .spacer { flex: 1; }

/* ---- 平台面板 ---- */
.pc-platforms {
    grid-area: plat;
    border-top: 1px dashed var(--border);
    padding-top: 0.7rem;
    margin-top: 0.2rem;
}
.plat-empty { color: #9ca3af; font-size: 0.85rem; padding: 0.3rem 0; }
.plat-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem;
    border: 1px solid #f1f2f4;
    border-radius: 8px;
    margin-bottom: 0.45rem;
}
.plat-row img {
    width: 46px; height: 46px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    background: #f3f4f6;
    flex-shrink: 0;
}
.plat-row .plat-name {
    font-weight: 600;
    background: #f0fdf4;
    color: #16a34a;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    white-space: nowrap;
}
.plat-row .plat-title { flex: 1; min-width: 0; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plat-row .plat-price { color: #e11d48; font-weight: 600; font-size: 0.85rem; white-space: nowrap; }
.plat-row .plat-sales { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

/* ---- 空状态 / 加载 ---- */
.empty, .loading {
    text-align: center;
    padding: 4rem 1rem;
    color: #9ca3af;
}
.empty i { font-size: 3rem; display: block; margin-bottom: 0.5rem; color: #d1d5db; }

/* ---- 分页 ---- */
.pager { display: flex; justify-content: center; align-items: center; gap: 0.75rem; margin: 1.25rem 0; }

/* ---- 图片灯箱 ---- */
.lb-content {
    background: rgba(17,17,20,.96);
    border: none;
    border-radius: 12px;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.lb-img {
    max-width: 92%;
    max-height: 78vh;
    object-fit: contain;
    transition: transform .2s;
    cursor: zoom-in;
}
.lb-img.zoomed { transform: scale(1.8); cursor: zoom-out; }
.lb-close {
    position: absolute; top: 10px; right: 14px;
    background: rgba(255,255,255,.15); color: #fff;
    border: none; width: 36px; height: 36px; border-radius: 50%;
    font-size: 1.3rem; line-height: 1; cursor: pointer; z-index: 5;
}
.lb-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,.15); color: #fff;
    border: none; width: 44px; height: 44px; border-radius: 50%;
    font-size: 1.8rem; line-height: 1; cursor: pointer; z-index: 5;
}
.lb-nav:hover { background: rgba(255,255,255,.3); }
.lb-prev { left: 14px; }
.lb-next { right: 14px; }
.lb-bar {
    position: absolute; bottom: 12px; left: 0; right: 0;
    display: flex; align-items: center; justify-content: center; gap: 1rem;
    color: #fff; z-index: 5;
}
.lb-counter { font-size: 0.85rem; opacity: .85; }

/* ---- 表单图片预览 ---- */
.img-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.img-preview img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.img-preview .first-tag { position: relative; }

/* ---- 编辑弹窗：已有图片（× 删除 / ⭐ 首图） ---- */
.img-existing { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.img-exist-item { position: relative; width: 64px; height: 64px; }
.img-exist-item img {
    width: 64px; height: 64px; object-fit: cover;
    border-radius: 8px; border: 1px solid var(--border);
}
.img-exist-item .img-del {
    position: absolute; top: -7px; right: -7px;
    width: 20px; height: 20px; border-radius: 50%;
    background: #ef4444; color: #fff; border: 2px solid #fff;
    font-size: 13px; line-height: 1; cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center;
}
.img-exist-item .img-del:hover { background: #dc2626; }
.img-exist-item .img-cover-star {
    position: absolute; bottom: -5px; left: -5px;
    width: 19px; height: 19px; border-radius: 50%;
    background: #fff; color: #f59e0b; font-size: 11px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 1px var(--border);
}

/* ---- 响应式 ---- */
@media (max-width: 768px) {
    .sidebar { width: 220px; }
    .product-card { grid-template-columns: 1fr; grid-template-areas: "media" "body" "plat"; }
    .pc-cover { width: 100%; height: 200px; }
    .topbar .brand span { display: none; }
}
