/* ============================================================================
   SHARED POI POPUP STYLES
   ============================================================================ */

:root {
  --popup-lower-padding-multiplier: 0; /* Controls how much taller the lower section is than content */
  --shared-poi-popup-top: calc(var(--header-height, 68px) + 1.25em);
  --shared-poi-popup-width: 500px;
  --shared-poi-popup-height: 500px;
  --shared-poi-popup-viewport-padding: 20px;
}

/* ============================================================================
   SHARED POI DETAIL POPUP (Bottom third of screen)
   ============================================================================ */

.shared-poi-popup {
  font-size: var(--text-md);
  position: fixed;
  top: var(--shared-poi-popup-top-position, var(--shared-poi-popup-top));
  left: var(--shared-poi-popup-left, 50%);
  max-width: var(--shared-poi-popup-width);
  height: var(--shared-poi-popup-height);
  max-height: calc(100vh - (var(--header-height, 68px) + 2.5em));
  border: none; 
  border-radius: 1em;
  z-index: var(--z-popup);
  padding: 0;
  box-shadow:
    0 20px 40px rgb(15 23 42 / 25%),
    0 8px 16px rgb(15 23 42 / 15%);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
  transform: var(--shared-poi-popup-transform, translateX(-50%));
  box-sizing: border-box;
  overflow: hidden;
}

.shared-poi-popup.hidden {
  opacity: 0;
  pointer-events: none;
  transform: var(
    --shared-poi-popup-hidden-transform,
    translateX(-50%) translateY(-1.25em)
  );
}

.popup-close-btn {
  position: absolute;
  top: 0.75em;
  right: 0.75em;
  width: 1.875em;
  height: 1.875em;
  background: rgb(0 0 0 / 20%);
  backdrop-filter: blur(8px);
  border: none;
  border-radius: 50%;
  color: var(--color-header-text);
  font-size: var(--text-lg);
  cursor: pointer;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;  
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 20;
  box-shadow: 0 2px 8px rgb(0 0 0 / 15%);
}

.popup-close-btn:hover {
  background: rgb(255 255 255 / 20%);
  transform: scale(1.1);
}

.poi-popup-content {
  display: flex;
  height: 100%;
  width: 100%;
  min-height: 0;
  box-sizing: border-box;
  overflow: hidden;
  border-radius: 1em;
}

.poi-popup-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  align-items: stretch;
  overflow: hidden;
}

.poi-popup-upper {
  flex: 0 0 50%;
  width: 100%;
  position: relative;
  overflow: hidden;
  background: var(--color-surface);
  border-radius: 1em 1em 0 0;
  display: flex;
  flex-direction: column;
}

.poi-popup-header-overlay {
  position: absolute;
  top: 1em;
  left: 50%;
  transform: translateX(-50%);
  /*width: calc(100% - 2em);*/
  max-width: 90%;
  background: rgb(0 0 0 / 20%);
  backdrop-filter: blur(8px);
  border-radius: 0.4em;
  padding: .1em .2em;
  box-shadow: 0 4px 16px rgb(0 0 0 / 30%);
  z-index: 10;
  box-sizing: border-box;
}

.poi-popup-header-overlay h3 {
  font-family: var(--font-family-base);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-lg);
  color: var(--color-header-text);
  letter-spacing: var(--letter-spacing-tight);
  text-transform: uppercase;
  line-height: var(--line-height-tight); /* prevent body inheritance */
}

.poi-popup-header-overlay p {
  font-family: var(--font-family-base);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-md);
  color: var(--color-header-text);
  letter-spacing: var(--letter-spacing-tight);
  text-transform: uppercase;
  line-height: var(--line-height-tight); /* prevent body inheritance */
}

/* ============================================================================
   SHARED POI POPUP MIDDLE SECTION
   
   --popup-body-ratio and --popup-attrs-ratio control the width split.
   Adjust only these two variables to change proportions.
   Default: 60% body / 40% attributes
   ============================================================================ */

.poi-popup-middle {
  /* Layout proportion controls — edit these to change the body/attributes split */
  --popup-body-ratio: 3;       /* body gets 3 parts  (60%) */
  --popup-attrs-ratio: 2;      /* attrs gets 2 parts (40%) */

  flex: 1;
  width: 100%;
  overflow: hidden;
  color: var(--color-ink);
  backdrop-filter: blur(12px);
  background: var(--color-overlay);
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  gap: 0.1em;
  padding: 0.75em 0.75em 0 0.75em;
  min-height: 0;
}

.poi-popup-body {
  flex: var(--popup-body-ratio, 3) 1 0%;
  display: flex;
  flex-direction: column;
  gap: 1em;
  min-width: 0;
  overflow: hidden;
}

.poi-popup-attributes-container {
  flex: var(--popup-attrs-ratio, 2) 1 0%;
  overflow: hidden auto;
  padding-right: 0.5em;
  scrollbar-width: thin;
  scrollbar-color: rgb(0 0 0 / 30%) rgb(0 0 0 / 8%);
  min-width: 0;
}

.poi-popup-images,
.poi-popup-no-image {
  width: 100%;
  height: 100%;
  cursor: pointer;
  display: flex;
  flex: 1;
  align-items: stretch;
  justify-content: stretch;
  min-height: 0;
}

.poi-popup-images picture {
  width: 100%;
  height: 100%;
  display: block;
  flex: 1;
}

.poi-popup-images img {
  width: 100%;
  height: 100%;
  min-height: 100%;
  object-fit: cover;
  border-radius: 16px 16px 0 0;
  display: block;
  object-position: center;
}

/* Error handling for broken images */
.poi-popup-images img::before {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: var(--color-background-hover);
}

.poi-popup-images img::after {
  content: "Could not load image";
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--color-muted);
  font-size: var(--text-base);
  font-style: italic;
}

.poi-popup-no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-background-hover);
  border-right: 1px solid var(--color-border);
  color: var(--color-muted);
  font-style: italic;
  border-radius: 16px 16px 0 0;
}

.poi-popup-image-nav {
  position: absolute;
  bottom: 0.625em;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25em;
  background: rgb(0 0 0 / 20%);
  backdrop-filter: blur(8px);
  padding: 0.3em;
  border-radius: 20px;
  z-index: 5; /* Ensure nav buttons are above image */
}

.image-nav-btn {
  width: 1.5em;
  height: 1.5em;
  background: rgb(255 255 255 / 10%);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  font-family: var(--font-family-base);
  font-size: var(--text-lg);
  font-weight: var(--font-weight-medium);
  color: var(--color-header-text);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-nav-btn:hover {
  background: rgb(255 255 255 / 20%);
  transform: scale(1.1);
}

#imageCounter {
  font-size: var(--text-base);
  color: rgb(255 255 255 / 70%);
}


/* Attribute list styling so items stay inside the popup and wrap nicely */
.poi-attributes {
  display: flex;
  flex-direction: column;
  gap: 0.25em;  
  margin-bottom: 0.5em;
}

.poi-attributes .attribute-item {
  display: flex;
  gap: 0.75em;
  align-items: center;
}

.poi-attributes .attr-icon {
  flex-shrink: 0;
  width: 2.125em;
  height: 2.125em;
  border-radius: 0.75em;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgb(41 94 155 / 18%);
}

.poi-attributes .attr-icon svg {
  display: block;
  color: var(--color-primary);
}

.poi-attributes .attr-text {
  display: flex;
  flex-direction: column;
  gap: 0.125em;
}

.poi-attributes .attr-label {
  color: var(--color-header-text);
  font-size: var(--text-sm);
  text-transform: uppercase;
  font-weight: var(--font-weight-medium);
}

.poi-attributes .attr-value {
  color: var(--color-header-text);
  font-weight: var(--font-weight-medium);
  font-size: var(--text-sm);
}


.poi-info {
  color: var(--color-header-text);
  line-height: 1.1;
  font-size: var(--text-sm);
  flex: 1;
  /*text-align: justify;*/
  word-spacing: -0.05em;
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow: hidden auto;
  margin-right: 0.35em;  /* reduced from 1em, but keeps scrollbar breathing room */
  padding-right: 0.75em;  /* increased from 0.5em for scrollbar spacing */  scrollbar-width: thin;
  scrollbar-color: rgb(0 0 0 / 30%) rgb(0 0 0 / 8%);
}

/* ============================================================================
   RICH-TEXT PROSE STYLES
   Covers all tags allowed by content_sanitizer.py: p, br, strong, em,
   ul, ol, li, blockquote, h2, h3, h4, a.
   Applied to .poi-description (full-details modal) and .poi-info (quick popup).
   ============================================================================ */

/* Wrapper used in the full-details modal alongside the "Description" h3 label */
.poi-info-full {
  margin-bottom: 1em;
}

/* Rich-text prose styles for CKEditor content in POI popups and full-details panel */
.poi-description {
  color: var(--color-ink);
  font-size: var(--text-sm, 0.875rem);
  line-height: 1.5;
}

.poi-description p {
  margin: 0 0 0.6em;
}

.poi-info p {
  margin: 0 0 0.5em;
}

.poi-description p:last-child,
.poi-info p:last-child {
  margin-bottom: 0;
}

.poi-description ul,
.poi-description ol {
  margin: 0.25em 0 0.6em 1.4em;
  padding: 0;
}

.poi-description ul {
  list-style: disc;
}

.poi-description ol {
  list-style: decimal;
}

.poi-description li {
  margin-bottom: 0.25em;
}

.poi-description .ck-indent-1,
.poi-info .ck-indent-1 { margin-left: 2.5rem; margin-inline-start: 2.5rem; }

.poi-description .ck-indent-2,
.poi-info .ck-indent-2 { margin-left: 5rem; margin-inline-start: 5rem; }

.poi-description .ck-indent-3,
.poi-info .ck-indent-3 { margin-left: 7.5rem; margin-inline-start: 7.5rem; }

.poi-description .ck-indent-4,
.poi-info .ck-indent-4 { margin-left: 10rem; margin-inline-start: 10rem; }

.poi-description .ck-indent-5,
.poi-info .ck-indent-5 { margin-left: 12.5rem; margin-inline-start: 12.5rem; }

.poi-description .ck-indent-6,
.poi-info .ck-indent-6 { margin-left: 15rem; margin-inline-start: 15rem; }

.poi-description .ck-indent-7,
.poi-info .ck-indent-7 { margin-left: 17.5rem; margin-inline-start: 17.5rem; }

.poi-description .ck-indent-8,
.poi-info .ck-indent-8 { margin-left: 20rem; margin-inline-start: 20rem; }

.poi-description h2,
.poi-description h3,
.poi-description h4 {
  font-weight: 600;
  margin: 0.75em 0 0.25em;
}

.poi-description strong {
  font-weight: 600;
}

.poi-description em {
  font-style: italic;
}

.poi-description blockquote {
  border-left: 3px solid var(--color-border, rgb(0 0 0 / 20%));
  color: var(--color-muted, inherit);
  margin: 0.5em 0 0.5em 0.75em;
  padding-left: 0.75em;
}

.poi-info ul,
.poi-info ol {
  margin: 0.25em 0 0.5em 1.25em;
  padding: 0;
}

.poi-info ul {
  list-style: disc;
}

.poi-info ol {
  list-style: decimal;
}

.poi-info li {
  margin-bottom: 0.2em;
}

.poi-info h2,
.poi-info h3,
.poi-info h4 {
  font-weight: 600;
  margin: 0.6em 0 0.2em;
  line-height: 1.25;
}

.poi-info strong {
  font-weight: 600;
}

.poi-info em {
  font-style: italic;
}

.poi-info blockquote {
  border-left: 3px solid rgb(0 0 0 / 20%);
  margin: 0.5em 0 0.5em 0.75em;
  padding-left: 0.75em;
}

/* ============================================================================
   POI POPUP LOWER SECTION (Action Buttons Area)

   This section contains action buttons for POI popups. It supports 4 scenarios:

   1. Booking mode, non-admin: Single "Book" button
   2. Booking mode, admin: "Book" button + admin management buttons
   3. Explore mode, non-admin: Single "Full Details" button
   4. Explore mode, admin: "Full Details" button + admin management buttons
   ============================================================================ */

.poi-popup-lower {
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  flex-flow: row wrap;
  gap: 0.75em;
  padding: calc(0.65em * var(--popup-lower-padding-multiplier)) 1.25em;
  backdrop-filter: blur(8px);
  background: var(--color-overlay);
  border-top: 1px solid var(--color-border);
  border-radius: 0 0 1em 1em;
  box-sizing: border-box;
  justify-content: center;
  align-items: center;
  min-height: fit-content;
}

/* ----------------------------------------------------------------------------
   PRIMARY ACTION BUTTON

   Used for main user actions like "Book" (booking mode) or "Full Details"
   (explore mode). Features transparent background with underline on hover.
   ---------------------------------------------------------------------------- */

.poi-action-btn {
  flex: 1;
  min-width: 200px;
  padding: 0.3em;
  background: transparent;
  border: none;
  color: var(--color-header-text);
  font-family: var(--font-family-base);
  font-size: var(--text-md);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  position: relative;
}

.poi-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Underline effect on hover */
.poi-action-btn:not(:disabled):hover {
  text-decoration: underline;
  color: var(--color-text-tertiary);
}

.poi-action-btn:not(:disabled):active {
  transform: scale(0.98);
}

/* ----------------------------------------------------------------------------
   ADMIN MANAGEMENT BUTTONS

   Minimal styling for admin-only actions like "Edit Location" and "Edit Details".
   These buttons are unformatted and compact to not distract from primary actions.
   ---------------------------------------------------------------------------- */

.poi-admin-btn {
  padding: 0.5em 0.875em;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-muted);
  font-family: var(--font-family-base);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.poi-admin-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.poi-admin-btn:not(:disabled):hover {
  background: var(--color-background-hover);
  border-color: var(--color-primary);
  color: var(--color-ink);
}

.poi-admin-btn:not(:disabled):active {
  transform: scale(0.95);
}


/* ============================================================================
   SHARED FULL DETAILS WINDOW
   ============================================================================ */

.shared-full-details {
  position: fixed;
  inset: calc(68px + 20px) 20px 20px; /* 68px header + 20px margin */
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
  border-radius: 12px;
  z-index: var(--z-popup);
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgb(0 0 0 / 50%);
  transition: opacity 0.3s ease;
}

.shared-full-details.hidden {
  opacity: 0;
  pointer-events: none;
}

.full-details-header {
  flex-shrink: 0;
  padding: 1.25em;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.full-details-header h2 {
  margin: 0;
  color: var(--color-ink);
  font-size: var(--text-xl);
}

.full-details-content {
  flex: 1;
  display: flex;
  min-height: 0; /* Important for flex children with overflow */
}

.full-details-layout {
  display: flex;
  width: 100%;
  height: 100%;
}

.full-details-left {
  flex: 0 0 40%;
  height: 100%;
  overflow-y: auto; /* Scroll if many images */
  border-right: 1px solid var(--color-border);
  padding: 1em; /* Padding for the gallery */
  display: flex;
  flex-direction: column;
  gap: 1em; /* Spacing between image items */
  align-items: center; /* Center images if they don't fill width */
}

.full-details-right {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 1.25em;
  overflow-y: auto; /* Scroll if content overflows */
  color: var(--color-ink); /* Ensure text is visible */
}

.full-details-images {
  display: flex;
  flex-direction: column;
  gap: 1em;
  width: 100%; /* Ensure the container takes full width */
}

.full-details-image-item {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden; /* Ensure image doesn't break border-radius */
  cursor: zoom-in; /* Indicate clickable for lightbox */
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.full-details-image-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgb(0 0 0 / 40%);
}

.full-details-image-item picture,
.full-details-image-item img {
  width: 100%;
  height: auto; /* Allow image to scale proportionally */
  display: block; /* Remove extra space below image */
}

.image-caption {
  padding: 0.5em 0.75em;
  background-color: rgb(0 0 0 / 30%);
  color: rgb(255 255 255 / 80%);
  font-size: var(--text-sm);
  text-align: center;
}

/* ============================================================================
   LIGHTBOX OVERLAY
   ============================================================================ */

.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;   /* fallback */
  height: 100dvh;  /* dynamic: correct even as browser chrome toggles */
  background: rgb(0 0 0 / 90%);
  z-index: var(--z-lightbox);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.lightbox-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.lightbox-close-btn {
  position: fixed;
  top: 1.25em;
  right: 1.25em;
  width: clamp(1.25em, 3vw, 2em);
  height: clamp(1.25em, 3vw, 2em);
  background: rgb(255 255 255 / 95%);
  border: none;
  border-radius: 50%;
  font-size: var(--text-xl);
  font-weight: 300;
  color: var(--color-ink, #0f172a);
  cursor: pointer;
  z-index: calc(var(--z-lightbox) + 1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgb(0 0 0 / 30%);
  transition:
    background-color 0.2s ease,
    transform 0.2s ease;
}

.lightbox-close-btn:hover {
  background: var(--color-surface);
  transform: scale(1.1);
}

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  position: relative;
  cursor: grab;
}

.lightbox-content.dragging {
  cursor: grabbing;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 90vh;
  display: block;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgb(0 0 0 / 50%);
  transition: transform 0.1s ease;
  transform-origin: center;
}

/* Lightbox Navigation Container - Reuses POI popup style */
.lightbox-nav-container {
  position: fixed;
  bottom: 2em;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625em;
  background: rgb(0 0 0 / 20%);
  backdrop-filter: blur(8px);
  padding: 0.3em 0.625em;
  border-radius: 20px;
  z-index: calc(var(--z-lightbox) + 1);
}

/* Lightbox Navigation Buttons - Reuses POI popup image-nav-btn style */
.lightbox-nav-btn {
  width: 1.5em;
  height: 1.5em;
  background: rgb(255 255 255 / 10%);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  font-family: var(--font-family-base);
  font-size: var(--text-lg);
  font-weight: var(--font-weight-medium);
  color: var(--color-header-text);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.lightbox-nav-btn:hover {
  background: rgb(255 255 255 / 20%);
  transform: scale(1.1);
}

.lightbox-nav-btn:active {
  transform: scale(0.95);
}

/* Lightbox Image Counter - Matches POI popup counter */
.lightbox-counter {
  font-size: var(--text-base);
  color: rgb(255 255 255 / 70%);
  z-index: calc(var(--z-lightbox) + 1);
}

/* ============================================================================
   RESPONSIVE: MOBILE LAYOUT
   ============================================================================ */

@media (max-width: 480px) {
  .shared-poi-popup {
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
    max-width: none;
    transform: none;
    border-radius: 1em;
    bottom: 0.5rem;
    top: auto;
    height: calc(100dvh - var(--header-height, 68px) - 1rem);
    max-height: calc(100dvh - var(--header-height, 68px) - 1rem);
  }

  .shared-poi-popup.hidden {
    transform: translateY(1.25em);
  }

  .poi-popup-layout {
    min-height: 0;
  }

  .poi-popup-upper {
    flex: 0 0 50%;
    min-height: 0;
  }

  .poi-popup-middle {
    /* Stack body above attributes on narrow screens */
    flex: 1 1 50%;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .poi-popup-body,
  .poi-popup-attributes-container {
    /* Reset ratio-based sizing — full width in stacked layout */
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    overflow: visible;
  }

  .poi-popup-attributes-container {
    /* Restore scroll containment after stacking */
    overflow: hidden auto;
    max-height: 12em;
  }

  .poi-action-btn {
    min-width: 0;
    width: 100%;
  }

  .full-details-left {
    flex: 0 0 100%;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
}
