/*
 * TripGoGo Map Styles
 * App-specific styles for Google Maps integration in trip views
 */

/* ===== Map Component Container ===== */
.map-component-container {
  position: relative;
  width: 100%;
}

.map {
  width: 100%;
  height: calc(100vh - 200px); /* Dynamic height based on viewport */
  max-height: 600px; /* Cap at 600px */
  min-height: 400px; /* Minimum for usability */
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.map-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 12px;
  background: #f5f5f5;
  border-radius: 6px;
  font-size: 0.9rem;
  color: #666;
}

.map-stats i {
  color: var(--primary-color, #1a73e8);
}

.map-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 500px;
  background: #f9f9f9;
  border-radius: 8px;
  border: 2px dashed #ddd;
  color: #999;
  text-align: center;
  padding: 2rem;
}

.map-empty-state i {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.map-empty-state p {
  font-size: 1.1rem;
  margin: 0 0 0.5rem 0;
  color: #666;
}

.map-empty-state small {
  font-size: 0.9rem;
  color: #999;
}

/* Legacy support for #map ID */
#map {
  width: 100%;
  height: 500px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Ensure map takes full height on detail page */
.trip-detail-container #map {
  height: 600px;
}

/* ===== Mobile Toggle Buttons ===== */
.trip-view-toggle {
  display: none; /* Hidden on desktop */
  gap: 8px;
  margin-bottom: 1rem;
  background: #f5f5f5;
  padding: 4px;
  border-radius: 8px;
}

.toggle-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: #666;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.toggle-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.toggle-btn.active {
  background: #fff;
  color: var(--primary-color, #1a73e8);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.toggle-btn i {
  font-size: 1rem;
}

/* ===== Map and Itinerary Layout ===== */
.map-itinerary-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 2rem;
  align-items: start; /* Enable sticky positioning */
  width: 100%;
}

.map-section,
.itinerary-section {
  min-width: 0; /* Prevent grid blowout */
}

/* Make map sticky on desktop */
.map-section {
  position: sticky;
  top: 1px; /* Account for fixed navbar */
  max-height: calc(100vh - 100px);
  overflow: hidden;
}

.map-section h2,
.itinerary-section h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 1rem 0 1rem 0;
  color: #333;
}

/* ===== Custom Map Markers ===== */
.marker-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Allow clicks to pass through empty space to markers behind */
  pointer-events: none;
  /* Smooth transition when zooming (marker separation/clustering) */
  transition: transform 0.3s ease-out;
  width: 32px;
  height: auto;
  overflow: visible;
}

.marker-content img {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  cursor: pointer;
  /* Re-enable clicks on the pin image */
  transition: transform 0.15s ease-out;
  pointer-events: none;
  position: relative;
  z-index: 1;
}

.pin-label {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  /* Re-enable clicks on the label */
  pointer-events: auto;
  transition: transform 0.15s ease-out;
  position: relative;
  z-index: 2;
}

.marker-content.marker-focused img,
.marker-content.marker-focused .pin-label {
  transform: scale(1.15);
}

/* Pin label color variants - match pin colors */
.pin-label-green {
  background: linear-gradient(
    135deg,
    var(--primary, --teal-400) 0%,
    var(--primary, --teal-400) 100%
  );
}

.pin-label-orange {
  background: linear-gradient(
    135deg,
    var(--secondary, #ff4000) 0%,
    var(--secondary, #ff4000) 100%
  );
}

.pin-label-red {
  background: linear-gradient(135deg, #a32e34 0%, #8a252a 100%);
}

.pin-label-golden {
  background: linear-gradient(
    135deg,
    var(--accent, #f3d38f) 0%,
    var(--accent, #f3d38f) 100%
  );
}

/* ===== Info Windows ===== */
.gm-style-iw {
  padding: 4px 8px 12px 8px !important; /* Minimal top padding */
  max-width: 300px;
}

.gm-style-iw-d {
  overflow: auto !important;
}

/* Marker info window content */
.marker-info-window {
  padding: 4px;
  min-width: 220px;
  max-width: 320px;
  font-family: "Segoe UI", Arial, sans-serif;
}

.marker-info-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px; /* Reduced from 8px */
}

.marker-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  background: var(--primary-color, #1a73e8);
  color: white;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 600;
}

.marker-title {
  margin: 0;
  font-size: 1.05rem; /* Slightly smaller */
  font-weight: 600;
  color: #222;
  flex: 1;
  line-height: 1.2; /* Tighter line height */
}

.marker-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px; /* Slightly smaller */
  background: #e3f2fd;
  color: #1976d2;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 6px; /* Reduced from 8px */
}

.marker-time,
.marker-duration {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0; /* Reduced from 6px */
  font-size: 0.9rem;
  color: #555;
}

.marker-time i,
.marker-duration i {
  color: #888;
  font-size: 0.85rem;
}

.marker-notes,
.marker-description {
  margin: 6px 0; /* Reduced from 8px */
  padding: 6px; /* Reduced from 8px */
  background: #f9f9f9;
  border-left: 3px solid #ddd;
  font-size: 0.9rem;
  color: #666;
  line-height: 1.4;
}

.marker-trip-link {
  margin-top: 8px; /* Reduced from 10px */
  padding-top: 8px; /* Reduced from 10px */
  border-top: 1px solid #eee;
}

.marker-trip-link .btn {
  width: 100%;
  justify-content: center;
}

/* Close button styling - smaller and more compact */
.gm-ui-hover-effect {
  opacity: 0.7 !important;
  width: 24px !important; /* Reduced from 32px */
  height: 24px !important; /* Reduced from 32px */
  top: 4px !important; /* Closer to top */
  right: 4px !important; /* Closer to edge */
}

.gm-ui-hover-effect:hover {
  opacity: 1 !important;
  background-color: rgba(0, 0, 0, 0.05) !important;
}

/* Close button icon (the X) - smaller */
.gm-ui-hover-effect > span {
  background-color: #666 !important;
  width: 12px !important; /* Reduced from 16px */
  height: 12px !important; /* Reduced from 16px */
  margin: 6px !important; /* Adjusted margin */
}

.gm-ui-hover-effect:hover > span {
  background-color: #333 !important;
}

.info-window-content {
  padding: 8px;
}

.info-window-content h3 {
  margin: 0 0 8px 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
}

.info-window-content p {
  margin: 4px 0;
  font-size: 0.9rem;
  color: #666;
}

.info-window-time {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  font-size: 0.85rem;
  color: #888;
}

.info-window-time i {
  font-size: 0.9rem;
}

.info-window-type {
  display: inline-block;
  padding: 2px 8px;
  background: #e3f2fd;
  color: #1976d2;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 6px;
}

/* ===== Loading States ===== */
.map-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 500px;
  background: #f5f5f5;
  border-radius: 8px;
  color: #666;
}

.map-loading i {
  font-size: 2rem;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ===== Empty State ===== */
.map-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 500px;
  background: #f5f5f5;
  border-radius: 8px;
  color: #999;
  text-align: center;
  padding: 2rem;
}

.map-empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.map-empty-state p {
  font-size: 1.1rem;
  margin: 0;
}

/* ===== Responsive Design ===== */

/* Tablet and below - Show toggle, stack layout */
@media (max-width: 1024px) {
  .trip-view-toggle {
    display: flex;
  }

  .map-itinerary-container {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Disable sticky on tablet/mobile */
  .map-section {
    position: relative; /* Override sticky */
    top: auto;
    max-height: none;
  }

  /* Hide inactive view on mobile */
  .map-section.hidden,
  .itinerary-section.hidden {
    display: none;
  }

  .map {
    height: 400px; /* Fixed height on mobile */
    max-height: none;
    min-height: auto;
  }

  #map {
    height: 400px;
  }
}

/* Mobile phones */
@media (max-width: 768px) {
  .map {
    height: 400px;
  }

  .map-empty-state {
    height: 400px;
  }

  #map {
    height: 350px;
  }

  .map-section h2,
  .itinerary-section h2 {
    font-size: 1.25rem;
  }

  .info-window-content {
    padding: 6px;
  }

  .info-window-content h3 {
    font-size: 1rem;
  }
}

/* ===== Map Controls Styling ===== */
/* Override Google Maps default button styles to match our design */

.gm-style button:hover {
  background-color: #f5f5f5 !important;
}

/* ===== User Location Marker ===== */
.user-location-marker {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #4285f4;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  position: relative;
}

.user-location-marker::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(66, 133, 244, 0.2);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0;
  }
}

/* ===== Map Bounds Padding ===== */
/* Ensure markers aren't cut off at edges */
.gm-style {
  padding: 20px;
}
