/**
 * Modern Mode Production Styles - Flatsome Theme Compatible
 * Clean, professional styling for production environment
 */

/* 基础容器样式 */
.wab-modern-frontend-wrapper {
    position: relative;
    margin: 30px 0;
    z-index: 1;
    clear: both;
    width: 100%;
}

.wab-demo-container {
    max-width: 1000px;
    margin: 20px auto;
    border: 1px solid #e0e0e0;
    padding: 25px;
    background: #ffffff;
    border-radius: 8px;
    color: #333333;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.wab-demo-title {
    color: #059669;
    text-align: center;
    margin-bottom: 25px;
    font-size: 22px;
    font-weight: 600;
}

/* 属性选择区域 */
.wab-attributes-section {
    margin-bottom: 25px;
}

.wab-attributes-section h3 {
    color: #333333;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

.wab-attribute-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    margin-bottom: 10px;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    transition: all 0.2s ease;

    /* 允许根据产品名自动增高，避免把数量控件挤出边框 */
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
}

.wab-attribute-item:hover {
    background: #f0fdf4;
    border-color: #059669;
}

.wab-attribute-name {
    color: #333333;
    font-weight: 500;
    flex: 1;
    min-width: 0; /* 允许 flex 子项收缩，避免把右侧控件顶出边框 */
    max-width: 100%;
    white-space: normal !important; /* 覆盖主题可能的 nowrap */
    overflow-wrap: anywhere; /* SKU/长单词强制换行 */
    word-break: break-word;
}

/* 数量控制（兼容两种容器类名：.wab-quantity-controls / .wab-qty-controls） */
.wab-quantity-controls,
.wab-qty-controls {
    display: inline-flex !important;
    align-items: center !important;
    gap: 2px !important;  /* 缩小间距，让减号靠近输入框 */

    /* 当行内元素换行时，让数量控件始终贴右并在需要时换到下一行 */
    margin-left: auto !important;
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: 100% !important;
    flex-wrap: nowrap !important;
}

.wab-qty-btn {
    width: 24px !important;  /* 从 40px 缩小到 24px */
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
    border: 1px solid #e2e8f0 !important;
    background: #ffffff !important;
    color: #475569 !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    position: relative !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
}

/* 防止主题按钮伪元素导致“+”溢出 */
.wab-qty-btn::before,
.wab-qty-btn::after {
    content: none !important;
    display: none !important;
}

.wab-qty-btn:hover {
    background: #059669;
    color: #ffffff;
    border-color: #059669;
    transform: scale(1.05);
}

.wab-qty-input {
    width: 32px !important;  /* 从 60px 缩小到 32px */
    height: 24px !important;
    min-width: 32px !important;
    min-height: 24px !important;
    max-width: 32px !important;
    max-height: 24px !important;
    text-align: center !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    background: #ffffff !important;
    color: #333333 !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
}

/* 套餐选择区域 */
.wab-package-section {
    margin-bottom: 25px;
}

.wab-package-section h3 {
    color: #333333;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

.wab-package-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.wab-package-btn {
    position: relative;
    background: #ffffff;
    color: #334155;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    padding: 20px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.wab-package-btn:hover {
    background: #f0fdf4;
    border-color: #059669;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(5, 150, 105, 0.15);
}

.wab-package-btn.selected {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff;
    border-color: #059669;
    box-shadow: 0 8px 20px rgba(5, 150, 105, 0.25);
}

.wab-package-label {
    font-weight: 600;
    margin-bottom: 5px;
}

.wab-package-discount {
    font-size: 14px;
    margin-bottom: 5px;
}

.wab-package-price {
    font-size: 18px;
    font-weight: 700;
}

.wab-hot-sale-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: #ffffff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* 总计区域 */
.wab-total-section {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.wab-total-item {
    color: #333333;
    margin-bottom: 12px;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
}

.wab-total-item-left {
    color: #666666;
}

.wab-total-item-right {
    color: #333333;
    font-weight: 600;
}

/* 添加购物车按钮 - 始终显示绿色，提升用户体验 */
.wab-add-to-cart-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    color: #ffffff !important;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 20px;
    box-shadow: 0 4px 0 #047857, 0 8px 20px rgba(5, 150, 105, 0.28);
    opacity: 1;
}

.wab-add-to-cart-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #047857 0%, #065f46 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 0 #065f46, 0 12px 24px rgba(5, 150, 105, 0.34);
}

.wab-add-to-cart-btn:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #047857, 0 4px 12px rgba(5, 150, 105, 0.2);
}

/* 禁用状态也保持绿色，但降低透明度和改变光标 */
.wab-add-to-cart-btn:disabled,
.wab-add-to-cart-btn.disabled {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    color: #ffffff !important;
    cursor: not-allowed;
    transform: none;
    opacity: 0.5;
    box-shadow: 0 2px 0 #047857, 0 4px 12px rgba(5, 150, 105, 0.15);
}

/* 确保按钮在所有状态下都有正确的文字颜色 */
.wab-add-to-cart-btn,
.wab-add-to-cart-btn:hover,
.wab-add-to-cart-btn:active,
.wab-add-to-cart-btn:focus,
.wab-add-to-cart-btn:disabled {
    color: #ffffff !important;
}

/* 进度条 */
.wab-progress {
    width: 100%;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
    margin: 10px 0;
}

.wab-progress .bar {
    height: 100%;
    background: linear-gradient(90deg, #059669, #34d399);
    transition: width 0.3s ease;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.2);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .wab-demo-container {
        margin: 15px;
        padding: 20px;
    }

    .wab-package-grid {
        grid-template-columns: 1fr;
    }

    /* 移动端：两行布局
       - 第1行：名称占满整行（可自动换行增高）
       - 第2行：左侧价格（可选），右侧数量控件（始终不溢出） */
    .wab-attribute-item {
        padding: 14px 14px 14px 16px; /* 右侧增加 padding，确保控件不超出 */
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: 10px;
        row-gap: 6px;
        align-items: start;
    }

    .wab-attribute-name,
    .wab-item-name {
        grid-column: 1 / -1;
        font-size: 14px;
        min-width: 0;
        max-width: 100%;
        white-space: normal !important;
        overflow-wrap: anywhere;
        word-break: break-word;
        line-height: 1.25;
    }

    .wab-attribute-name * {
        white-space: normal !important;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .wab-item-price {
        grid-column: 1 / 2;
        align-self: center;
        font-size: 13px;
        color: #64748b;
        white-space: nowrap;
    }

    .wab-quantity-controls,
    .wab-qty-controls {
        grid-column: 2 / 3;
        justify-self: end;
        align-self: center;
        max-width: 75px !important;
        gap: 2px !important;
        margin-right: 0 !important;
    }

    /* 数量控件进一步压缩（避免占用过多空间） - 强制应用 */
    .wab-qty-btn {
        width: 22px !important;
        height: 22px !important;
        min-width: 22px !important;
        min-height: 22px !important;
        max-width: 22px !important;
        max-height: 22px !important;
        font-size: 13px !important;
        line-height: 1 !important;
        padding: 0 !important;
        margin: 0 !important;
        flex-shrink: 0 !important;
        border-width: 1px !important;
        box-sizing: border-box !important;
    }

    .wab-qty-input {
        width: 28px !important;
        height: 22px !important;
        min-width: 28px !important;
        min-height: 22px !important;
        max-width: 28px !important;
        max-height: 22px !important;
        font-size: 11px !important;
        line-height: 1 !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        flex-shrink: 0 !important;
        border-width: 1px !important;
    }
}

/* 小屏幕手机优化 - 修复数量选择器超出边框问题 */
@media (max-width: 480px) {
    .wab-demo-container {
        margin: 10px;
        padding: 15px;
    }

    /* 小屏手机：极致压缩数量控件，强制应用所有样式 */
    .wab-attribute-item {
        padding: 10px 12px 10px 12px !important;
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto !important;
        column-gap: 8px !important;
        row-gap: 6px !important;
        align-items: start !important;
    }

    .wab-attribute-name,
    .wab-item-name {
        grid-column: 1 / -1 !important;
        font-size: 13px !important;
        min-width: 0 !important;
        max-width: 100% !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        word-break: break-word !important;
        line-height: 1.25 !important;
    }

    .wab-item-price {
        grid-column: 1 / 2 !important;
        align-self: center !important;
        font-size: 12px !important;
        color: #64748b !important;
        white-space: nowrap !important;
    }

    .wab-quantity-controls,
    .wab-qty-controls {
        grid-column: 2 / 3 !important;
        justify-self: end !important;
        align-self: center !important;
        max-width: 68px !important;
        gap: 2px !important;
        margin-right: 0 !important;
    }

    .wab-qty-btn {
        width: 20px !important;
        height: 20px !important;
        min-width: 20px !important;
        min-height: 20px !important;
        max-width: 20px !important;
        max-height: 20px !important;
        font-size: 12px !important;
        line-height: 1 !important;
        flex-shrink: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        border-width: 1px !important;
        box-sizing: border-box !important;
    }

    .wab-qty-input {
        width: 24px !important;
        height: 20px !important;
        min-width: 24px !important;
        min-height: 20px !important;
        max-width: 24px !important;
        max-height: 20px !important;
        font-size: 11px !important;
        line-height: 1 !important;
        flex-shrink: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        border-width: 1px !important;
    }

    .wab-package-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .wab-package-btn {
        padding: 16px 12px;
    }

    .wab-add-to-cart-btn {
        padding: 14px;
        font-size: 15px;
    }
}

/* 加载状态 */
.wab-demo-container.is-loading {
    opacity: 0.7;
    pointer-events: none;
}

.wab-demo-container.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid #e9ecef;
    border-top-color: #059669;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ==============================
   轻金边增强（Modern 模式）
   保留绿色主视觉，仅增加精致金色点缀
   ============================== */
.wab-demo-container {
    border-color: #e7d7a2;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(212, 175, 55, 0.16);
}

.wab-demo-title {
    text-shadow: 0 1px 0 rgba(231, 201, 106, 0.2);
}

.wab-package-btn.selected {
    border-color: #059669;
    box-shadow: 0 8px 20px rgba(5, 150, 105, 0.25);
}

/* 底部保持进度条金色尾光，不覆盖加购按钮状态样式 */

.wab-progress .bar {
    background: linear-gradient(90deg, #059669 0%, #34d399 65%, #e7c96a 100%);
}