/**
 * TwinsRealEstate - Map Component Styles
 * Styles for the property location map and address display
 */

/**
 * Property Detail Page - Map Section Styles
 * 
 * True full-screen map with responsive heights
 * Uses modern CSS with design tokens
 * 
 * Version: 2.0 (Modern CSS)
 * Updated: 2025-01-27
 */

/* ========================================================================
   FULL-SCREEN MAP SECTION (True 100vw width)
   ======================================================================== */

.property-map-section {
  /* Break out of container to achieve true full-screen width */
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  
  /* Much bigger height - 140vh for enhanced visibility */
  height: 140vh;
  min-height: 1000px;
  
  /* Add spacing above and below - CRITICAL for preventing overlap */
  margin-block: var(--section-spacing-sm) var(--section-spacing-lg);
  padding: 0;
  padding-bottom: 0; /* Ensure map-info is not cut */
  background-color: var(--color-background-secondary, #f9fafb);
  /* Allow map-info to be visible - don't clip it */
  overflow: visible;
  border-top: 4px solid var(--property-border);
  border-bottom: none; /* Remove bottom border, let map-info handle it */
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.12);
  /* Ensure map section is not cut off */
  z-index: 1;
  /* Use flexbox to ensure map-info is properly positioned */
  display: flex;
  flex-direction: column;
}

/* ========================================================================
   MAP CONTAINER
   ======================================================================== */

.map-container {
  margin: 0;
  /* Map container takes available space - map-info will be below */
  flex: 1;
  width: 100%;
  height: calc(100% - 100px); /* Reserve space for map-info */
  min-height: 900px;
  border-radius: 0;
  overflow: hidden;
  background-color: var(--color-background-secondary, #f9fafb);
  position: relative;
  transition: var(--transition);
  border: none;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.08);
}

/* Map fullscreen mode */
.map-container.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  margin: 0;
  z-index: 9999;
  border-radius: 0;
  border: none;
  animation: map-fullscreen-in 0.3s ease;
}

@keyframes map-fullscreen-in {
  from {
    opacity: 0.8;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Map controls container */
/* ========================================================================
   MAP CONTROLS
   ======================================================================== */

.map-controls {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.map-type-selector {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  background-color: var(--color-background);
  border-radius: var(--card-radius-sm);
  box-shadow: var(--card-shadow);
  padding: var(--space-xs);
}

.map-control {
  background-color: var(--color-background);
  border: none;
  border-radius: var(--card-radius-sm);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  padding: var(--space-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--property-text-secondary);
  transition: var(--transition-fast);
  width: clamp(32px, 4vw, 36px);
  height: clamp(32px, 4vw, 36px);
  min-width: 32px;
  min-height: 32px;
}

.map-control:hover {
  background-color: var(--color-background-secondary);
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
}

.map-control:focus {
  outline: 2px solid var(--property-accent);
  outline-offset: 2px;
}

.map-control.active {
  background-color: var(--property-accent);
  color: var(--property-primary);
}

.fullscreen-control {
  color: #555;
}

/* ========================================================================
   MAP INFO SECTION
   ======================================================================== */

.map-info {
  /* Map-info is below map-container, outside the overflow:hidden area */
  position: relative;
  width: 100%;
  min-height: 100px;
  height: 100px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: 1.5rem 2.5rem;
  background: var(--color-background);
  border-top: 4px solid var(--property-border);
  border-bottom: 4px solid var(--property-border);
  flex-wrap: wrap;
  gap: 2rem;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
  transition: var(--transition);
  z-index: 10;
  box-sizing: border-box;
  /* Ensure it's fully visible and not cut off */
  flex-shrink: 0;
}

.map-info:hover {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
  /* Don't transform - keep it in place to prevent layout shift */
}

@media (prefers-reduced-motion: no-preference) {
  .map-info:hover {
    transform: translateY(-1px);
  }
}

.map-address {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex: 1;
  min-width: 0;
}

.map-address i {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  color: var(--property-accent);
  flex-shrink: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .map-address i {
    animation: pulse 2s infinite;
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.address-text {
  flex: 1;
}

.property-address {
  margin: 0;
  font-size: var(--font-subheading);
  line-height: var(--font-subheading-line-height);
  color: var(--property-text);
  font-weight: var(--font-weight-semibold, 600);
  font-family: var(--font-family-body, 'Poppins', sans-serif);
}

.address-text {
  min-width: 0;
}

.map-actions {
  display: flex;
  gap: var(--space-md);
  flex-shrink: 0;
  max-width: 100%;
  flex-wrap: wrap;
  box-sizing: border-box;
}

.map-actions .btn {
  padding: var(--space-sm) var(--space-lg);
  font-weight: var(--font-weight-semibold, 600);
  font-size: var(--font-body);
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  border-radius: var(--card-radius-sm);
  white-space: nowrap;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-actions .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.map-actions .btn.btn-primary {
  background-color: var(--accent-color);
  color: white;
  border: none;
}

.map-actions .btn.btn-outline {
  background-color: transparent;
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.map-actions .btn i {
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* Desktop: Show full text, hide compact text */
.map-actions .btn .btn-text-full {
  display: inline;
}

.map-actions .btn .btn-text-compact {
  display: none;
}

/* Fallback states */
.map-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--color-text-secondary);
  padding: 2rem;
  background-color: rgba(245, 245, 245, 0.7);
}

.map-fallback i {
  font-size: 3rem;
  margin-bottom: 1rem;
  color: var(--color-text-secondary);
}

.map-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background-color: rgba(231, 76, 60, 0.1);
  color: var(--error-color);
  font-weight: 500;
  text-align: center;
  padding: 1rem;
  border-radius: var(--radius-md);
}

/* Map info window styling */
.map-info-window {
  padding: 8px;
  min-width: 150px;
}

.map-info-window h3 {
  margin: 0 0 5px 0;
  font-size: 16px;
  color: var(--accent-color);
}

.map-info-window p {
  margin: 5px 0;
  font-size: 14px;
}

/* Loading state */
.map-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 15px 25px;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 50px;
  color: var(--color-text-primary);
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
}

.map-loading i {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========================================================================
   RESPONSIVE ADJUSTMENTS
   ======================================================================== */

/* Tablet */
@media (min-width: 768px) and (max-width: 991px) {
  .property-map-section {
    height: 120vh;
    min-height: 800px;
  }
  
  .map-container {
    height: calc(100% - 100px);
    min-height: 700px;
  }

  .map-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .map-actions .btn {
    width: 100%;
    min-width: 0;
    white-space: normal;
  }
}

/* Mobile */
@media (max-width: 767px) {
  .property-map-section {
    height: 100vh;
    min-height: 700px;
  }
  
  .map-container {
    height: calc(100% - 110px);
    min-height: 600px;
  }
  
  .map-info {
    height: auto;
    min-height: 0;
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 1rem;
    gap: 1rem;
    box-sizing: border-box;
  }
  
  .map-address {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  
  .map-address i {
    font-size: clamp(1rem, 2vw, 1.25rem);
  }
  
  .property-address {
    font-size: var(--font-body);
    word-break: break-word;
    overflow-wrap: break-word;
  }
  
  .map-actions {
    width: 100%;
    flex-wrap: nowrap;
    flex-direction: row;
    align-items: stretch;
    gap: 0.75rem;
    box-sizing: border-box;
    overflow: hidden;
  }
  
  .map-actions .btn {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
  }
  
  /* Show compact text, hide full text on mobile */
  .map-actions .btn .btn-text-full {
    display: none;
  }
  
  .map-actions .btn .btn-text-compact {
    display: inline;
  }
  
  /* Compact "Get Directions" button on mobile */
  .map-actions .btn.btn-primary {
    flex: 1 1 auto;
    min-width: 0;
  }
  
  /* Compact "My Location" button on mobile */
  .map-actions #map-locate-button {
    flex: 0 0 auto;
    min-width: fit-content;
  }
  
  /* On very small screens, show only icons */
  @media (max-width: 360px) {
    .map-actions .btn .btn-text-compact {
      display: none;
    }
    
    .map-actions .btn {
      padding: 0.5rem;
      min-width: 44px;
      justify-content: center;
    }
    
    .map-actions .btn i {
      margin: 0;
    }
  }
  
  .map-controls {
    top: var(--space-xs);
    right: var(--space-xs);
    gap: var(--space-xs);
  }
}

/* Dark mode styles */
html[data-theme="dark"] .property-map-section {
  background-color: var(--color-dark-bg, #1a1a1a);
}

html[data-theme="dark"] .map-container {
  background-color: var(--color-dark-bg-light);
  border-color: var(--color-dark-border);
  box-shadow: none;
}

html[data-theme="dark"] .map-info {
  background-color: var(--color-dark-bg-light, #1f2937);
  border-color: var(--color-dark-border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .map-control {
  background-color: var(--color-dark-bg-light);
  color: var(--color-dark-text-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .map-control:hover {
  background-color: var(--color-dark-bg-lighter);
}

html[data-theme="dark"] .map-control.active {
  background-color: var(--accent-color);
  color: white;
}

html[data-theme="dark"] .map-address i {
  color: var(--accent-color);
}

html[data-theme="dark"] .property-address {
  color: var(--color-dark-text-primary);
}

html[data-theme="dark"] .map-actions .btn.btn-outline {
  border-color: var(--color-dark-border);
  color: var(--color-dark-text-primary);
}

html[data-theme="dark"] .map-fallback {
  color: var(--color-dark-text-secondary);
  background-color: rgba(30, 30, 30, 0.7);
}

html[data-theme="dark"] .map-fallback i {
  color: var(--color-dark-text-secondary);
}

html[data-theme="dark"] .map-error {
  background-color: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
}

html[data-theme="dark"] .map-loading {
  background-color: var(--color-dark-bg-light);
  color: var(--color-dark-text-primary);
}

html[data-theme="dark"] .map-info-window {
  background-color: var(--color-dark-bg-light);
  color: var(--color-dark-text-primary);
  border-color: var(--color-dark-border);
}

html[data-theme="dark"] .map-info-window h3 {
  color: var(--accent-color);
}

/* Map type control styling for Google Maps */
.gm-style {
  font-family: var(--font-family);
}

.gm-style-iw {
  border-radius: 8px !important;
  padding: 12px !important;
}

html[data-theme="dark"] .gm-style-iw {
  background-color: var(--color-dark-bg-light) !important;
  color: var(--color-dark-text-primary) !important;
}

html[data-theme="dark"] .gm-style-iw * {
  color: var(--color-dark-text-primary) !important;
}

/* Advanced Markers (new Google Maps markers) */
/* Property marker */
.custom-property-marker {
  cursor: pointer;
}

.map-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50% 50% 50% 0;
  background-color: var(--accent-color, #FF5A5F);
  transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  position: relative;
  animation: drop 0.5s ease;
}

.map-pin i {
  transform: rotate(45deg);
  color: white;
  font-size: 14px;
}

/* User marker */
.custom-user-marker {
  cursor: pointer;
}

.map-user-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #4285F4;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  animation: pulse-user 2s infinite;
}

.map-user-pin i {
  color: white;
  font-size: 16px;
}

/* Place markers */
.custom-place-marker {
  cursor: pointer;
}

.map-place-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background-color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  position: relative;
  transition: transform 0.2s ease;
}

.map-place-pin:hover,
.map-place-pin:focus {
  transform: scale(1.1);
  z-index: 10;
}

.map-place-pin i {
  color: var(--accent-color, #FF5A5F);
  font-size: 14px;
}

.map-place-pin.featured {
  background-color: var(--accent-color, #FF5A5F);
}

.map-place-pin.featured i {
  color: white;
}

/* Marker animations */
@keyframes drop {
  0% {
    transform: translateY(-50px) rotate(-45deg);
    opacity: 0;
  }
  100% {
    transform: translateY(0) rotate(-45deg);
    opacity: 1;
  }
}

@keyframes pulse-user {
  0% {
    box-shadow: 0 0 0 0 rgba(66, 133, 244, 0.6);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(66, 133, 244, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(66, 133, 244, 0);
  }
}

/* Dark theme adjustments for markers */
html[data-theme="dark"] .map-pin {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .map-user-pin {
  border-color: #333;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .map-place-pin {
  background-color: #333;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .map-place-pin i {
  color: #FF5A5F;
}
