/* Location List Wrapper */
.rd-location-list-wrapper {
  margin: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.rd-location-list-wrapper.rd-location-list-standalone {
  margin-top: 0;
}

/* Header */
.rd-location-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.rd-location-list-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #111827;
}

/* Toggle Button */
.rd-location-list-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #374151;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.rd-location-list-toggle:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
  color: #3b82f6;
}

.rd-location-list-toggle:active {
  transform: scale(0.98);
}

.rd-location-list-toggle .rd-toggle-icon {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rd-location-list-collapsed .rd-location-list-toggle .rd-toggle-icon {
  transform: rotate(-90deg);
}

/* Location List Container */
.rd-location-list {
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease,
    transform 0.3s ease;
  opacity: 1;
  transform: scaleY(1);
  transform-origin: top;
}

.rd-location-list-collapsed .rd-location-list {
  max-height: 0;
  opacity: 0;
  transform: scaleY(0.95);
}

/* Location Item - Unified structure for desktop & mobile */
.rd-location-item {
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.rd-location-item:nth-child(even) {
  background-color: #f9fafb;
}

.rd-location-item:last-child {
  border-bottom: none;
}

/* Line 1: Flexbox container - DESKTOP: img|title|desc|buttons, MOBILE: wraps */
.rd-location-item-line-1 {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

/* Image */
.rd-location-item-image {
  width: 80px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  order: 1;
}

.rd-location-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rd-location-item-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
}

.rd-location-item-image-placeholder svg {
  width: 80px;
  height: 80px;
}

/* Title */
.rd-location-item-title-wrapper {
  flex: 0 0 200px;
  min-width: 0;
  order: 2;
}

.rd-location-item-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.4;
  word-wrap: break-word;
}

/* Description - DESKTOP: in line-1, MOBILE: wraps below */
.rd-location-item-description {
  flex: 1 1 200px;
  min-width: 0;
  max-width: 350px;
  color: #6b7280;
  font-size: 0.875rem;
  line-height: 1.5;
  margin: 0;
  order: 3;
}

.rd-location-item-description p {
  margin: 0;
}

.rd-location-item-description p:last-child {
  margin-bottom: 0;
}

/* Actions (buttons) */
.rd-location-item-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
  order: 4;
}

/* Show on Map button - hidden by default, shown when map loads */
.rd-location-jump-to-map-icon {
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.rd-location-jump-to-map-icon.visible {
  display: flex;
}

.rd-location-jump-to-map-icon svg {
  width: 18px;
  height: 18px;
}

/* Links toggle button - always visible if there are links */
.rd-location-links-toggle-btn {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.rd-location-links-toggle-btn:hover {
  background: #e5e7eb;
}

/* Line 2: Links section (collapsible) - base padding only, display controlled below */
.rd-location-item-line-2 {
  padding: 0 0.5rem 0.5rem;
}

.rd-location-links-toggle-btn svg {
  width: 16px;
  height: 16px;
  transition: transform 0.3s ease;
}

.rd-location-links-toggle-btn.rd-location-links-toggle-open svg {
  transform: rotate(180deg);
}

/* Disabled state for toggle button (no links available) */
.rd-location-links-toggle-btn.rd-location-links-toggle-disabled {
  opacity: 0.3;
  cursor: not-allowed;
  /* pointer-events kept to allow tooltip to show */
}

.rd-location-links-toggle-btn.rd-location-links-toggle-disabled:hover {
  background: #f3f4f6;
}

/* Links toggle button */
.rd-location-links-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
}

.rd-location-links-toggle:hover {
  background: #e5e7eb;
}

/* Simple Links Popup */
.rd-simple-links-popup {
  position: fixed;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  max-height: 80vh;
  max-width: 90vw;
  width: 300px;
  overflow: hidden;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  animation: rdFadeIn 0.2s ease-out;
}

@keyframes rdFadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.rd-simple-popup-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #6b7280;
  padding: 4px;
  border-radius: 4px;
  z-index: 2;
}

.rd-simple-popup-close:hover {
  background: #f3f4f6;
  color: #1f2937;
}

.rd-simple-popup-content {
  padding: 16px;
  overflow-y: auto;
  max-height: calc(80vh - 32px);
}

.rd-simple-link-group {
  margin-bottom: 12px;
}

.rd-simple-link-group:last-child {
  margin-bottom: 0;
}

.rd-simple-link-group-title {
  font-weight: 600;
  font-size: 14px;
  color: #374151;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rd-simple-link-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rd-simple-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: #1f2937;
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  transition: background-color 0.15s ease;
}

.rd-simple-link:hover {
  background-color: #f3f4f6;
  text-decoration: none;
}

.rd-simple-link[target="_blank"]::after {
  content: "↗";
  margin-left: 4px;
  font-size: 12px;
  opacity: 0.7;
}

.rd-location-links-toggle-icon {
  transition: transform 0.3s ease;
}

.rd-location-links-toggle-open .rd-location-links-toggle-icon {
  transform: rotate(180deg);
}

/* Line 2: Links (3 equal sections: Anchors | Internal | External) */
.rd-location-item-line-2 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  align-items: flex-start;
  max-height: 500px;
  overflow: hidden;
  opacity: 1;
  margin-top: 0.5rem;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.rd-location-item-line-2.rd-location-links-collapsed {
  max-height: 0;
  opacity: 0;
}

.rd-location-links-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
  min-width: 0;
}

.rd-location-links-anchors,
.rd-location-links-internal,
.rd-location-links-external {
  display: contents;
}

/* Dropdown for many links */
.rd-location-links-dropdown {
  position: relative;
  width: 100%;
}

.rd-location-links-dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  color: #374151;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.rd-location-links-dropdown-toggle:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.rd-dropdown-arrow {
  transition: transform 0.2s ease;
}

.rd-location-links-dropdown.open .rd-dropdown-arrow {
  transform: rotate(180deg);
}

.rd-location-links-dropdown-content {
  display: none;
  flex-direction: column;
  gap: 0.375rem;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 300px;
  overflow-y: auto;
}

.rd-location-links-dropdown.open .rd-location-links-dropdown-content {
  display: flex;
}

.rd-location-links-dropdown-content .rd-location-action {
  width: 100%;
  white-space: normal;
  word-break: break-word;
}

/* Section headings */
.rd-location-links-heading {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.rd-location-action {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  color: #374151;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  max-width: 100%;
}

.rd-location-action:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #111827;
  text-decoration: none;
}

.rd-location-action:active {
  transform: scale(0.98);
}

.rd-location-action svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

.rd-location-action .rd-link-icon {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}

.rd-location-action span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* All link buttons use neutral theme colors */
.rd-location-anchor-link,
.rd-location-internal-link,
.rd-location-external-link {
  display: inline-flex;
}

/* Primary content associations get a distinct color */
.rd-location-internal-link-primary {
  background-color: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.rd-location-internal-link-primary:hover {
  background-color: #bfdbfe;
  border-color: #60a5fa;
}

/* Empty State */
.rd-location-list-empty {
  padding: 2rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.9375rem;
}

/* Responsive */
@media (max-width: 768px) {
  .rd-location-list-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .rd-location-list-toggle {
    align-self: stretch;
    justify-content: center;
  }

  .rd-location-item {
    padding: 1rem;
  }

  .rd-location-item-line-1 {
    flex-direction: row;
    gap: 0.75rem;
  }

  .rd-location-item-title-wrapper {
    min-width: 100%;
    max-width: 100%;
  }

  .rd-location-item-map-button {
    align-self: flex-end;
  }

  .rd-location-item-line-2 {
    flex-direction: column;
    gap: 0.75rem;
  }

  .rd-location-links-section {
    width: 100%;
  }

  .rd-location-action {
    width: 100%;
    justify-content: center;
  }
}

/* Print styles */
/* Responsive: Mobile Layout */
@media (max-width: 768px) {
  .rd-location-item-image {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
  }

  .rd-location-item-image-placeholder svg {
    width: 60px;
    height: 60px;
  }

  /* Title takes remaining space on first line */
  .rd-location-item-title-wrapper {
    flex: 1 1 0;
    min-width: 0;
  }

  /* Force description to wrap to new line on mobile */
  .rd-location-item-description {
    flex: 1 1 100%;
    order: 5;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
  }

  /* Buttons stay on first line with image + title */
  .rd-location-item-actions {
    order: 4;
    flex-shrink: 0;
  }

  /* Stack link sections vertically on mobile */
  .rd-location-item-line-2 {
    flex-direction: column;
    gap: 1rem;
  }

  .rd-location-links-section {
    flex: 1 1 100%;
    min-width: 100%;
  }
}

@media print {
  .rd-location-list-toggle {
    display: none;
  }

  .rd-location-list-collapsed .rd-location-list {
    max-height: none;
    opacity: 1;
    transform: none;
  }

  .rd-location-action {
    display: none;
  }
}

/* ========================================
   Location Image Lightbox & Hover Preview
   ======================================== */

/* Hidden gallery links (for additional images) */
.rd-location-gallery-hidden {
  display: none !important;
}

/* Make thumbnail clickable */
.rd-location-item-image a {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.rd-location-item-image a img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease, filter 0.2s ease;
}

/* Hover effect on thumbnail */
.rd-location-item-image:hover a img {
  transform: scale(1.05);
  filter: brightness(1.1);
}

/* Hover preview - larger image tooltip */
.rd-location-item-image {
  position: relative;
}

.rd-location-item-image::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  width: 200px;
  height: 150px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  margin-bottom: 8px;
}

.rd-location-item-image:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* Set the preview image via CSS variable (set by JS) */
.rd-location-item-image[data-preview-url]::after {
  background-image: var(--preview-url);
}

/* Skeleton Loading Styles */
.rd-location-list-lazy .rd-location-item-skeleton {
  min-height: 80px;
}

.rd-location-skeleton-content {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.rd-location-image-skeleton {
  width: 80px;
  height: 60px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: rd-skeleton-shimmer 1.5s infinite;
  flex-shrink: 0;
}

.rd-location-text-skeleton {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rd-skeleton-title {
  height: 1.25rem;
  width: 60%;
  border-radius: 4px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: rd-skeleton-shimmer 1.5s infinite;
}

.rd-skeleton-description {
  height: 0.875rem;
  width: 90%;
  border-radius: 4px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: rd-skeleton-shimmer 1.5s infinite;
}

.rd-skeleton-description.rd-skeleton-short {
  width: 50%;
}

@keyframes rd-skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Hide skeleton content when enriched */
.rd-location-item-skeleton.rd-location-item-enriched
  .rd-location-skeleton-content {
  display: none;
}

/* ==========================================================================
   Favorite Button Styles (List Context)
   ========================================================================== */

/* List-specific favorite button - matches map/links button style (36x36px) */
.rd-fav-location-btn--list {
  width: 36px;
  height: 36px;
  padding: 0;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  color: #e74c3c;
  transition: all 0.15s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rd-fav-location-btn--list:hover {
  background: #e5e7eb;
}

.rd-fav-location-btn--list .rd-fav-icon {
  width: 18px;
  height: 18px;
}

/* Pink active state for list buttons */
.rd-fav-location-btn--list.rd-fav-location-btn--active {
  background: #e74c3c;
  border-color: #e74c3c;
  color: white;
}

.rd-fav-location-btn--list.rd-fav-location-btn--active:hover {
  background: #c0392b;
  border-color: #c0392b;
}

.rd-fav-location-btn--list.rd-fav-location-btn--active .rd-fav-icon {
  color: white;
  stroke: white;
  fill: white;
}
