/**
 * Tile M2 Calculator Styles
 */

/* Hide normal WooCommerce price when calculator is active */
.tmc-hidden-price {
    display: none !important;
}

/* Also hide the price in variation forms */
.single-product .tmc-calculator-wrapper ~ form.variations_form .woocommerce-variation-price {
    display: none !important;
}

/* Hide price range for variable products with calculator */
body.single-product .product.has-tmc-calculator .price:not(.tmc-price-per-m2) {
    display: none !important;
}


/* Price per m2 display */
.tmc-price-per-m2 {
    margin-bottom: 10px;
    padding: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    display: block;
    width: 100%;
    text-align: center;
}

.tmc-price-per-m2 .price-label {
    color: #666;
    font-weight: 400;
    margin-right: 5px;
}

.tmc-price-per-m2 .price-label.from-price {
    font-style: italic;
}

.tmc-price-per-m2 .price-amount {
    color: #c476c2;
    font-size: 18px;
}

.tmc-price-per-m2 .price-suffix {
    color: #666;
    font-weight: 400;
    font-size: 14px;
}

/* Calculator wrapper */
.tmc-calculator-wrapper {
    margin: 5px 0 15px 0;
    background: #fff;
}

.tmc-calculator-wrapper h4 {
    margin: 0 0 15px 0;
    padding: 0;
    font-size: 18px;
    color: #333;
    border-bottom: 2px solid #c476c2;
    padding-bottom: 8px;
}

/* Quantity fields */
.tmc-quantity-fields {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.tmc-qty-field {
    flex: 1;
    min-width: 150px;
}

.tmc-qty-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
    font-size: 0.95em;
}

    .tmc-qty-field input {
        margin-bottom: 0!important;
    }

.tmc-qty-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
    transition: all 0.3s ease;
    background: #fff;
    box-sizing: border-box;
}

.tmc-qty-input:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.tmc-qty-input:hover {
    border-color: #999;
}

/* Tile info display */
.tmc-tile-info {
    font-size: 14px;
    color: #666;
    text-align: center;
}

.tmc-tile-info .tile-size-info {
    display: block;
    line-height: 1.5;
}

/* Variation notice */
.tmc-variation-notice {
    margin-top: 10px;
    color: #666;
    font-size: 14px; 
    font-style: italic;
    text-align: center;
}

.tmc-variation-notice small {
    display: block;
}

/* Disabled input styles */
.tmc-qty-input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Loading/updating state */
.tmc-calculator-wrapper.updating .tmc-qty-input {
    background-color: #f9f9f9;
    position: relative;
}

.tmc-calculator-wrapper.updating .tmc-qty-field::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 15px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid #0073aa;
    border-top-color: transparent;
    border-radius: 50%;
    animation: tmc-spin 0.6s linear infinite;
}

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

/* Highlight updated fields */
.tmc-qty-input.updated {
    animation: tmc-highlight 0.5s ease;
}

@keyframes tmc-highlight {
    0% { background-color: #fff; }
    50% { background-color: #e8f4f8; }
    100% { background-color: #fff; }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .tmc-quantity-fields {
        flex-direction: column;
        gap: 15px;
    }
    
    .tmc-qty-field {
        width: 100%;
    }
    
    .tmc-calculator-wrapper {
        padding: 15px;
    }
    
    .tmc-price-per-m2 {
        display: block;
        text-align: center;
        width: 100%;
        box-sizing: border-box;
    }
}

/* Integration with WooCommerce quantity field */
.tmc-calculator-wrapper ~ .quantity,
.tmc-calculator-wrapper ~ form .quantity {
    display: none !important;
}

/* Hide quantity field in variable product forms when calculator is active */
.has-tmc-calculator form.cart .quantity,
.has-tmc-calculator form.variations_form .quantity {
    display: none !important;
}

/* Hide the quantity label if it exists */
.has-tmc-calculator label[for="quantity"],
.has-tmc-calculator .quantity-label {
    display: none !important;
}

/* Variable product adjustments */
.variations_form .tmc-calculator-wrapper {
    clear: both;
    margin-top: 5px;
}

/* Add to cart button with price */
.single_add_to_cart_button .tmc-button-text {
    display: inline-block;
    width: 100%;
}

/* Ensure button maintains proper styling when text changes */
.single_add_to_cart_button {
    min-width: 200px;
    white-space: nowrap;
    transition: all 0.3s ease;
}

/* Optional: Add icon or separator for price display */
.single_add_to_cart_button .tmc-price-separator {
    margin: 0 5px;
    opacity: 0.7;
}