/* ========== 后台管理专用样式 ========== */
/* 独立于前台品牌设计，后台用自己的简洁样式 */

:root {
    --primary: #1c4e3e;
    --primary-hover: #153d30;
    --on-primary: #ffffff;
    --bg: #f5f3ef;
    --surface: #ebe6de;
    --text: #1a1a1a;
    --text-primary: #4d4d4d;
    --text-secondary: #999999;
    --border: #d9d9d9;
    --border-light: #e8e8e8;
    --font-heading: 'Montserrat', 'Noto Sans SC', 'PingFang SC', sans-serif;
    --font-body: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 8px;
    --shadow-sm: 0 1px 4px rgba(28, 78, 62, 0.06);
    --shadow-md: 0 2px 12px rgba(28, 78, 62, 0.08);
    --shadow-lg: 0 4px 24px rgba(28, 78, 62, 0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ========== 导航栏 ========== */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    height: 64px;
    background-color: var(--primary);
    color: var(--on-primary);
}

.nav-brand {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 1px;
}

.nav-links {
    display: flex;
    gap: 24px;
}

.nav-link {
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    padding: 8px 0;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.nav-link:hover {
    color: var(--on-primary);
}

.nav-link.active {
    color: var(--on-primary);
    border-bottom-color: var(--on-primary);
}

/* ========== 主内容区 ========== */
main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px 60px;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 22px;
    color: var(--text);
    margin-bottom: 24px;
    padding-left: 12px;
    border-left: 4px solid var(--primary);
}

/* ========== 表单卡片 ========== */
.admin-form-card {
    max-width: 600px;
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-md);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 8px;
    font-weight: bold;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    background: #fff;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
}

.form-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    margin-top: -4px;
}

.form-group textarea {
    resize: vertical;
    line-height: 1.6;
}

/* ========== 按钮 ========== */
.form-submit-btn {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    color: var(--on-primary);
    background-color: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s;
    font-family: inherit;
}

.form-submit-btn:hover {
    background-color: var(--primary-hover);
}

.form-message {
    margin-top: 16px;
    padding: 0;
    font-size: 14px;
    border-radius: var(--radius-md);
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s, padding 0.3s;
}

.form-message.show {
    padding: 12px 16px;
    max-height: 60px;
}

.form-message.success {
    background-color: #e1efdb;
    color: var(--primary);
}

.form-message.error {
    background-color: #ffeaea;
    color: #a94442;
}

/* ========== 产品列表 ========== */
.admin-product-list {
    max-width: 600px;
}

.admin-product-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #fff;
    border-radius: var(--radius-md);
    padding: 14px 20px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
}

.admin-product-id {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 30px;
}

.admin-product-name {
    flex: 1;
    font-size: 14px;
    color: var(--text);
}

.admin-product-price {
    font-family: var(--font-heading);
    font-size: 15px;
    color: var(--primary);
    font-weight: bold;
}

/* ========== 操作按钮 ========== */
.delete-btn {
    padding: 6px 14px;
    font-size: 12px;
    color: #fff;
    background-color: #a94442;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.2s;
    font-family: inherit;
}

.delete-btn:hover {
    background-color: #8a3535;
}

.edit-btn {
    padding: 6px 14px;
    font-size: 12px;
    color: #fff;
    background-color: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.2s;
    font-family: inherit;
}

.edit-btn:hover {
    background-color: var(--primary-hover);
}

/* ========== 弹窗（通用） ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 30px;
    width: 90%;
    max-width: 560px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2,
.modal-content h3 {
    font-family: var(--font-heading);
    color: var(--text);
    margin-bottom: 20px;
}

.modal-btns {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 8px;
}

.modal-cancel-btn {
    padding: 10px 24px;
    font-size: 14px;
    color: var(--text-primary);
    background-color: #f0f0f0;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s;
    font-family: inherit;
}

.modal-cancel-btn:hover {
    background-color: #e0e0e0;
}

/* ========== 编辑弹窗 ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 30px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    font-family: var(--font-heading);
    font-size: 18px;
    color: var(--text);
    margin-bottom: 20px;
}

.modal-btns {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 8px;
}

.modal-cancel-btn {
    padding: 10px 24px;
    font-size: 14px;
    color: var(--text-primary);
    background-color: #f0f0f0;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s;
    font-family: inherit;
}

.modal-cancel-btn:hover {
    background-color: #e0e0e0;
}

/* ========== 后台表格 ========== */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.admin-table th {
    background-color: var(--primary);
    color: var(--on-primary);
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
}

.admin-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    color: var(--text);
}

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

.admin-table tr:hover td {
    background-color: var(--bg);
}

/* ========== 后台卡片网格 ========== */
.admin-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.admin-card h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    color: var(--text);
    margin-bottom: 16px;
}

/* ========== 后台导航卡片等高 ========== */
.admin-nav-grid a {
    display: flex;
    text-decoration: none;
    color: inherit;
}
.admin-nav-grid .admin-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.admin-nav-grid .admin-card p {
    flex: 1;
}

/* ========== 后台统计卡片 ========== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.stat-card .stat-value {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: bold;
    color: var(--primary);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ========== 标签选择器 ========== */
.tag-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-group-title {
    width: 100%;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
    margin-bottom: 4px;
}

.tag-option {
    padding: 6px 14px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
    color: var(--text-primary);
    user-select: none;
}

.tag-option:hover {
    border-color: var(--primary);
}

.tag-option.selected {
    color: #fff;
    border-color: transparent;
}

/* 不同标签类型的颜色 */
.tag-option[data-type="series"].selected { background-color: #1c4e3e; }
.tag-option[data-type="score_range"].selected { background-color: #8b5cf6; }
.tag-option[data-type="material"].selected { background-color: #f59e0b; }
.tag-option[data-type="craft"].selected { background-color: #3b82f6; }
.tag-option[data-type="style"].selected { background-color: #ec4899; }
.tag-option[data-type="default"].selected { background-color: #1c4e3e; }

/* SPU 列表中的标签显示 */
.spu-tags {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
}

.spu-tag-badge {
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 9999px;
    color: #fff;
}

.spu-tag-badge[data-type="series"] { background-color: #1c4e3e; }
.spu-tag-badge[data-type="score_range"] { background-color: #8b5cf6; }
.spu-tag-badge[data-type="material"] { background-color: #f59e0b; }
.spu-tag-badge[data-type="craft"] { background-color: #3b82f6; }
.spu-tag-badge[data-type="style"] { background-color: #ec4899; }
.spu-tag-badge[data-type="default"] { background-color: #999; }

/* ========== SPU 列表卡片 ========== */
.spu-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #fff;
    border-radius: var(--radius-md);
    padding: 14px 20px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
}

.spu-card img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.spu-info {
    flex: 1;
}

.spu-info h3 {
    font-size: 16px;
    color: var(--text);
    margin-bottom: 4px;
}

.spu-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.spu-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ========== 按钮 ========== */
.btn {
    padding: 6px 14px;
    font-size: 12px;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: opacity 0.2s;
    font-family: inherit;
}

.btn:hover { opacity: 0.85; }
.btn-edit { background-color: var(--primary); }
.btn-delete { background-color: #a94442; }
.btn-spec { background-color: #6b7280; }
.btn-listed { background-color: #27ae60; }
.btn-unlisted { background-color: #95a5a6; }
.btn-featured { background-color: #e67e22; }
.btn-unfeatured { background-color: #bdc3c7; color: #566; }
.spu-card--unlisted { opacity: 0.5; }
.sort-input {
    width: 50px;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    text-align: center;
    flex-shrink: 0;
}

/* 拖拽排序相关 */
.drag-handle {
    cursor: grab;
    color: #b0b8c0;
    font-size: 20px;
    line-height: 1;
    padding: 0 4px;
    flex-shrink: 0;
    user-select: none;
}

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

.sort-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
    font-weight: 600;
}

.spu-card[draggable="true"] {
    transition: box-shadow 0.2s, opacity 0.2s;
}

.spu-card.dragging {
    opacity: 0.4;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.spu-card.drag-over {
    border-top: 3px solid var(--primary);
    padding-top: 11px;
}

/* ========== 图片预览 ========== */
.image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.image-preview-item {
    position: relative;
    width: 100px;
}

.image-preview-item img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
}

.image-preview-item.is-cover img {
    border-color: #f59e0b;
}

.image-preview-item .cover-label {
    position: absolute;
    top: 2px;
    left: 2px;
    background: #f59e0b;
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 2px;
}

.image-preview-item .img-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.image-preview-item .img-actions button {
    padding: 2px 8px;
    font-size: 11px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 2px;
    cursor: pointer;
}

.image-preview-item .img-actions button:hover {
    background: var(--bg);
}

/* ========== 复选框组 ========== */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ========== 加载动画 ========== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
@media (max-width: 768px) {
    .navbar {
        padding: 0 16px;
        height: 56px;
    }

    .nav-brand {
        font-size: 15px;
    }

    .nav-links {
        gap: 12px;
    }

    .nav-link {
        font-size: 12px;
    }

    main {
        padding: 20px 16px 40px;
    }

    .admin-form-card {
        padding: 20px;
    }

    .admin-table {
        font-size: 12px;
    }

    .admin-table th,
    .admin-table td {
        padding: 8px 10px;
    }
}
