
<?php $__env->startSection('title', 'Desain Rumah || KLINIK PKP JAWA 3'); ?>

<?php $__env->startSection('content'); ?>
    <style>
        /* CSS Custom Properties for better dark mode support */
        :root {
            --bg-primary: #f9fafb;
            --bg-secondary: #ffffff;
            --bg-card: #ffffff;
            --bg-card-hover: #f8fafc;
            --text-primary: #1f2937;
            --text-secondary: #6b7280;
            --text-muted: #d1d5db;
            --border-color: #e5e7eb;
            --border-hover: #667eea;
            --shadow-soft: 0 4px 6px rgba(0, 0, 0, 0.1);
            --shadow-medium: 0 12px 24px rgba(0, 0, 0, 0.15);
        }

        [data-theme="dark"],
        body.dark-mode {
            --bg-primary: #1f2937;
            --bg-secondary: #111827;
            --bg-card: #374151;
            --bg-card-hover: #4b5563;
            --text-primary: #f9fafb;
            --text-secondary: #d1d5db;
            --text-muted: #6b7280;
            --border-color: #4b5563;
            --border-hover: #667eea;
            --shadow-soft: 0 4px 6px rgba(102, 126, 234, 0.1);
            --shadow-medium: 0 12px 24px rgba(102, 126, 234, 0.2);
        }

        /* Hero Section */
        .hero-section {
            background: linear-gradient(135deg, var(--judges-base) 0%, var(--judges-base) 100%);
            min-height: 500px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            overflow: hidden;
            padding: 4rem 2rem;
        }

        .hero-section::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320"><path fill="%23ffffff" fill-opacity="0.1" d="M0,96L48,112C96,128,192,160,288,160C384,160,480,128,576,112C672,96,768,96,864,112C960,128,1056,160,1152,160C1248,160,1344,128,1392,112L1440,96L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z"></path></svg>') no-repeat bottom;
            background-size: cover;
        }

        .hero-content {
            position: relative;
            z-index: 1;
            max-width: 800px;
            text-align: center;
            color: white;
        }

        .hero-title {
            font-size: 3rem;
            font-weight: 700;
            margin-bottom: 1rem;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
            color: #f9fafb;
        }

        .hero-subtitle {
            font-size: 1.25rem;
            margin-bottom: 2rem;
            opacity: 0.95;
            line-height: 1.8;
            max-width: 600px;
            margin-left: auto;
            margin-right: auto;
        }

        .hero-divider {
            width: 100px;
            height: 4px;
            background: white;
            margin: 2rem auto;
            border-radius: 2px;
        }

        /* Container Section */
        .design-section {
            padding: 4rem 2rem;
            background-color: var(--bg-primary);
            transition: background-color 0.3s ease;
        }

        [data-theme="dark"] .design-section,
        body.dark-mode .design-section {
            background-color: var(--bg-primary);
        }

        .section-title {
            text-align: center;
            font-size: 2.5rem;
            font-weight: 700;
            color: var(--text-primary);
            margin-bottom: 1rem;
            transition: color 0.3s ease;
        }

        .section-subtitle {
            text-align: center;
            font-size: 1.125rem;
            color: var(--text-secondary);
            margin-bottom: 3rem;
            max-width: 600px;
            margin-left: auto;
            margin-right: auto;
            transition: color 0.3s ease;
        }

        /* Card Grid */
        .design-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
            gap: 2rem;
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 1rem;
        }

        /* Design Card */
        .design-card {
            background: var(--bg-card);
            border-radius: 16px;
            overflow: hidden;
            box-shadow: var(--shadow-soft);
            transition: all 0.3s ease;
            cursor: pointer;
            border: 1px solid var(--border-color);
        }

        .design-card:hover {
            transform: translateY(-8px);
            box-shadow: var(--shadow-medium);
            border-color: var(--border-hover);
        }

        [data-theme="dark"] .design-card,
        body.dark-mode .design-card {
            background: var(--bg-card);
            border-color: var(--border-color);
        }

        [data-theme="dark"] .design-card:hover,
        body.dark-mode .design-card:hover {
            box-shadow: var(--shadow-medium);
            border-color: var(--border-hover);
        }

        .design-image {
            width: 100%;
            height: 250px;
            object-fit: cover;
            background-color: var(--border-color);
            transition: background-color 0.3s ease;
        }

        .design-content {
            padding: 1.5rem;
        }

        .design-category {
            display: inline-block;
            padding: 0.25rem 0.75rem;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-size: 0.75rem;
            font-weight: 600;
            border-radius: 12px;
            margin-bottom: 0.75rem;
            text-transform: uppercase;
        }

        .design-title {
            font-size: 1.5rem;
            font-weight: 700;
            color: var(--text-primary);
            margin-bottom: 0.75rem;
            line-height: 1.4;
            transition: color 0.3s ease;
        }

        .design-description {
            font-size: 0.9375rem;
            color: var(--text-secondary);
            line-height: 1.6;
            margin-bottom: 1.5rem;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
            transition: color 0.3s ease;
        }

        .design-actions {
            display: flex;
            gap: 0.75rem;
        }

        .btn-download,
        .btn-video {
            flex: 1;
            padding: 0.75rem 1rem;
            border-radius: 8px;
            font-weight: 600;
            font-size: 0.875rem;
            text-align: center;
            text-decoration: none;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
        }

        .btn-download {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
        }

        .btn-download:hover {
            background: linear-gradient(135deg, #5568d3 0%, #6941a0 100%);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
        }

        .btn-video {
            background: var(--bg-card);
            color: #dc2626;
            border: 2px solid #dc2626;
            transition: all 0.3s ease;
        }

        .btn-video:hover {
            background: #dc2626;
            color: white;
        }

        [data-theme="dark"] .btn-video,
        body.dark-mode .btn-video {
            background: var(--bg-card);
            color: #dc2626;
            border-color: #dc2626;
        }

        [data-theme="dark"] .btn-video:hover,
        body.dark-mode .btn-video:hover {
            background: #dc2626;
            color: white;
        }

        /* Empty State */
        .empty-state {
            text-align: center;
            padding: 4rem 2rem;
        }

        .empty-state-icon {
            font-size: 4rem;
            color: var(--text-muted);
            margin-bottom: 1rem;
            transition: color 0.3s ease;
        }

        .empty-state-text {
            font-size: 1.125rem;
            color: var(--text-secondary);
            transition: color 0.3s ease;
        }

        /* Loading */
        .loading-container {
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 4rem;
        }

        .spinner {
            width: 50px;
            height: 50px;
            border: 4px solid var(--border-color);
            border-top-color: #667eea;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            transition: border-color 0.3s ease;
        }

        [data-theme="dark"] .spinner,
        body.dark-mode .spinner {
            border-color: var(--border-color);
            border-top-color: #667eea;
        }

        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }

        /* Responsive */
        @media (max-width: 768px) {
            .hero-title {
                font-size: 2rem;
            }

            .hero-subtitle {
                font-size: 1rem;
            }

            .section-title {
                font-size: 2rem;
            }

            .design-grid {
                grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
                gap: 1.5rem;
            }
        }
    </style>

    <!-- Hero Section -->
    <section class="hero-section">
        <div class="hero-content">
            <h1 class="hero-title">Desain Rumah</h1>
            <div class="hero-divider"></div>
            <p class="hero-subtitle">
                Temukan berbagai pilihan desain rumah yang telah kami siapkan untuk Anda.
                Setiap desain dirancang dengan mempertimbangkan kenyamanan, estetika, dan
                efisiensi ruang untuk menciptakan hunian impian Anda.
            </p>
        </div>
    </section>

    <!-- Design Cards Section -->
    <section class="design-section">
        <div class="container">
            <h2 class="section-title">Koleksi Desain Rumah</h2>
            <p class="section-subtitle">
                Jelajahi berbagai desain rumah terbaik yang dapat menjadi inspirasi untuk hunian impian Anda
            </p>

            <!-- Loading State -->
            <div id="loading-container" class="loading-container">
                <div class="spinner"></div>
            </div>

            <!-- Cards Grid -->
            <div id="design-grid" class="design-grid" style="display: none;">
                <!-- Cards will be inserted here by JavaScript -->
            </div>

            <!-- Empty State -->
            <div id="empty-state" class="empty-state" style="display: none;">
                <div class="empty-state-icon">🏠</div>
                <p class="empty-state-text">Belum ada desain rumah yang tersedia saat ini.</p>
            </div>

            <!-- Jawa-III Designs Section -->
            <div class="container" style="margin-top: 3rem;">
                <h2 class="section-title">Koleksi Desain Rumah dari Klinik PKP Jawa-III</h2>
                <p class="section-subtitle">Desain yang diwariskan/turis dari Klinik PKP Jawa-III.</p>

                <!-- Loading State Jawa-III -->
                <div id="loading-container-jawa3" class="loading-container">
                    <div class="spinner"></div>
                </div>

                <!-- Cards Grid Jawa-III -->
                <div id="design-grid-jawa3" class="design-grid" style="display: none;"></div>

                <!-- Empty State Jawa-III -->
                <div id="empty-state-jawa3" class="empty-state" style="display: none;">
                    <div class="empty-state-icon">🏠</div>
                    <p class="empty-state-text">Belum ada desain rumah dari KRS Jawa-III.</p>
                </div>
            </div>
        </div>
    </section>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script>
        // Dark mode synchronization function
        function syncDarkMode() {
            const isDarkMode = document.documentElement.getAttribute('data-theme') === 'dark';

            if (isDarkMode) {
                document.body.classList.add('dark-mode');
            } else {
                document.body.classList.remove('dark-mode');
            }
        }

        // Initialize dark mode on page load
        syncDarkMode();

        // Watch for theme changes
        const observer = new MutationObserver(function(mutations) {
            mutations.forEach(function(mutation) {
                if (mutation.type === 'attributes' && mutation.attributeName === 'data-theme') {
                    syncDarkMode();
                }
            });
        });

        observer.observe(document.documentElement, {
            attributes: true,
            attributeFilter: ['data-theme']
        });

        $(document).ready(function() {
            const BASE_URL = "<?php echo e(env('BASE_URL')); ?>";
            const DAERAH = "<?php echo e(env('DAERAH')); ?>";

            console.log('Fetching data from:', `${BASE_URL}/api/public/sites/${DAERAH}`);

            // Fetch house designs data
            $.ajax({
                url: `${BASE_URL}/api/public/sites/${DAERAH}`,
                method: 'GET',
                success: function(response) {
                    console.log('API Response:', response);

                    // Hide loading
                    $('#loading-container').hide();

                    // Get house designs from response
                    const houseDesigns = response.local?.houseDesigns || [];

                    console.log('House Designs:', houseDesigns);

                    if (houseDesigns.length > 0) {
                        // Show grid
                        $('#design-grid').show();

                        // Render cards
                        renderDesignCards(houseDesigns);
                    } else {
                        // Show empty state
                        $('#empty-state').show();
                    }
                },
                error: function(xhr, status, error) {
                    console.error('Error fetching data:', error);
                    console.error('Status:', status);
                    console.error('Response:', xhr.responseText);

                    // Hide loading
                    $('#loading-container').hide();

                    // Show empty state
                    $('#empty-state').show();
                    $('#empty-state .empty-state-text').text(
                        'Terjadi kesalahan saat memuat data. Silakan coba lagi nanti.');
                }
            });

            function renderDesignCards(designs) {
                const grid = $('#design-grid');
                grid.empty();

                designs.forEach(design => {
                    const imageUrl = design.path_image ?
                        `${BASE_URL}/${design.path_image}` :
                        'https://placehold.co/400x300?text=No+Image';

                    const fileUrl = design.path_file ?
                        `${BASE_URL}/${design.path_file}` :
                        '#';

                    const videoUrl = design.video_id && design.video_id !== null ?
                        true :
                        false;

                    const categoryName = design.category?.name || 'Desain Rumah';
                    const title = design.title || 'Untitled';
                    const description = design.description || 'Tidak ada deskripsi tersedia.';

                    const card = `
                        <div class="design-card">
                            <img src="${imageUrl}" 
                                 alt="${title}" 
                                 class="design-image"
                                 onerror="this.src='https://placehold.co/400x300?text=No+Image'">
                            <div class="design-content">
                                <span class="design-category">${categoryName}</span>
                                <h3 class="design-title">${title}</h3>
                                <p class="design-description">${description}</p>
                                <div class="design-actions">
                                    ${fileUrl !== '#' ? `
                                                            <a href="${fileUrl}" 
                                                               target="_blank" 
                                                               class="btn-download"
                                                               download>
                                                                <svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
                                                                    <path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/>
                                                                    <path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z"/>
                                                                </svg>
                                                                Download
                                                            </a>
                                                        ` : ''}
                                    ${videoUrl ? `
                                                            <a href="#" 
                                                               class="btn-video"
                                                               onclick="alert('Video tersedia untuk desain ini'); return false;">
                                                                <svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
                                                                    <path d="M6.79 5.093A.5.5 0 0 0 6 5.5v5a.5.5 0 0 0 .79.407l3.5-2.5a.5.5 0 0 0 0-.814l-3.5-2.5z"/>
                                                                    <path d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V4zm15 0a1 1 0 0 0-1-1H2a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4z"/>
                                                                </svg>
                                                                Lihat Video
                                                            </a>
                                                        ` : `
                                                            <a href="${imageUrl}" 
                                                               target="_blank" 
                                                               class="btn-video">
                                                                <svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
                                                                    <path d="M10.5 8a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z"/>
                                                                    <path d="M0 8s3-5.5 8-5.5S16 8 16 8s-3 5.5-8 5.5S0 8 0 8zm8 3.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z"/>
                                                                </svg>
                                                                Lihat Detail
                                                            </a>
                                                        `}
                                </div>
                            </div>
                        </div>
                    `;

                    grid.append(card);
                });

                // Ensure dark mode is applied to new content
                syncDarkMode();
            }

            // Fetch Jawa-III designs
            $.ajax({
                url: `${BASE_URL}/api/public/sites/${DAERAH}`,
                method: 'GET',
                success: function(response) {
                    console.log('API Response (Jawa-III):', response);
                    $('#loading-container-jawa3').hide();
                    // Get inherited house designs from response
                    const jawaDesigns = response.inherited?.houseDesigns || [];
                    console.log('Inherited Designs from Jawa-III:', jawaDesigns);
                    if (jawaDesigns.length > 0) {
                        $('#design-grid-jawa3').show();
                        renderDesignCardsJawa(jawaDesigns);
                    } else {
                        $('#empty-state-jawa3').show();
                    }
                },
                error: function(xhr, status, error) {
                    console.error('Error fetching Jawa-III designs:', error);
                    $('#loading-container-jawa3').hide();
                    $('#empty-state-jawa3').show();
                    $('#empty-state-jawa3 .empty-state-text').text(
                        'Terjadi kesalahan saat memuat data KRS Jawa-III. Silakan coba lagi nanti.');
                }
            });

            function renderDesignCardsJawa(designs) {
                const grid = $('#design-grid-jawa3');
                grid.empty();
                designs.forEach(design => {
                    const imageUrl = design.path_image ?
                        `${BASE_URL}/${design.path_image}` :
                        'https://placehold.co/400x300?text=No+Image';

                    const fileUrl = design.path_file ?
                        `${BASE_URL}/${design.path_file}` :
                        '#';

                    const videoUrl = design.video_id && design.video_id !== null ?
                        true :
                        false;

                    const categoryName = design.category?.name || 'Desain Rumah';
                    const title = design.title || 'Untitled';
                    const description = design.description || 'Tidak ada deskripsi tersedia.';

                    const card = `
                        <div class="design-card">
                            <img src="${imageUrl}" 
                                 alt="${title}" 
                                 class="design-image"
                                 onerror="this.src='https://placehold.co/400x300?text=No+Image'">
                            <div class="design-content">
                                <span class="design-category">${categoryName}</span>
                                <h3 class="design-title">${title}</h3>
                                <p class="design-description">${description}</p>
                                <div class="design-actions">
                                    ${fileUrl !== '#' ? `
                                                            <a href="${fileUrl}" 
                                                               target="_blank" 
                                                               class="btn-download"
                                                               download>
                                                                <svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
                                                                    <path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/>
                                                                    <path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z"/>
                                                                </svg>
                                                                Download
                                                            </a>
                                                        ` : ''}
                                    ${videoUrl ? `
                                                            <a href="#" 
                                                               class="btn-video"
                                                               onclick="alert('Video tersedia untuk desain ini'); return false;">
                                                                <svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
                                                                    <path d="M6.79 5.093A.5.5 0 0 0 6 5.5v5a.5.5 0 0 0 .79.407l3.5-2.5a.5.5 0 0 0 0-.814l-3.5-2.5z"/>
                                                                    <path d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V4zm15 0a1 1 0 0 0-1-1H2a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4z"/>
                                                                </svg>
                                                                Lihat Video
                                                            </a>
                                                        ` : `
                                                            <a href="${imageUrl}" 
                                                               target="_blank" 
                                                               class="btn-video">
                                                                <svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
                                                                    <path d="M10.5 8a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z"/>
                                                                    <path d="M0 8s3-5.5 8-5.5S16 8 16 8s-3 5.5-8 5.5S0 8 0 8zm8 3.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z"/>
                                                                </svg>
                                                                Lihat Detail
                                                            </a>
                                                        `}
                                </div>
                            </div>
                        </div>
                    `;

                    grid.append(card);
                });

                // Ensure dark mode is applied to new content
                syncDarkMode();
            }
        });
    </script>
    <?php if (isset($component)) { $__componentOriginal86ed18220e5516026aef66b347e6e7af = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal86ed18220e5516026aef66b347e6e7af = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.footer_one','data' => []] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('footer_one'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal86ed18220e5516026aef66b347e6e7af)): ?>
<?php $attributes = $__attributesOriginal86ed18220e5516026aef66b347e6e7af; ?>
<?php unset($__attributesOriginal86ed18220e5516026aef66b347e6e7af); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal86ed18220e5516026aef66b347e6e7af)): ?>
<?php $component = $__componentOriginal86ed18220e5516026aef66b347e6e7af; ?>
<?php unset($__componentOriginal86ed18220e5516026aef66b347e6e7af); ?>
<?php endif; ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.layout1', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\laravel\krs-jawa3-template\daerah\resources\views/home/designkrsjawa3.blade.php ENDPATH**/ ?>