/* Checkout Popup Modal Styles */
:root {
    /* Inherit from main styles */
    --popup-primary: var(--primary-color, #d87126);
    --popup-success: #27ae60;
    --popup-danger: #e74c3c;
    --popup-warning: #f39c12;
    --popup-light: var(--extra-light, #fdfaf6);
    --popup-dark: var(--text-dark, #171717);
    --popup-border: var(--border-color, #e5e5e5);
    --popup-shadow: var(--boxshadow-color, rgba(0, 0, 0, 0.2));
    --popup-shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Dark theme variables */
[data-theme="dark"] {
    --popup-light: var(--background-color, #121212);
    --popup-dark: var(--text-dark, #ffffff);
    --popup-border: var(--border-color, #333333);
    --popup-shadow: var(--boxshadow-color, rgba(0, 0, 0, 0.4));
    --popup-shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* Modal Overlay */
.checkout-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.checkout-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal Container */
.checkout-modal {
    background: var(--white, #ffffff);
    border-radius: 20px;
    box-shadow: var(--popup-shadow-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.8) translateY(50px);
    transition: all 0.3s ease;
    position: relative;
}

[data-theme="dark"] .checkout-modal {
    background: var(--card-bg, #1e1e1e);
    border: 1px solid var(--popup-border);
}

.checkout-modal-overlay.active .checkout-modal {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.modal-header {
    background: linear-gradient(135deg, var(--popup-primary), var(--primary-color-dark, #a85518));
    color: white;
    padding: 1.5rem;
    border-radius: 20px 20px 0 0;
    position: relative;
    text-align: center;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    font-family: 'Poppins', sans-serif;
}

/* Stock Banner */
.stock-banner {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    padding: 1rem;
    margin: 1.5rem;
    margin-bottom: 0;
    text-align: center;
    border: 1px solid var(--popup-border);
}

[data-theme="dark"] .stock-banner {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    border-color: var(--popup-border);
}

.stock-date {
    font-size: 0.9rem;
    color: var(--text-light, #737373);
    margin-bottom: 0.25rem;
    display: block;
}

.stock-count {
    font-size: 1rem;
    font-weight: 600;
    color: var(--popup-dark);
}

/* Modal Body */
.modal-body {
    padding: 1.5rem;
}

/* Selected Product Display */
.selected-product {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--popup-border);
}

.product-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.product-image-display {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 15px;
    overflow: hidden;
    background: rgba(216, 113, 38, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.product-image-display img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

.product-info {
    flex: 1;
}

.product-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--popup-dark);
    margin: 0 0 0.5rem 0;
    font-family: 'Poppins', sans-serif;
}

.product-description {
    font-size: 0.9rem;
    color: var(--text-light, #737373);
    margin: 0 0 0.5rem 0;
    line-height: 1.4;
}

.base-price {
    font-size: 1rem;
    font-weight: 600;
    color: var(--popup-primary);
}

/* Product Options */
.product-options {
    margin-bottom: 1.5rem;
}

.product-option {
    border: 2px solid var(--popup-border);
    border-radius: 15px;
    margin-bottom: 1rem;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.product-option:hover {
    border-color: var(--popup-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(216, 113, 38, 0.15);
}

.product-option.selected {
    border-color: var(--popup-primary);
    background: rgba(216, 113, 38, 0.05);
}

.product-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    margin: 0;
}

.product-option-label {
    display: flex;
    align-items: center;
    padding: 1rem;
    gap: 1rem;
}

.option-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--popup-primary);
    min-width: 80px;
}

.option-content {
    flex: 1;
}

.option-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--popup-dark);
    margin-bottom: 0.25rem;
}

.option-description {
    font-size: 0.9rem;
    color: var(--text-light, #737373);
    margin-bottom: 0.5rem;
}

.option-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.option-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-free-shipping {
    background: var(--popup-success);
    color: white;
}

.badge-best-seller {
    background: var(--popup-danger);
    color: white;
}

/* Form Fields */
.form-section {
    margin-bottom: 1.5rem;
}

.form-section h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--popup-dark);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--popup-border);
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--popup-dark);
    margin-bottom: 0.5rem;
}

.required {
    color: var(--popup-danger);
}

.form-control, .form-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--popup-border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    background: var(--white, #ffffff);
    color: var(--popup-dark);
    transition: all 0.3s ease;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: var(--card-bg, #1e1e1e);
    border-color: var(--popup-border);
    color: var(--popup-dark);
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--popup-primary);
    box-shadow: 0 0 0 0.2rem rgba(216, 113, 38, 0.25);
}

/* Variety Selection */
.variety-section {
    margin-bottom: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--popup-border);
}

.variety-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--popup-dark);
    margin-bottom: 0.5rem;
    display: block;
}

.variety-options {
    color: var(--popup-primary);
    font-weight: 700;
    font-size: 0.9rem;
}

.variety-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--popup-border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    background: var(--white, #ffffff);
    color: var(--popup-dark);
    transition: all 0.3s ease;
}

[data-theme="dark"] .variety-input {
    background: var(--card-bg, #1e1e1e);
    border-color: var(--popup-border);
    color: var(--popup-dark);
}

.variety-input:focus {
    outline: none;
    border-color: var(--popup-primary);
    box-shadow: 0 0 0 0.2rem rgba(216, 113, 38, 0.25);
}

/* Order Summary */
.order-summary {
    background: rgba(216, 113, 38, 0.05);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(216, 113, 38, 0.2);
}

[data-theme="dark"] .order-summary {
    background: rgba(216, 113, 38, 0.1);
    border-color: rgba(216, 113, 38, 0.3);
}

.summary-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--popup-primary);
    margin-bottom: 1rem;
    text-align: center;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.summary-row:last-child {
    margin-bottom: 0;
}

.summary-row.total {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--popup-primary);
    padding-top: 0.75rem;
    border-top: 2px solid var(--popup-primary);
}

/* Action Buttons */
.modal-actions {
    padding: 0 1.5rem 1.5rem;
}

.checkout-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--popup-primary), var(--primary-color-dark, #a85518));
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.checkout-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(216, 113, 38, 0.3);
}

.checkout-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.checkout-btn i {
    font-size: 1.2rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .checkout-modal {
        margin: 0.5rem;
        max-height: 95vh;
        border-radius: 15px;
    }
    
    .modal-header {
        padding: 1.25rem;
        border-radius: 15px 15px 0 0;
    }
    
    .modal-title {
        font-size: 1.25rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .stock-banner {
        margin: 1rem;
        margin-bottom: 0;
        padding: 0.75rem;
    }
    
    /* Mobile Product Header */
    .product-header {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    .product-image-display {
        width: 100px;
        height: 100px;
        margin: 0 auto;
    }
    
    .product-name {
        font-size: 1.1rem;
    }
    
    .product-description {
        font-size: 0.85rem;
    }
    
    .product-option-label {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    .option-price {
        min-width: auto;
        font-size: 1.5rem;
    }
    
    .form-control, .form-select, .variety-input {
        padding: 0.875rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .modal-actions {
        padding: 0 1rem 1rem;
    }
    
    .checkout-btn {
        padding: 1.25rem;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .checkout-modal-overlay {
        padding: 0.5rem;
    }
    
    .checkout-modal {
        margin: 0;
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 1rem;
        border-radius: 12px 12px 0 0;
    }
    
    .modal-title {
        font-size: 1.1rem;
    }
    
    .stock-banner {
        margin: 0.75rem;
        margin-bottom: 0;
    }
    
    .option-badges {
        justify-content: center;
    }
    
    .summary-row {
        font-size: 0.9rem;
    }
    
    .summary-row.total {
        font-size: 1.1rem;
    }
}

/* Animation for form validation */
.form-control.error, .form-select.error, .variety-input.error {
    border-color: var(--popup-danger);
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Loading state */
.checkout-btn.loading {
    pointer-events: none;
}

.checkout-btn.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

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