/**
 * Door Price Calculator Styles - Theme Adaptive
 *
 * @package DoorPriceCalculator
 */

.dpc-calculator-wrapper {
    margin: 0 0 20px 0;
    clear: both;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Force visibility for variable products */
.variations_form .dpc-calculator-wrapper {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Hide the default variations reset button when door calculator is enabled */
body.dpc-calculator-enabled .reset_variations {
    display: none !important;
}

.dpc-calculator-title {
    display: none;
}

.dpc-calculator-form {
    display: block;
}

.dpc-calculator-section {
    margin-bottom: 0;
    margin-top: 0;
}

.dpc-calculator-section:last-of-type {
    margin-bottom: 0;
}

.dpc-calculator-section + .dpc-calculator-section {
    margin-top: 0;
}

.dpc-calculator-section h4 {
    display: none;
    margin: 0;
    padding: 0;
}

.dpc-form-row {
    display: table;
    width: 100%;
    margin-bottom: 0;
    margin-top: 0;
    border-spacing: 0;
    border-collapse: collapse;
}

.dpc-form-group {
    display: table-row;
}

/* Alternating row colors - gray, white, gray pattern (no borders) */
.dpc-form-group:nth-child(odd) label,
.dpc-form-group:nth-child(odd) > div {
    background-color: #f7f7f7;
}

.dpc-form-group:nth-child(even) label,
.dpc-form-group:nth-child(even) > div {
    background-color: #ffffff;
}

.dpc-form-group label {
    display: table-cell;
    padding: 12px 10px;
    vertical-align: middle;
    width: 33%;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
}

.dpc-form-group label .required {
    color: var(--wc-red, #dc3232);
}

.dpc-form-group label .dpc-range-text {
    display: block;
    font-size: 0.85em;
    font-weight: normal;
    opacity: 0.7;
    margin-top: 3px;
    text-align: center;
}

.dpc-form-group > div {
    display: table-cell;
    padding: 12px 10px;
    vertical-align: middle;
}

.dpc-form-group input[type="number"],
.dpc-form-group select {
    width: 100%;
    max-width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: inherit;
    font-family: inherit;
    background-color: #ffffff;
    line-height: 1.5;
}

.dpc-form-group input[type="number"]:focus,
.dpc-form-group select:focus {
    outline: none;
    border-color: #999;
}

.dpc-help-text {
    display: none;
}

.dpc-options-group {
    display: table;
    width: 100%;
    border-spacing: 0;
    border-collapse: collapse;
    margin-top: 0;
}

.dpc-option-item {
    display: table-row;
}

/* Alternating row colors for options - continue the pattern */
.dpc-option-item:nth-child(odd) .dpc-option-checkbox-cell,
.dpc-option-item:nth-child(odd) .dpc-option-label {
    background-color: #f7f7f7;
}

.dpc-option-item:nth-child(even) .dpc-option-checkbox-cell,
.dpc-option-item:nth-child(even) .dpc-option-label {
    background-color: #ffffff;
}

.dpc-option-item:hover .dpc-option-checkbox-cell,
.dpc-option-item:hover .dpc-option-label {
    background-color: #f0f0f0;
}

.dpc-option-checkbox-cell {
    display: table-cell;
    width: 33%;
    padding: 12px 10px;
    vertical-align: middle;
    text-align: center;
}

.dpc-option-item input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--theme-color, var(--wc-blue, #2271b1));
    width: 18px;
    height: 18px;
    margin: 0;
}

.dpc-option-label {
    display: table-cell;
    padding: 12px 10px;
    vertical-align: middle;
    font-size: inherit;
    text-align: left;
    cursor: pointer;
}

.dpc-calculator-summary {
    margin-top: 0;
}

.dpc-calculation-info {
    margin-bottom: 0;
}

.dpc-calculator-actions {
    margin-top: 0;
    padding: 8px 10px;
    text-align: center;
    background-color: #f7f7f7;
}

.dpc-reset-button {
    display: inline-block;
    color: #dc3232;
    text-decoration: none;
    font-size: 11px;
    font-weight: 400;
    opacity: 0.8;
    transition: all 0.2s ease;
}

.dpc-reset-button:hover {
    color: #a00;
    opacity: 1;
    text-decoration: underline;
}

.dpc-reset-button:focus {
    outline: none;
    color: #a00;
    opacity: 1;
}

.dpc-area-display {
    font-size: 0.9em;
    display: block;
    opacity: 0.7;
}

.dpc-area-display strong {
    font-weight: 600;
}

.dpc-price-display {
    display: table;
    width: 100%;
    border-spacing: 0;
    border-collapse: collapse;
}

.dpc-price-label {
    display: table-cell;
    padding: 12px 10px;
    vertical-align: middle;
    width: 33%;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    background-color: #f7f7f7;
}

.dpc-price-value {
    display: table-cell;
    padding: 12px 10px;
    vertical-align: middle;
    text-align: left;
    font-size: 1.5em;
    font-weight: 700;
    background-color: #f7f7f7;
}

.dpc-price-value .woocommerce-Price-amount {
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
}

/* Sale price styling */
.dpc-price-wrapper {
    display: block;
}

.dpc-prices {
    display: block;
    margin-bottom: 4px;
}

.dpc-price-value del,
.dpc-price-value .dpc-regular-price {
    opacity: 0.6;
    margin-right: 8px;
    font-size: 0.7em;
    font-weight: 400;
    text-decoration: line-through;
}

.dpc-price-value ins,
.dpc-price-value .dpc-sale-price {
    text-decoration: none;
    background: transparent;
    font-weight: 700;
    font-size: 1em;
}

.dpc-savings {
    font-size: 0.65em;
    color: #77a464;
    font-weight: 400;
    margin-top: 4px;
    opacity: 0.9;
}

.dpc-error-message {
    background: var(--wc-red-50, #ffebee);
    border: 1px solid var(--wc-red, #dc3232);
    color: var(--wc-red, #dc3232);
    padding: 10px 12px;
    border-radius: 3px;
    margin-top: 12px;
    font-size: 0.95em;
}

.dpc-loading {
    opacity: 0.6;
    pointer-events: none;
}

.dpc-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: dpc-spin 1s linear infinite;
}

@keyframes dpc-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Admin Styles */
.dpc-meta-box p {
    margin: 10px 0;
}

.dpc-meta-box label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
}

.dpc-meta-box .description {
    font-style: italic;
    color: #666;
    font-size: 12px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dpc-form-group label,
    .dpc-form-group > div {
        display: block;
        width: 100%;
        padding: 8px 10px;
    }
    
    .dpc-form-group label {
        padding-bottom: 4px;
    }
    
    .dpc-form-group label .dpc-range-text {
        margin-top: 2px;
    }
    
    .dpc-form-group > div {
        padding-top: 4px;
        padding-bottom: 8px;
    }

    /* Maintain alternating colors on mobile */
    .dpc-form-group:nth-child(odd) label,
    .dpc-form-group:nth-child(odd) > div {
        background-color: #f7f7f7;
    }

    .dpc-form-group:nth-child(even) label,
    .dpc-form-group:nth-child(even) > div {
        background-color: #ffffff;
    }

    .dpc-price-label,
    .dpc-price-value {
        display: block;
        width: 100%;
        padding: 8px 10px;
    }
    
    .dpc-price-label {
        padding-bottom: 4px;
    }
    
    .dpc-price-value {
        padding-top: 4px;
        font-size: 1.1em;
    }

    .dpc-option-checkbox-cell,
    .dpc-option-label {
        padding: 12px 10px;
    }
    
    .dpc-option-item input[type="checkbox"] {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 480px) {
    .dpc-option-label {
        font-size: 0.9em;
    }
    
    .dpc-option-checkbox-cell {
        width: 25%;
    }
    
    .dpc-calculator-actions {
        padding: 6px 10px;
    }
    
    .dpc-reset-button {
        font-size: 10px;
    }
}

/* WooCommerce Compatibility */
.woocommerce div.product form.cart .dpc-calculator-wrapper {
    margin-bottom: 15px;
    margin-top: 0;
}

.woocommerce div.product form.cart .variations {
    margin-bottom: 20px;
}

/* Calculator appears after variations table */
.woocommerce .variations_form .dpc-calculator-wrapper {
    margin-top: 20px;
    margin-bottom: 15px;
}

/* Hide Add to Cart button until calculator is filled */
.dpc-calculator-enabled .single_add_to_cart_button {
    display: none !important;
}

.dpc-calculator-enabled.dpc-fields-filled .single_add_to_cart_button {
    display: inline-block !important;
}

/* Hide quantity field until calculator is filled */
.dpc-calculator-enabled .quantity {
    display: none !important;
}

.dpc-calculator-enabled.dpc-fields-filled .quantity {
    display: block !important;
}

/* Hide "Kontakt oss for tilbud" button when calculator is enabled (as soon as variation is selected) */
.dpc-calculator-enabled a[href*="kontakt"]:not(.woocommerce-LoopProduct-link),
.dpc-calculator-enabled .contact-button,
.dpc-calculator-enabled .quote-button,
.dpc-calculator-enabled a.button[href*="kontakt"],
.dpc-calculator-enabled .variations_form .button[href*="kontakt"] {
    display: none !important;
}

/* Hide all product and variation prices when calculator is enabled */
.dpc-calculator-enabled .woocommerce-variation-price,
.dpc-calculator-enabled .single_variation_wrap .woocommerce-variation-price,
.dpc-calculator-enabled .single_variation .price,
.dpc-calculator-enabled .product .price,
.dpc-calculator-enabled .summary .price,
.dpc-calculator-enabled p.price,
.dpc-calculator-enabled .woocommerce-Price-amount {
    display: none !important;
}

/* But keep the calculator's price visible */
.dpc-calculator-enabled .dpc-price-value,
.dpc-calculator-enabled .dpc-price-value .woocommerce-Price-amount {
    display: table-cell !important;
}

/* Cart & Checkout Display */
.woocommerce-cart-form .dpc-cart-meta,
.woocommerce-checkout-review-order .dpc-order-meta {
    font-size: 0.9em;
    opacity: 0.8;
    margin-top: 5px;
}

.woocommerce-cart-form .dpc-cart-meta strong,
.woocommerce-checkout-review-order .dpc-order-meta strong {
    font-weight: 600;
    opacity: 1;
}

/* Theme Integration */
body .dpc-calculator-wrapper * {
    box-sizing: border-box;
}

/* Inherit theme button styles if present */
.dpc-calculator-wrapper button.button,
.dpc-calculator-wrapper .button {
    font-family: inherit;
}

