<?php
/**
 * Template for Google Sheets Integration page
 *
 * @package HVAC_Community_Events
 * @subpackage Templates
 */

// Exit if accessed directly.
if (!defined('ABSPATH')) {
    exit;
}

get_header(); ?>

<div class="hvac-page-wrapper">
    <main class="hvac-main-content">
        <?php echo do_shortcode('[hvac_google_sheets]'); ?>
    </main>
</div>

<style>
/* Google Sheets specific styles */
.hvac-google-sheets-admin {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Alert styles */
.hvac-alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 6px;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 10px;
}

.hvac-alert-success {
    background-color: #d4edda;
    border-left-color: #28a745;
    color: #155724;
}

.hvac-alert-error {
    background-color: #f8d7da;
    border-left-color: #dc3545;
    color: #721c24;
}

.hvac-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.hvac-status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #6c757d;
}

.hvac-status-value.success {
    color: #28a745;
    font-weight: 600;
}

.hvac-status-value.error {
    color: #dc3545;
    font-weight: 600;
}

.hvac-latest-report {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
}

.hvac-report-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.hvac-event-selection {
    display: flex;
    gap: 15px;
    align-items: end;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.hvac-event-selection label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.hvac-select {
    min-width: 250px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.hvac-event-sheets-list {
    display: grid;
    gap: 10px;
}

.hvac-event-sheet-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #007cba;
}

.hvac-sheet-info h4 {
    margin: 0 0 5px 0;
    color: #333;
}

.hvac-sheet-trainer,
.hvac-sheet-date {
    font-size: 12px;
    color: #666;
    margin-right: 10px;
}

.hvac-no-sheets {
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.hvac-history-list {
    display: grid;
    gap: 10px;
}

.hvac-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f1f3f4;
    border-radius: 4px;
}

.hvac-history-meta {
    display: flex;
    gap: 15px;
    align-items: center;
}

.hvac-history-date {
    font-weight: 600;
    color: #333;
}

.hvac-history-user {
    color: #666;
    font-size: 14px;
}

/* Loading overlay */
.hvac-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.hvac-loading-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    max-width: 300px;
}

.hvac-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Notifications */
.hvac-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 6px;
    color: white;
    font-weight: 600;
    z-index: 10000;
    max-width: 400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.hvac-notification-success {
    background: #28a745;
}

.hvac-notification-error {
    background: #dc3545;
}

.hvac-notification-warning {
    background: #ffc107;
    color: #212529;
}

.hvac-notification button {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Icons */
.hvac-icon-sheets::before { content: "📊"; }
.hvac-icon-connection::before { content: "🔗"; }
.hvac-icon-test::before { content: "🧪"; }
.hvac-icon-auth::before { content: "🔐"; }
.hvac-icon-report::before { content: "📈"; }
.hvac-icon-events::before { content: "📅"; }
.hvac-icon-history::before { content: "📜"; }
.hvac-icon-calendar::before { content: "📅"; }
.hvac-icon-external::before { content: "🔗"; }
.hvac-icon-create::before { content: "➕"; }
.hvac-icon-arrow-left::before { content: "←"; }

/* Responsive adjustments */
@media (max-width: 768px) {
    .hvac-google-sheets-admin {
        padding: 15px;
    }
    
    .hvac-status-grid {
        grid-template-columns: 1fr;
    }
    
    .hvac-event-selection {
        flex-direction: column;
        align-items: stretch;
    }
    
    .hvac-select {
        min-width: auto;
        width: 100%;
    }
    
    .hvac-report-meta,
    .hvac-event-sheet-item,
    .hvac-history-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .hvac-notification {
        left: 10px;
        right: 10px;
        top: 10px;
        max-width: none;
    }
}
</style>

<?php get_footer(); ?>