/**
 * Locations Nav Popover Styles
 * Mirrors services-popover.css — dark theme, mobile bottom-sheet
 */

/* ── Menu item wrapper ─────────────────────────────────────────────────────── */

.locations-menu-item {
  position: relative;
  display: flex !important;
  align-items: center;
  gap: 0.25rem;
}

.locations-menu-item.menu-item-has-popover {
  display: flex !important;
  flex-direction: row;
  gap: 0.25rem;
  align-items: center;
}

.locations-menu-item.menu-item-has-popover > a {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff !important;
}

/* ── Trigger button ────────────────────────────────────────────────────────── */

.locations-popover-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: #fff;
  transition:
    transform 0.3s ease,
    background-color 0.2s ease;
  border-radius: 4px;
  min-width: 28px;
  min-height: 28px;
}

.locations-popover-trigger:hover,
.locations-popover-trigger:focus {
  background-color: rgba(255, 255, 255, 0.1);
  outline: none;
  color: #fff;
}

.locations-popover-trigger:focus-visible {
  outline: 2px solid #ffc107;
  outline-offset: 2px;
}

.locations-popover-trigger[aria-expanded="true"] {
  transform: rotate(180deg);
}

.locations-popover-trigger svg {
  font-size: 18px;
  width: 18px;
  height: 18px;
  transition: transform 0.3s ease;
}

/* ── Popover container ─────────────────────────────────────────────────────── */

.locations-popover {
  position: absolute;
  top: calc(100% + 1rem);
  left: 50%;
  transform: translateX(-50%);
  min-width: 280px;
  max-width: 90vw;
  background: #1a1a1a;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease,
    transform 0.3s ease;
  pointer-events: none;
}

.locations-popover[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transform: translateX(-50%) translateY(0);
}

/* Keep display:block when hidden attr present (transition instead of display) */
.locations-popover[hidden] {
  display: block;
  opacity: 0;
  visibility: hidden;
}

/* Arrow */
.locations-popover::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 10px solid #1a1a1a;
}

/* ── Inner scroll container ────────────────────────────────────────────────── */

.locations-popover-inner {
  padding: 1.25rem;
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.locations-popover-inner::-webkit-scrollbar {
  width: 8px;
}
.locations-popover-inner::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}
.locations-popover-inner::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}
.locations-popover-inner::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ── "View All" CTA ────────────────────────────────────────────────────────── */

.locations-popover-all {
  display: block;
  width: 100%;
  padding: 0.875rem 1rem;
  background: var(--primary-color);
  color: #1a1a1a !important;
  font-weight: 600;
  text-align: center;
  text-decoration: none !important;
  border-radius: 6px;
  line-height: 1 !important;
  margin-bottom: 1rem;
  transition:
    background-color 0.2s ease,
    transform 0.1s ease;
}

.locations-popover-all:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(254, 169, 6, 0.35);
  outline: none;
}

.locations-popover-all:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ── Location grid ─────────────────────────────────────────────────────────── */

.locations-popover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}

/* ── Individual location item ──────────────────────────────────────────────── */

.locations-popover-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff !important;
  text-decoration: none !important;
  border-radius: 6px;
  transition:
    background-color 0.2s ease,
    transform 0.1s ease;
}

.locations-popover-item:hover,
.locations-popover-item:focus {
  background: rgba(254, 169, 6, 0.15);
  transform: translateX(3px);
  outline: none;
}

.locations-popover-item:focus-visible {
  outline: 2px solid #ffc107;
  outline-offset: 2px;
}

.locations-popover-item svg {
  color: var(--primary-color);
  font-size: 15px;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.locations-popover-item__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.locations-popover-item__city {
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
}

.locations-popover-item__province {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.02em;
}

/* ── Overlay (mobile/tablet) ───────────────────────────────────────────────── */

.locations-popover-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
  backdrop-filter: blur(4px);
}

.locations-popover-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ── Astra header context ──────────────────────────────────────────────────── */

.ast-builder-menu-1 .locations-menu-item,
.main-header-menu .locations-menu-item {
  position: relative;
}

/* ── Responsive — mobile bottom sheet ─────────────────────────────────────── */

@media (max-width: 921px) {
  .locations-popover {
    position: fixed;
    top: auto !important;
    left: 0 !important;
    right: 0;
    bottom: 0;
    transform: translateY(100%);
    max-width: 100%;
    min-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 80vh;
  }

  .locations-popover[aria-hidden="false"] {
    transform: translateY(0);
  }

  .locations-popover::before {
    display: none;
  }

  /* Drag handle */
  .locations-popover::after {
    content: "";
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
  }

  .locations-popover-inner {
    max-height: calc(80vh - 3rem);
    padding: 2rem 1.5rem;
  }

  .locations-popover-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 544px) {
  .locations-popover-grid {
    grid-template-columns: 1fr;
  }

  .locations-popover-all {
    padding: 1rem;
    font-size: 1rem;
  }

  .locations-popover-item {
    padding: 0.75rem;
    font-size: 1rem;
  }

  .locations-popover-item__city {
    font-size: 0.95rem;
  }
}
