/* CSS Reset and Variables */
:root {
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --color-primary: #395145;
  /* Updated Brand Green */
  --color-primary-light: #4c6c5c;
  --color-primary-dark: #27372f;
  --color-accent: #d4af37;
  /* Gold accent */
  --color-bg-dark: #121212;
  --color-bg-light: #f5f6f5;
  --color-text-light: #ffffff;
  --color-text-dark: #1a1a1a;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg-dark);
  color: var(--color-text-dark);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* App Container Layout */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* --- LEFT HAND SIDE: MAP VIEWPORT (LOCKED) --- */
.map-viewport {
  flex: 1;
  height: 100%;
  position: relative;
  overflow: hidden;
  background-color: var(--color-bg-dark);
  cursor: default;
  user-select: none;
}

/* SVG + Image Wrapper - Locked Crop */
.map-scale-wrapper {
  position: absolute;
  /* Exact crop calculated from template matching */
  width: 182%;
  left: -37.8%;
  top: -1%;
  transform-origin: center center;
}

.render-image {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}

.overlay-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Interactive SVG Lot Polygons and Rects */
.lot-overlay {
  pointer-events: auto;
  cursor: pointer;
  stroke: rgba(255, 255, 255, 0.6);
  stroke-width: 4;
  stroke-linejoin: round;
  fill-opacity: 0;
  /* Default view: only borders shown (not filled) */
  transition: fill-opacity var(--transition-normal), stroke var(--transition-normal), stroke-width var(--transition-normal), opacity var(--transition-normal);
  fill-rule: evenodd;
}

/* Specific Lot Coloring matching the mockup exactly */
.lot-overlay.type-c {
  fill: #701f22;
}

/* Maroon for Type C */
.lot-overlay.type-a-5bed,
.lot-overlay.type-a-4bed {
  fill: #246564;
}

/* Teal for Type A */
.lot-overlay.type-b2 {
  fill: #75254a;
}

/* Purple/Magenta for Type B2 */
.lot-overlay.type-b1 {
  fill: #487d55;
}

/* Green for Type B1 */

/* Hover state styling */
.lot-overlay:hover,
.lot-overlay.highlighted {
  fill-opacity: 0.65;
  /* Translucent fill on hover */
  stroke: #ffffff;
  stroke-width: 8;
}

/* Lot label text styling on Map */
.lot-label {
  fill: #ffffff;
  font-family: var(--font-display);
  font-size: 55px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
  letter-spacing: 0.5px;
  filter: drop-shadow(0px 3px 6px rgba(0, 0, 0, 0.6));
  opacity: 0;
  /* Hide text overlays by default in "all" view */
  transition: opacity var(--transition-normal);
}

/* Display text overlay only if filter for that type is applied or lot is hovered */
.lot-overlay:hover+.lot-label,
.lot-overlay.highlighted+.lot-label,
.lot-overlay.active-filter+.lot-label {
  opacity: 1;
}

.lot-sublabel {
  font-size: 45px;
  font-weight: 500;
}

/* Filter dimming classes */
.lot-overlay.dimmed {
  opacity: 0.12;
  fill-opacity: 0;
  pointer-events: none;
}

/* Pulse Animation for filtered/active lots */
@keyframes pulseGlow {
  0% {
    stroke-width: 4;
    stroke: rgba(255, 255, 255, 0.6);
  }

  50% {
    stroke-width: 8;
    stroke: rgba(255, 255, 255, 1);
  }

  100% {
    stroke-width: 4;
    stroke: rgba(255, 255, 255, 0.6);
  }
}

.lot-overlay.active-filter {
  animation: pulseGlow 2s infinite ease-in-out;
  stroke: #ffffff;
  fill-opacity: 0.65;
  /* Translucent fill when filter is applied */
  opacity: 1;
}

/* Navigation Help Tip */
.map-help-tip {
  position: absolute;
  top: 30px;
  left: 30px;
  background: rgba(18, 18, 18, 0.65);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 18px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  z-index: 5;
  pointer-events: none;
}

.map-help-tip svg {
  width: 18px;
  height: 18px;
  fill: var(--color-accent);
}


/* --- RIGHT HAND SIDE: SIDEBAR --- */
.sidebar {
  width: 360px;
  background-color: var(--color-primary);
  color: var(--color-text-light);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 40px 24px;
  height: 100vh;
  overflow: hidden;
  /* No scrollbar needed now! */
  flex-shrink: 0;
  box-shadow: -8px 0 35px rgba(0, 0, 0, 0.4);
  z-index: 10;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

/* Vertical and horizontal centering for filter buttons */
.filter-menu-container {
  margin-top: auto;
  margin-bottom: auto;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.filter-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
  /* Matches mockup button proportions */
}

/* Premium Filter Buttons matching mockup styling */
.filter-btn {
  width: 100%;
  height: 48px;
  background-color: #6e7d73;
  /* Mockup button background */
  color: var(--color-text-light);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-align: left;
  transition: all var(--transition-normal);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.filter-btn:hover {
  background-color: #85968b;
  transform: translateY(-2px);
}

.filter-btn.active {
  background-color: var(--color-accent);
  color: var(--color-bg-dark);
  font-weight: 600;
  box-shadow: 0 6px 15px rgba(212, 175, 55, 0.3);
}

.btn-badge {
  background: rgba(255, 255, 255, 0.2);
  color: var(--color-text-light);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  font-family: var(--font-sans);
}

.filter-btn.active .btn-badge {
  background: var(--color-bg-dark);
  color: var(--color-text-light);
}

/* Sidebar Logo Container (Fixed Overflow) */
.sidebar-logo-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  margin-top: auto;
}

.sidebar-logo {
  max-width: 130px;
  height: auto;
  display: block;
  opacity: 0.95;
  transition: opacity var(--transition-fast);
  filter: brightness(1.05) contrast(1.05);
}

.sidebar-logo:hover {
  opacity: 1;
}


/* --- FLOATING TOOLTIP --- */
.custom-tooltip {
  position: fixed;
  background: rgba(18, 18, 18, 0.85);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 16px 20px;
  color: var(--color-text-light);
  pointer-events: none;
  z-index: 100;
  display: none;
  min-width: 220px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4), 0 3px 10px rgba(0, 0, 0, 0.2);
  transform: translate(-50%, -120%);
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
  opacity: 0;
}

.custom-tooltip.visible {
  display: block;
  opacity: 1;
  transform: translate(-50%, -110%);
}

.tooltip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

.tooltip-lot {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.tooltip-badge {
  font-size: 11px;
  text-transform: uppercase;
  background: var(--color-accent);
  color: var(--color-bg-dark);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.tooltip-action {
  font-size: 11px;
  color: var(--color-accent);
  font-weight: 500;
  display: block;
  letter-spacing: 0.5px;
}


/* --- FULLSCREEN VR 360 MODAL --- */
.vr-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.vr-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.vr-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}

.vr-modal-content {
  position: relative;
  width: 100vw;
  /* Full Screen */
  height: 100vh;
  /* Full Screen */
  background-color: #1a1a1a;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
  border: none;
  display: flex;
  flex-direction: column;
  transform: scale(1);
  z-index: 2;
}

.vr-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 25px;
  background-color: var(--color-bg-dark);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--color-text-light);
  flex-shrink: 0;
}

.vr-modal-title-area {
  display: flex;
  align-items: center;
  gap: 15px;
}

.vr-modal-lot {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.vr-modal-type {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.vr-modal-controls {
  display: flex;
  gap: 12px;
}

.vr-control-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-text-light);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.vr-control-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.vr-control-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

.vr-control-btn.close-btn {
  background: #a93c3c;
  border-color: transparent;
}

.vr-control-btn.close-btn:hover {
  background: #c54848;
}

.vr-iframe-container {
  flex-grow: 1;
  position: relative;
  background: #000;
}

.vr-iframe-container iframe {
  width: 100%;
  height: 100%;
  display: block;
}

/* Spinner Loader inside iframe */
.vr-loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #111;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-size: 14px;
  gap: 15px;
  z-index: 1;
  transition: opacity var(--transition-normal);
  pointer-events: none;
}

.vr-loader.hidden {
  opacity: 0;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(212, 175, 55, 0.1);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}


/* --- RESPONSIVE MEDIA QUERIES --- */
@media (max-width: 1024px), (orientation: portrait) {
  .app-container {
    flex-direction: column;
    height: auto;
    width: 100%;
    overflow: visible;
  }

  .map-viewport {
    height: auto;
    width: 100%;
    aspect-ratio: 6000 / 3375;
    /* Lock aspect ratio to match the map image */
    overflow: hidden;
  }

  .map-scale-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    aspect-ratio: 6000 / 3375;
    left: 0;
    top: 0;
    transform: none;
  }

  .sidebar {
    width: 100%;
    height: auto;
    min-height: auto;
    padding: 25px;
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.3);
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    justify-content: center;
    gap: 20px;
    overflow-y: visible;
  }

  .filter-menu-container {
    margin: 0;
  }

  .filter-menu {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 100%;
    justify-content: center;
  }

  .filter-btn {
    width: auto;
    min-width: 140px;
    height: 40px;
    font-size: 13px;
    padding: 0 16px;
  }

  /* Horizontal swipe view is ONLY activated on mobile screens in portrait mode */
  @media (max-width: 768px) and (orientation: portrait) {
    .map-viewport {
      height: 60vh;
      aspect-ratio: auto;
      overflow-x: auto;
      overflow-y: hidden;
      -webkit-overflow-scrolling: touch;
    }

    .map-scale-wrapper {
      height: 100%;
      width: auto;
      aspect-ratio: 6000 / 3375;
    }
  }
}

@media (max-width: 600px) {
  .filter-btn {
    width: calc(50% - 4px);
  }

  .map-help-tip {
    display: none;
  }
}

/* Dynamically scale the map to fit both width and height bottlenecks on desktop viewports */
@media (min-width: 1025px) and (orientation: landscape) {
  .map-scale-wrapper {
    width: min(182%, calc(182vh * 1.777)) !important;
    left: calc(50% - min(182%, calc(182vh * 1.777)) * 0.488) !important;
    top: -1% !important;
    height: auto !important;
  }
}