/**
 * SD Tier Pricing - Frontend Styles
 * 基于原文档恢复 + 列表页适配
 */

/* ========================================
   容器样式
   ======================================== */
.sdtp-tier-pricing-container {
    margin: 0;
    padding: 0;
}

/* ========================================
   价格显示区域
   ======================================== */
.summary-inner .price,.product-wrapper .price {display:none;}
.product-wrapper .price {display:none !important; }
.summary-inner .sdtp-unit-price .price,.product-wrapper .sdtp-unit-price .price {
    display: inline-block !important; 
}

.sdtp-price-display {
    display: flex;
    flex-wrap: wrap;
    position: relative;
    font-weight: 600;
    margin-bottom: 8px;
}

.sdtp-price-per-unit {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    margin-top: 8px;
    align-items: center;
    line-height: 1;
}

.sdtp-save-amount,
.sdtp-original-total {
    flex-basis: 50%;
    font-size: 14px !important;
    line-height: 1.75;
    font-weight: 600;
    height: 30px;
}

.sdtp-save-amount {
    color: #e53e3e; /* 红色 */
    text-align: left;
}

.sdtp-original-total {
    color: #a0aec0; /* 灰色 */
    text-decoration: line-through;
    text-align: right;
}

.sdtp-unit-price {
    font-weight: 600;
    font-size: 14px !important;
   /*flex-basis:100%*/
    line-height: 14px !important;
    margin-top: 8px;
}

.sdtp-unit-price .price {
    font-weight: 600;
    font-size: 16px !important;
}

.sdtp-total-price {
    position: absolute;
    right: 0;
    bottom: 0;
    line-height: 1;
}

.sdtp-total-price .sdtp-total {
    font-size: 16px;
    line-height: 1;
    font-weight: 600;
}

/* ========================================
   阶梯价格列表
   ======================================== */
.sdtp-tier-list-wrapper {
    padding: 16px 0;
    margin: 8px 0;
}

.sdtp-tier-list {
    display: flex;
    flex-wrap: wrap;
    font-size: 12px;
    margin: 0 -4px;
    list-style: none !important;
    padding-left: 0 !important;
}

.sdtp-tier-item {
    flex-basis: calc(50% - 8px);
    border: 1px solid #e2e8f0;
    text-align: center;
    margin: 0 4px 8px;
    padding: 8px;
    position: relative;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
}

.sdtp-tier-item:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.sdtp-tier-item.active {
    background: #1a202c; /* dark */
    border-color: #1a202c;
    color: #fff;
}
.sdtp-tier-item.active span{color:#fff !important;}
.sdtp-tier-item span {
    display: block;
}

.sdtp-tier-item span.price,
.sdtp-tier-item .woocommerce-Price-amount,
.sdtp-tier-item .woocommerce-Price-currencySymbol,
.sdtp-tier-item bdi {
    display: inline !important;
}

/* 阶梯数量 */
.sdtp-tier-qty {
    font-size: 14px;
}

.sdtp-tier-total .price,
.sdtp-tier-total .woocommerce-Price-amount {
    display: inline;
    font-weight: 600;
    font-size: 14px !important;
}

/* 单价显示 */
.sdtp-tier-unit-price {
    font-size: 12px;
    color: #718096;
}

.sdtp-tier-item.active .sdtp-tier-unit-price {
    color: rgba(255, 255, 255, 0.7);
}

.sdtp-tier-unit-price .price,
.sdtp-tier-unit-price .woocommerce-Price-amount {
    display: inline;
    font-size: 10px !important;
    line-height: 1;
    font-weight: 400;
}

/* 折扣徽章 */
.sdtp-tier-discount {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e53e3e;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    color: #fff;
    font-weight: 700;
    font-size: 10px;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* ========================================
   分类页徽章 (Original style - kept for compatibility)
   ======================================== */
.sdtp-loop-badge {
    display: inline-block;
    background: #e53e3e;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 5px;
}


/* ========================================
   响应式设计
   ======================================== */
@media (min-width: 768px) {
    .sdtp-save-amount,
    .sdtp-original-total {
        font-size: 24px !important;
        margin-bottom: 5px;
    }
    
    .sdtp-footer-price-row,
    .sdtp-footer-quantity-row {
        max-width: 400px;
        margin: 0 auto;
    }
    
    .sdtp-footer-price-row {
        margin-bottom: 8px;
    }
}

/* ========================================
   列表页/分类页样式调整 (Loop) - 最终修正版
   (Grid 5列 + 显示底部价格)
   ======================================== */

/* 1. 容器重置 */
.sdtp-loop-wrapper .sdtp-tier-pricing-container {
    margin: 5px 0 0;
    padding: 0;
    width: 100%;
}
.sdtp-loop-wrapper{padding:0 15px;}
.sdtp-loop-wrapper .sdtp-tier-list-wrapper {
    padding: 0;
    margin-bottom: 0;
}

.sdtp-loop-wrapper .sdtp-unit-price .price {
    font-size: 14px !important;
}


/* 2. 列表布局：Grid 5列 */
.sdtp-loop-wrapper .sdtp-tier-list {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 3px !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

/* 3. 单个方块样式 */
.sdtp-loop-wrapper .sdtp-tier-item {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    
    width: 100% !important;
    min-width: 0 !important;
    min-height: 40px !important;
    
    margin: 0 !important;
    padding: 4px 1px !important;
    
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #fff;
    color: #374151;
    box-sizing: border-box;
    float: none;
}

.sdtp-loop-wrapper .sdtp-tier-item.active {
    background: #111827;
    border-color: #111827;
    color: #fff;
}

/* 4. 方块内文字 */
/* 上方的数字 */
.sdtp-loop-qty {
    font-size: 12px !important;
    font-weight: 400;
    line-height: 1.1 !important; /* 紧凑但分离的行高 */
    margin-bottom: 2px !important; /* 数字和下方单位的距离 */
    display: block;
}

.sdtp-loop-unit {
    font-size: 11px !important;
    font-weight: 400;
    line-height: 1 !important;
    display: block;
    opacity: 0.9;
    text-transform: lowercase; /* 比如 Cans 变成 cans */
}

.sdtp-loop-wrapper .sdtp-tier-item.active .sdtp-loop-unit {
    color: #e5e7eb;
}

/* 5. 价格显示区域 (本次修改重点：恢复显示并重新排版) */
.sdtp-loop-wrapper .sdtp-price-display {
    display: flex !important;        /* 恢复 flex 显示 */
    justify-content: space-between !important; /* 左右分布 */
    align-items: center !important;  /* 垂直居中 */
    flex-wrap: nowrap !important;
    margin-top: 15px !important;      /* 顶部间距 */
    padding-top: 6px !important;
    /* border-top: 1px dashed #e5e7eb;  加条虚线分隔，更清晰 */
    width: 100%;
}

/* 重置价格区域内部元素的宽度和边距 */
.sdtp-loop-wrapper .sdtp-price-per-unit,
.sdtp-loop-wrapper .sdtp-unit-price {
    margin: 0 !important;
    width: auto !important;
    line-height: 1.2 !important;
}

/* 左侧：单价 ($7.99 / cans) */
.sdtp-loop-wrapper .sdtp-unit-price {
    font-size: 12px !important;
    color: #4b5563;
    font-weight: 600;
}

/* 右侧：总价 ($7.99) */
.sdtp-loop-wrapper .sdtp-total-price {
    position: static !important; /* 清除绝对定位 */
    display: block !important;
}

.sdtp-loop-wrapper .sdtp-total-price .sdtp-total {
    font-size: 14px !important;
    font-weight: 700;
    color: #111827;
    line-height: 1 !important;
}

/* 列表页空间有限，强制隐藏“节省金额”和“原价划线”，防止挤乱布局 */
.sdtp-loop-wrapper .sdtp-save-amount,
.sdtp-loop-wrapper .sdtp-original-total {
    display: none !important;
}

/* 6. 仍然隐藏的其他非必要元素 */
.sdtp-loop-wrapper .sdtp-footer-add-to-cart-wrapper, /* 底部固定栏 */
.sdtp-loop-wrapper .sdtp-tier-discount,              /* 方块内的折扣标 */
.sdtp-loop-wrapper .sdtp-tier-total,                 /* 方块内的总价 */
.sdtp-loop-wrapper .sdtp-tier-unit-price {           /* 方块内的单价 */
    display: none !important;
}

@media screen and (max-width: 768px) {
.sdtp-loop-wrapper {padding: 0 5px;}
.wd-product.wd-hover-standard .wd-add-btn {
    padding: 0 5px 15px 5px;
}
}

/* ========================================
   WooCommerce 覆盖
   ======================================== */
.woocommerce .sdtp-tier-list {
    list-style: none !important;
    padding-left: 0 !important;
    margin: 0 -4px;
}

.woocommerce .sdtp-tier-item::before {
    display: none !important;
}

/* ========================================
   动画效果
   ======================================== */
.sdtp-tier-item {
    transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.sdtp-tier-item:active {
    transform: scale(0.98);
}

.sdtp-price-display .price,
.sdtp-total-price .price {
    transition: color 0.15s ease;
}

/* ========================================
   底部固定购买栏 (详情页) - 桌面端+移动端
   ======================================== */
.sdtp-footer-add-to-cart {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    background: rgba(255, 255, 255, 0.98);
    z-index: 999999;
    padding: 12px 16px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
    display: none;
    transform: translateY(0);
}

.sdtp-footer-add-to-cart.visible {
    display: block !important;
}

.sdtp-footer-price-row,
.sdtp-footer-quantity-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.sdtp-footer-quantity-row {
    margin-bottom: 0;
}

.sdtp-footer-price-row {
    font-size: 16px;
    font-weight: 600;
}

.sdtp-footer-price-each {
    color: #c2620f;
}

.sdtp-footer-price-total {
    color: #374151;
}

.sdtp-footer-quantity-row > div {
    flex: 1;
}

.sdtp-footer-select {
    font-size: 13px;
    border-radius: 8px;
    background-color: #1a202c;
    color: #fff;
    border-color: #1a202c;
    line-height: 1;
    height: 40px;
    width: 100%;
    padding: 8px 35px 8px 12px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 20px auto;
    cursor: pointer;
}

.sdtp-footer-add-btn {
    background: #06ba76;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    padding: 10px 16px;
    border-radius: 8px;
    width: 100%;
    height: 40px;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

.sdtp-footer-add-btn:hover {
    background: #059669;
}

.sdtp-footer-button .sdtp-footer-add-btn {
    background: #000;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    border-radius: .5rem;
    width: 100%;
    min-height: auto;
    height: 35.5px;
}
.sdtp-footer-quantity .sdtp-footer-select{
    font-size: 13px;
    border-radius: .5rem;
    line-height: 1;
    height: 35.5px;
    width: 100%;
}

.sdtp-footer-add-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* 桌面端布局优化 - 内容居中限制宽度 */
@media (min-width: 768px) {
    .sdtp-footer-add-to-cart {
        padding: 12px 20px;
    }
    
    .sdtp-footer-add-to-cart > .sdtp-footer-price-row,
    .sdtp-footer-add-to-cart > .sdtp-footer-quantity-row {
        max-width: 500px;
        margin-left: auto;
        margin-right: auto;
    }
    
    .sdtp-footer-add-to-cart > .sdtp-footer-price-row {
        margin-bottom: 10px;
    }
    
    .sdtp-footer-add-to-cart > .sdtp-footer-quantity-row {
        margin-bottom: 0;
    }
}