/* Simple Product Bundles - Frontend Styles
 * Designed to complement the Twenty Twenty-Five theme
 * Uses native CSS custom properties and fluid typography
 */

/* CSS Custom Properties - aligned with Twenty Twenty-Five */
.bundle-items-wrapper {
    --bundle-spacing: clamp(1rem, 3vw, 1.5rem);
    --bundle-gap: clamp(0.75rem, 2vw, 1rem);
    --bundle-radius: 0;
    --bundle-border: 1px solid currentColor;
    --bundle-border-subtle: 1px solid rgba(0, 0, 0, 0.1);
    --bundle-text: inherit;
    --bundle-text-muted: rgba(0, 0, 0, 0.6);
    --bundle-bg: transparent;
    --bundle-bg-hover: rgba(0, 0, 0, 0.02);
    --bundle-accent: currentColor;
    --bundle-success: #2e7d32;
    
    margin: var(--bundle-spacing) 0;
    font-family: inherit;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .bundle-items-wrapper {
        --bundle-border-subtle: 1px solid rgba(255, 255, 255, 0.15);
        --bundle-text-muted: rgba(255, 255, 255, 0.6);
        --bundle-bg-hover: rgba(255, 255, 255, 0.03);
        --bundle-success: #66bb6a;
    }
}

/* Main heading */
.bundle-items-wrapper .bundle-heading {
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 var(--bundle-spacing);
    padding-bottom: var(--bundle-gap);
    border-bottom: var(--bundle-border);
}

/* Bundle items list - card layout */
.bundle-items-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Individual bundle item */
.bundle-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: var(--bundle-gap);
    align-items: center;
    padding: var(--bundle-spacing) 0;
    border-bottom: var(--bundle-border-subtle);
    transition: background-color 0.15s ease;
}

.bundle-item:last-child {
    border-bottom: none;
}

/* Product thumbnail */
.bundle-item-image {
    width: clamp(48px, 10vw, 72px);
    aspect-ratio: 1;
    flex-shrink: 0;
}

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

/* Product info */
.bundle-item-details {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    min-width: 0;
}

.bundle-item-name {
    font-size: clamp(0.875rem, 2vw, 1rem);
    font-weight: 500;
    margin: 0;
    line-height: 1.3;
}

.bundle-item-price {
    font-size: clamp(0.8125rem, 1.8vw, 0.9375rem);
    color: var(--bundle-text-muted);
    margin: 0;
}

/* Volume Discount Tiers */
.bundle-volume-tiers {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-top: 0.25rem;
}

.volume-tiers-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bundle-text-muted);
    font-weight: 600;
}

.volume-tiers-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.volume-tier-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 3px;
    color: var(--bundle-text-muted);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.volume-tier-badge.active {
    background: var(--bundle-success);
    border-color: var(--bundle-success);
    color: #fff;
    transform: scale(1.02);
}

.volume-tier-badge.next-tier {
    border-color: var(--bundle-success);
    color: var(--bundle-success);
    animation: pulse-border 2s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.3);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(46, 125, 50, 0);
    }
}

/* Dark mode badges */
@media (prefers-color-scheme: dark) {
    .volume-tier-badge {
        background: rgba(255, 255, 255, 0.06);
        border-color: rgba(255, 255, 255, 0.12);
    }
    
    .volume-tier-badge.active {
        background: var(--bundle-success);
        border-color: var(--bundle-success);
    }
    
    .volume-tier-badge.next-tier {
        border-color: var(--bundle-success);
        color: var(--bundle-success);
    }
}

/* Quantity controls */
.bundle-item-quantity {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.375rem;
}

.bundle-qty-control {
    display: flex;
    align-items: center;
    border: var(--bundle-border);
}

.bundle-qty-btn {
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.125rem;
    font-weight: 400;
    color: inherit;
    transition: background-color 0.15s ease;
    padding: 0;
    line-height: 1;
}

.bundle-qty-btn:hover {
    background: var(--bundle-bg-hover);
}

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

.bundle-qty-input {
    width: 3rem;
    height: 2.25rem;
    text-align: center;
    border: none;
    border-left: var(--bundle-border);
    border-right: var(--bundle-border);
    font-size: 0.9375rem;
    font-family: inherit;
    background: transparent;
    color: inherit;
    -moz-appearance: textfield;
    padding: 0;
}

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

.bundle-qty-input:focus {
    outline: none;
    background: var(--bundle-bg-hover);
}

.bundle-qty-hint {
    font-size: 0.6875rem;
    color: var(--bundle-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Item pricing container */
.bundle-item-pricing {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

/* Item subtotal */
.bundle-item-subtotal {
    font-size: clamp(0.875rem, 2vw, 1rem);
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
    min-width: 5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.bundle-item-subtotal .original-price {
    text-decoration: line-through;
    color: var(--bundle-text-muted);
    font-weight: 400;
    font-size: 0.875em;
}

.bundle-item-subtotal .discounted-price {
    color: var(--bundle-success);
}

/* Item savings badge */
.bundle-item-savings {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--bundle-success);
    background: rgba(46, 125, 50, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
    .bundle-item-savings {
        background: rgba(102, 187, 106, 0.15);
    }
}

/* Bundle summary/totals */
.bundle-summary {
    margin-top: var(--bundle-spacing);
    padding-top: var(--bundle-spacing);
    border-top: var(--bundle-border);
}

.bundle-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: clamp(0.875rem, 2vw, 1rem);
}

.bundle-summary-row.bundle-subtotal-row {
    color: var(--bundle-text-muted);
}

.bundle-summary-row.bundle-volume-savings-row {
    color: var(--bundle-success);
}

.bundle-summary-row.bundle-discount-row {
    color: var(--bundle-success);
}

.bundle-summary-row.bundle-total-row {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    font-weight: 600;
    padding-top: var(--bundle-gap);
    margin-top: 0.25rem;
    border-top: var(--bundle-border);
}

.bundle-summary-label {
    margin: 0;
}

.bundle-summary-value {
    font-weight: 600;
}

/* Add to cart section */
.bundle-cart-form .bundle-add-to-cart {
    display: flex;
    align-items: center;
    gap: var(--bundle-gap);
    margin-top: var(--bundle-spacing);
    padding-top: var(--bundle-spacing);
    border-top: var(--bundle-border);
}

.bundle-cart-form .quantity {
    display: flex;
    align-items: center;
    border: var(--bundle-border);
}

.bundle-cart-form .quantity .qty {
    width: 4rem;
    height: 3rem;
    text-align: center;
    border: none;
    font-size: 1rem;
    font-family: inherit;
    background: transparent;
    color: inherit;
}

.bundle-cart-form .single_add_to_cart_button {
    flex: 1;
    max-width: none;
    /* Allow theme to control button styling (font, colors, border-radius, etc.) */
}

/* Empty/error state */
.bundle-empty-message {
    padding: var(--bundle-spacing);
    text-align: center;
    color: var(--bundle-text-muted);
    font-style: italic;
}

/* Hidden discount input */
input[name="bundle_discount"] {
    display: none;
}

/* Hide images variant */
.bundle-hide-images .bundle-item {
    grid-template-columns: 1fr auto;
}

/* Responsive - Mobile first refinements */
@media (max-width: 600px) {
    .bundle-item {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
    }
    
    .bundle-item-image {
        grid-row: span 2;
        align-self: start;
    }
    
    .bundle-item-quantity {
        grid-column: 2;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        margin-top: 0.5rem;
    }
    
    .bundle-item-subtotal {
        min-width: auto;
    }
    
    .bundle-qty-hint {
        order: -1;
    }
    
    .bundle-cart-form .bundle-add-to-cart {
        flex-direction: column;
        align-items: stretch;
    }
    
    .bundle-cart-form .quantity {
        justify-content: center;
    }
}

/* Price suffix (e.g., "Excl. BTW") */
.bundle-price-suffix {
    font-size: 0.75em;
    font-weight: 400;
    color: var(--bundle-text-muted);
    margin-left: 0.25em;
}

/* Print styles */
@media print {
    .bundle-qty-control,
    .bundle-add-to-cart {
        display: none;
    }
    
    .bundle-item {
        break-inside: avoid;
    }
}

/* ==========================================================================
   Cart Tax Breakdown - Collapsible Display
   ========================================================================== */

.bundle-tax-collapsible {
    display: flex;
    flex-direction: column;
}

.bundle-tax-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    padding: 0.25rem 0;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    color: inherit;
    text-align: right;
}

.bundle-tax-toggle:hover {
    opacity: 0.8;
}

.bundle-tax-toggle:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.bundle-tax-total {
    font-weight: 600;
}

.bundle-tax-toggle-icon {
    font-size: 0.65em;
    transition: transform 0.2s ease;
    opacity: 0.6;
}

.bundle-tax-toggle[aria-expanded="true"] .bundle-tax-toggle-icon {
    transform: rotate(180deg);
}

.bundle-tax-breakdown {
    width: 100%;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
    .bundle-tax-breakdown {
        border-top-color: rgba(255, 255, 255, 0.15);
    }
}

.bundle-tax-breakdown-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.bundle-tax-breakdown-item {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 4px;
    font-size: 0.875rem;
}

@media (prefers-color-scheme: dark) {
    .bundle-tax-breakdown-item {
        background: rgba(255, 255, 255, 0.04);
    }
}

.breakdown-product {
    font-weight: 500;
    color: inherit;
}

.breakdown-details {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.8125rem;
    color: var(--bundle-text-muted, rgba(0, 0, 0, 0.6));
}

@media (prefers-color-scheme: dark) {
    .breakdown-details {
        color: rgba(255, 255, 255, 0.6);
    }
}

.breakdown-subtotal {
    opacity: 0.8;
}

.breakdown-rate {
    opacity: 0.7;
    font-style: italic;
}

.breakdown-tax {
    font-weight: 600;
    color: inherit;
    margin-left: auto;
}

/* Animation for expand/collapse */
.bundle-tax-breakdown {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.bundle-tax-breakdown[style*="display: none"] {
    max-height: 0;
    opacity: 0;
}

.bundle-tax-breakdown:not([style*="display: none"]) {
    max-height: 500px;
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .bundle-tax-breakdown-item {
        font-size: 0.8125rem;
    }
    
    .breakdown-details {
        font-size: 0.75rem;
    }
}

/* ==========================================================================
   WooCommerce Blocks Cart - Tax Breakdown
   ========================================================================== */

.bundle-tax-blocks-wrapper {
    padding: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    margin-bottom: 14px;
}

@media (prefers-color-scheme: dark) {
    .bundle-tax-blocks-wrapper {
        border-top-color: rgba(255, 255, 255, 0.15);
    }
}

.bundle-tax-blocks-wrapper .bundle-tax-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    color: inherit;
    text-align: left;
}

.bundle-tax-blocks-wrapper .bundle-tax-label {
    flex: 1;
    font-weight: 400;
}

.bundle-tax-blocks-wrapper .bundle-tax-total {
    font-weight: 600;
}

.bundle-tax-blocks-wrapper .bundle-tax-toggle-icon {
    font-size: 0.7em;
    opacity: 0.6;
    transition: transform 0.2s ease;
    margin-left: 0.5rem;
}

.bundle-tax-blocks-wrapper .bundle-tax-toggle[aria-expanded="true"] .bundle-tax-toggle-icon {
    transform: rotate(180deg);
}

.bundle-tax-blocks-wrapper .bundle-tax-breakdown {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
    .bundle-tax-blocks-wrapper .bundle-tax-breakdown {
        border-top-color: rgba(255, 255, 255, 0.1);
    }
}

.bundle-tax-blocks-wrapper .bundle-tax-breakdown-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bundle-tax-blocks-wrapper .bundle-tax-breakdown-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 4px;
    font-size: 0.875rem;
}

@media (prefers-color-scheme: dark) {
    .bundle-tax-blocks-wrapper .bundle-tax-breakdown-item {
        background: rgba(255, 255, 255, 0.04);
    }
}

.bundle-tax-blocks-wrapper .breakdown-product {
    font-weight: 500;
}

.bundle-tax-blocks-wrapper .breakdown-details {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.8125rem;
    opacity: 0.7;
}

.bundle-tax-blocks-wrapper .breakdown-tax {
    font-weight: 600;
    opacity: 1;
    margin-left: auto;
}
