/* Google Map with View - Unified Layout */
.google-map-with-view-container {
  width: 100%;
}

.google-map-with-view-container .autocomplete-wrapper {
  margin: 1rem 0;
}

.responsive-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* PC styles (768px and above) */
@media (min-width: 768px) {

  /* PC: top - Map on top, content below */
  .responsive-layout.pc-top {
    flex-direction: column;
  }

  /* PC: bottom - Content on top, map below */
  .responsive-layout.pc-bottom {
    flex-direction: column-reverse;
  }

  /* PC: left - Map on left, content on right */
  .responsive-layout.pc-left {
    flex-direction: row;
  }

  /* PC: right - Content on left, map on right */
  .responsive-layout.pc-right {
    flex-direction: row-reverse;
  }

  /* Width adjustment for horizontal layouts */
  .responsive-layout.pc-left .google-map-wrapper,
  .responsive-layout.pc-left .view-content-wrapper,
  .responsive-layout.pc-right .google-map-wrapper,
  .responsive-layout.pc-right .view-content-wrapper {
    flex: 1;
  }
}

/* Mobile styles (767px and below) */
@media (max-width: 767px) {

  /* Mobile: top - Map on top, content below */
  .responsive-layout.sp-top {
    flex-direction: column;
  }

  /* Mobile: bottom - Content on top, map below */
  .responsive-layout.sp-bottom {
    flex-direction: column-reverse;
  }
}

/* Common styles */
.google-map-wrapper,
.view-content-wrapper {
  width: 100%;
}

.google-map-wrapper #map {
  min-height: 500px;
  /* Adjust as needed */
}

@media (max-width: 767px) {
  .google-map-wrapper #map {
    height: 50vh !important;
    min-height: 300px;
  }
}

/* Spacing adjustment for horizontal layouts */
@media (min-width: 768px) {

  .responsive-layout.pc-left .google-map-wrapper,
  .responsive-layout.pc-right .view-content-wrapper {
    margin-right: 20px;
  }

  .responsive-layout.pc-right .google-map-wrapper,
  .responsive-layout.pc-left .view-content-wrapper {
    margin-left: 20px;
  }
}

/* Map Container */
.map-container-relative {
  position: relative !important;
}

/* Search Button */
.map-search-button {
  position: relative;
  top: 80%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  /* Button styling to match site design */
  display: none;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

/* Loading state for search button */
.map-search-button:disabled,
.map-search-button.loading {
  opacity: 0.7;
  cursor: not-allowed;
  pointer-events: none;
}

.map-search-button.loading::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 8px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Loading Overlay */
.map-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: wait;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.8);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Loading Spinner */
.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 16px;
  color: #333;
  font-weight: 500;
  margin: 0;
}

/* Body class for loading state */
body.map-search-loading {
  overflow: hidden;
}

/* Info Window Styles */
.map-info-window {
  max-width: 300px;
  padding: 15px;
  font-family: inherit;
}

.map-info-window h3 {
  margin: 0 0 10px 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.map-info-window h3 a {
  color: #333;
  text-decoration: none;
  transition: color 0.2s ease;
}

.map-info-window h3 a:hover {
  color: #667eea;
  text-decoration: underline;
}

.map-info-window p {
  margin: 8px 0;
  font-size: 14px;
  color: #666;
  line-height: 1.5;
}

/* Responsive Design */
@media (max-width: 768px) {
  .map-search-button {
    font-size: 12px;
    padding: 10px 20px;
    border-radius: 20px;
  }

  .google-map-container {
    height: 400px;
  }

  .map-message {
    right: 10px;
    left: 10px;
    max-width: none;
    font-size: 13px;
  }

  .map-loading-content {
    margin: 20px;
    padding: 25px;
  }

  .loading-spinner {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 600px) {
  .gm-style-iw {
    max-width: 85vw !important;
  }
}

@media (max-width: 480px) {
  .map-search-button {
    font-size: 11px;
    padding: 8px 16px;
    gap: 6px;
  }

  .map-search-button i {
    font-size: 12px;
  }

  .google-map-container {
    height: 350px;
  }
}

/* High DPI Display Support */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
  .map-search-button {
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
  }
}

/* Dark Mode Support (optional) */
@media (prefers-color-scheme: dark) {
  .map-loading-content {
    background: #2d3748;
    color: white;
  }

  .loading-text {
    color: #e2e8f0;
  }

  .map-info-window h3 a {
    color: #e2e8f0;
  }

  .map-info-window h3 a:hover {
    color: #90cdf4;
  }
}

/* Animation for smooth show/hide */
.map-search-button {
  transition: all 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

.map-search-button[style*="display: block"] {
  animation: searchButtonShow 0.3s ease-out;
}

@keyframes searchButtonShow {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Place Autocomplete Styles */
gmp-place-autocomplete {
  border-radius: var(--bs-border-radius);
  margin-bottom: 0.5rem;
}

.view-empty .init-hidden {
  display: none;
}

.initialized .view-empty .init-hidden {
  display: block;
}

#location-view .view-content {
  position: relative;
  overflow-y: auto;
}
