/**
 * PW Variations Manager - Frontend Styles
 *
 * @package PW_Variations_Manager
 */

/* ==========================================================================
   Measurements Form
   ========================================================================== */

.pwvm-medidas-form {
    margin: 20px 0;
    padding: 16px;
    background: #f8f9fa;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
}

.pwvm-medidas-form--table {
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    width: 100%;
}

.pwvm-medidas-form--table .pwvm-form-row {
    gap: 10px;
    width: 100%;
}

.pwvm-medidas-form--table .pwvm-field {
    min-width: 120px;
}

.pwvm-medidas-form--table .pwvm-input-number {
    max-width: 100%;
    width: 100%;
}

.pwvm-measurements-row .value {
    width: 100%;
}

/* Keep dependent row visually attached to its controller */
tr.pwvm-merge-top th,
tr.pwvm-merge-top td {
    border-top: 0 !important;
    padding-top: 0 !important;
}

tr.pwvm-merge-top {
    border-top: 0 !important;
}

tr.pwvm-merge-top::before,
tr.pwvm-merge-top::after {
    border-top: 0 !important;
}

form.cart table.variations tr.pwvm-merge-top,
form.woocommerce-cart-form table.variations tr.pwvm-merge-top {
    border-top: 0 !important;
    border-top-style: none !important;
    border-top-width: 0 !important;
}

tr.pwvm-merge-bottom th,
tr.pwvm-merge-bottom td {
    border-bottom: 0 !important;
    padding-bottom: 0 !important;
}

tr.pwvm-merge-bottom {
    border-bottom: 0 !important;
}

tr.pwvm-merge-bottom::before,
tr.pwvm-merge-bottom::after {
    border-bottom: 0 !important;
}

form.cart table.variations tr.pwvm-merge-bottom,
form.woocommerce-cart-form table.variations tr.pwvm-merge-bottom {
    border-bottom: 0 !important;
    border-bottom-style: none !important;
    border-bottom-width: 0 !important;
}

.pwvm-form-title {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
}

.pwvm-form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.pwvm-field {
    flex: 1;
    min-width: 140px;
}

.pwvm-field label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: #1d2327;
}

.pwvm-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pwvm-unit {
    font-weight: 400;
    color: #757575;
    font-size: 0.85em;
}

.pwvm-range-hint {
    display: block;
    font-weight: 400;
    color: #757575;
    font-size: 11px;
    margin-top: 4px;
}

.pwvm-input-number {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.2;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.pwvm-input-number:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.15);
}

.pwvm-input-number.pwvm-valid {
    border-color: #46b450;
}

.pwvm-input-number.pwvm-invalid {
    border-color: #dc3232;
}

.pwvm-input-feedback {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    min-height: 14px;
}

.pwvm-input-feedback.error {
    color: #dc3232;
}

/* Loading state */
.pwvm-medidas-form.pwvm-loading {
    position: relative;
    pointer-events: none;
}

.pwvm-medidas-form.pwvm-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.pwvm-medidas-form.pwvm-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid #e1e4e8;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: pwvm-spin 0.8s linear infinite;
    z-index: 1;
}

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

/* No match message */
.pwvm-no-match-message {
    margin-top: 12px;
    padding: 10px 14px;
    background: #fff8e5;
    border: 1px solid #ffb900;
    border-radius: 4px;
    color: #826200;
    font-size: 14px;
}

/* ==========================================================================
   Dynamic Price Display
   ========================================================================== */

.pw-dynamic-price {
    transition: opacity 0.2s;
}

.pw-dynamic-price .pw-price-display {
    display: inline-block;
}

.pw-dynamic-price.pwvm-price-updated .pw-price-display {
    animation: pwvm-highlight 0.6s ease;
}

@keyframes pwvm-highlight {
    0% { background-color: rgba(0, 115, 170, 0.15); }
    100% { background-color: transparent; }
}

/* ==========================================================================
   Conditional Attribute Visibility
   ========================================================================== */

.pwvm-visible {
    display: table-row !important;
}

/* Smooth transition for hiding */
tr.pwvm-visible {
    opacity: 1;
    transition: opacity 0.2s;
}

/* ==========================================================================
   WooCommerce Variation Override
   ========================================================================== */

/* Hide default WooCommerce variation price when using our shortcode */
.product .pw-dynamic-price ~ .woocommerce-variation-price,
.product .woocommerce-variation-price:has(~ .pw-dynamic-price) {
    display: none !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 480px) {
    .pwvm-form-row {
        flex-direction: column;
        gap: 15px;
    }

    .pwvm-field {
        width: 100%;
        min-width: 100%;
    }

    .pwvm-medidas-form {
        padding: 15px;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .pwvm-medidas-form {
        background: #fff;
        border: 1px solid #000;
        page-break-inside: avoid;
    }

    .pwvm-input-number {
        border: 1px solid #000;
    }
}
