/* FINAL FIX for quantity field layout */

/* Main container */
.wcc-quantity-option {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Left side container - make it take available space but not force full width */
.wcc-quantity-option > div:first-child {
    flex: 1 1 0 !important; /* Take available space but can shrink */
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    min-width: 0 !important;
}

/* Title container - fixed width, centered content */
.wcc-quantity-option > div:first-child > div:not(.wcc-option-image) {
    flex: 0 0 160px !important; /* Fixed width */
    text-align: center !important;
}

/* H4 title styling - FORCE CENTER AND COMPACT */
.wcc-quantity-option h4 {
    display: block !important;
    margin: 0 0 4px 0 !important;
    padding: 0 5px !important; /* Small padding for text breathing room */
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #333 !important;
    line-height: 1.3 !important;
    text-align: center !important;
    white-space: nowrap !important; /* Keep on one line */
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    width: 100% !important; /* Full width of container */
    
    /* Force horizontal text */
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    letter-spacing: normal !important;
    word-spacing: normal !important;
}

/* Price styling - centered */
.wcc-option-price {
    text-align: center !important;
    display: block !important;
    margin: 0 auto !important;
}

/* Quantity controls container - keep compact but with margin */
.wcc-quantity-option > div[style*="flex-shrink: 0"] {
    flex: 0 0 auto !important;
    max-width: 210px !important;
    margin-right: 10px !important;
}

/* Override any inline styles that set width */
.wcc-quantity-option div[style*="width: 100%"] h4 {
    width: auto !important;
}

.wcc-quantity-option div[style*="flex: 1"] {
    flex: 0 0 auto !important;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .wcc-quantity-option {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 10px !important;
    }
    
    /* Left container on mobile */
    .wcc-quantity-option > div:first-child {
        width: 100% !important;
        flex-direction: column !important;
        align-items: center !important;
        margin-bottom: 10px !important;
    }
    
    /* Image on mobile */
    .wcc-option-image {
        margin: 0 auto 8px auto !important;
    }
    
    /* Title container on mobile - remove fixed width */
    .wcc-quantity-option > div:first-child > div:not(.wcc-option-image) {
        flex: 1 1 auto !important;
        width: 100% !important;
        text-align: center !important;
    }
    
    /* H4 title on mobile - CRITICAL FIX */
    .wcc-quantity-option h4 {
        display: inline-block !important;
        width: auto !important;
        max-width: 100% !important;
        margin: 0 auto 4px auto !important;
        padding: 0 10px !important;
        font-size: 13px !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        line-height: 1.4 !important;
        text-align: center !important;
        
        /* FORCE HORIZONTAL TEXT ON MOBILE */
        writing-mode: horizontal-tb !important;
        text-orientation: mixed !important;
        -webkit-writing-mode: horizontal-tb !important;
        -ms-writing-mode: lr-tb !important;
        letter-spacing: 0 !important;
        transform: none !important;
        display: block !important;
    }
    
    /* Quantity controls on mobile */
    .wcc-quantity-option > div[style*="flex-shrink: 0"] {
        width: auto !important;
        margin: 0 auto !important;
        max-width: 180px !important;
    }
}

/* CRITICAL - Override any width: 100% on h4 with maximum specificity */
html body .woocommerce .wcc-customization-container .wcc-quantity-option h4[style*="width: 100%"],
html body .wcc-quantity-option h4[style*="width: 100%"],
.wcc-quantity-option h4[style*="width: 100%"] {
    width: auto !important;
}

/* Force center alignment on all text elements in title area */
.wcc-quantity-option > div:first-child * {
    text-align: center !important;
}