/**
 * WPAY-Pro 发卡前台样式
 */

.wppay-card-wrap {
    margin: 24px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: #1f2329;
}

.wppay-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.wppay-card-item {
    background: #fff;
    border: 1px solid #e5e6eb;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: box-shadow .2s ease, transform .2s ease;
}

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

.wppay-card-head {
    margin-bottom: 12px;
}

.wppay-card-name {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.4;
    color: #1f2329;
}

.wppay-card-price {
    font-size: 26px;
    font-weight: 700;
    color: #d63638;
    line-height: 1.1;
}

.wppay-card-price .unit {
    font-size: 15px;
    font-weight: 600;
    margin-right: 1px;
}

.wppay-card-desc {
    font-size: 13px;
    color: #646a73;
    line-height: 1.6;
    margin-bottom: 14px;
    flex: 1;
}

.wppay-card-desc p {
    margin: 0 0 6px;
}

.wppay-card-meta {
    margin-bottom: 14px;
    font-size: 12px;
}

.wppay-card-meta .stock {
    display: inline-block;
    padding: 2px 10px;
    background: #e8f5ee;
    color: #00a32a;
    border-radius: 10px;
}

.wppay-card-meta .stock.out {
    background: #f5f5f5;
    color: #999;
}

.wppay-card-foot {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wppay-card-buy {
    width: 100%;
    padding: 11px 0;
    border: none;
    border-radius: 6px;
    background: #d63638;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s ease;
}

.wppay-card-buy:hover:not(.disabled) {
    background: #b32b2d;
}

.wppay-card-buy.disabled,
.wppay-card-buy[disabled] {
    background: #c9cdd4;
    cursor: not-allowed;
}

.wppay-card-tip {
    font-size: 11px;
    color: #999;
    text-align: center;
}

.wppay-card-empty {
    padding: 40px;
    text-align: center;
    color: #999;
    background: #f7f8fa;
    border-radius: 8px;
}

.wppay-card-pick-link {
    margin-top: 20px;
    text-align: center;
    font-size: 14px;
    color: #646a73;
}

.wppay-card-pick-link a {
    color: #2271b1;
    text-decoration: none;
    border-bottom: 1px dashed #2271b1;
}

/* ============ 取卡面板 ============ */
.wppay-pick-panel {
    margin-top: 20px;
    padding: 22px;
    background: #f7f8fa;
    border: 1px solid #e5e6eb;
    border-radius: 10px;
}

.wppay-pick-panel h3 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
}

.wppay-pick-desc {
    font-size: 13px;
    color: #646a73;
    margin: 0 0 16px;
}

.wppay-pick-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.wppay-pick-form input {
    flex: 1;
    min-width: 160px;
    padding: 10px 12px;
    border: 1px solid #dcdfe6;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}

.wppay-pick-form input:focus {
    border-color: #d63638;
}

.wppay-pick-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    background: #d63638;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.wppay-pick-btn:hover {
    background: #b32b2d;
}

.wppay-pick-result {
    margin-top: 16px;
    font-size: 14px;
}

.wppay-pick-msg {
    padding: 12px 16px;
    border-radius: 6px;
    background: #fff8e6;
    border: 1px solid #ffe58f;
    color: #8c6d1f;
    font-size: 13px;
}

.wppay-pick-msg.error {
    background: #fff1f0;
    border-color: #ffccc7;
    color: #cf1322;
}

/* ============ 弹窗 ============ */
.wppay-card-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wppay-card-modal-box {
    position: relative;
    background: #fff;
    border-radius: 12px;
    padding: 30px 28px 24px;
    width: 380px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
}

.wppay-card-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 24px;
    line-height: 1;
    color: #c9cdd4;
    cursor: pointer;
}

.wppay-card-modal-close:hover {
    color: #646a73;
}

.wppay-card-modal-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #1f2329;
}

.wppay-card-modal-price {
    font-size: 28px;
    font-weight: 700;
    color: #d63638;
    margin-bottom: 20px;
}

.wppay-card-modal-price .unit {
    font-size: 16px;
}

.wppay-card-channel {
    display: block;
    width: 100%;
    padding: 13px 0;
    margin-bottom: 12px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    text-align: center;
}

.wppay-card-channel.alipay {
    background: #1677ff;
}

.wppay-card-channel.wxpay {
    background: #07c160;
}

.wppay-card-channel:hover {
    opacity: .9;
}

.wppay-card-modal-qr {
    text-align: center;
}

.wppay-card-modal-qr img {
    width: 200px;
    height: 200px;
    display: block;
    margin: 0 auto 14px;
    border: 1px solid #eee;
    border-radius: 8px;
}

.wppay-card-modal-tip {
    font-size: 12px;
    color: #999;
    text-align: center;
    margin-top: 10px;
    line-height: 1.6;
}

.wppay-card-order-box {
    background: #f7f8fa;
    border-radius: 6px;
    padding: 12px 14px;
    margin: 14px 0;
    font-size: 12px;
    color: #646a73;
    line-height: 1.8;
    word-break: break-all;
}

.wppay-card-order-box code {
    font-family: Consolas, Monaco, monospace;
    color: #d63638;
    background: #fff;
    padding: 1px 6px;
    border-radius: 3px;
}

.wppay-card-loading {
    text-align: center;
    padding: 30px 0;
    color: #646a73;
    font-size: 14px;
}

.wppay-card-success-icon {
    font-size: 40px;
    text-align: center;
    margin-bottom: 10px;
}

/* ============ 下单邮箱输入 ============ */
.wppay-buy-field {
    margin: 0 0 6px;
}

.wppay-buy-field label {
    display: block;
    font-size: 13px;
    color: #646a73;
    margin-bottom: 8px;
}

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

.wppay-buy-email {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 12px;
    border: 1px solid #dcdfe6;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.wppay-buy-email:focus {
    border-color: #d63638;
}

.wppay-buy-hint {
    font-size: 11px;
    color: #999;
    margin: 6px 0 16px;
}

.wppay-buy-error {
    margin: 10px 0 0;
    padding: 8px 12px;
    font-size: 12px;
    background: #fff1f0;
    border: 1px solid #ffccc7;
    color: #cf1322;
    border-radius: 5px;
}

/* ============ 订单查询结果列表 ============ */
.wppay-order-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wppay-order-list-head {
    font-size: 13px;
    color: #646a73;
}

.wppay-order-item {
    background: #fff;
    border: 1px solid #e5e6eb;
    border-radius: 8px;
    padding: 14px 16px;
}

.wppay-order-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.wppay-order-goods {
    font-size: 15px;
    font-weight: 600;
    color: #1f2329;
}

.wppay-order-price {
    font-size: 16px;
    font-weight: 700;
    color: #d63638;
    flex-shrink: 0;
}

.wppay-order-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    font-size: 12px;
    color: #646a73;
    align-items: center;
    margin-bottom: 10px;
}

.wppay-order-meta code {
    font-family: Consolas, Monaco, monospace;
    background: #f7f8fa;
    padding: 1px 6px;
    border-radius: 3px;
    color: #1f2329;
}

.wppay-order-meta .status {
    padding: 1px 8px;
    border-radius: 9px;
    font-size: 11px;
}

.wppay-order-meta .status.ok {
    background: #e8f5ee;
    color: #00a32a;
}

.wppay-order-meta .status.wait {
    background: #fff8e6;
    color: #8c6d1f;
}

.wppay-order-card {
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 12px;
}

.wppay-order-card .row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.wppay-order-card .row:last-child {
    margin-bottom: 0;
}

.wppay-order-card .label {
    width: 56px;
    flex-shrink: 0;
    color: #646a73;
    font-size: 12px;
    line-height: 26px;
}

/* 长卡密不截断，自动换行完整展示 */
.wppay-order-card .val,
.wppay-order-card .extra {
    flex: 1;
    min-width: 120px;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    background: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    word-break: break-all;
    white-space: pre-wrap;
    line-height: 1.6;
}

.wppay-order-notice {
    font-size: 12px;
    color: #8c6d1f;
    background: #fff8e6;
    border: 1px solid #ffe58f;
    padding: 8px 12px;
    border-radius: 5px;
}

/* 通用复制按钮（订单列表 / 取卡卡片共用） */
.copy {
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid #dcdfe6;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    color: #646a73;
    flex-shrink: 0;
    line-height: 1.6;
}

.copy:hover {
    border-color: #d63638;
    color: #d63638;
}

/* ============ 订单类型标记（卡密 / 实物） ============ */
.wppay-order-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 400;
    color: #2271b1;
    background: #e8f2fb;
    border-radius: 9px;
    vertical-align: middle;
}

.wppay-order-tag.physical {
    color: #b35000;
    background: #fef3e6;
}

/* ============ 实物订单：商品明细 ============ */
.wppay-order-items {
    margin-top: 8px;
    border-top: 1px dashed #ebeef5;
    padding-top: 8px;
}

.wppay-order-itemrow {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    font-size: 13px;
}

.wppay-order-itemname {
    flex: 1;
    min-width: 0;
    color: #1f2329;
    word-break: break-all;
}

.wppay-order-itemqty {
    color: #646a73;
    flex-shrink: 0;
}

.wppay-order-itemsub {
    width: 80px;
    text-align: right;
    color: #d63638;
    font-weight: 600;
    flex-shrink: 0;
}

/* ============ 实物订单：物流信息 ============ */
.wppay-order-ship {
    margin-top: 8px;
    padding: 10px 12px;
    font-size: 13px;
    color: #1f2329;
    background: #f0f9f2;
    border: 1px solid #c6e5cc;
    border-radius: 5px;
    line-height: 1.8;
}

.wppay-order-ship code {
    background: #fff;
    padding: 1px 6px;
    border-radius: 3px;
    word-break: break-all;
}

.wppay-order-shiptime {
    font-size: 12px;
    color: #8a8f99;
}

@media (max-width: 600px) {
    .wppay-card-grid {
        grid-template-columns: 1fr;
    }
    .wppay-pick-form {
        flex-direction: column;
    }
    .wppay-pick-form input,
    .wppay-pick-btn {
        width: 100%;
    }
    .wppay-order-head {
        flex-direction: column;
        align-items: flex-start;
    }
    .wppay-order-card .label {
        width: auto;
        line-height: 1.6;
    }
    .wppay-order-itemrow {
        flex-wrap: wrap;
    }
    .wppay-order-itemsub {
        width: auto;
        margin-left: auto;
    }
}

/* ============ 发卡商品：购物车按钮 / 多张卡密 ============ */
.wppay-card-actions {
    margin: 0 0 10px;
}

.wppay-card-actions .wppay-qty {
    height: 34px;
}

.wppay-card-actions .wppay-qty button,
.wppay-card-actions .wppay-qty input {
    height: 32px;
}

.wppay-card-add {
    flex: 1;
    min-width: 84px;
    height: 34px;
    padding: 0 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid #d63638;
    color: #d63638;
    background: #fff;
    transition: background .2s;
    white-space: nowrap;
}

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

.wppay-card-foot {
    margin-bottom: 8px;
}

.wppay-card-tip {
    display: block;
}

.wppay-order-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wppay-order-cardname {
    font-size: 13px;
    font-weight: 600;
    color: #1f2329;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px dashed #ebeef5;
}

/* ============ 商品主图 ============ */
.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-card-item {
    overflow: hidden;
}

/* ============ 文章正文中的并排显示 ============ */
/*
 * 块级插入短代码时，WordPress 会把 [wppay_card] 包进 <p>，
 * 导致商品网格被当作行内容、卡片挤成一行。
 * 这里把含商品网格的容器强制恢复为块级并占满宽度。
 */
.wppay-card-wrap:has(.wppay-card-grid),
.wppay-shop-wrap:has(.wppay-shop-grid) {
    display: block;
    width: 100%;
    clear: both;
}

p:has(> .wppay-card-wrap),
p:has(> .wppay-shop-wrap) {
    display: block;
    margin: 0;
    padding: 0;
}

.wppay-card-wrap:has(.wppay-card-grid) .wppay-card-grid,
.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-card-wrap[data-cols="1"] .wppay-card-grid,
.wppay-shop-wrap[data-cols="1"] .wppay-shop-grid {
    grid-template-columns: minmax(0, 1fr) !important;
}

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

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