/* =====================================================
   Geo Map Locations — Public Stylesheet
   Responsive, mobile-first, touch-friendly
   ===================================================== */

/* ----- Map Container ----- */
.gml-map-wrapper {
  width: 100%;
  position: relative;
  box-sizing: border-box;
  border-radius: 8px;

  /* CRITICAL: Do NOT use overflow:hidden here.
     Leaflet popups are absolutely-positioned and float OUTSIDE this div.
     overflow:hidden clips them, causing Leaflet to repeatedly reposition
     the popup — which on mobile looks like the popup flashing open/closed.
     We keep the border-radius visually via a box-shadow instead.         */
  overflow: visible;

  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  margin: 1.5em 0;
}

/* Keep the map tile area itself rounded by targeting the container directly */
.gml-map-container {
  width: 100%;
  min-height: 200px;
  background: #e8e8e8;
  display: block;
  border-radius: 8px;
  overflow: hidden;
}

/* Mobile: ensure a minimum usable height but DO NOT override the
   shortcode's explicit height setting (that was the old bug).
   The shortcode sets height inline via style="height:Npx" — an
   !important rule here would silently ignore the user's setting. */
@media (max-width: 600px) {
  .gml-map-container {
    min-height: 320px;
    /* No height override — let the shortcode setting win */
  }
}

/* ----- Custom SVG Marker ----- */
.gml-custom-marker {
  background: none !important;
  border: none !important;

  /* iOS fix: removes the 300 ms tap-delay so the marker responds instantly.
     "manipulation" allows tap + pinch-zoom but not double-tap-zoom.        */
  touch-action: manipulation;
  cursor: pointer;

  /* iOS fix: prevents the blue highlight flash on tap */
  -webkit-tap-highlight-color: transparent;
}

.gml-custom-marker svg {
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.35));
  transition: transform 0.15s ease;

  /* Prevent the SVG itself from intercepting touch events that should
     be handled by the Leaflet marker layer above it */
  pointer-events: none;
}

.gml-custom-marker:hover svg,
.gml-custom-marker:focus svg {
  transform: scale(1.15) translateY(-3px);
}

/* ----- Leaflet Popup Overrides ----- */
.gml-leaflet-popup .leaflet-popup-content-wrapper {
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(0, 0, 0, 0.08);

  /* iOS fix: enables momentum scrolling inside the popup so long content
     is scrollable on iPhone/iPad without the popup closing             */
  -webkit-overflow-scrolling: touch;
}

.gml-leaflet-popup .leaflet-popup-content {
  margin: 0;
  width: auto !important;

  /* iOS fix: allow the popup content to scroll vertically on small screens
     without triggering the page scroll or closing the popup              */
  overflow-y: auto;
  max-height: 80vh;     /* never taller than 80% of the viewport          */
  -webkit-overflow-scrolling: touch;
}

.gml-leaflet-popup .leaflet-popup-tip {
  background: #ffffff;
}

/* ----- Popup Inner Structure ----- */
.gml-popup {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  color: #333;
  line-height: 1.5;
  max-width: 320px;
  min-width: 260px;
}

/* Thumbnail */
.gml-popup__thumb {
  width: 100%;
  height: 140px;
  overflow: hidden;
}

.gml-popup__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Body */
.gml-popup__body {
  padding: 14px 16px 16px;
}

/* Name */
.gml-popup__name {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 10px;
  color: #1a1a1a;
  line-height: 1.3;
}

/* Rows (address, price, phone) */
.gml-popup__row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 0 0 8px;
  font-size: 13px;
  color: #555;
}

.gml-popup__row:last-of-type {
  margin-bottom: 12px;
}

.gml-icon {
  font-style: normal;
  font-size: 14px;
  line-height: 1.4;
  flex-shrink: 0;
}

.gml-popup__price strong {
  color: #27ae60;
  font-weight: 700;
  font-size: 14px;
}

.gml-popup__phone a {
  color: #2980b9;
  text-decoration: none;
  font-weight: 500;
}

.gml-popup__phone a:hover {
  text-decoration: underline;
}

/* Buttons */
.gml-popup__links {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 12px;
}

.gml-btn {
  display: block;
  width: 100%;
  text-align: center;
  padding: 9px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
  transition: background 0.2s ease, transform 0.1s ease;
  cursor: pointer;
  box-sizing: border-box;
}

.gml-btn:active {
  transform: scale(0.98);
}

.gml-btn--primary {
  background: #2563eb;
  color: #ffffff !important;
  border: none;
}

.gml-btn--primary:hover {
  background: #1d4ed8;
  color: #ffffff !important;
}

.gml-btn--secondary {
  background: transparent;
  color: #2563eb !important;
  border: 2px solid #2563eb;
}

.gml-btn--secondary:hover {
  background: #eff6ff;
}

/* ----- Mobile Popup Adjustments ----- */
@media (max-width: 480px) {
  .gml-leaflet-popup .leaflet-popup-content-wrapper {
    border-radius: 8px;
  }

  .gml-popup {
    font-size: 13px;
    min-width: 220px;
    max-width: 88vw;
  }

  .gml-popup__name {
    font-size: 15px;
  }

  .gml-popup__thumb {
    height: 110px;
  }
}

/* ----- Cluster Overrides ----- */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-clip: padding-box;
}

.marker-cluster-small {
  background-color: rgba(37, 99, 235, 0.2);
}
.marker-cluster-small div {
  background-color: rgba(37, 99, 235, 0.7);
  color: #fff;
  font-weight: 700;
}

.marker-cluster-medium {
  background-color: rgba(234, 88, 12, 0.2);
}
.marker-cluster-medium div {
  background-color: rgba(234, 88, 12, 0.7);
  color: #fff;
  font-weight: 700;
}

.marker-cluster-large {
  background-color: rgba(220, 38, 38, 0.2);
}
.marker-cluster-large div {
  background-color: rgba(220, 38, 38, 0.7);
  color: #fff;
  font-weight: 700;
}

/* =====================================================
   Reviews & Ratings — Public Styles
   ===================================================== */

/* ----- Average rating display in popup ----- */
.gml-popup__avg-rating {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 10px;
  flex-wrap: wrap;
}

.gml-stars-display {
  display: inline-flex;
  gap: 1px;
}

.gml-star {
  font-style: normal;
  font-size: 15px;
  line-height: 1;
}

.gml-star--on  { color: #f59e0b; }
.gml-star--off { color: #d1d5db; }

.gml-rating-num {
  font-size: 12px;
  font-weight: 700;
  color: #374151;
}

.gml-review-count {
  font-size: 11px;
  color: #6b7280;
}

/* ----- Editor comment & rating rows ----- */
.gml-popup__admin-comment em {
  font-style: italic;
  color: #555;
}

.gml-popup__editor-rating {
  font-size: 12px;
  color: #6b7280;
}

/* ----- Review toggle button ----- */
.gml-review-section {
  border-top: 1px solid #e5e7eb;
  margin-top: 14px;
  padding-top: 10px;
}

.gml-review-toggle {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #f59e0b;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  width: 100%;
  text-align: center;
  transition: background 0.2s, border-color 0.2s;
}

.gml-review-toggle:hover {
  background: #fef3c7;
  border-color: #f59e0b;
}

/* ----- Review form ----- */
.gml-review-form {
  margin-top: 12px;
}

.gml-form-title {
  font-weight: 700;
  font-size: 13px;
  color: #1f2937;
  margin: 0 0 8px;
}

/* Interactive star picker */
.gml-star-picker {
  display: flex;
  gap: 2px;
  margin-bottom: 4px;
}

.gml-star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  color: #d1d5db;
  padding: 2px 1px;
  transition: color 0.1s, transform 0.1s;
  line-height: 1;
}

.gml-star-btn:hover,
.gml-star-btn--active {
  color: #f59e0b;
  transform: scale(1.15);
}

.gml-star-btn:focus-visible {
  outline: 2px solid #2563eb;
  border-radius: 3px;
}

.gml-star-hint {
  font-size: 11px;
  color: #9ca3af;
  margin: 0 0 10px;
  font-style: italic;
}

/* Form inputs */
.gml-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical;
  background: #ffffff;
  color: #1f2937;
}

.gml-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.gml-input::placeholder { color: #9ca3af; }

/* Submit button (extends gml-btn) */
.gml-btn--submit {
  background: #f59e0b;
  color: #1a1a1a !important;
  border: none;
  width: 100%;
  padding: 10px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: block;
  text-align: center;
}

.gml-btn--submit:hover  { background: #d97706; }
.gml-btn--submit:active { transform: scale(0.98); }
.gml-btn--submit:disabled {
  background: #e5e7eb;
  color: #9ca3af !important;
  cursor: not-allowed;
}

/* Status messages */
.gml-form-status {
  font-size: 12px;
  margin: 8px 0 0;
  min-height: 18px;
  border-radius: 4px;
  padding: 5px 8px;
}

.gml-form-status:empty { padding: 0; }

.gml-form-status--success {
  background: #d1fae5;
  color: #065f46;
  font-weight: 600;
}

.gml-form-status--error {
  background: #fee2e2;
  color: #991b1b;
  font-weight: 600;
}

/* ----- Admin star rating widget ----- */
.gml-admin-stars {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}

.gml-star-label {
  cursor: pointer;
}

.gml-star-radio { display: none; }

.gml-star-label .gml-star {
  font-size: 24px;
  cursor: pointer;
  transition: color 0.1s, transform 0.1s;
}

.gml-star-label:hover .gml-star,
.gml-star-label .gml-star--on {
  color: #f59e0b;
  transform: scale(1.1);
}

.gml-star-label .gml-star:not(.gml-star--on) {
  color: #d1d5db;
}

.gml-star-value {
  margin-left: 8px;
  font-weight: 700;
  font-size: 14px;
  color: #374151;
}

.gml-char-hint {
  font-size: 11px;
  color: #9ca3af;
  margin: 2px 0 0;
  font-style: italic;
}

/* ----- Mobile ----- */
@media (max-width: 480px) {
  .gml-star-btn { font-size: 19px; }
  .gml-popup__avg-rating { font-size: 12px; }
}

/* =====================================================
   Popup Custom Image
   ===================================================== */

.gml-popup__custom-img {
  /* Width & height are set inline by JS from saved values */
  border-radius: 6px 6px 0 0;   /* top rounding to match popup */
  overflow: hidden;
  display: block;
  margin: 0 auto 12px !important;
  box-sizing: border-box;
  /* Allow the image to shrink on very small screens */
  max-width: 100% !important;
}

.gml-popup__custom-img img {
  display: block;
  width: 100%;
  object-fit: cover;
  border: none;
  vertical-align: bottom;
  /* Inherit height from parent (set inline) */
}

/* When the image sits at the very top of the popup (no thumb),
   bleed it to the edges of the content wrapper */
.gml-leaflet-popup .leaflet-popup-content .gml-popup > .gml-popup__custom-img:first-child {
  border-radius: 0;               /* full bleed at top */
  margin-left:  -12px !important;
  margin-right: -12px !important;
  width: calc(100% + 24px) !important;
  max-width: calc(100% + 24px) !important;
}

/* Mobile: never overflow the viewport */
@media (max-width: 480px) {
  .gml-popup__custom-img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
  }
  .gml-popup__custom-img img {
    height: auto !important;
    max-height: 200px;
  }
}
