/**
 * 产品选择器样式文件 - 清理重构版
 * 
 * @version 3.0.0
 * @description 移除所有重复定义和冗余代码
 */

/* ==================================================
   基础变量定义
   ================================================== */
:root {
    --wscm-theme-color: #667eea;
    --wscm-border-radius: 8px;
    --wscm-card-gap: 12px;
    --wscm-transition: all 0.3s ease;
}

/* ==================================================
   预防界面闪现
   ================================================== */
.zib-widget.pay-box:not(.wscm-processed):not(.wscm-keep-native):not(.wscm-replaced) {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.zib-widget.pay-box.wscm-processed,
.zib-widget.pay-box.wscm-keep-native,
.zib-widget.pay-box.wscm-replaced {
    opacity: 1;
}

/* ==================================================
   产品选择器容器
   ================================================== */
.wscm-product-cards {
    margin: 22px 0;
}

/* ==================================================
   标题样式（统一定义，无阴影）
   ================================================== */
.wscm-cards-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 17px;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--wscm-border-radius);
    position: relative;
    overflow: hidden;
    transition: var(--wscm-transition);
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    /* 无阴影 */
    box-shadow: none;
    text-shadow: none;
}

.wscm-cards-title:hover {
    transform: translateY(-1px);
}

.wscm-cards-title i {
    margin-right: 8px;
    font-size: 16px;
}

/* 标题动画效果 */
.wscm-cards-title::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: wscm-title-shine 3s infinite;
    pointer-events: none;
}

@keyframes wscm-title-shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ==================================================
   主题预设（无阴影）
   ================================================== */
.wscm-cards-title.theme-classic-blue {
    background: linear-gradient(135deg, #1da1f2 0%, #0d8bd9 100%);
}

.wscm-cards-title.theme-purple-dream {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.wscm-cards-title.theme-fresh-green {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.wscm-cards-title.theme-vibrant-orange {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
}

.wscm-cards-title.theme-passionate-red {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.wscm-cards-title.theme-minimal-gray {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #495057;
}

.wscm-cards-title.theme-dark-professional {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

.wscm-cards-title.theme-rainbow-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #f5576c 75%, #4facfe 100%);
}

/* ==================================================
   产品卡片网格
   ================================================== */
.wscm-cards-grid {
    display: flex;
    flex-direction: column;
    gap: var(--wscm-card-gap);
}

/* ==================================================
   产品卡片（无阴影）
   ================================================== */
.wscm-product-card {
    position: relative;
    padding: 14px;
    background: linear-gradient(135deg, #eef4ff 0%, #f5eeff 100%);
    border: 2px solid #e3e8f7;
    border-radius: var(--wscm-border-radius);
    cursor: pointer;
    transition: var(--wscm-transition);
    min-height: 90px;
    display: flex;
    flex-direction: column;
    /* 无阴影 */
    box-shadow: none;
}

/* 只在支持hover的设备上启用hover效果（排除触摸设备） */
@media (hover: hover) {
    .wscm-product-card:hover:not(.purchased) {
        transform: translateY(-2px);
        border-color: var(--theme-color, #667eea);
    }
    
    /* 已购买卡片的悬停效果 - 提示可点击查看订单 */
    .wscm-product-card.purchased:hover {
        transform: translateY(-2px);
        border-color: var(--success-color, #28a745);
        box-shadow: 0 4px 12px rgba(40, 167, 69, 0.15);
    }
}

.wscm-product-card.selected {
    border-color: var(--theme-color, #1da1f2);
    background: linear-gradient(135deg, 
        rgba(29, 161, 242, 0.06) 0%, 
        rgba(29, 161, 242, 0.03) 100%);
}

.wscm-product-card.recommended {
    border-color: #ffc107;
}

/* 已购买状态 */
.wscm-product-card.purchased {
    opacity: 0.85;
    background: var(--muted-bg-color, #f8f9fa);
    border-color: var(--main-border-color, #dee2e6);
    cursor: pointer; /* 改为pointer表示可点击 */
    /* pointer-events: none; 移除此行以允许点击事件 */
}

/* ==================================================
   卡片内容元素
   ================================================== */
.wscm-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.wscm-product-name {
    font-size: 15px;
    font-weight: 700;
    color: #ff6b6b;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.wscm-card-price {
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: 16px;
    font-weight: 700;
    color: #e74c3c;
    white-space: nowrap;
}

.wscm-card-price .currency {
    margin-right: 2px; /* ¥符号与金额之间的间隔 */
}

/* 已购买商品的价格添加删除线 */
.wscm-product-card.purchased .wscm-card-price {
    text-decoration: line-through;
    opacity: 0.9;
}

.wscm-card-desc {
    font-size: 15px;
    color: #6c757d;
    line-height: 1.5;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    margin-right: 80px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 徽章 */
.wscm-recommend-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    color: #fff;
    padding: 3px 10px;
    font-size: 11px;
    border-radius: 0 var(--wscm-border-radius) 0 12px;
    font-weight: 600;
}

.wscm-purchased-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--green-color, #28a745);
    color: white;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
}

/* 悬停时提示可点击 */
.wscm-product-card.purchased:hover .wscm-purchased-badge {
    background: var(--success-color, #218838);
    transform: scale(1.05);
}

/* 添加点击提示 */
.wscm-purchased-badge::after {
    content: ' →';
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wscm-product-card.purchased:hover .wscm-purchased-badge::after {
    opacity: 1;
}

.wscm-card-indicator {
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-size: 21px;
    color: var(--theme-color, #1da1f2);
    opacity: 0;
    transform: scale(0.8);
    transition: var(--wscm-transition);
}

.wscm-product-card.selected .wscm-card-indicator {
    opacity: 1;
    transform: scale(1);
}

/* ==================================================
   支付按钮
   ================================================== */
.wscm-buy-section {
    margin-top: 15px;
    text-align: center;
}

.wscm-custom-pay-btn {
    display: inline-block;
    min-width: 140px;
    padding: 10px 30px;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
    letter-spacing: 0.3px;
    white-space: nowrap;
    transition: var(--wscm-transition);
}

/* ==================================================
   暗黑模式
   ================================================== */
@media (prefers-color-scheme: dark) {
    /* 不覆盖标题样式，让主题类保持自己的颜色 */
    
    .wscm-product-card {
        background: var(--body-bg-color, #2c3e50);
        border-color: var(--border-color, #34495e);
    }
    
    /* 暗黑模式下选中状态 */
    .wscm-product-card.selected {
        border-color: var(--theme-color, #1da1f2) !important;
        background: linear-gradient(135deg, 
            rgba(29, 161, 242, 0.08) 0%, 
            rgba(29, 161, 242, 0.04) 100%);
    }
    
    /* 暗黑模式下hover状态 - 只在支持hover的设备上启用 */
    @media (hover: hover) {
        .wscm-product-card:hover:not(.purchased) {
            border-color: var(--theme-color, #667eea);
        }
    }
    
    /* 商品名称已经默认是红色，无需重复定义 */
    
    .wscm-card-desc {
        color: var(--muted-color, #bdc3c7);
    }
}

/* 特定主题在暗黑模式下的适配 */
body.dark-theme .wscm-cards-title.theme-minimal-gray,
.dark-theme .wscm-cards-title.theme-minimal-gray {
    /* 灰色主题在暗黑模式下调整为深色 */
    background: linear-gradient(135deg, #495057 0%, #343a40 100%);
    color: #f8f9fa;
}

body.dark-theme .wscm-product-card,
.dark-theme .wscm-product-card {
    background: var(--body-bg-color, #2c3e50);
    border-color: var(--border-color, #34495e);
}

/* 商品名称已经默认是红色，无需重复定义 */

body.dark-theme .wscm-card-desc,
.dark-theme .wscm-card-desc {
    color: var(--muted-color, #bdc3c7);
}

/* 暗黑模式下已购买产品的差异化显示 */
body.dark-theme .wscm-product-card.purchased,
.dark-theme .wscm-product-card.purchased {
    background: rgba(76, 175, 80, 0.08);  /* 淡绿色背景，与"已购买"标签呼应 */
    border-color: rgba(76, 175, 80, 0.15); /* 淡绿色边框 */
}

/* 暗黑模式下选中状态的样式 - 确保边框显示 */
body.dark-theme .wscm-product-card.selected,
.dark-theme .wscm-product-card.selected {
    border-color: var(--theme-color, #1da1f2) !important;  /* 保持选中的蓝色边框 */
    background: linear-gradient(135deg, 
        rgba(29, 161, 242, 0.08) 0%, 
        rgba(29, 161, 242, 0.04) 100%);
}

/* 暗黑模式下hover状态 - 只在支持hover的设备上启用 */
@media (hover: hover) {
    body.dark-theme .wscm-product-card:hover:not(.purchased),
    .dark-theme .wscm-product-card:hover:not(.purchased) {
        border-color: var(--theme-color, #667eea);
    }
}

/* 移动端暗黑模式下的卡片样式覆盖 */
@media (max-width: 768px) {
    body.dark-theme .wscm-product-card,
    .dark-theme .wscm-product-card {
        background: var(--body-bg-color, #2c3e50);
        border-color: var(--border-color, #34495e);
    }
    
    /* 移动端暗黑模式下选中状态 */
    body.dark-theme .wscm-product-card.selected,
    .dark-theme .wscm-product-card.selected {
        border-color: var(--theme-color, #1da1f2) !important;
        background: linear-gradient(135deg, 
            rgba(29, 161, 242, 0.08) 0%, 
            rgba(29, 161, 242, 0.04) 100%);
    }
}

@media (max-width: 480px) {
    body.dark-theme .wscm-product-card,
    .dark-theme .wscm-product-card {
        background: var(--body-bg-color, #2c3e50);
        border-color: var(--border-color, #34495e);
    }
    
    /* 移动端暗黑模式下选中状态 */
    body.dark-theme .wscm-product-card.selected,
    .dark-theme .wscm-product-card.selected {
        border-color: var(--theme-color, #1da1f2) !important;
        background: linear-gradient(135deg, 
            rgba(29, 161, 242, 0.08) 0%, 
            rgba(29, 161, 242, 0.04) 100%);
    }
}

/* ==================================================
   响应式设计
   ================================================== */
@media (max-width: 768px) {
    .wscm-product-cards {
        margin: 18px 0;
    }
    
    .wscm-cards-title {
        font-size: 14px;
        padding: 10px 14px;
        margin-bottom: 15px;
    }
    
    .wscm-cards-title i {
        font-size: 15px;
        margin-right: 6px;
    }
    
    .wscm-cards-grid {
        gap: 10px;
    }
    
    .wscm-product-card {
        padding: 12px;
        min-height: 85px;
        background: linear-gradient(135deg, #eef4ff 0%, #f5eeff 100%);
        border: 2px solid #e3e8f7;
    }
    
    .wscm-product-name {
        font-size: 15px;
    }
    
    .wscm-card-price {
        font-size: 15px;
    }
    
    .wscm-card-desc {
        font-size: 15px;
        margin-right: 70px;
        color: #6c757d;
        font-weight: 500;
        letter-spacing: 0.5px;
    }
    
    .wscm-custom-pay-btn {
        display: inline-block;
        min-width: auto;
        font-size: 14px;
        padding: 10px 20px;
    }
    
    .wscm-purchased-badge {
        padding: 3px 8px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .wscm-product-cards {
        margin: 13px 0;
    }
    
    .wscm-cards-title {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .wscm-cards-grid {
        gap: 11px;
    }
    
    .wscm-product-card {
        padding: 10px;
        min-height: 80px;
        background: linear-gradient(135deg, #eef4ff 0%, #f5eeff 100%);
        border: 2px solid #e3e8f7;
    }
    
    .wscm-card-desc {
        margin-right: 65px;
        font-size: 14px;
        color: #6c757d;
        font-weight: 500;
        letter-spacing: 0.5px;
        -webkit-line-clamp: 3;
    }
    
    .wscm-buy-section {
        margin-top: 15px;
    }
}

/* ==================================================
   工具类
   ================================================== */
.wscm-content-offset {
    margin-top: 10px;
}

.wscm-single-product-info {
    margin: 10px 0;
}

/* 防止FOUC（Flash of Unstyled Content） */
.wscm-initial-hide {
    display: none;
}

/* PHP拦截器隐藏的原生盒子 */
.wscm-hidden-native {
    display: none;
}

/* 占位符 */
#wscm-paybox-placeholder {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==================================================
   移动端底部支付栏特殊处理
   ================================================== */
/* 移除所有对.single-pay-tabbar的样式定义，避免与主题样式冲突 */
/* 主题已经定义了按钮的样式，插件不应该覆盖 */

/* ==================================================
   清理：确保所有元素无阴影
   ================================================== */
.wscm-cards-title,
.wscm-cards-title:hover,
.wscm-cards-title[class*="theme-"],
.wscm-product-card,
.wscm-product-card:hover,
.wscm-product-card.selected,
.wscm-product-card.purchased {
    box-shadow: none;
    text-shadow: none;
    filter: none;
}

.wscm-cards-title i {
    text-shadow: none;
}

.wscm-cards-title::before,
.wscm-cards-title::after,
.wscm-product-card::before,
.wscm-product-card::after {
    box-shadow: none;
    text-shadow: none;
    filter: none;
}
/* ==================================================
   发货提示样式
   ================================================== */
.wscm-shipping-notice {
    margin-top: 10px;
    padding: 6px 10px;
    background: linear-gradient(135deg, #fff7ed 0%, #ffede6 100%);
    border-left: 3px solid #ff6b35;
    border-radius: 4px;
    font-size: 13px;
    color: #d14e00;
    display: inline-block;
    align-self: flex-start; /* 关键：在flex容器中不拉伸，保持自适应宽度 */
    transition: all 0.3s ease;
}

.wscm-shipping-notice i {
    color: #ff6b35;
    font-size: 14px;
    margin-right: 5px;
    vertical-align: middle; /* 确保图标垂直居中 */
}

.wscm-shipping-notice span {
    vertical-align: middle; /* 确保文字垂直居中 */
}

/* 暗黑模式下的发货提示 */
body.dark-theme .wscm-shipping-notice,
.dark-theme .wscm-shipping-notice {
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.15) 0%, rgba(255, 107, 53, 0.08) 100%);
    border-left-color: #ff8c5a;
    color: #ffb088;
}

body.dark-theme .wscm-shipping-notice i,
.dark-theme .wscm-shipping-notice i {
    color: #ff8c5a;
}

/* 移动端发货提示 */
@media (max-width: 768px) {
    .wscm-shipping-notice {
        font-size: 12px;
        padding: 5px 8px;
        margin-top: 8px;
    }
    
    .wscm-shipping-notice i {
        font-size: 13px;
        margin-right: 5px;
    }
}
