<turbo-stream action="replace" target="listings"><template>
  <turbo-frame id="listings" target="_top">
    <section class="listings">
    <div class="card-view">
        <article>
        <figure class="carousel">
        <div class="carousel-images">
            <div class="carousel-image active">
              <a data-turbo-frame="_top" href="/offices/2"><img loading="eager" src="https://www.kuida.co/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTUsInB1ciI6ImJsb2JfaWQifX0=--801bc4bde3a6eb6a7aead930746050b789bbd888/office-02.jpg" /></a>
            </div>
            <div class="carousel-image ">
              <a data-turbo-frame="_top" href="/offices/2"><img loading="lazy" src="https://www.kuida.co/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTYsInB1ciI6ImJsb2JfaWQifX0=--293fe500c472acfc3572e926bd9bb395a4f5f4ca/office-05.jpg" /></a>
            </div>
        </div>
        <button class="carousel-arrow prev" aria-label="Previous image">❮</button>
        <button class="carousel-arrow next" aria-label="Next image">❯</button>
      </figure>
          <section>
            <h3><a data-turbo-frame="_top" href="/offices/2">Fisioterapia</a></h3>
            <p>Professional medical office space with comprehensive amenities. The office features multiple cons...</p>
              <div class="office-categories-list" style="display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0;">
                  <span style="background: rgba(224, 78, 83, 0.1); color: #e04e53; padding: 0.25rem 0.6rem; border-radius: 12px; font-size: 0.8rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.3rem;">
                      <i class="fa-solid fa-head-side-virus" style="font-size: 0.75rem;"></i>
                    Psiquiátrico
                  </span>
                  <span style="background: rgba(224, 78, 83, 0.1); color: #e04e53; padding: 0.25rem 0.6rem; border-radius: 12px; font-size: 0.8rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.3rem;">
                      <i class="fa-solid fa-running" style="font-size: 0.75rem;"></i>
                    Fisioterapia
                  </span>
              </div>
              <div class="office-rating" style="display: flex; align-items: center; gap: 0.5rem; margin: 0.75rem 0;">
                <div class="rating-stars" style="display: flex; gap: 2px;">
                    <i class="fas fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                    <i class="fas fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                    <i class="fas fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                    <i class="fas fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                    <i class="far fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                </div>
                <span style="color: #666; font-size: 0.9rem; font-weight: 600;">
                  3.7 (3)
                </span>
              </div>
            <p>100000.0</p>
          </section>
        </article>
        <article>
        <figure class="carousel">
        <div class="carousel-images">
            <div class="carousel-image active">
              <a data-turbo-frame="_top" href="/offices/4"><img loading="eager" src="https://www.kuida.co/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTksInB1ciI6ImJsb2JfaWQifX0=--eefa1320bab221069443c6b7891e73f9b35ab795/office-04.jpg" /></a>
            </div>
            <div class="carousel-image ">
              <a data-turbo-frame="_top" href="/offices/4"><img loading="lazy" src="https://www.kuida.co/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MjAsInB1ciI6ImJsb2JfaWQifX0=--56e9247f3c854557ce28117e1b0acdd3f89d28b6/office-07.jpg" /></a>
            </div>
        </div>
        <button class="carousel-arrow prev" aria-label="Previous image">❮</button>
        <button class="carousel-arrow next" aria-label="Next image">❯</button>
      </figure>
          <section>
            <h3><a data-turbo-frame="_top" href="/offices/4">Psiquiátrico</a></h3>
            <p>Well-maintained medical office with excellent facilities. This space offers a professional enviro...</p>
              <div class="office-categories-list" style="display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0;">
                  <span style="background: rgba(224, 78, 83, 0.1); color: #e04e53; padding: 0.25rem 0.6rem; border-radius: 12px; font-size: 0.8rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.3rem;">
                      <i class="fa-solid fa-head-side-virus" style="font-size: 0.75rem;"></i>
                    Psiquiátrico
                  </span>
              </div>
              <div class="office-rating" style="display: flex; align-items: center; gap: 0.5rem; margin: 0.75rem 0;">
                <div class="rating-stars" style="display: flex; gap: 2px;">
                    <i class="fas fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                    <i class="fas fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                    <i class="fas fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                    <i class="fas fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                    <i class="far fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                </div>
                <span style="color: #666; font-size: 0.9rem; font-weight: 600;">
                  4.3 (3)
                </span>
              </div>
            <p>600000.0</p>
          </section>
        </article>
        <article>
        <figure class="carousel">
        <div class="carousel-images">
            <div class="carousel-image active">
              <a data-turbo-frame="_top" href="/offices/5"><img loading="eager" src="https://www.kuida.co/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MjEsInB1ciI6ImJsb2JfaWQifX0=--4dd5a846fb95bcadfbfe232b9cf723fc16682483/office-05.jpg" /></a>
            </div>
            <div class="carousel-image ">
              <a data-turbo-frame="_top" href="/offices/5"><img loading="lazy" src="https://www.kuida.co/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MjIsInB1ciI6ImJsb2JfaWQifX0=--1dedf69b0b57b159210205ae11151a65e3657014/office-08.jpg" /></a>
            </div>
        </div>
        <button class="carousel-arrow prev" aria-label="Previous image">❮</button>
        <button class="carousel-arrow next" aria-label="Next image">❯</button>
      </figure>
          <section>
            <h3><a data-turbo-frame="_top" href="/offices/5">Psiquiátrico</a></h3>
            <p>Premium medical office space with state-of-the-art facilities. This office offers excellent natur...</p>
              <div class="office-categories-list" style="display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0;">
                  <span style="background: rgba(224, 78, 83, 0.1); color: #e04e53; padding: 0.25rem 0.6rem; border-radius: 12px; font-size: 0.8rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.3rem;">
                      <i class="fa-solid fa-eye" style="font-size: 0.75rem;"></i>
                    Oftalmológico
                  </span>
                  <span style="background: rgba(224, 78, 83, 0.1); color: #e04e53; padding: 0.25rem 0.6rem; border-radius: 12px; font-size: 0.8rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.3rem;">
                      <i class="fa-solid fa-hand-holding-medical" style="font-size: 0.75rem;"></i>
                    Dermatológico
                  </span>
                  <span style="background: rgba(224, 78, 83, 0.1); color: #e04e53; padding: 0.25rem 0.6rem; border-radius: 12px; font-size: 0.8rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.3rem;">
                      <i class="fa-solid fa-head-side-virus" style="font-size: 0.75rem;"></i>
                    Psiquiátrico
                  </span>
              </div>
              <div class="office-rating" style="display: flex; align-items: center; gap: 0.5rem; margin: 0.75rem 0;">
                <div class="rating-stars" style="display: flex; gap: 2px;">
                    <i class="fas fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                    <i class="fas fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                    <i class="fas fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                    <i class="far fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                    <i class="far fa-star" style="color: #ffc107; font-size: 0.9rem;"></i>
                </div>
                <span style="color: #666; font-size: 0.9rem; font-weight: 600;">
                  3.3 (3)
                </span>
              </div>
            <p>500000.0</p>
          </section>
        </article>
    </div>
  <div class="map-view">
    <div id="map-container">Vista de mapa</div>
  </div>
  <button class="view-toggle" aria-label="Toggle view">
    <span class="icon">🗺️</span>
    <span>Vista de mapa</span>
  </button>
</section>

<script>

carousels.forEach(carousel => {
  const images = carousel.querySelectorAll('.carousel-image');
  const prevButton = carousel.querySelector('.prev');
  const nextButton = carousel.querySelector('.next');
  let currentIndex = 0;

  const showImage = (index) => {
    images.forEach((img, i) => {
      img.classList.toggle('active', i === index);
    });
    // Lazy load the image when it becomes active
    const lazyImg = images[index].querySelector('.lazy-image');
    if (lazyImg && lazyImg.dataset.src) {
      lazyImg.src = lazyImg.dataset.src;
      delete lazyImg.dataset.src;
    }
  };

  if (prevButton) {
    prevButton.addEventListener('click', () => {
      currentIndex = (currentIndex - 1 + images.length) % images.length;
      showImage(currentIndex);
    });
  }

  if (nextButton) {
    nextButton.addEventListener('click', () => {
      currentIndex = (currentIndex + 1) % images.length;
      showImage(currentIndex);
    });
  }
});
</script>
</turbo-frame></template></turbo-stream>