<?php
/**
 * Enqueue child styles.
 */
function child_enqueue_styles() {
    wp_enqueue_style( 'child-theme', get_stylesheet_directory_uri() . '/style.css', array(), 100 );
}

add_action( 'wp_enqueue_scripts', 'child_enqueue_styles' );

/**
 * Set up Wine Establishment theme defaults
 */
function wine_establishment_setup_theme_defaults() {
    // Set up color palette
    $color_palette = array(
        'palette' => array(
            array(
                'color' => '#722F37', // Deep Burgundy
                'slug' => 'palette1',
                'name' => 'Burgundy',
            ),
            array(
                'color' => '#D4AF37', // Gold
                'slug' => 'palette2',
                'name' => 'Gold',
            ),
            array(
                'color' => '#2C2C2C', // Charcoal
                'slug' => 'palette3',
                'name' => 'Charcoal',
            ),
            array(
                'color' => '#555555', // Medium Gray
                'slug' => 'palette4',
                'name' => 'Medium Gray',
            ),
            array(
                'color' => '#999999', // Light Gray
                'slug' => 'palette5',
                'name' => 'Light Gray',
            ),
            array(
                'color' => '#F8F8F8', // Very Light Gray
                'slug' => 'palette6',
                'name' => 'Very Light Gray',
            ),
            array(
                'color' => '#E8E8E8', // Border Gray
                'slug' => 'palette7',
                'name' => 'Border Gray',
            ),
            array(
                'color' => '#FFFFFF', // White
                'slug' => 'palette8',
                'name' => 'White',
            ),
            array(
                'color' => '#FFFFFF', // White for text
                'slug' => 'palette9',
                'name' => 'White Text',
            ),
        ),
    );
    
    // Set Kadence color palette
    set_theme_mod( 'kadence_global_palette', json_encode( $color_palette ) );
    
    // Set typography defaults
    set_theme_mod( 'base_font', array(
        'family' => 'Montserrat',
        'google' => true,
        'weight' => '400',
        'variant' => 'regular',
    ) );
    
    set_theme_mod( 'heading_font', array(
        'family' => 'Playfair Display',
        'google' => true,
        'weight' => '700',
        'variant' => '700',
    ) );
    
    // Set header defaults
    set_theme_mod( 'header_sticky', 'main' );
    set_theme_mod( 'header_reveal_scroll_up', true );
    set_theme_mod( 'header_background', array(
        'desktop' => array(
            'color' => 'rgba(255, 255, 255, 0.98)',
        ),
    ) );
    
    // Set button defaults
    set_theme_mod( 'buttons_typography', array(
        'size' => array(
            'desktop' => '14',
        ),
        'lineHeight' => array(
            'desktop' => '1.6',
        ),
        'family' => 'inherit',
        'weight' => '500',
        'transform' => 'uppercase',
        'spacing' => array(
            'desktop' => '1',
        ),
    ) );
}
add_action( 'after_switch_theme', 'wine_establishment_setup_theme_defaults' );

/**
 * Add custom CSS for Wine Establishment
 */
function wine_establishment_custom_css() {
    ?>
    <style>
        /* Gold divider style */
        .kt-divider-style-stripe {
            border-top-color: var(--global-palette2) !important;
        }
        
        /* Smooth scroll behavior */
        html {
            scroll-behavior: smooth;
        }
        
        /* Header shadow */
        #main-header.item-is-fixed {
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        
        /* Service card hover effect */
        .service-card {
            transition: transform 0.3s ease;
        }
        
        .service-card:hover {
            transform: translateY(-10px);
        }
        
        /* Form styling */
        .wpcf7 input[type="text"],
        .wpcf7 input[type="email"],
        .wpcf7 input[type="tel"],
        .wpcf7 textarea {
            width: 100%;
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-family: inherit;
        }
        
        /* Footer background */
        #footer {
            background-color: var(--global-palette3);
            color: var(--global-palette9);
        }
        
        #footer a {
            color: var(--global-palette5);
        }
        
        #footer a:hover {
            color: var(--global-palette2);
        }
    </style>
    <?php
}
add_action( 'wp_head', 'wine_establishment_custom_css' );

/**
 * Add WhatsApp floating button
 */
function wine_establishment_whatsapp_button() {
    ?>
    <a href="https://wa.me/16493323994" class="whatsapp-float" target="_blank" style="position: fixed; bottom: 30px; right: 30px; background: #25D366; color: white; width: 60px; height: 60px; border-radius: 50%; text-align: center; line-height: 60px; font-size: 30px; box-shadow: 0 5px 20px rgba(0,0,0,0.3); z-index: 999; transition: transform 0.3s ease;">
        <svg style="width: 30px; height: 30px; display: inline-block; vertical-align: middle;" viewBox="0 0 24 24" fill="currentColor">
            <path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.693.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/>
        </svg>
    </a>
    <style>
        .whatsapp-float:hover {
            transform: scale(1.1);
        }
    </style>
    <?php
}
add_action( 'wp_footer', 'wine_establishment_whatsapp_button' );
