/**
 * AJAX Checkout Enhanced Styles
 * Comprehensive styling for improved checkout experience with loading states and error handling
 */

/* Form Field Validation States */
.tf-checkout-cart-main .is-valid {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25) !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' fill='%2328a745' viewBox='0 0 16 16'%3e%3cpath d='M12.736 3.97a.733.733 0 0 1 1.047 0c.286.289.29.756.01 1.05L7.88 12.01a.733.733 0 0 1-1.065.02L3.217 8.384a.757.757 0 0 1 0-1.06.733.733 0 0 1 1.047 0l3.052 3.093 5.4-6.425a.247.247 0 0 1 .02-.022Z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

.tf-checkout-cart-main .is-invalid {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23dc3545' viewBox='0 0 16 16'%3e%3cpath d='M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

.tf-checkout-cart-main select.is-valid,
.tf-checkout-cart-main select.is-invalid {
    background-position: right 0.75rem center, center right 2.25rem;
    padding-right: calc(0.75em + 2.3125rem);
}

/* Validation Messages */
.validation-message {
    margin-top: 0.25rem;
    min-height: 1.2rem;
    display: flex;
    align-items: center;
}

.validation-message small {
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.validation-message .icon {
    font-size: 0.875rem;
    margin-right: 0.25rem;
}

.validation-message .text-danger {
    color: #dc3545 !important;
}

.validation-message .text-success {
    color: #28a745 !important;
}

/* Loading States */
.checkout-form-loading {
    position: relative;
    pointer-events: none !important;
    opacity: 0.7 !important;
    transition: opacity 0.3s ease;
}

.checkout-form-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
    pointer-events: none;
}

.checkout-form-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 11;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Submit Button Loading State */
.tf-btn[disabled] {
    opacity: 0.8;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-loading .spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.125em;
}

/* Enhanced Notifications */
.notification-alert {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
    backdrop-filter: blur(10px);
    animation: slideInRight 0.3s ease-out;
}

.notification-alert.alert-success {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.notification-alert.alert-danger {
    background: linear-gradient(135deg, #dc3545, #e74c3c);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.notification-alert.alert-info {
    background: linear-gradient(135deg, #17a2b8, #007bff);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.notification-alert.alert-warning {
    background: linear-gradient(135deg, #ffc107, #fd7e14);
    color: #212529;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.notification-alert .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.notification-alert.alert-warning .btn-close {
    filter: brightness(0) invert(0);
}

@keyframes slideInRight {
    0% {
        transform: translateX(100%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Field Focus Enhancement */
.tf-checkout-cart-main input:focus,
.tf-checkout-cart-main select:focus,
.tf-checkout-cart-main textarea:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Payment Method Enhancement */
.payment_accordion {
    transition: all 0.3s ease;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.payment_accordion:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.payment_check {
    cursor: pointer;
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.payment_check:hover {
    border-color: #007bff;
    background-color: rgba(0, 123, 255, 0.05);
}

.payment_check input:checked ~ .pay-title {
    color: #007bff;
    font-weight: 600;
}

.payment_check input:checked {
    background-color: #007bff;
    border-color: #007bff;
}

/* Terms Checkbox Enhancement */
.checkbox-wrap {
    position: relative;
    margin-bottom: 1rem;
}

.checkbox-wrap input[type="checkbox"] {
    margin-right: 0.5rem;
    transform: scale(1.2);
}

.checkbox-wrap label {
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.checkbox-wrap input:checked ~ label {
    color: #007bff;
}

/* Order Summary Enhancement */
.box-your-order {
    background: #f8f9fa;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
    position: sticky;
    top: 20px;
}

.order-item {
    padding: 1rem 0;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s ease;
}

.order-item:hover {
    background-color: rgba(0, 123, 255, 0.02);
    border-radius: 0.25rem;
    margin: 0 -0.5rem;
    padding: 1rem 0.5rem;
}

.order-item:last-child {
    border-bottom: none;
}

.img-prd {
    width: 60px;
    height: 60px;
    border-radius: 0.5rem;
    overflow: hidden;
    flex-shrink: 0;
}

.img-prd img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.order-item:hover .img-prd img {
    transform: scale(1.05);
}

/* Total Section Enhancement */
.last-total {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.list-total {
    list-style: none;
    padding: 0;
    margin: 0;
}

.total-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #dee2e6;
}

.total-item:last-child {
    border-bottom: none;
    margin-bottom: 1rem;
}

/* Form Section Headers */
.tf-page-checkout h2.title {
    color: #212529;
    font-weight: 600;
    margin-bottom: 1.5rem;
    position: relative;
    padding-bottom: 0.5rem;
}

.tf-page-checkout h2.title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    border-radius: 2px;
}

/* Responsive Enhancements */
@media (max-width: 991.98px) {
    .fl-sidebar-cart {
        margin-top: 2rem;
    }
    
    .box-your-order {
        position: static;
    }
    
    .notification-alert {
        right: 10px;
        left: 10px;
        min-width: auto;
        max-width: none;
    }
}

@media (max-width: 575.98px) {
    .tf-checkout-cart-main .cols.tf-grid-layout.sm-col-2 {
        grid-template-columns: 1fr;
    }
    
    .notification-alert {
        font-size: 0.875rem;
    }
    
    .validation-message small {
        font-size: 0.8rem;
    }
}

/* Error State Animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

.field-error-animation {
    animation: shake 0.6s ease-in-out;
}

/* Success State Animation */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.field-success-animation {
    animation: pulse 0.6s ease-in-out;
}

/* Form Progress Indicator */
.checkout-progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 0.5rem;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
}

.progress-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 20px;
    right: -50%;
    width: 100%;
    height: 2px;
    background: #dee2e6;
    z-index: 1;
}

.progress-step.active::after {
    background: #007bff;
}

.progress-step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #dee2e6;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 2;
}

.progress-step.active .progress-step-number {
    background: #007bff;
    color: white;
}

.progress-step.completed .progress-step-number {
    background: #28a745;
    color: white;
}

.progress-step-text {
    font-size: 0.875rem;
    text-align: center;
    color: #6c757d;
}

.progress-step.active .progress-step-text {
    color: #007bff;
    font-weight: 600;
}

.progress-step.completed .progress-step-text {
    color: #28a745;
}

/* Accessibility Improvements */
.tf-checkout-cart-main input:focus,
.tf-checkout-cart-main select:focus,
.tf-checkout-cart-main textarea:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.tf-checkout-cart-main .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .is-valid {
        border-color: #006600 !important;
    }
    
    .is-invalid {
        border-color: #cc0000 !important;
    }
    
    .text-success {
        color: #006600 !important;
    }
    
    .text-danger {
        color: #cc0000 !important;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .tf-checkout-cart-main input,
    .tf-checkout-cart-main select,
    .tf-checkout-cart-main textarea,
    .payment_accordion,
    .payment_check,
    .order-item,
    .notification-alert {
        transition: none;
    }
    
    .field-error-animation,
    .field-success-animation {
        animation: none;
    }
    
    .checkout-form-loading::after {
        animation: none;
    }
}
