
<?php $__env->startSection('title', 'Buku dari KRS Jawa III || 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, #667eea 0%, #178ee3 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 */
        .archive-section {
            padding: 4rem 2rem;
            background-color: var(--bg-primary);
            transition: background-color 0.3s ease;
        }

        [data-theme="dark"] .archive-section,
        body.dark-mode .archive-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 */
        .archive-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
            gap: 2rem;
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 1rem;
        }

        /* Archive Card */
        .archive-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);
        }

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

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

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

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

        .archive-content {
            padding: 1.5rem;
        }

        .archive-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;
        }

        .archive-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;
        }

        .archive-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;
        }

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

        .btn-download,
        .btn-view {
            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-view {
            background: var(--bg-card);
            color: #667eea;
            border: 2px solid #667eea;
            transition: all 0.3s ease;
        }

        .btn-view:hover {
            background: #667eea;
            color: white;
        }

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

        [data-theme="dark"] .btn-view:hover,
        body.dark-mode .btn-view:hover {
            background: #667eea;
            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;
            }

            .archive-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">Buku dari KRS Jawa III</h1>
            <div class="hero-divider"></div>
            <p class="hero-subtitle">
                Koleksi buku dan dokumen yang diwariskan dari KRS Jawa III untuk mendukung
                program perumahan dan pembangunan di seluruh wilayah.
            </p>
        </div>
    </section>

    <!-- Archive Cards Section -->
    <section class="archive-section">
        <div class="container">
            <h2 class="section-title">Koleksi Buku dari KRS Jawa III</h2>
            <p class="section-subtitle">
                Akses berbagai buku dan dokumen yang dibagikan dari KRS Jawa III
            </p>

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

            <!-- Cards Grid -->
            <div id="archive-grid" class="archive-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 buku dari KRS Jawa III yang tersedia saat ini.</p>
            </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 archives data from Jawa-III
            $.ajax({
                url: `${BASE_URL}/api/public/sites/${DAERAH}`,
                method: 'GET',
                success: function(response) {
                    console.log('API Response:', response);

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

                    // Get inherited archives from response
                    const archives = response.inherited?.archives || [];

                    console.log('Inherited Archives from Jawa-III:', archives);

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

                        // Render cards
                        renderArchiveCards(archives);
                    } 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 KRS Jawa III. Silakan coba lagi nanti.');
                }
            });

            function renderArchiveCards(archives) {
                const grid = $('#archive-grid');
                grid.empty();

                archives.forEach(archive => {
                    const imageUrl = archive.path_image ?
                        `${BASE_URL}/${archive.path_image}` :
                        'https://via.placeholder.com/400x300?text=No+Image';

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

                    const categoryName = archive.category?.name || 'Buku KRS Jawa III';
                    const title = archive.title || 'Untitled';
                    const description = archive.description || 'Tidak ada deskripsi tersedia.';

                    const card = `
                        <div class="archive-card">
                            <img src="${imageUrl}" 
                                 alt="${title}" 
                                 class="archive-image"
                                 onerror="this.src='https://via.placeholder.com/400x300?text=No+Image'">
                            <div class="archive-content">
                                <span class="archive-category">${categoryName}</span>
                                <h3 class="archive-title">${title}</h3>
                                <p class="archive-description">${description}</p>
                                <div class="archive-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>
                                                ` : ''}
                                    <a href="${imageUrl}" 
                                       target="_blank" 
                                       class="btn-view">
                                        <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\krs-jawa3-web-template\resources\views/home/bukukrs3.blade.php ENDPATH**/ ?>