@tailwind base;
@tailwind components;
@tailwind utilities;

html,
body,
#root {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  /* Prevent scrollbars on body */
}

/* Custom tweaks for MapLibre Popup to match Tailwind aesthetics */
.maplibregl-popup-content {
  padding: 0;
  border-radius: 0.75rem;
  /* rounded-xl */
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  overflow: hidden;
  border: none;
}

.maplibregl-popup-close-button {
  padding: 8px;
  color: #4b5563;
  font-size: 16px;
  z-index: 10;
}

.maplibregl-popup-close-button:hover {
  background-color: transparent;
  color: #000;
}

/* CSS cho User Location Marker (Vị trí của bạn) */
@keyframes pulse-ring {
  0% {
    transform: scale(0.33);
    opacity: 1;
  }

  80%,
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

.user-marker-root {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 0;
  height: 0;
  overflow: visible;
}

.user-marker-container {
  width: 60px;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  cursor: pointer;
  /* Visual container is now centered inside the 0x0 root */
}

.user-marker-pulse {
  position: absolute;
  width: 60px;
  height: 60px;
  background-color: rgba(59, 130, 246, 0.5);
  /* blue-500 */
  border-radius: 50%;
  animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
  z-index: 1;
}

.user-marker-dot {
  position: relative;
  width: 18px;
  height: 18px;
  background-color: #2563EB;
  /* blue-600 */
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 2;
}

/* --- FARM MARKER STYLES --- */

/* Hiệu ứng lan tỏa (Pulse) màu xanh */
@keyframes pulse-ring-green {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0.6;
  }

  100% {
    transform: translate(-50%, -50%) scale(2.0);
    opacity: 0;
  }
}

/* 
   FIX: Separate the MapLibre container from the visual wrapper.
   MapLibre applies transform to .farm-marker-root for positioning.
   We must NOT apply CSS transforms to .farm-marker-root, or it overrides location.
*/
.farm-marker-root {
  cursor: pointer;
  display: flex;
  justify-content: center;
  /* Ensure content is centered horizontally for accurate anchoring */
  /* width/height will be determined by content */
}

/* This wrapper handles the visual layout and hover scale */
.farm-marker-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.farm-marker-wrapper:hover {
  transform: scale(1.15) translateY(-5px);
  z-index: 50;
}

/* Vòng tròn lan tỏa phía sau */
.farm-marker-pulse {
  position: absolute;
  top: 28px;
  /* Center vertially relative to the circle part (56px height / 2) */
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  background-color: rgba(34, 197, 94, 0.5);
  /* green-500 */
  border-radius: 50%;
  animation: pulse-ring-green 2.5s infinite;
  z-index: 0;
  pointer-events: none;
}

/* Khung tròn chứa ảnh */
.farm-marker-frame {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: white;
  padding: 3px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
  z-index: 10;
  border: 2px solid #22c55e;
  /* green-500 border for extra visibility */
}

.farm-marker-image {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background-color: #e5e7eb;
  display: block;
}

/* Mũi tên trỏ xuống (Pin tail) */
.farm-marker-tail {
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid #22c55e;
  /* green-500 matching border */
  margin-top: -1px;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.1));
  z-index: 9;
  transform: translateY(-1px);
  /* Slight overlap to prevent gap */
}

/* Force MapLibre container to have dimensions */
.maplibregl-map {
  height: 100% !important;
  width: 100% !important;
  position: absolute !important;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  /* Ensure it takes space */
  display: block !important;
  min-height: 500px !important;
  /* Restore fallback */
  z-index: 1;
  /* Ensure it is above the background but below overlays */
}