/**
 * WPAY-Pro 实物商品 / 购物车样式
 */

/* ============ 公共容器 ============ */
.wppay-shop-wrap {
    box-sizing: border-box;
    color: #1f2329;
    font-size: 14px;
    line-height: 1.6;
}

.wppay-shop-wrap *,
.wppay-shop-wrap *::before,
.wppay-shop-wrap *::after {
    box-sizing: border-box;
}

/* ============ 工具栏 ============ */
.wppay-shop-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.wppay-shop-title {
    font-size: 18px;
    font-weight: 700;
}

.wppay-shop-cart-link {
    color: #d63638;
    text-decoration: none;
    font-size: 14px;
    border: 1px solid #f0c8c8;
    background: #fff5f5;
    padding: 6px 14px;
    border-radius: 18px;
}

.wppay-shop-cart-link:hover {
    background: #ffecec;
}

.wppay-shop-cart-count {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    padding: 0 4px;
    margin-left: 2px;
    font-size: 11px;
    color: #fff;
    background: #d63638;
    border-radius: 9px;
}

/* ============ 商品网格 ============ */
.wppay-shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    align-items: start;
}

.wppay-shop-item {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #ebeef5;
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow .2s, transform .2s;
}

.wppay-shop-item:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
    transform: translateY(-2px);
}

.wppay-shop-thumb {
    position: relative;
    width: 100%;
    padding-top: 62%;
    background: #f7f8fa;
    overflow: hidden;
}

.wppay-shop-thumb img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wppay-shop-thumb-ph {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    color: #b8bcc4;
    letter-spacing: 2px;
}

.wppay-shop-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 10px;
    font-size: 12px;
    color: #fff;
    background: rgba(0, 0, 0, .55);
    border-radius: 10px;
}

.wppay-shop-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px 14px 14px;
}

.wppay-shop-name {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    color: #1f2329;
}

.wppay-shop-desc {
    margin-bottom: 8px;
    font-size: 12px;
    color: #8a8f99;
    max-height: 54px;
    overflow: hidden;
}

.wppay-shop-desc p {
    margin: 0 0 4px;
}

/* ============ 商品详情（经典编辑器富文本展开区） ============ */
.wppay-shop-detail-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0 0 8px;
    padding: 2px 10px;
    font-size: 12px;
    line-height: 20px;
    color: #2271b1;
    background: #f4f8fd;
    border: 1px solid #d3e2f4;
    border-radius: 12px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.wppay-shop-detail-toggle:hover {
    background: #e9f2fc;
}

.wppay-shop-detail-toggle.active {
    color: #d63638;
    background: #fff5f5;
    border-color: #f0c8c8;
}

.wppay-shop-detail-toggle .arrow {
    font-size: 10px;
    line-height: 1;
}

.wppay-shop-detail {
    display: none;
    margin: 0 0 10px;
    padding: 12px 14px;
    border: 1px solid #eceef1;
    border-radius: 6px;
    background: #fafbfc;
    font-size: 13px;
    line-height: 1.7;
    color: #4a5260;
    max-height: 380px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.wppay-shop-detail.show {
    display: block;
}

.wppay-shop-detail-inner > *:first-child {
    margin-top: 0;
}

.wppay-shop-detail-inner > *:last-child {
    margin-bottom: 0;
}

.wppay-shop-detail-inner p {
    margin: 0 0 8px;
}

.wppay-shop-detail-inner h1,
.wppay-shop-detail-inner h2,
.wppay-shop-detail-inner h3,
.wppay-shop-detail-inner h4,
.wppay-shop-detail-inner h5,
.wppay-shop-detail-inner h6 {
    margin: 12px 0 6px;
    font-weight: 600;
    line-height: 1.4;
    color: #1f2329;
}

.wppay-shop-detail-inner h1 { font-size: 17px; }
.wppay-shop-detail-inner h2 { font-size: 16px; }
.wppay-shop-detail-inner h3 { font-size: 15px; }
.wppay-shop-detail-inner h4,
.wppay-shop-detail-inner h5,
.wppay-shop-detail-inner h6 { font-size: 14px; }

.wppay-shop-detail-inner img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 8px auto;
    border-radius: 4px;
}

.wppay-shop-detail-inner ul,
.wppay-shop-detail-inner ol {
    margin: 0 0 8px;
    padding-left: 22px;
}

.wppay-shop-detail-inner li {
    margin: 2px 0;
}

.wppay-shop-detail-inner a {
    color: #2271b1;
    text-decoration: underline;
}

.wppay-shop-detail-inner blockquote {
    margin: 8px 0;
    padding: 8px 12px;
    border-left: 3px solid #d3e2f4;
    background: #fff;
    color: #6b7280;
}

.wppay-shop-detail-inner table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
}

.wppay-shop-detail-inner th,
.wppay-shop-detail-inner td {
    border: 1px solid #e5e7eb;
    padding: 6px 8px;
    font-size: 12px;
    text-align: left;
}

.wppay-shop-detail-inner th {
    background: #f2f4f7;
    font-weight: 600;
}

.wppay-shop-detail-inner hr {
    border: 0;
    border-top: 1px dashed #e5e7eb;
    margin: 10px 0;
}

.wppay-shop-price {
    margin-top: auto;
    font-size: 20px;
    font-weight: 700;
    color: #d63638;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.wppay-shop-price .unit {
    font-size: 13px;
    font-weight: 400;
}

.wppay-shop-stock {
    font-size: 12px;
    font-weight: 400;
    color: #8a8f99;
}

.wppay-shop-stock.out {
    color: #d63638;
}

/* ============ 数量控件 ============ */
.wppay-qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid #dcdfe6;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.wppay-qty button {
    width: 30px;
    height: 30px;
    line-height: 1;
    border: 0;
    background: #f7f8fa;
    color: #4e5969;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
}

.wppay-qty button:hover {
    background: #eef0f3;
    color: #d63638;
}

.wppay-qty input {
    width: 46px;
    height: 30px;
    border: 0;
    border-left: 1px solid #eef0f3;
    border-right: 1px solid #eef0f3;
    text-align: center;
    font-size: 14px;
    color: #1f2329;
    background: #fff;
    padding: 0;
    outline: none;
}

/* ============ 商品操作区 ============ */
.wppay-shop-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.wppay-shop-add,
.wppay-shop-buy {
    flex: 1;
    min-width: 78px;
    height: 34px;
    padding: 0 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid #d63638;
    transition: opacity .2s;
    white-space: nowrap;
}

.wppay-shop-add {
    color: #d63638;
    background: #fff;
}

.wppay-shop-add:hover {
    background: #fff5f5;
}

.wppay-shop-buy {
    color: #fff;
    background: #d63638;
}

.wppay-shop-buy:hover {
    opacity: .88;
}

.wppay-shop-add[disabled] {
    color: #b8bcc4;
    background: #f7f8fa;
    border-color: #e5e6eb;
    cursor: not-allowed;
}

.wppay-shop-empty,
.wppay-cart-empty {
    padding: 40px 16px;
    text-align: center;
    color: #8a8f99;
    background: #fff;
    border: 1px dashed #dcdfe6;
    border-radius: 10px;
}

.wppay-shop-foottip {
    margin-top: 14px;
    font-size: 12px;
    color: #a0a5ad;
    text-align: center;
}

/* ============ 购物车 ============ */
.wppay-cart-box {
    background: #fff;
    border: 1px solid #ebeef5;
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 18px;
}

.wppay-cart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f2f5;
    margin-bottom: 6px;
}

.wppay-cart-head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.wppay-cart-clear {
    font-size: 12px;
    color: #8a8f99;
    text-decoration: none;
}

.wppay-cart-clear:hover {
    color: #d63638;
}

.wppay-cart-thead,
.wppay-cart-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wppay-cart-thead {
    padding: 10px 0;
    font-size: 12px;
    color: #8a8f99;
    border-bottom: 1px solid #f0f2f5;
}

.wppay-cart-row {
    padding: 14px 0;
    border-bottom: 1px solid #f7f8fa;
}

.wppay-cart-thead .col-goods,
.wppay-cart-goods {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wppay-cart-thead .col-price,
.wppay-cart-price {
    width: 90px;
    text-align: center;
    flex-shrink: 0;
}

.wppay-cart-thead .col-qty,
.wppay-cart-qtybox {
    width: 130px;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}

.wppay-cart-thead .col-sub,
.wppay-cart-subtotal {
    width: 100px;
    text-align: right;
    flex-shrink: 0;
    font-weight: 600;
    color: #d63638;
}

.wppay-cart-thead .col-op,
.wppay-cart-del {
    width: 60px;
    text-align: right;
    flex-shrink: 0;
}

.wppay-cart-thumb {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 6px;
    background: #f7f8fa;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b8bcc4;
    font-size: 12px;
}

.wppay-cart-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wppay-cart-name {
    min-width: 0;
    font-size: 14px;
    color: #1f2329;
    word-break: break-all;
}

.wppay-cart-stock {
    font-size: 12px;
    color: #a0a5ad;
}

.wppay-cart-del a {
    font-size: 12px;
    color: #8a8f99;
    text-decoration: none;
}

.wppay-cart-del a:hover {
    color: #d63638;
}

.wppay-cart-foot {
    margin-top: 12px;
}

.wppay-shop-continue {
    font-size: 13px;
    color: #2271b1;
    text-decoration: none;
}

/* ============ 结算 ============ */
.wppay-checkout-box {
    background: #fff;
    border: 1px solid #ebeef5;
    border-radius: 10px;
    padding: 16px 18px 20px;
}

.wppay-checkout-box h3 {
    margin: 0 0 14px;
    font-size: 16px;
    font-weight: 600;
}

.wppay-checkout-field {
    margin-bottom: 14px;
}

.wppay-checkout-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #4e5969;
    font-weight: 500;
}

.wppay-checkout-field .req {
    color: #d63638;
}

.wppay-checkout-field input,
.wppay-checkout-field textarea,
.wppay-checkout-field select {
    width: 100%;
    max-width: 520px;
    padding: 9px 12px;
    font-size: 14px;
    color: #1f2329;
    background: #fff;
    border: 1px solid #dcdfe6;
    border-radius: 6px;
    outline: none;
    transition: border-color .2s;
    box-sizing: border-box;
}

.wppay-checkout-field textarea {
    resize: vertical;
    line-height: 1.5;
}

.wppay-checkout-field input:focus,
.wppay-checkout-field textarea:focus,
.wppay-checkout-field select:focus {
    border-color: #d63638;
}

.wppay-field-hint {
    margin: 4px 0 0;
    font-size: 12px;
    color: #a0a5ad;
}

.wppay-checkout-error {
    margin: 4px 0 12px;
    padding: 10px 14px;
    font-size: 13px;
    color: #d63638;
    background: #fff5f5;
    border: 1px solid #f7d4d4;
    border-radius: 6px;
}

.wppay-checkout-total {
    margin: 6px 0 14px;
    padding-top: 14px;
    border-top: 1px solid #f0f2f5;
    font-size: 14px;
    color: #4e5969;
}

.wppay-checkout-total strong {
    font-size: 22px;
    color: #d63638;
}

.wppay-checkout-count {
    margin-left: 6px;
    font-size: 12px;
    color: #8a8f99;
}

.wppay-checkout-submit {
    display: inline-block;
    min-width: 200px;
    height: 44px;
    padding: 0 26px;
    font-size: 15px;
    color: #fff;
    background: #d63638;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity .2s;
}

.wppay-checkout-submit:hover {
    opacity: .9;
}

.wppay-checkout-submit[disabled] {
    background: #d9b3b3;
    cursor: not-allowed;
}

.wppay-checkout-tip {
    margin: 10px 0 0;
    font-size: 12px;
    color: #a0a5ad;
}

/* ============ 轻提示 ============ */
.wppay-shop-toast {
    position: fixed;
    left: 50%;
    bottom: 60px;
    transform: translateX(-50%);
    z-index: 999999;
    display: none;
    padding: 10px 20px;
    font-size: 13px;
    color: #fff;
    background: rgba(31, 35, 41, .88);
    border-radius: 20px;
    max-width: 80vw;
    text-align: center;
}

/* ============ 响应式 ============ */
@media (max-width: 640px) {
    .wppay-shop-grid {
        grid-template-columns: 1fr;
    }

    .wppay-cart-thead {
        display: none;
    }

    .wppay-cart-row {
        flex-wrap: wrap;
        gap: 6px 10px;
    }

    .wppay-cart-goods {
        flex: 1 1 100%;
    }

    .wppay-cart-price,
    .wppay-cart-qtybox,
    .wppay-cart-subtotal,
    .wppay-cart-del {
        width: auto;
        flex: 1;
        text-align: left;
    }

    .wppay-cart-del {
        text-align: right;
    }

    .wppay-checkout-field input,
    .wppay-checkout-field textarea,
    .wppay-checkout-field select {
        max-width: 100%;
    }

    .wppay-checkout-submit {
        width: 100%;
    }
}

/* ============ 主图（发卡商品卡片） ============ */
.wppay-card-thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f7f8fa;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

.wppay-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ============ 文章正文中的并排显示（实物商品） ============ */
.wppay-shop-wrap:has(.wppay-shop-grid) {
    display: block;
    width: 100%;
    clear: both;
}

.wppay-shop-wrap:has(.wppay-shop-grid) .wppay-shop-grid {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(var(--wppay-cols, 3), minmax(0, 1fr));
}

/* 单列：设置里填 1 时（data-cols="1"）自适应单列堆叠 */
.wppay-shop-wrap[data-cols="1"] .wppay-shop-grid {
    grid-template-columns: minmax(0, 1fr) !important;
}

@media (max-width: 900px) {
    .wppay-shop-wrap:has(.wppay-shop-grid) .wppay-shop-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .wppay-shop-wrap:has(.wppay-shop-grid) .wppay-shop-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}
