<?php
/**
 * Plugin Name:       Construction Dashboard
 * Description:       Provides core functionality for the construction management dashboard, including custom post types for Projects and Site Logs, and the dark theme.
 * Version:           1.0.0
 * Author:            Flatlogic AI Engineer
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       construction-dashboard
 */

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
	die;
}

add_action('init', function() {
    register_post_type('project', [
        'labels' => [
            'name' => 'Projects',
            'singular_name' => 'Project',
            'add_new' => 'Add New Project',
            'edit_item' => 'Edit Project',
        ],
        'public' => true,
        'show_in_rest' => true,
        'menu_icon' => 'dashicons-hammer',
        'supports' => ['title', 'editor', 'thumbnail', 'custom-fields'],
        'has_archive' => true,
    ]);

    register_post_type('site_log', [
        'labels' => [
            'name' => 'Site Logs',
            'singular_name' => 'Site Log',
            'add_new' => 'Add New Log',
            'edit_item' => 'Edit Log',
        ],
        'public' => true,
        'show_in_rest' => true,
        'menu_icon' => 'dashicons-camera',
        'supports' => ['title', 'editor', 'thumbnail'],
    ]);
});

// Inject Dark Theme Styles
add_action('wp_head', function() {
    ?>
    <style>
        :root {
            --wp--preset--color--background: #121212 !important;
            --wp--preset--color--text: #e0e0e0 !important;
            --wp--preset--color--primary: #ffd700 !important;
        }
        body { background-color: #121212 !important; color: #e0e0e0 !important; }
        .wp-block-post-title, h1, h2, h3, .wp-block-heading { color: #ffd700 !important; }
        .dashboard-widget { 
            background: #1e1e1e; 
            padding: 24px; 
            border-radius: 12px; 
            border: 1px solid #333; 
            margin-bottom: 20px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.3);
        }
        .dashboard-grid { 
            display: grid; 
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); 
            gap: 20px; 
        }
        /* Sidebar Simulation / Header Styling */
        header { border-bottom: 1px solid #333; margin-bottom: 40px; padding-bottom: 20px; }
        .wp-block-navigation a { color: #ffd700 !important; }
    </style>
    <?php
});
