/* Purchase Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.show {
    display: flex;
    opacity: 1;
    visibility: visible;
}

.modal-content {
    position: relative;
    background: white;
    width: 90%;
    max-width: 600px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: modalSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 90vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #3498db #f1f1f1;
    scroll-behavior: smooth;
    transition: all 0.3s ease;
}

.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #3498db;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}

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

.modal-header {
    background: linear-gradient(to right, #2c3e50, #3498db);
    color: white;
    padding: 1.5rem;
    position: relative;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

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

.close-modal:hover {
    transform: rotate(90deg);
    background: rgba(255, 255, 255, 0.2);
}

.purchase-summary {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2rem;
    padding: 2rem;
    background: linear-gradient(145deg, #f8f9fa, #ffffff);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.purchase-summary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, rgba(52, 152, 219, 0.05), rgba(46, 204, 113, 0.05));
    pointer-events: none;
}

.purchase-summary img {
    width: 180px;
    height: auto;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    padding: 15px;
    background: white;
    transition: transform 0.3s ease;
}

.purchase-summary img:hover {
    transform: scale(1.02);
}

.product-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.product-info h3 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
}

.modal-price {
    font-size: 1.5rem;
    background: linear-gradient(45deg, #2ecc71, #27ae60);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: bold;
    margin-top: 0.5rem;
    display: inline-block;
    position: relative;
}

.modal-price::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(45deg, #2ecc71, transparent);
}

.purchase-form {
    padding: 1.5rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f8f9fa;
    color: #2c3e50;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.form-group input:hover,
.form-group textarea:hover {
    border-color: #3498db;
    background: white;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    background: white;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.1);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

.quantity-selector {
    margin-bottom: 1.5rem;
}

.quantity-selector h3 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-size: 1rem;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(145deg, #f8f9fa, #ffffff);
    padding: 0.75rem;
    border-radius: 15px;
    border: 2px solid #e9ecef;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    width: fit-content;
}

.quantity-btn {
    width: 35px;
    height: 35px;
    border: none;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #2c3e50;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.quantity-btn:hover:not(:disabled) {
    background: #3498db;
    color: white;
}

.quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#quantity {
    width: 60px;
    text-align: center;
    border: none;
    font-size: 1.1rem;
    background: transparent;
    color: #2c3e50;
}

.delivery-options {
    margin-bottom: 1.5rem;
}

.delivery-options h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
    font-size: 1rem;
}

.delivery-choice {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    border: 2px solid #e9ecef;
    border-radius: 15px;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    position: relative;
    overflow: hidden;
}

.delivery-choice::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: #3498db;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.delivery-choice:hover::before {
    opacity: 1;
}

.delivery-choice input[type="radio"]:checked + label {
    color: #3498db;
}

.delivery-choice:has(input[type="radio"]:checked) {
    border-color: #3498db;
    background: linear-gradient(145deg, #f8f9fa, #ffffff);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.1);
}

.delivery-choice:hover {
    border-color: #3498db;
    background: #f8f9fa;
}

.delivery-choice input[type="radio"] {
    margin-top: 3px;
}

.delivery-choice label {
    flex: 1;
    cursor: pointer;
}

.method-title {
    display: block;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.method-desc {
    display: block;
    font-size: 0.9rem;
    color: #666;
}

.total-section {
    background: linear-gradient(145deg, #f8f9fa, #ffffff);
    padding: 2rem;
    border-radius: 20px;
    margin-top: 2rem;
    border: 2px solid #e9ecef;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.total-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, #3498db, #2ecc71);
    opacity: 0.5;
}

.subtotal,
.delivery-fee,
.total {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.total {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
    font-weight: bold;
    font-size: 1.2rem;
    color: #2c3e50;
}

.submit-order {
    width: 100%;
    padding: 1.25rem;
    background: linear-gradient(45deg, #2ecc71, #27ae60);
    color: white;
    border: none;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 2rem;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.submit-order::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        120deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: 0.5s;
}

.submit-order:hover::before {
    left: 100%;
}

.submit-order:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.3);
}

.submit-order:hover:not(:disabled) {
    background: #27ae60;
}

.submit-order:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* Validation Styles */
.form-group input:invalid,
.form-group textarea:invalid {
    border-color: #e74c3c;
}

.validation-message {
    display: none;
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.form-group input:invalid + .validation-message {
    display: block;
}

/* Loading State */
.submit-order.loading {
    position: relative;
    color: transparent;
}

.submit-order.loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 480px) {
    .modal {
        padding: 0;
    }
    
    .modal-content {
        margin: 0;
        width: 100%;
        height: 100vh;
        border-radius: 0;
        max-height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }

    .modal-header {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .purchase-summary {
        grid-template-columns: 1fr;
        text-align: center;
        padding: 1rem;
    }

    .purchase-summary img {
        width: 150px;
        margin: 0 auto;
    }

    .purchase-form {
        padding: 1rem;
    }

    .quantity-controls {
        justify-content: center;
        margin: 0 auto;
    }

    .form-group input,
    .form-group textarea {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: 12px;
    }

    .delivery-choice {
        padding: 1rem;
    }

    .total-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .submit-order {
        position: sticky;
        bottom: 1rem;
        margin: 0 1rem;
        width: calc(100% - 2rem);
        padding: 1rem;
    }
}
