/**
 * Frontend CSS for Calculated Products
 */

/* Main Container */
.calculated-product-parameters {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 25px;
    margin: 25px 0;
}

.calculated-product-parameters h3 {
    margin: 0 0 20px 0;
    padding: 0 0 15px 0;
    border-bottom: 2px solid #007cba;
    color: #333;
    font-size: 1.3em;
    font-weight: 600;
}

/* Parameter Fields */
.parameter-field {
    margin-bottom: 20px;
}

.parameter-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.parameter-input {
    width: 100%;
    max-width: 350px;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    background-color: #fff;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.parameter-input:focus {
    border-color: #007cba;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

.parameter-input:invalid {
    border-color: #dc3545;
}

.parameter-description {
    display: block;
    margin-top: 6px;
    color: #6c757d;
    font-size: 13px;
    line-height: 1.4;
}

/* Price Display */
.calculated-price-display {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #007cba;
    border-radius: 8px;
    padding: 20px;
    margin: 25px 0;
    text-align: center;
}

.price-label {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.price-amount {
    font-size: 2em;
    font-weight: bold;
    color: #28a745;
    margin-bottom: 5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.price-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #007cba;
    font-weight: 500;
}

.price-loading .spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #e3f2fd;
    border-top-color: #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Form Styling */
.calculated-product-form {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.calculated-product-form .quantity {
    margin: 20px 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.calculated-product-form .quantity label {
    font-weight: 600;
    color: #333;
    margin-bottom: 0;
}

.calculated-product-form .quantity input {
    width: 80px;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 16px;
}

/* Add to Cart Button */
.single_add_to_cart_button {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 15px 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.2);
}

.single_add_to_cart_button:hover:not(:disabled) {
    background: linear-gradient(135deg, #218838 0%, #1ea085 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(40, 167, 69, 0.3);
}

.single_add_to_cart_button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

/* Error Messages */
.calculated-products-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-left: 4px solid #dc3545;
    border-radius: 4px;
    padding: 12px 15px;
    margin: 15px 0;
    font-size: 14px;
    line-height: 1.5;
}

/* Select Styling */
select.parameter-input {
    background-image: url("data:image/svg+xml;charset=US-ASCII,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'><path fill='%23666' d='m0,1l2,2l2,-2z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* Loading States */
.updating-price {
    opacity: 0.6;
    position: relative;
    pointer-events: none;
}

.updating-price::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ddd;
    border-top-color: #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

/* Responsive Design */
@media (max-width: 768px) {
    .calculated-product-parameters {
        padding: 20px 15px;
        margin: 20px 0;
    }
    
    .parameter-input {
        max-width: 100%;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .price-amount {
        font-size: 1.8em;
    }
    
    .calculated-product-form .quantity {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .single_add_to_cart_button {
        width: 100%;
        padding: 15px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .calculated-product-parameters {
        padding: 15px 10px;
        border-radius: 6px;
    }
    
    .calculated-product-parameters h3 {
        font-size: 1.2em;
    }
    
    .calculated-price-display {
        padding: 15px;
    }
    
    .price-amount {
        font-size: 1.6em;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .calculated-product-parameters {
        background: #2c3e50;
        border-color: #34495e;
        color: #ecf0f1;
    }
    
    .calculated-product-parameters h3 {
        color: #ecf0f1;
        border-bottom-color: #3498db;
    }
    
    .parameter-field label {
        color: #ecf0f1;
    }
    
    .parameter-input {
        background-color: #34495e;
        border-color: #4a5f7a;
        color: #ecf0f1;
    }
    
    .parameter-input:focus {
        border-color: #3498db;
        box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    }
    
    .calculated-price-display {
        background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
        border-color: #3498db;
    }
    
    .price-label {
        color: #bdc3c7;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Focus Styles for Accessibility */
.parameter-input:focus,
.single_add_to_cart_button:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .parameter-input {
        border-width: 3px;
    }
    
    .single_add_to_cart_button {
        border: 2px solid #000;
    }
    
    .calculated-price-display {
        border-width: 3px;
    }
}