<?php
/**
 * File: style.css
 * Create this file in: /wp-content/themes/divi-child/style.css
 */
?>

/*
Theme Name: Divi Child - Beehive Solutions
Description: Child theme for Divi 5 - Beehive Solutions customizations
Author: Beehive Solutions
Template: Divi
Version: 1.0.0
*/

/* Import parent theme styles */
@import url("../Divi/style.css");

/* 
=== BEEHIVE SOLUTIONS CUSTOM STYLES ===
Add your custom CSS below this line
*/

/* Portfolio Grid Styles */
.portfolio-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.portfolio-header {
    text-align: center;
    margin-bottom: 3rem;
}

.portfolio-header h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #333;
}

.portfolio-header p {
    font-size: 1.2rem;
    color: #666;
    max-width: 600px;
    margin: 0 auto;
}

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

.project-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.project-image {
    position: relative;
    height: 250px;
    overflow: hidden;
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.project-card:hover .project-image img {
    transform: scale(1.05);
}

.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #f5f5f5;
    color: #999;
    font-size: 1.1rem;
}

.project-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.project-card:hover .project-overlay {
    opacity: 1;
}

.project-actions {
    text-align: center;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    margin: 0.25rem;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.btn-primary {
    background: #007cba;
    color: white;
}

.btn-primary:hover {
    background: #005a87;
}

.btn-secondary {
    background: #666;
    color: white;
}

.btn-secondary:hover {
    background: #444;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.project-info {
    padding: 1.5rem;
}

.project-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.3rem;
}

.project-title a {
    color: #333;
    text-decoration: none;
}

.project-title a:hover {
    color: #007cba;
}

.client-name {
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

.project-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.project-type,
.technologies {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: #f0f0f0;
    color: #666;
}

.project-excerpt {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.5;
}

/* Single Project Styles */
.single-project {
    /* max-width: 1200px; */
    margin: 0 auto;
    padding: 2rem;
}

.project-header {
    background: #f8f9fa;
    padding: 2rem;
    margin-bottom: 3rem;
    border-radius: 8px;
}

.project-breadcrumb {
    margin-bottom: 1rem;
}

.project-breadcrumb a {
    color: #007cba;
    text-decoration: none;
    font-size: 0.9rem;
}

.project-breadcrumb a:hover {
    text-decoration: underline;
}

.single-project .project-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #333;
}

.project-meta-header {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.meta-item {
    font-size: 0.9rem;
    color: #666;
}

.project-featured-image {
    margin-bottom: 3rem;
    text-align: center;
}

.project-featured-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.project-content {
    margin-bottom: 3rem;
}

.project-section {
    margin-bottom: 3rem;
}

.project-section h2 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: #333;
    border-bottom: 2px solid #007cba;
    padding-bottom: 0.5rem;
}

.project-section p {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #666;
}

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

.before-image,
.after-image {
    text-align: center;
}

.before-image h3,
.after-image h3 {
    margin-bottom: 1rem;
    color: #333;
}

.before-image img,
.after-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

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

.additional-image img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.project-navigation {
    background: #f8f9fa;
    padding: 2rem;
    margin-bottom: 3rem;
    border-radius: 8px;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-prev,
.nav-next {
    text-decoration: none;
    color: #333;
    max-width: 45%;
}

.nav-prev:hover,
.nav-next:hover {
    color: #007cba;
}

.nav-label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.nav-title {
    display: block;
    font-weight: 500;
    font-size: 1.1rem;
}

.nav-next {
    text-align: right;
}

.project-cta {
    background: linear-gradient(135deg, #007cba, #005a87);
    color: white;
    padding: 3rem;
    text-align: center;
    border-radius: 8px;
}

.cta-content h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.cta-content p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.project-cta .btn {
    background: white;
    color: #007cba;
}

.project-cta .btn:hover {
    background: #f0f0f0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .portfolio-container,
    .single-project {
        padding: 1rem;
    }
    
    .portfolio-header h1,
    .single-project .project-title {
        font-size: 2rem;
    }
    
    .project-actions {
        flex-direction: column;
    }
    
    .btn {
        display: block;
        margin: 0.25rem 0;
    }
    
    .project-header {
        padding: 1.5rem;
    }
    
    .project-meta-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-prev,
    .nav-next {
        max-width: 100%;
        text-align: center;
    }
    
    .before-after-images {
        grid-template-columns: 1fr;
    }
    
    .additional-images {
        grid-template-columns: 1fr;
    }
}

/*
=== END BEEHIVE SOLUTIONS CUSTOM STYLES ===
*/

<?php
/**
 * File: functions.php
 * Create this file in: /wp-content/themes/divi-child/functions.php
 */

// Prevent direct access
if (!defined('ABSPATH')) {
    exit;
}

/**
 * Enqueue parent and child theme styles
 */
function beehive_child_theme_styles() {
    // Enqueue parent theme stylesheet
    wp_enqueue_style('divi-parent-style', get_template_directory_uri() . '/style.css');
    
    // Enqueue child theme stylesheet
    wp_enqueue_style('divi-child-style', 
        get_stylesheet_directory_uri() . '/style.css',
        array('divi-parent-style'),
        wp_get_theme()->get('Version')
    );
}
add_action('wp_enqueue_scripts', 'beehive_child_theme_styles');

/**
 * Add ACF support check
 */
function beehive_acf_support_check() {
    if (!class_exists('ACF')) {
        add_action('admin_notices', function() {
            echo '<div class="notice notice-warning is-dismissible">';
            echo '<p><strong>Beehive Solutions:</strong> Advanced Custom Fields plugin is required for the portfolio functionality. Please install and activate ACF.</p>';
            echo '</div>';
        });
    }
}
add_action('init', 'beehive_acf_support_check');

/**
 * Custom function to display project meta
 */
function beehive_get_project_meta($post_id = null) {
    if (!$post_id) {
        $post_id = get_the_ID();
    }
    
    $meta = array(
        'project_url' => get_field('project_url', $post_id),
        'client_name' => get_field('client_name', $post_id),
        'project_type' => get_field('project_type', $post_id),
        'technologies_used' => get_field('technologies_used', $post_id),
        'project_year' => get_field('project_year', $post_id),
        'project_challenge' => get_field('project_challenge', $post_id),
        'solution_overview' => get_field('solution_overview', $post_id),
        'project_results' => get_field('project_results', $post_id),
        'additional_images' => get_field('additional_images', $post_id),
        'before_image' => get_field('before_image', $post_id),
        'after_image' => get_field('after_image', $post_id)
    );
    
    return $meta;
}

/**
 * Add custom body classes for portfolio pages
 */
function beehive_custom_body_classes($classes) {
    if (is_page_template('page-portfolio.php')) {
        $classes[] = 'portfolio-grid-page';
    }
    
    if (is_singular('project')) {
        $classes[] = 'single-project-page';
    }
    
    return $classes;
}
add_filter('body_class', 'beehive_custom_body_classes');

/**
 * Customize excerpt length for projects
 */
function beehive_project_excerpt_length($length) {
    if (get_post_type() === 'project') {
        return 20; // Show 20 words for project excerpts
    }
    return $length;
}
add_filter('excerpt_length', 'beehive_project_excerpt_length');

/**
 * Add "Read More" link to project excerpts
 */
function beehive_project_excerpt_more($more) {
    if (get_post_type() === 'project') {
        return '... <a href="' . get_permalink() . '" class="read-more">View Project</a>';
    }
    return $more;
}
add_filter('excerpt_more', 'beehive_project_excerpt_more');

/**
 * Add theme support for post thumbnails if not already enabled
 */
function beehive_theme_support() {
    if (!current_theme_supports('post-thumbnails')) {
        add_theme_support('post-thumbnails');
    }
    
    // Add custom image sizes for portfolio
    add_image_size('portfolio-grid', 400, 300, true);
    add_image_size('portfolio-featured', 1200, 600, true);
}
add_action('after_setup_theme', 'beehive_theme_support');

/**
 * Flush rewrite rules on theme activation
 */
function beehive_flush_rewrite_rules() {
    flush_rewrite_rules();
}
add_action('after_switch_theme', 'beehive_flush_rewrite_rules');

/**
 * Add custom CSS for Divi compatibility
 */
function beehive_divi_compatibility_css() {
    if (is_page_template('page-portfolio.php') || is_singular('project')) {
        ?>
        <style>
        /* Ensure compatibility with Divi's CSS */
        .et_pb_section .portfolio-container,
        .et_pb_section .single-project {
            max-width: none;
        }
        
        /* Override Divi's default margins if needed */
        .portfolio-grid-page #main-content,
        .single-project-page #main-content {
            padding-top: 0;
        }
        
        /* Ensure buttons don't conflict with Divi button styles */
        .project-card .btn,
        .single-project .btn {
            font-family: inherit;
            border: none;
            text-transform: none;
            letter-spacing: normal;
        }
        </style>
        <?php
    }
}
add_action('wp_head', 'beehive_divi_compatibility_css');

/**
 * Optional: Add admin menu item for portfolio management
 */
function beehive_admin_menu() {
    add_submenu_page(
        'edit.php?post_type=project',
        'Portfolio Settings',
        'Portfolio Settings',
        'manage_options',
        'portfolio-settings',
        'beehive_portfolio_settings_page'
    );
}
add_action('admin_menu', 'beehive_admin_menu');

function beehive_portfolio_settings_page() {
    ?>
    <div class="wrap">
        <h1>Portfolio Settings</h1>
        <div class="card">
            <h2>Quick Setup Guide</h2>
            <ol>
                <li>Make sure Advanced Custom Fields is installed and activated</li>
                <li>Create your "Project Details" field group with the provided fields</li>
                <li>Create a new page and select "Portfolio Grid" as the template</li>
                <li>Start adding projects with featured images and project details</li>
            </ol>
        </div>
        
        <div class="card">
            <h2>Template Files Location</h2>
            <p><strong>Portfolio Grid:</strong> /wp-content/themes/divi-child/page-portfolio.php</p>
            <p><strong>Single Project:</strong> /wp-content/themes/divi-child/single-project.php</p>
        </div>
        
        <div class="card">
            <h2>Required ACF Fields</h2>
            <ul>
                <li>project_url (URL)</li>
                <li>client_name (Text)</li>
                <li>project_type (Select)</li>
                <li>technologies_used (Text)</li>
                <li>project_year (Number)</li>
                <li>project_challenge (Textarea)</li>
                <li>solution_overview (Textarea)</li>
                <li>project_results (Textarea)</li>
                <li>additional_images (Image)</li>
                <li>before_image (Image)</li>
                <li>after_image (Image)</li>
            </ul>
        </div>
    </div>
    <?php
}

?>
