/**
 * NEVSIN Product Manager - Frontend Styles
 * 视图页面可自定义风格：
 *   方式1: 在主题CSS中覆盖 .cpm-* 类名样式
 *   方式2: 复制此文件到主题 /nevsin-product-manager/frontend.css 修改
 *   方式3: 在主题 functions.php 中移除 cpm-frontend 样式并自行编写
 */

/* ─── 变量（可覆盖） ─── */
:root {
    --cpm-primary: #2563eb;
    --cpm-primary-hover: #1d4ed8;
    --cpm-danger: #dc2626;
    --cpm-success: #16a34a;
    --cpm-text: #1f2937;
    --cpm-text-light: #6b7280;
    --cpm-bg: #ffffff;
    --cpm-bg-light: #f9fafb;
    --cpm-border: #e5e7eb;
    --cpm-radius: 8px;
    --cpm-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ─── 通用按钮 ─── */
.cpm-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--cpm-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1.5;
}

.cpm-btn--primary {
    background: var(--cpm-primary);
    color: #fff;
}
.cpm-btn--primary:hover {
    background: var(--cpm-primary-hover);
}

.cpm-btn--submit {
    background: var(--cpm-danger);
    color: #fff;
    width: 100%;
    justify-content: center;
    font-size: 16px;
    padding: 14px;
}
.cpm-btn--submit:hover {
    opacity: 0.9;
}

.cpm-btn--text {
    background: transparent;
    color: var(--cpm-text-light);
    text-align: center;
    justify-content: center;
    width: 100%;
    margin-top: 8px;
}

.cpm-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* ─── 商品列表 ─── */
.cpm-grid {
    display: grid;
    gap: 20px;
}
.cpm-grid--products {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.cpm-product-card {
    background: var(--cpm-bg);
    border: 1px solid var(--cpm-border);
    border-radius: var(--cpm-radius);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}
.cpm-product-card:hover {
    box-shadow: var(--cpm-shadow);
    transform: translateY(-2px);
}

.cpm-product-card__link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.cpm-product-card__thumb {
    aspect-ratio: 16/10;
    overflow: hidden;
    background: var(--cpm-bg-light);
}
.cpm-product-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cpm-product-card__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #d1d5db;
}
.cpm-product-card__placeholder .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
}

.cpm-product-card__body {
    padding: 14px;
}

.cpm-product-card__title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 6px;
    color: var(--cpm-text);
    line-height: 1.4;
}

.cpm-product-card__brief {
    font-size: 13px;
    color: var(--cpm-text-light);
    margin: 0 0 10px;
    line-height: 1.5;
}

.cpm-product-card__price {
    display: flex;
    align-items: baseline;
    gap: 2px;
    color: var(--cpm-danger);
    font-weight: 700;
}
.cpm-price-symbol { font-size: 14px; }
.cpm-price-amount { font-size: 22px; }
.cpm-price-unit { font-size: 12px; color: var(--cpm-text-light); font-weight: 400; margin-left: 4px; }

.cpm-product-card__specs {
    margin-top: 6px;
    font-size: 12px;
    color: var(--cpm-text-light);
}

/* ─── 商品详情 ─── */
.cpm-detail-header {
    display: flex;
    gap: 30px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.cpm-detail-header__thumb {
    flex: 0 0 400px;
    max-width: 400px;
}
.cpm-detail-header__thumb img {
    width: 100%;
    border-radius: var(--cpm-radius);
    border: 1px solid var(--cpm-border);
}
.cpm-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    background: var(--cpm-bg-light);
    border-radius: var(--cpm-radius);
    color: #d1d5db;
}

.cpm-detail-header__info {
    flex: 1;
    min-width: 300px;
}

.cpm-detail-title {
    font-size: 26px;
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--cpm-text);
}

.cpm-detail-brief {
    font-size: 14px;
    color: var(--cpm-text-light);
    margin-bottom: 20px;
    line-height: 1.6;
}

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

/* ─── 规格选择 ─── */
.cpm-specs-section {
    margin-bottom: 20px;
}

.cpm-specs-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.cpm-spec-item {
    display: flex;
    flex-direction: column;
    padding: 10px 20px;
    border: 2px solid var(--cpm-border);
    border-radius: var(--cpm-radius);
    cursor: pointer;
    transition: all 0.2s;
    background: var(--cpm-bg);
    min-width: 100px;
    text-align: center;
}
.cpm-spec-item:hover {
    border-color: var(--cpm-primary) !important;
}
.cpm-spec-item.cpm-spec-item--active {
    color: #fff !important;
    border-color: var(--cpm-primary) !important;
    background: var(--cpm-primary) !important;
    box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.3);
}

.cpm-spec-item__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--cpm-text);
}

.cpm-spec-item__price {
    font-size: 16px;
    font-weight: 700;
    color: var(--cpm-danger);
    margin-top: 4px;
}

/* ─── 购买区域 ─── */
.cpm-buy-section {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 20px 0;
    border-top: 1px solid var(--cpm-border);
    border-bottom: 1px solid var(--cpm-border);
    margin-bottom: 20px;
}

.cpm-buy-price {
    display: flex;
    align-items: baseline;
    gap: 2px;
    color: var(--cpm-danger);
}
.cpm-buy-price__label { font-size: 14px; color: var(--cpm-text-light); font-weight: 400; }
.cpm-buy-price__symbol { font-size: 18px; font-weight: 700; }
.cpm-buy-price__amount { font-size: 30px; font-weight: 700; }

.cpm-qty-control {
    display: flex;
    align-items: center;
    gap: 0;
}
.cpm-qty-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--cpm-border);
    background: var(--cpm-bg);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.cpm-qty-btn:hover { background: var(--cpm-bg-light); }
.cpm-qty-minus { border-radius: var(--cpm-radius) 0 0 var(--cpm-radius); }
.cpm-qty-plus  { border-radius: 0 var(--cpm-radius) var(--cpm-radius) 0; border-left: none; }
.cpm-qty-minus { border-right: none; }
.cpm-qty-input {
    width: 50px;
    height: 36px;
    border: 1px solid var(--cpm-border);
    text-align: center;
    font-size: 14px;
    -moz-appearance: textfield;
}
.cpm-qty-input::-webkit-inner-spin-button,
.cpm-qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ─── 扩展字段 ─── */
.cpm-extra-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 30px;
    margin-top: 16px;
    padding: 12px 0;
}
.cpm-extra-field-item { font-size: 13px; }
.cpm-extra-field-label { color: var(--cpm-text-light); }
.cpm-extra-field-value { color: var(--cpm-text); font-weight: 500; }

/* ─── 内容区块 ─── */
.cpm-section {
    margin-bottom: 40px;
}

.cpm-section-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--cpm-primary);
    color: var(--cpm-text);
}

/* ─── 特点卡片 ─── */
.cpm-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.cpm-feature-card {
    text-align: center;
    padding: 20px;
    background: var(--cpm-bg-light);
    border-radius: var(--cpm-radius);
    border: 1px solid var(--cpm-border);
}
.cpm-feature-card__icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
}
.cpm-feature-card__icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.cpm-feature-card__title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 6px;
    color: var(--cpm-text);
}
.cpm-feature-card__desc {
    font-size: 13px;
    color: var(--cpm-text-light);
    margin: 0;
    line-height: 1.5;
}

/* ─── 购买流程 ─── */
.cpm-steps-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.cpm-step-item {
    display: flex;
    gap: 16px;
    padding: 20px 0;
    border-bottom: 1px solid var(--cpm-border);
}
.cpm-step-item:last-child { border-bottom: none; }

.cpm-step-item__num {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cpm-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
}

.cpm-step-item__body { flex: 1; }

.cpm-step-item__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.cpm-step-item__icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}
.cpm-step-item__title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--cpm-text);
}
.cpm-step-item__desc {
    font-size: 14px;
    color: var(--cpm-text-light);
    margin: 0;
    line-height: 1.6;
}

/* ─── 商品详情富文本 ─── */
.cpm-detail-content {
    line-height: 1.8;
    color: var(--cpm-text);
    font-size: 15px;
}
.cpm-detail-content img { max-width: 100%; height: auto; }
.cpm-detail-content h2, .cpm-detail-content h3 { margin: 1.5em 0 0.8em; }
.cpm-detail-content table { border-collapse: collapse; }
.cpm-detail-content td, .cpm-detail-content th { border: 1px solid var(--cpm-border); padding: 8px 12px; }

/* ─── 购物车页面 ─── */
.cpm-cart-page { max-width: 1000px; margin: 0 auto; }

.cpm-cart-section { margin-bottom: 30px; }

.cpm-cart-section-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--cpm-primary);
}

.cpm-cart-table {
    width: 100%;
    border-collapse: collapse;
}
.cpm-cart-table th {
    text-align: left;
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--cpm-text-light);
    border-bottom: 2px solid var(--cpm-border);
}
.cpm-cart-table td {
    padding: 14px 8px;
    border-bottom: 1px solid var(--cpm-border);
    vertical-align: middle;
}
.cpm-cart-col-thumb { width: 70px; }
.cpm-cart-col-thumb img { width: 60px; height: 60px; object-fit: cover; border-radius: 4px; border: 1px solid var(--cpm-border); }
.cpm-cart-col-spec { width: 120px; font-size: 14px; color: var(--cpm-text-light); }
.cpm-cart-col-price { width: 100px; font-size: 14px; }
.cpm-cart-col-qty { width: 140px; }
.cpm-cart-col-subtotal { width: 100px; }
.cpm-cart-col-action { width: 50px; text-align: center; }

.cpm-cart-product-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--cpm-text);
    text-decoration: none;
}
.cpm-cart-product-title:hover { color: var(--cpm-primary); }

.cpm-cart-qty-control {
    display: flex;
    align-items: center;
}
.cpm-cart-qty-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--cpm-border);
    background: var(--cpm-bg);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cpm-cart-qty-btn:hover { background: var(--cpm-bg-light); }
.cpm-cart-qty-minus { border-radius: 4px 0 0 4px; border-right: none; }
.cpm-cart-qty-plus { border-radius: 0 4px 4px 0; border-left: none; }
.cpm-cart-qty-input {
    width: 44px;
    height: 30px;
    border: 1px solid var(--cpm-border);
    text-align: center;
    font-size: 13px;
    -moz-appearance: textfield;
}
.cpm-cart-qty-input::-webkit-inner-spin-button,
.cpm-cart-qty-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.cpm-cart-remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #d1d5db;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s;
}
.cpm-cart-remove-btn:hover { color: var(--cpm-danger); }

/* ─── 结算表单 ─── */
.cpm-checkout-section { margin-bottom: 30px; }

.cpm-checkout-form { max-width: 600px; }

.cpm-form-row {
    display: flex;
    gap: 16px;
}
.cpm-form-row .cpm-form-group { flex: 1; }

.cpm-form-group {
    margin-bottom: 16px;
}
.cpm-form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--cpm-text);
}
.cpm-form-group input,
.cpm-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--cpm-border);
    border-radius: var(--cpm-radius);
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.cpm-form-group input:focus,
.cpm-form-group textarea:focus {
    outline: none;
    border-color: var(--cpm-primary);
}
.cpm-required { color: var(--cpm-danger); }

/* ─── 订单汇总 ─── */
.cpm-cart-summary {
    background: var(--cpm-bg-light);
    border-radius: var(--cpm-radius);
    padding: 20px;
    margin-top: 20px;
}

.cpm-cart-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
    color: var(--cpm-text-light);
}
.cpm-cart-summary-row--total {
    border-top: 1px solid var(--cpm-border);
    margin-top: 8px;
    padding-top: 12px;
    font-size: 18px;
    font-weight: 700;
    color: var(--cpm-text);
}
.cpm-cart-total { color: var(--cpm-danger); font-size: 24px; }

/* ─── 空状态 ─── */
.cpm-empty-cart, .cpm-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--cpm-text-light);
}
.cpm-empty-cart .dashicons, .cpm-empty-state .dashicons {
    font-size: 64px;
    width: 64px;
    height: 64px;
    color: #d1d5db;
    margin-bottom: 16px;
}
.cpm-empty-cart h2 { margin: 0 0 8px; color: var(--cpm-text); }

/* ─── 成功提示 ─── */
.cpm-success-notice {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--cpm-radius);
    margin-bottom: 30px;
}
.cpm-success-notice .dashicons {
    font-size: 40px;
    width: 40px;
    height: 40px;
    color: var(--cpm-success);
    flex-shrink: 0;
}
.cpm-success-notice h3 { margin: 0 0 4px; color: #166534; }

/* ─── Toast 提示 ─── */
.cpm-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    padding: 12px 24px;
    border-radius: var(--cpm-radius);
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s;
    pointer-events: none;
}
.cpm-toast.cpm-toast--show {
    opacity: 1;
    transform: translateY(0);
}
.cpm-toast--success { background: var(--cpm-success); }
.cpm-toast--error { background: var(--cpm-danger); }
.cpm-toast--info { background: var(--cpm-primary); }

/* ─── 购物车角标 ─── */
.cpm-cart-badge {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cpm-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.2s;
    text-decoration: none;
}
.cpm-cart-badge:hover { transform: scale(1.1); }
.cpm-cart-badge__count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: var(--cpm-danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ─── 响应式 ─── */
@media (max-width: 768px) {
    .cpm-detail-header { flex-direction: column; }
    .cpm-detail-header__thumb { flex: 1; max-width: 100%; }
    .cpm-grid--products { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .cpm-form-row { flex-direction: column; }
    .cpm-cart-table { font-size: 13px; }
    .cpm-cart-col-spec, .cpm-cart-col-price { display: none; }
    .cpm-buy-section { gap: 12px; }
    .cpm-buy-price__amount { font-size: 24px; }
    .cpm-features-grid { grid-template-columns: 1fr 1fr; }
}
