<?php
/**
 * Pricing Display Component
 * Provides consistent pricing display formatting across service pages
 */

function displayPricingSection($title, $services) {
    echo '<div class="pricing-section">';
    echo '<h3 style="color: #ff6600; font-size: 1.8rem; margin-bottom: 2rem; text-align: center;">' . htmlspecialchars($title) . '</h3>';
    echo '<div class="pricing-grid">';
    
    foreach ($services as $service) {
        echo '<div class="pricing-item">';
        echo '<div class="pricing-header">';
        echo '<h4>' . htmlspecialchars($service['name']) . '</h4>';
        echo '<div class="price">' . htmlspecialchars($service['price']) . '</div>';
        echo '</div>';
        
        if (!empty($service['description'])) {
            echo '<p class="pricing-description">' . htmlspecialchars($service['description']) . '</p>';
        }
        
        if (!empty($service['includes'])) {
            echo '<div class="pricing-includes">';
            echo '<strong>Includes:</strong>';
            echo '<ul>';
            foreach ($service['includes'] as $include) {
                echo '<li>' . htmlspecialchars($include) . '</li>';
            }
            echo '</ul>';
            echo '</div>';
        }
        
        if (!empty($service['notes'])) {
            echo '<div class="pricing-notes">';
            echo '<small>' . htmlspecialchars($service['notes']) . '</small>';
            echo '</div>';
        }
        
        echo '</div>';
    }
    
    echo '</div>';
    echo '</div>';
}

function displayServiceFees($fees) {
    echo '<div class="service-fees-section">';
    echo '<h3 style="color: #ff6600; font-size: 1.6rem; margin-bottom: 1.5rem;">Service Fees & Options</h3>';
    echo '<div class="fees-grid">';
    
    foreach ($fees as $fee) {
        echo '<div class="fee-item">';
        echo '<h4>' . htmlspecialchars($fee['name']) . '</h4>';
        echo '<div class="fee-details">';
        foreach ($fee['details'] as $detail) {
            echo '<p>' . htmlspecialchars($detail) . '</p>';
        }
        echo '</div>';
        echo '</div>';
    }
    
    echo '</div>';
    echo '</div>';
}

function displayDiscountInfo() {
    echo '<div class="discount-section" style="background: linear-gradient(135deg, rgba(255,102,0,0.1) 0%, rgba(204,82,0,0.1) 100%); border-left: 4px solid #ff6600; padding: 1.5rem; border-radius: 10px; margin: 2rem 0;">';
    echo '<h4 style="color: #ff6600; margin-bottom: 1rem;">Available Discounts</h4>';
    echo '<ul style="margin: 0; padding-left: 1.5rem;">';
    echo '<li><strong>Senior Discount:</strong> 10% off (65+ years)</li>';
    echo '<li><strong>Military Discount:</strong> 15% off (active/veteran)</li>';
    echo '<li><strong>Multiple Service Discount:</strong> 10% off (3+ services)</li>';
    echo '</ul>';
    echo '</div>';
}
?>

<style>
.pricing-section {
    background: #ffffff;
    border-radius: 20px;
    padding: 3rem;
    margin: 3rem 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border-left: 5px solid #ff6600;
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.pricing-item {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    padding: 2rem;
    border: 2px solid #ff6600;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.pricing-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #ff6600, #ffaa00, #ff6600);
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.pricing-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(255,102,0,0.2);
}

.pricing-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.pricing-header h4 {
    color: #333333;
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.price {
    background: linear-gradient(135deg, #ff6600 0%, #cc5200 100%);
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    font-weight: 700;
    font-size: 1.1rem;
    white-space: nowrap;
    margin-left: 1rem;
}

.pricing-description {
    color: #666666;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.pricing-includes {
    margin-bottom: 1rem;
}

.pricing-includes strong {
    color: #ff6600;
    display: block;
    margin-bottom: 0.5rem;
}

.pricing-includes ul {
    margin: 0;
    padding-left: 1.5rem;
    color: #555555;
}

.pricing-includes li {
    margin-bottom: 0.25rem;
}

.pricing-notes {
    color: #777777;
    font-style: italic;
    border-top: 1px solid #ddd;
    padding-top: 1rem;
}

.service-fees-section {
    background: #ffffff;
    border-radius: 20px;
    padding: 3rem;
    margin: 3rem 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border-left: 5px solid #ff6600;
}

.fees-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.fee-item {
    background: linear-gradient(135deg, rgba(255,102,0,0.05) 0%, rgba(204,82,0,0.05) 100%);
    border-radius: 15px;
    padding: 1.5rem;
    border: 1px solid rgba(255,102,0,0.3);
}

.fee-item h4 {
    color: #ff6600;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.fee-details p {
    color: #555555;
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .pricing-section,
    .service-fees-section {
        padding: 2rem;
    }
    
    .pricing-grid,
    .fees-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .pricing-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .price {
        margin-left: 0;
        margin-top: 0.5rem;
        align-self: flex-start;
    }
}
</style>
