/* Frontend Styles for Product Bundle */
/* Theme-agnostic styles that work with any layout */

/* CSS Variables - easily customizable by themes */
.pb-bundle-wrapper {
    --pb-primary-color: #3498db;
    --pb-success-color: #27ae60;
    --pb-danger-color: #e74c3c;
    --pb-text-color: currentColor;
    --pb-border-color: #e0e0e0;
    --pb-bg-light: #f7f7f7;
    --pb-spacing: 20px;
    --pb-border-radius: 8px;
}

/* Bundle Wrapper - adapts to theme's container */
.pb-bundle-wrapper {
    width: 100%;
    max-width: 100%;
    margin: 0;
    color: var(--pb-text-color);
}

/* Inherit theme's typography */
.pb-bundle-wrapper h1,
.pb-bundle-wrapper h2,
.pb-bundle-wrapper h3,
.pb-bundle-wrapper h4,
.pb-bundle-wrapper p {
    font-family: inherit;
    line-height: inherit;
}

/* Inherit theme's link colors */
.pb-bundle-wrapper a {
    color: inherit;
    transition: opacity 0.3s ease;
}

.pb-bundle-wrapper a:hover {
    opacity: 0.8;
}

/* Bundle Images */
.pb-bundle-images {
    margin-bottom: 30px;
}

.pb-main-image {
    width: 100%;
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    background: #f7f7f7;
    line-height: 0;
}

.pb-main-image img {
    width: 100%;
    height: auto;
    display: block;
}

.pb-gallery-thumbnails {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.pb-thumb-item {
    width: 80px;
    height: 80px;
    border: 2px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pb-thumb-item:hover {
    border-color: #3498db;
    transform: scale(1.05);
}

.pb-thumb-item.active {
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

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

/* Bundle Description */
.pb-bundle-description {
    margin-bottom: 30px;
}

/* Bundle Pricing */
.pb-bundle-pricing {
    margin-bottom: 30px;
    padding: var(--pb-spacing);
    background: var(--pb-bg-light);
    border-radius: var(--pb-border-radius);
}

.pb-price-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.pb-regular-price {
    font-size: 20px;
    color: #999;
    text-decoration: line-through;
}

.pb-sale-price {
    font-size: 28px;
    font-weight: bold;
    color: var(--pb-success-color);
    text-decoration: none;
}

.pb-price {
    font-size: 28px;
    font-weight: bold;
    color: var(--pb-text-color);
}

.pb-discount-badge {
    background: var(--pb-danger-color);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

/* Bundle Products */
.pb-bundle-products {
    margin-bottom: 30px;
}

.pb-bundle-products h3 {
    font-size: 22px;
    margin-bottom: 20px;
    color: var(--pb-text-color);
    border-bottom: 2px solid var(--pb-primary-color);
    padding-bottom: 10px;
}

.pb-products-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Product Item */
.pb-product-item {
    display: grid;
    grid-template-columns: 100px 1fr auto;
    gap: var(--pb-spacing);
    padding: var(--pb-spacing);
    background: white;
    border: 1px solid var(--pb-border-color);
    border-radius: var(--pb-border-radius);
    transition: all 0.3s ease;
}

.pb-product-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: var(--pb-primary-color);
}

.pb-product-item.pb-out-of-stock {
    opacity: 0.6;
    background: #f9f9f9;
}

/* Product Image */
.pb-product-image img {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Product Info */
.pb-product-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.pb-product-name {
    margin: 0 0 10px 0;
    font-size: 18px;
}

.pb-product-name a {
    color: #2c3e50;
    text-decoration: none;
}

.pb-product-name a:hover {
    color: #3498db;
}

.pb-product-price {
    font-size: 16px;
    font-weight: 600;
    color: var(--pb-success-color);
    margin-bottom: 8px;
}

.pb-product-price.pb-free-gift-price {
    display: flex;
    align-items: baseline;
    gap: 6px;
    color: inherit;
}

.pb-product-price.pb-free-gift-price .pb-valued-at {
    font-size: 13px;
    color: #777;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.pb-price-label {
    font-size: 12px;
    color: #999;
    font-weight: normal;
}

/* Stock Status */
.pb-stock-status {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.pb-out-of-stock-notice {
    color: var(--pb-danger-color);
    font-weight: 600;
}

.pb-out-of-stock-notice .dashicons {
    color: var(--pb-danger-color);
}

.pb-in-stock-notice {
    color: var(--pb-success-color);
}

/* Product Quantity */
.pb-product-quantity {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Quantity Controls */
.pb-quantity-controls {
    display: flex;
    align-items: center;
    gap: 0;
    border: 2px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}

.pb-qty-btn {
    width: 36px;
    height: 36px;
    background: #f7f7f7;
    border: none;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    color: #555;
    transition: all 0.2s ease;
}

.pb-qty-btn:hover:not(:disabled) {
    background: var(--pb-primary-color);
    color: white;
}

.pb-qty-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pb-quantity-input {
    width: 60px;
    height: 36px;
    text-align: center;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    font-size: 16px;
    font-weight: 600;
}

.pb-quantity-input::-webkit-inner-spin-button,
.pb-quantity-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Fixed Quantity */
.pb-quantity-fixed {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f7f7f7;
    border-radius: 6px;
}

.pb-qty-label {
    font-size: 14px;
    color: #666;
}

.pb-qty-value {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

/* Add to Cart */
.pb-add-to-cart-wrapper {
    text-align: center;
    padding: 30px 20px;
    background: #f7f7f7;
    border-radius: 8px;
}

/* Button row for multiple buttons */
.pb-buttons-row {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.pb-add-to-cart-btn {
    font-size: 18px;
    padding: 15px 40px;
    border-radius: var(--pb-border-radius);
    background: var(--pb-primary-color);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.pb-add-to-cart-btn:hover:not(.disabled) {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pb-add-to-cart-btn.disabled {
    background: #95a5a6;
    cursor: not-allowed;
    opacity: 0.6;
}

.pb-add-to-cart-btn.loading {
    position: relative;
    color: transparent;
}

.pb-add-to-cart-btn.loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid #fff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: pb-spinner 0.8s linear infinite;
}

@keyframes pb-spinner {
    to { transform: rotate(360deg); }
}

/* Buy Now Button */
.pb-buy-now-btn {
    font-size: 18px;
    padding: 15px 40px;
    border-radius: var(--pb-border-radius);
    background: var(--pb-success-color, #27ae60);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.pb-buy-now-btn:hover:not(.disabled) {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pb-buy-now-btn.loading {
    position: relative;
    color: transparent;
}

.pb-buy-now-btn.loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid #fff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: pb-spinner 0.8s linear infinite;
}

/* Cart Message */
.pb-cart-message {
    margin-top: 15px;
    padding: 12px 20px;
    border-radius: 6px;
    display: none;
}

.pb-cart-message.success {
    display: block;
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.pb-cart-message.error {
    display: block;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Responsive */
@media (max-width: 768px) {
    .pb-product-item {
        grid-template-columns: 80px 1fr;
        gap: 15px;
    }
    
    .pb-product-quantity {
        grid-column: 1 / -1;
        justify-content: flex-start;
        margin-top: 10px;
    }
    
    .pb-price-wrapper {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .pb-add-to-cart-btn {
        width: 100%;
        padding: 12px 20px;
        font-size: 16px;
    }
}

/* WoodMart Theme Specific Compatibility */
.pb-woodmart-compat {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* WoodMart product page layouts */
.woodmart-product-design-default .pb-bundle-wrapper,
.woodmart-product-design-sticky .pb-bundle-wrapper,
.woodmart-product-design-alt .pb-bundle-wrapper {
    margin: 30px 0;
    width: 100%;
}

/* WoodMart button compatibility */
.woodmart-buttons .pb-add-to-cart-btn,
.product-type-bundle .pb-add-to-cart-btn {
    display: inline-block;
    width: auto;
    min-width: 200px;
}

/* Ensure bundle products list is visible in WoodMart */
.product-type-bundle .pb-bundle-products,
.product-type-bundle .pb-products-list {
    display: block !important;
    visibility: visible !important;
}

/* WoodMart single product summary compatibility */
.single-product-content .pb-bundle-wrapper {
    width: 100%;
    max-width: 100%;
}

/* Free gift badge for WoodMart */
.pb-free-gift {
    background: var(--wd-success-color, #27ae60);
    color: white;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
}
