<div class="container">
    <div class="header-section">
        <div class="header-title">{{ $library->name }}</div>
        <div class="header-subtitle">{{ $library->description }}</div>
    </div>

    <div class="button-group">
        <span class="active-indicator"></span>
        <button class="toogle-button active_button">{{ $library->library_title }}</button>
        <button class="toogle-button">{{ $library->online_resources_title }}</button>
    </div>

    <div class="content-container" id="libries">
        <div class="content-sections">
            <div class="open-hours-section">
                <div class="open-hours-title">{{ $library->opening_hours_title }}</div>
                <div class="open-hours-item">{{ $library->library_opening_time }} - {{ $library->library_closing_time }}
                </div>
                <div class="open-hours-item">{{ $library->library_time_description }}</div>
            </div>
            <div class="contact-section">
                <div class="contact-title">{{ $library->contact_title }}</div>
                <div class="contact-subtitle">{{ $library->tittle_circulation }}</div>
                <div class="contact-info">Contact: {{ $library->desk_contact_number1 }} /
                    {{ $library->desk_contact_number2 }}</div>
                <div class="contact-info">E-mail: {{ $library->desk_email }}</div>
                <div class="contact-subtitle">{{ $library->desk_title_2 }}</div>
                <ul class="contact-list">
                    <li class="contact-list-item">{{ $library->renewal_text_1 }}</li>
                    <li class="contact-list-item">{{ $library->renewal_text_2 }}</li>
                    <li class="contact-list-item">{{ $library->renewal_text_3 }}</li>
                </ul>
            </div>
        </div>

        <div class="library-policies-section"
            style="background: url('{{ asset('storage/' . $library->background_image) }}') center center/cover no-repeat;">
            <div class="policies-content-card">
                <div class="policies-title">{{ $library->library_policy_title }}</div>
                @php
                    $paragraphs = explode("\n\n", $library->library_policy_description);
                @endphp
                @foreach($paragraphs as $paragraph)
                    @if(trim($paragraph) !== '')
                        <p class="policy-paragraph">{{ trim($paragraph) }}</p>
                    @endif
                @endforeach
            </div>
        </div>
    </div>
</div>

<script>
document.addEventListener('DOMContentLoaded', function() {
    const buttons = document.querySelectorAll('.toogle-button');
    const libraryContent = document.getElementById('libries');
    const resourcesContent = document.getElementById('online_resources');
    const activeIndicator = document.querySelector('.active-indicator');

    // Initial state: show library, hide resources
    if (libraryContent) libraryContent.style.display = 'block';
    if (resourcesContent) resourcesContent.style.display = 'none';

    buttons.forEach((btn, idx) => {
        btn.addEventListener('click', function() {
            // Remove active class from all buttons
            buttons.forEach(b => b.classList.remove('active_button'));
            // Add active class to clicked button
            btn.classList.add('active_button');

            // Toggle content
            if (idx === 0) {
                if (libraryContent) libraryContent.style.display = 'block';
                if (resourcesContent) resourcesContent.style.display = 'none';
                if (activeIndicator) activeIndicator.style.left = '0';
            } else {
                if (libraryContent) libraryContent.style.display = 'none';
                if (resourcesContent) resourcesContent.style.display = 'block';
                if (activeIndicator) activeIndicator.style.left = '50%';
            }
        });
    });
});
</script>
<style>
    /* Enhanced responsive styles */
@media (max-width: 1200px) {
    .container {
        padding: 0 20px;
    }
    .header-section {
        padding: 2.5rem 0;
    }
    .header-title {
        font-size: 2.2rem;
        margin-bottom: 1rem;
    }
    .header-subtitle {
        font-size: 1.1rem;
    }
    .button-group {
        margin: 2.5rem 0;
        gap: 0.8rem;
    }
    .toogle-button {
        padding: 0.8rem 1.6rem;
        font-size: 0.95rem;
    }
    .content-container {
        gap: 2rem;
        margin-top: 2.5rem;
    }
    .content-sections {
        gap: 1.8rem;
    }
    .open-hours-section, .contact-section {
        padding: 1.8rem;
    }
    .open-hours-title, .contact-title {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }
    .open-hours-item, .contact-info {
        font-size: 0.95rem;
        margin-bottom: 0.8rem;
    }
    .contact-subtitle {
        font-size: 1rem;
        margin: 1rem 0 0.8rem 0;
    }
    .contact-list-item {
        font-size: 0.9rem;
        margin-bottom: 0.6rem;
    }
    .library-policies-section {
        padding: 2.5rem;
    }
    .policies-content-card {
        padding: 2rem;
    }
    .policies-title {
        font-size: 1.4rem;
        margin-bottom: 1.5rem;
    }
    .policy-paragraph {
        font-size: 0.95rem;
        margin-bottom: 1rem;
    }
}

@media (max-width: 992px) {
    .container {
        padding: 0 15px;
    }
    .header-section {
        padding: 2rem 0;
    }
    .header-title {
        font-size: 2rem;
        margin-bottom: 0.8rem;
    }
    .header-subtitle {
        font-size: 1rem;
    }
    .button-group {
        margin: 2rem 0;
        gap: 0.6rem;
    }
    .toogle-button {
        padding: 0.7rem 1.4rem;
        font-size: 0.9rem;
    }
    .content-container {
        gap: 1.5rem;
        margin-top: 2rem;
    }
    .content-sections {
        gap: 1.5rem;
    }
    .open-hours-section, .contact-section {
        padding: 1.5rem;
    }
    .open-hours-title, .contact-title {
        font-size: 1.2rem;
        margin-bottom: 0.8rem;
    }
    .open-hours-item, .contact-info {
        font-size: 0.9rem;
        margin-bottom: 0.7rem;
    }
    .contact-subtitle {
        font-size: 0.95rem;
        margin: 0.8rem 0 0.7rem 0;
    }
    .contact-list-item {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
    }
    .library-policies-section {
        padding: 2rem;
    }
    .policies-content-card {
        padding: 1.8rem;
    }
    .policies-title {
        font-size: 1.3rem;
        margin-bottom: 1.3rem;
    }
    .policy-paragraph {
        font-size: 0.9rem;
        margin-bottom: 0.9rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 12px;
    }
    .header-section {
        padding: 1.5rem 0;
    }
    .header-title {
        font-size: 1.8rem;
        margin-bottom: 0.6rem;
    }
    .header-subtitle {
        font-size: 0.95rem;
    }
    .button-group {
        margin: 1.5rem 0;
        gap: 0.5rem;
    }
    .toogle-button {
        padding: 0.6rem 1.2rem;
        font-size: 0.85rem;
    }
    .content-container {
        gap: 1.2rem;
        margin-top: 1.5rem;
    }
    .content-sections {
        gap: 1.2rem;
    }
    .open-hours-section, .contact-section {
        padding: 1.2rem;
    }
    .open-hours-title, .contact-title {
        font-size: 1.1rem;
        margin-bottom: 0.6rem;
    }
    .open-hours-item, .contact-info {
        font-size: 0.85rem;
        margin-bottom: 0.6rem;
    }
    .contact-subtitle {
        font-size: 0.9rem;
        margin: 0.6rem 0 0.6rem 0;
    }
    .contact-list-item {
        font-size: 0.8rem;
        margin-bottom: 0.4rem;
    }
    .library-policies-section {
        padding: 1.5rem;
    }
    .policies-content-card {
        padding: 1.5rem;
    }
    .policies-title {
        font-size: 1.2rem;
        margin-bottom: 1.1rem;
    }
    .policy-paragraph {
        font-size: 0.85rem;
        margin-bottom: 0.8rem;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 0 10px;
    }
    .header-section {
        padding: 1.2rem 0;
    }
    .header-title {
        font-size: 1.6rem;
        margin-bottom: 0.5rem;
    }
    .header-subtitle {
        font-size: 0.9rem;
    }
    .button-group {
        margin: 1.2rem 0;
        gap: 0.4rem;
    }
    .toogle-button {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
    .content-container {
        gap: 1rem;
        margin-top: 1.2rem;
    }
    .content-sections {
        gap: 1rem;
    }
    .open-hours-section, .contact-section {
        padding: 1rem;
    }
    .open-hours-title, .contact-title {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    .open-hours-item, .contact-info {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }
    .contact-subtitle {
        font-size: 0.85rem;
        margin: 0.5rem 0 0.5rem 0;
    }
    .contact-list-item {
        font-size: 0.75rem;
        margin-bottom: 0.3rem;
    }
    .library-policies-section {
        padding: 1.2rem;
    }
    .policies-content-card {
        padding: 1.2rem;
    }
    .policies-title {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    .policy-paragraph {
        font-size: 0.8rem;
        margin-bottom: 0.7rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 8px;
    }
    .header-section {
        padding: 1rem 0;
    }
    .header-title {
        font-size: 1.4rem;
        margin-bottom: 0.4rem;
    }
    .header-subtitle {
        font-size: 0.85rem;
    }
    .button-group {
        margin: 1rem 0;
        gap: 0.3rem;
    }
    .toogle-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
    .content-container {
        gap: 0.8rem;
        margin-top: 1rem;
    }
    .content-sections {
        gap: 0.8rem;
    }
    .open-hours-section, .contact-section {
        padding: 0.8rem;
    }
    .open-hours-title, .contact-title {
        font-size: 0.95rem;
        margin-bottom: 0.4rem;
    }
    .open-hours-item, .contact-info {
        font-size: 0.75rem;
        margin-bottom: 0.4rem;
    }
    .contact-subtitle {
        font-size: 0.8rem;
        margin: 0.4rem 0 0.4rem 0;
    }
    .contact-list-item {
        font-size: 0.7rem;
        margin-bottom: 0.25rem;
    }
    .library-policies-section {
        padding: 1rem;
    }
    .policies-content-card {
        padding: 1rem;
    }
    .policies-title {
        font-size: 1rem;
        margin-bottom: 0.8rem;
    }
    .policy-paragraph {
        font-size: 0.75rem;
        margin-bottom: 0.6rem;
    }
}

@media (max-width: 400px) {
    .container {
        padding: 0 6px;
    }
    .header-section {
        padding: 0.8rem 0;
    }
    .header-title {
        font-size: 1.2rem;
        margin-bottom: 0.3rem;
    }
    .header-subtitle {
        font-size: 0.8rem;
    }
    .button-group {
        margin: 0.8rem 0;
        gap: 0.25rem;
    }
    .toogle-button {
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
    }
    .content-container {
        gap: 0.6rem;
        margin-top: 0.8rem;
    }
    .content-sections {
        gap: 0.6rem;
    }
    .open-hours-section, .contact-section {
        padding: 0.6rem;
    }
    .open-hours-title, .contact-title {
        font-size: 0.9rem;
        margin-bottom: 0.3rem;
    }
    .open-hours-item, .contact-info {
        font-size: 0.7rem;
        margin-bottom: 0.3rem;
    }
    .contact-subtitle {
        font-size: 0.75rem;
        margin: 0.3rem 0 0.3rem 0;
    }
    .contact-list-item {
        font-size: 0.65rem;
        margin-bottom: 0.2rem;
    }
    .library-policies-section {
        padding: 0.8rem;
    }
    .policies-content-card {
        padding: 0.8rem;
    }
    .policies-title {
        font-size: 0.95rem;
        margin-bottom: 0.6rem;
    }
    .policy-paragraph {
        font-size: 0.7rem;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 360px) {
    .container {
        padding: 0 4px;
    }
    .header-section {
        padding: 0.6rem 0;
    }
    .header-title {
        font-size: 1.1rem;
        margin-bottom: 0.25rem;
    }
    .header-subtitle {
        font-size: 0.75rem;
    }
    .button-group {
        margin: 0.6rem 0;
        gap: 0.2rem;
    }
    .toogle-button {
        padding: 0.25rem 0.5rem;
        font-size: 0.65rem;
    }
    .content-container {
        gap: 0.5rem;
        margin-top: 0.6rem;
    }
    .content-sections {
        gap: 0.5rem;
    }
    .open-hours-section, .contact-section {
        padding: 0.5rem;
    }
    .open-hours-title, .contact-title {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }
    .open-hours-item, .contact-info {
        font-size: 0.65rem;
        margin-bottom: 0.25rem;
    }
    .contact-subtitle {
        font-size: 0.7rem;
        margin: 0.25rem 0 0.25rem 0;
    }
    .contact-list-item {
        font-size: 0.6rem;
        margin-bottom: 0.15rem;
    }
    .library-policies-section {
        padding: 0.6rem;
    }
    .policies-content-card {
        padding: 0.6rem;
    }
    .policies-title {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
    .policy-paragraph {
        font-size: 0.65rem;
        margin-bottom: 0.4rem;
    }
}
</style>
