/* General Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body, html {
  height: 100%;
  font-family: Arial, sans-serif;
  overflow: hidden;
}

/* Map Styling */
#map {
  width: 100%;
  height: 100vh;
  position: relative;
}

/* Top-left Filters Panel */
#filters {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255, 255, 255, 0.95);
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Search Box */
#search-box {
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 5px;
}
#search-box.active { display: flex; }

#search-input {
  padding: 5px 10px;
  width: 180px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

#search-toggle,
#search-close {
  background: #007bff;
  color: #fff;
  border: none;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
}
#search-toggle:hover,
#search-close:hover { background: #0056b3; }

select {
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid #ccc;
}

/* Locate Button */
#locate-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: #007bff;
  color: white;
  border: none;
  padding: 12px 14px;
  border-radius: 50%;
  font-size: 20px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  z-index: 1000;
}
#locate-btn:hover { background-color: #0056b3; }

/* Modal Overlay */
#modal {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}
#modal.show { display: flex; }

/* Modal Panel (desktop/tablet default) */
#modal-content {
  background: #fff;
  width: 90%;
  max-width: 600px;
  border-radius: 10px;
  padding: 20px;
  position: relative;

  /* Ensure internal scroll instead of overflow off-screen */
  max-height: 90vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Header (single rule; keeps controls visible) */
#modal-header {
  /* sticky keeps buttons visible while scrolling content */
  position: sticky;
  top: 0;
  z-index: 999;              /* above any swiper arrows */
  background: #fff;

  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;              /* allow title to shrink */
  margin-bottom: 10px;
  padding-bottom: 2px;
}

#modal-title {
  flex: 1;
  font-size: 1.4rem;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;   /* long titles won't push buttons out */
}

/* Fullscreen button */
#modal-fullscreen {
  background: none;
  border: none;
  cursor: pointer;
  margin-left: auto;
  margin-right: 4px;
  flex: 0 0 auto;            /* never shrink */

  /* bigger tap target for mobile */
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

/* Close button */
#modal-close {
  cursor: pointer;
  color: #888;
  flex: 0 0 auto;            /* never shrink */

  /* bigger tap target for mobile */
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border-radius: 6px;
}
#modal-close:hover { color: #000; }

/* Tabs */
#modal-tabs {
  display: flex;
  margin-bottom: 10px;
  border-bottom: 1px solid #ccc;
}
.tab-btn {
  padding: 10px 15px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab-btn.active {
  border-color: #007bff;
  font-weight: bold;
  color: #007bff;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Info Text */
#tab-info p { margin-bottom: 10px; }

/* Swiper Container */
.swiper {
  width: 100%;
  height: 300px;
}
.swiper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

/* Make sure swiper arrows don't overlay header buttons */
#modal-content .swiper-button-prev,
#modal-content .swiper-button-next { z-index: 10; }

/* Call Button */
#call-btn {
  display: inline-block;
  margin-top: 15px;
  padding: 10px 16px;
  background: #28a745;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  text-align: center;
}
#call-btn:hover { background: #218838; }

/* Fullscreen class (via your JS toggle) */
#modal-content.fullscreen {
  width: 100vw !important;
  height: 100vh !important;           /* desktop/tablet */
  max-width: none;
  max-height: none;
  border-radius: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Make images scale nicely in fullscreen */
#modal-content.fullscreen .swiper-slide img {
  height: 100%;
  object-fit: contain;
}

/* ---- Mobile fixes ---- */
@media (max-width: 480px) {
  /* Stretch modal so content starts at top; avoids vertical centering issues */
  #modal { align-items: stretch; }

  /* Fullscreen on mobile to avoid viewport clipping & notches */
  #modal-content {
    width: 100vw !important;
    height: 100dvh !important;         /* dynamic viewport height (iOS/Android) */
    max-width: none;
    max-height: none;
    border-radius: 0;
    padding: 16px;

    /* account for notches & home indicator */
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
  }

  #modal-header {
    top: env(safe-area-inset-top);     /* keep header below notch */
    padding-top: 4px;
  }

  #modal-title { font-size: 1.1rem; }

  #modal-fullscreen,
  #modal-close {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .swiper { height: 45dvh; }           /* keep space for header/buttons */
}

/* Fallback if env() not supported */
@supports not (padding: max(0px)) {
  @media (max-width: 480px) {
    #modal-header { top: 0; }
  }
}

#locate-btn, 
#next-btn, 
#prev-btn {
  position: absolute;
  right: 20px;
  width: 45px;
  height: 45px;
  border: none;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  cursor: pointer;
  font-size: 18px;
  z-index: 1000; /* stay above map */
}

/* Position each button separately */
#locate-btn {
  bottom: 20px;
}

#next-btn {
  bottom: 75px; /* just above locate */
}

#prev-btn {
  bottom: 130px; /* above next */
}
