/**
 * Extended Warranty Styles
 * Styling for warranty options display on single product pages
 */

/* Extended Warranty Options Container */
.extended-warranty-options {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.extended-warranty-options h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

/* Warranty Options List */
.warranty-options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Individual Warranty Option */
.warranty-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.warranty-option:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
}

.warranty-option input[type="radio"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #007bff;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    position: relative;
    margin-right: 12px;
    flex-shrink: 0;
}

.warranty-option input[type="radio"]:checked {
    background: #007bff;
}

.warranty-option input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

.warranty-option input[type="radio"]:checked + .warranty-label {
    font-weight: 600;
    color: #007bff;
}

/* Warranty Label */
.warranty-label {
    flex: 1;
    font-size: 14px;
    color: #333;
    transition: all 0.3s ease;
}

/* Warranty Price */
.warranty-price {
    font-size: 14px;
    font-weight: 600;
    color: #28a745;
    margin-left: 10px;
}

.warranty-option input[type="radio"]:checked ~ .warranty-price {
    color: #007bff;
}

/* Selected State */
.warranty-option:has(input[type="radio"]:checked) {
    border-color: #007bff;
    background: #f0f8ff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15);
}

/* No Warranty Option Styling */
.warranty-option:first-child {
    border-color: #6c757d;
}

.warranty-option:first-child:hover {
    border-color: #495057;
}

.warranty-option:first-child input[type="radio"] {
    border-color: #6c757d;
}

.warranty-option:first-child input[type="radio"]:checked {
    background: #6c757d;
}

.warranty-option:first-child .warranty-price {
    color: #6c757d;
}

/* Grand Total Integration */
.grand-warranty-line {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.grand-warranty-line .label {
    font-size: 14px;
    color: #666;
}

.grand-warranty-line .amount {
    font-size: 14px;
    font-weight: 600;
    color: #007bff;
}

/* Responsive Design */
@media (max-width: 768px) {
    .extended-warranty-options {
        margin: 15px 0;
        padding: 15px;
    }
    
    .warranty-option {
        padding: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .warranty-option input[type="radio"] {
        margin-right: 0;
        margin-bottom: 5px;
    }
    
    .warranty-label {
        font-size: 13px;
    }
    
    .warranty-price {
        font-size: 13px;
        margin-left: 0;
        align-self: flex-end;
    }
}

@media (max-width: 480px) {
    .extended-warranty-options h4 {
        font-size: 15px;
    }
    
    .warranty-options-list {
        gap: 10px;
    }
    
    .warranty-option {
        padding: 10px;
    }
    
    .warranty-label {
        font-size: 12px;
    }
    
    .warranty-price {
        font-size: 12px;
    }
}

/* Animation for warranty selection */
.warranty-option {
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Loading state for add to cart button when warranty is selected */
.single_add_to_cart_button.warranty-loading {
    position: relative;
    color: transparent;
}

.single_add_to_cart_button.warranty-loading::after {
    content: "Adding with Warranty...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 14px;
}

/* Integration with existing grand total styles */
.grand-total-breakdown .grand-warranty-line {
    display: flex;
}

/* Warranty badge for cart items */
.warranty-badge {
    display: inline-block;
    background: #007bff;
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 5px;
    font-weight: 500;
}

/* Admin warranty options styling */
.warranty-options-admin {
    margin-top: 15px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.warranty-options-admin h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 14px;
    font-weight: 600;
}

.warranty-options-admin .description {
    margin: 0 0 15px 0;
    color: #666;
    font-style: italic;
}

.warranty-option-row {
    display: grid;
    grid-template-columns: 1fr 2fr 100px 80px;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.warranty-option-row input[type="text"] {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
}

.warranty-option-row input[type="number"] {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
}

.warranty-option-row .button {
    background: #dc3545;
    border-color: #dc3545;
    color: white;
    padding: 5px 10px;
    font-size: 12px;
    height: auto;
    line-height: 1.2;
}

.warranty-option-row .button:hover {
    background: #c82333;
    border-color: #bd2130;
}

#add-warranty-option {
    background: #0073aa;
    border-color: #0073aa;
    color: white;
    margin-top: 10px;
}

#add-warranty-option:hover {
    background: #005a87;
    border-color: #005a87;
}

/* Admin form field styling */
.woocommerce_options_panel .warranty-options-admin {
    margin: 0;
    padding: 12px;
}

/* WordPress admin specific styling */
.woocommerce_options_panel .warranty-options-admin .warranty-option-row input[type="text"],
.woocommerce_options_panel .warranty-options-admin .warranty-option-row input[type="number"] {
    margin: 0 !important;
    box-shadow: inset 0 1px 2px rgba(0,0,0,.07);
}

.woocommerce_options_panel .warranty-options-admin .button {
    margin: 0 !important;
    text-decoration: none;
    cursor: pointer;
}

/* Fix for WordPress admin form styling conflicts */
.warranty-options-admin input[type="text"]:focus,
.warranty-options-admin input[type="number"]:focus {
    border-color: #5b9dd9;
    box-shadow: 0 0 2px rgba(30,140,190,.8);
}

/* Responsive admin styling */
@media (max-width: 782px) {
    .warranty-option-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .warranty-option-row input[type="text"],
    .warranty-option-row input[type="number"] {
        width: 100%;
    }
}
