/**
 * TPS Profit Engine - Bundle Discount UI
 */

:root {
    --tps-primary: #45aad3;
    --tps-primary-dark: #3a91b5;
}

/* Main Container */
.tps-upsells {
    margin: 12px 0;
    padding: 0;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

/* Bundle Discount Banner */
.tps-bundle-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: linear-gradient(135deg, #fff8e6 0%, #fff3cc 100%);
    border-bottom: 1px solid #f0d78c;
    position: relative;
    overflow: hidden;
}

.tps-bundle-banner.tps-bundle-complete {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-bottom-color: #a5d6a7;
}

.tps-bundle-icon {
    font-size: 16px;
}

.tps-bundle-text {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: #8b6914;
}

.tps-bundle-complete .tps-bundle-text {
    color: #2e7d32;
}

.tps-bundle-progress {
    font-size: 12px;
    font-weight: 700;
    color: #8b6914;
    background: rgba(255,255,255,0.6);
    padding: 2px 8px;
    border-radius: 10px;
}

.tps-bundle-complete .tps-bundle-progress {
    color: #2e7d32;
    background: rgba(255,255,255,0.8);
}

/* Header */
.tps-upsells-header {
    padding: 12px 15px 8px;
}

.tps-upsells-title {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Items Container */
.tps-upsells-items {
    display: flex;
    flex-direction: column;
    padding: 0 12px 12px;
    gap: 8px;
}

/* Individual Item */
.tps-upsell-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 12px;
    background: #fff;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

.tps-upsell-item:hover {
    border-color: var(--tps-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Main row items alignment */
.tps-upsell-item > .tps-item-image,
.tps-upsell-item > .tps-add-btn,
.tps-upsell-item > .tps-in-cart-label {
    align-self: center;
}

/* In Cart State */
.tps-upsell-item.tps-in-cart {
    background: #f0fdf4;
    border-color: #86efac;
}

.tps-upsell-item.tps-in-cart:hover {
    border-color: #22c55e;
}

/* Image */
.tps-item-image {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    position: relative;
}

.tps-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.tps-item-image a {
    display: block;
}

.tps-cart-check {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 18px;
    height: 18px;
    background: #22c55e;
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Details */
.tps-item-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.tps-item-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-decoration: none;
    flex: 1;
}

.tps-item-name:hover {
    color: var(--tps-primary);
}

.tps-item-price {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    white-space: nowrap;
}

/* In Cart Label */
.tps-in-cart-label {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    color: #22c55e;
    padding: 6px 12px;
    background: #dcfce7;
    border-radius: 4px;
}

/* Add Button */
.tps-add-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: var(--tps-primary);
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tps-add-btn:hover {
    background: var(--tps-primary-dark);
    transform: translateY(-1px);
}

.tps-add-btn:active {
    transform: translateY(0);
}

.tps-add-btn.tps-loading {
    opacity: 0.7;
    pointer-events: none;
}

.tps-add-btn.tps-added {
    background: #22c55e;
}

/* Info Toggle Button */
.tps-info-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    padding: 4px 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    color: #666;
    transition: color 0.2s ease;
}

.tps-info-toggle:hover {
    color: #333;
}

.tps-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: #4db8e8;
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    font-style: normal;
    font-weight: 700;
}

.tps-info-text {
    font-weight: 500;
}

.tps-info-arrow {
    font-size: 8px;
    transition: transform 0.3s ease;
}

.tps-info-toggle[aria-expanded="true"] .tps-info-arrow {
    transform: rotate(180deg);
}

/* Info Panel */
.tps-item-info-panel {
    flex-basis: 100%;
    width: 100%;
    background: linear-gradient(135deg, #f0f9ff 0%, #e8f4fc 100%);
    border-top: 1px solid #d0e8f5;
    padding: 15px;
    margin-top: 5px;
    border-radius: 6px;
    animation: tps-slide-down 0.3s ease-out;
}

@keyframes tps-slide-down {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tps-info-section {
    margin-bottom: 12px;
}

.tps-info-section:last-of-type {
    margin-bottom: 10px;
}

.tps-info-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tps-info-desc {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: #555;
}

.tps-why-combine {
    background: #fff;
    padding: 10px 12px;
    border-radius: 4px;
    border-left: 3px solid #4db8e8;
}

.tps-why-combine .tps-info-label {
    color: #4db8e8;
}

.tps-info-link {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: #4db8e8;
    text-decoration: none;
    transition: color 0.2s ease;
}

.tps-info-link:hover {
    color: #3a91b5;
    text-decoration: underline;
}

/* Bundle Celebration Animation */
.tps-bundle-banner.tps-celebrating {
    animation: tps-celebrate-pulse 0.5s ease-in-out 3;
    background: linear-gradient(135deg, #d4edda 0%, #b8e0c0 100%);
}

@keyframes tps-celebrate-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.tps-confetti {
    position: absolute;
    top: -20px;
    font-size: 20px;
    animation: tps-confetti-fall 2s ease-out forwards;
    pointer-events: none;
    z-index: 10;
}

@keyframes tps-confetti-fall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(60px) rotate(360deg);
    }
}

/* Mobile */
@media (max-width: 767px) {
    .tps-upsells {
        margin: 10px 0;
    }
    
    .tps-bundle-banner {
        padding: 8px 12px;
        flex-wrap: wrap;
    }
    
    .tps-bundle-text {
        font-size: 12px;
    }
    
    .tps-upsells-header {
        padding: 10px 12px 6px;
    }
    
    .tps-upsells-items {
        padding: 0 10px 10px;
        gap: 6px;
    }
    
    .tps-upsell-item {
        padding: 8px 10px;
        gap: 10px;
    }
    
    .tps-item-image {
        width: 45px;
        height: 45px;
    }
    
    .tps-item-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    
    .tps-item-name {
        font-size: 13px;
    }
    
    .tps-item-price {
        font-size: 13px;
    }
    
    .tps-add-btn {
        padding: 7px 12px;
        font-size: 11px;
    }
    
    .tps-in-cart-label {
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* Product page specific */
.tps-location-product_page {
    margin-top: 15px;
}

/* Checkout specific - more prominent */
.tps-location-checkout {
    border-color: #f39c12;
}

.tps-location-checkout .tps-bundle-banner {
    background: linear-gradient(135deg, #fef3cd 0%, #fce8a6 100%);
}

.tps-location-checkout .tps-add-btn {
    background: #f39c12;
}

.tps-location-checkout .tps-add-btn:hover {
    background: #e67e22;
}

/* ==========================================
   STACKS - Homepage/Shortcode Display
   Matches The Ped Shop site aesthetic
   ========================================== */

/* Stacks Grid */
.tps-stacks-grid {
    display: grid !important;
    gap: 30px !important;
    margin: 30px 0 !important;
}

.tps-stacks-cols-1 { grid-template-columns: 1fr !important; }
.tps-stacks-cols-2 { grid-template-columns: repeat(2, 1fr) !important; }
.tps-stacks-cols-3 { grid-template-columns: repeat(3, 1fr) !important; }
.tps-stacks-cols-4 { grid-template-columns: repeat(4, 1fr) !important; }

@media (max-width: 992px) {
    .tps-stacks-cols-3,
    .tps-stacks-cols-4 { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 576px) {
    .tps-stacks-grid { grid-template-columns: 1fr !important; }
}

/* Stack Card */
.tps-stack.tps-stack-card {
    background: #fff !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 15px rgba(0,0,0,0.08) !important;
    overflow: hidden !important;
    position: relative !important;
    padding: 25px !important;
    margin: 0 !important;
}

/* Discount Tag - like "-15%" on site */
.tps-stack .tps-stack-discount-tag {
    position: absolute !important;
    top: 15px !important;
    left: 15px !important;
    background: #5bc0de !important;
    color: #fff !important;
    padding: 5px 10px !important;
    border-radius: 4px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    z-index: 10 !important;
    display: inline-block !important;
}

/* Badge - "Most Popular" etc */
.tps-stack .tps-stack-badge {
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    z-index: 10 !important;
    transform: none !important;
    background: none !important;
    padding: 0 !important;
}

.tps-stack .tps-stack-badge span {
    background: #f39c12 !important;
    color: #fff !important;
    padding: 5px 12px !important;
    border-radius: 4px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    display: inline-block !important;
}

/* Stack Header */
.tps-stack .tps-stack-header {
    text-align: center !important;
    margin-bottom: 20px !important;
    padding-top: 35px !important;
    padding-bottom: 0 !important;
    border: none !important;
    background: none !important;
}

.tps-stack .tps-stack-name {
    margin: 0 0 8px 0 !important;
    font-size: 22px !important;
    font-weight: 700 !important;
    color: #333 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

.tps-stack .tps-stack-description {
    margin: 0 !important;
    color: #777 !important;
    font-size: 14px !important;
}

/* Products Grid - Horizontal layout like site */
.tps-stack .tps-stack-products-grid {
    display: flex !important;
    justify-content: center !important;
    gap: 25px !important;
    flex-wrap: wrap !important;
    margin-bottom: 25px !important;
    padding: 25px 0 !important;
    border-top: 1px solid #eee !important;
    border-bottom: 1px solid #eee !important;
    background: none !important;
}

.tps-stack .tps-stack-product-card {
    text-align: center !important;
    flex: 0 1 150px !important;
    display: block !important;
}

.tps-stack .tps-stack-product-card .tps-stack-product-image {
    width: 130px !important;
    height: 130px !important;
    margin: 0 auto 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: none !important;
    border: none !important;
}

.tps-stack .tps-stack-product-card .tps-stack-product-image img {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
}

.tps-stack .tps-stack-product-card .tps-stack-product-name {
    display: block !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #333 !important;
    margin-bottom: 5px !important;
    line-height: 1.3 !important;
}

.tps-stack .tps-stack-product-card .tps-stack-product-price {
    font-size: 14px !important;
    color: #666 !important;
    display: block !important;
}

.tps-stack .tps-stack-product-price del {
    color: #999 !important;
    margin-right: 5px !important;
}

.tps-stack .tps-stack-product-price ins {
    text-decoration: none !important;
    color: #e74c3c !important;
    font-weight: 600 !important;
}

/* Stack Footer - Pricing & Button */
.tps-stack .tps-stack-footer {
    text-align: center !important;
    background: none !important;
    padding: 0 !important;
}

.tps-stack .tps-stack-pricing {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 15px !important;
    margin-bottom: 8px !important;
    padding: 0 !important;
    background: none !important;
}

.tps-stack .tps-stack-price-original {
    font-size: 18px !important;
    color: #999 !important;
    text-decoration: line-through !important;
}

.tps-stack .tps-stack-price-final {
    font-size: 28px !important;
    font-weight: 700 !important;
    color: #e74c3c !important;
}

.tps-stack .tps-stack-savings {
    color: #27ae60 !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    margin-bottom: 20px !important;
}

/* Add to Cart Button - Blue to match site */
.tps-stack button.tps-stack-add-btn,
.tps-stack .tps-stack-add-btn {
    display: inline-block !important;
    width: 100% !important;
    max-width: 300px !important;
    padding: 14px 30px !important;
    border: none !important;
    border-radius: 4px !important;
    background: #4db8e8 !important;
    background-color: #4db8e8 !important;
    color: #fff !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    line-height: 1.4 !important;
}

.tps-stack button.tps-stack-add-btn:hover,
.tps-stack .tps-stack-add-btn:hover {
    background: #3ca8d8 !important;
    background-color: #3ca8d8 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 15px rgba(77, 184, 232, 0.4) !important;
}

.tps-stack button.tps-stack-add-btn:active,
.tps-stack .tps-stack-add-btn:active {
    transform: translateY(0) !important;
}

.tps-stack button.tps-stack-add-btn:disabled,
.tps-stack .tps-stack-add-btn:disabled {
    opacity: 0.7 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

.tps-stack button.tps-stack-add-btn.tps-added,
.tps-stack .tps-stack-add-btn.tps-added {
    background: #27ae60 !important;
    background-color: #27ae60 !important;
}

/* Responsive */
@media (max-width: 576px) {
    .tps-stack.tps-stack-card {
        padding: 20px 15px !important;
    }
    
    .tps-stack .tps-stack-products-grid {
        gap: 15px !important;
    }
    
    .tps-stack .tps-stack-product-card {
        flex: 0 1 100px !important;
    }
    
    .tps-stack .tps-stack-product-card .tps-stack-product-image {
        width: 90px !important;
        height: 90px !important;
    }
    
    .tps-stack .tps-stack-product-card .tps-stack-product-name {
        font-size: 12px !important;
    }
    
    .tps-stack .tps-stack-price-final {
        font-size: 24px !important;
    }
}

/* Add All to Cart Button */
.tps-add-all-wrapper {
    display: flex;
    justify-content: center;
    padding: 12px 20px;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-top: 1px solid #90caf9;
}

.tps-add-all-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    background: linear-gradient(135deg, #4db8e8 0%, #45aad3 100%);
    color: #fff !important;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(69, 170, 211, 0.3);
    min-width: 250px;
}

.tps-add-all-btn:hover {
    background: linear-gradient(135deg, #5bc4f2 0%, #4db8e8 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(69, 170, 211, 0.4);
}

.tps-add-all-btn:active {
    transform: translateY(0);
}

.tps-add-all-btn.tps-loading {
    opacity: 0.8;
    cursor: not-allowed;
}

.tps-add-all-text {
    display: inline;
}

.tps-add-all-loading {
    display: none;
}

.tps-add-all-loading .tps-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: tps-spin 0.8s linear infinite;
}

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

.tps-add-all-success {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    background: #4caf50;
    color: #fff;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    animation: tps-success-pulse 0.5s ease;
}

@keyframes tps-success-pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); opacity: 1; }
}

/* Mobile responsive */
@media (max-width: 576px) {
    .tps-add-all-wrapper {
        padding: 12px 15px;
    }
    
    .tps-add-all-btn {
        width: 100%;
        min-width: auto;
        padding: 12px 20px;
        font-size: 14px;
    }
}
