/* ==========================================
   Root / Wrapper
========================================== */
#stallion-map-container {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f5f5f5;
  color: #333;
  height: 100%;
  margin-bottom: 3em;
}

.stallion-map-wrapper {
  display: flex;
  flex-direction: column;
  /*height: 800px;*/
  background: #f5f5f5;
  color: #333;
}

/* ==========================================
   Header
========================================== */
.map-header {
  background: #fff;
  padding: 16px 24px;
  border-bottom: 2px solid #204971;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.map-header h1 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.0 !important;
  margin: 0;
  margin-bottom: 0.2em;
  color: #204971;
}

.map-header .subtitle {
  font-size: 14px;
  font-weight: 400;
  color: #666;
  position: absolute;
}

.stats {
  display: flex;
  gap: 24px;
}

.stat {
  text-align: center;
}

.stat-number {
  font-size: 24px;
  font-weight: 700;
  color: #204971;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
}

/* ==========================================
   Main Content – Side-by-Side Layout
========================================== */
.map-content {
  display: flex;
  width: 100%;
  height: 100%;
  aspect-ratio: 3 / 2;
  border: 1px solid #204971;
}

/* Map Area (left) */
#map-area {  
  flex: 1 1 auto;
  position: relative;
  background: #f8f8f8;
  padding-bottom: 66.67%;
  height: 0;
}

.map-area svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Sidebar (right) */
.map-sidebar {
  flex: 0 0 300px;
  width: 300px;
  background: #fff;
  border-left: 1px solid #ddd;
  overflow-y: auto;
  position: relative;
}

.sidebar-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #204971;
  color: white;
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-legend {
  padding: 12px 18px;
  background: #f8f8f8;
  border-bottom: 1px solid #eee;
}

.legend-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  margin-bottom: 8px;
}

.legend-items {
  display: flex;
  gap: 16px;
  align-items: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-marker {
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.legend-item span {
  font-size: 11px;
  color: #666;
}

/* ==========================================
   Sidebar Farm Items
========================================== */
.sidebar-farm {
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background 0.15s ease;
}

.sidebar-farm.selected,
.sidebar-farm:hover {
  background: rgba(199, 234, 251, .5);
}

.farm-header {
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.farm-name {
  font-weight: 500;
  font-size: 13px;
  color: #333;
}

.farm-count {
  background: #204971;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.farm-stallions {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 18px;
}

.farm-stallions.expanded {
  max-height: 500px;
  padding: 0 18px 10px 18px;
}

.sidebar-stallions-list {
  font-size: .65em;
}

.sidebar-stallion {
  padding: 6px 18px;
  transition: all 0.15s ease;
}

.sidebar-stallion a {
  color: #1a472a;
  text-decoration: none;
  display: block;
  width: fit-content;
}

.sidebar-stallion.highlighted {
  background: rgba(199, 234, 251, .5);
  font-weight: bold;
  border-left: 4px solid #f89838;
}

.sidebar-stallion:hover {
  background: rgba(240, 247, 242, 0.7);
}

/* ==========================================
   Markers & Interactions
========================================== */
.marker {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 10;
}

.marker.farm-marker.selected {
  anchor-name: --farm-marker;
  z-index: 201;
}

.marker.farm-marker:not(.selected):hover {
  anchor-name: --farm-hover-marker;
}

.marker-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fbd12d;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  transition: transform 0.15s ease;
}

.marker.selected .marker-icon {
  background-color: #f89838;
  border-color: #204971;
  box-shadow: 0 0 0 3px rgba(26,71,42,0.4), 0 4px 12px rgba(0,0,0,0.3);
}

.ftboa-icon {
  width: 44px;
  height: 32px;
  border-radius: 4px;
  background: var(--awb-color5);
  font-size: 8px;
  letter-spacing: 0.5px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* ==========================================
   Tooltips & Popups
========================================== */
.marker-tooltip,
.marker-popup {
  position: absolute;
  z-index: 200;
  color: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.marker-tooltip {
  background: #204971;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 6px;
  padding: 6px 12px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}

.ftboa-tooltip {
  font-size: 11px;
}

.tooltip-name {
  font-weight: 600;
  margin-bottom: 2px;
}

.tooltip-address {
  opacity: 0.8;
}

.marker-popup {
  position-anchor: --farm-marker;
  transition: opacity 0.2s ease;
  top: anchor(center);
  left: anchor(right);
  transform: translate(12px, -50%);
  background: #fff;
  border: 2px solid #f89838;
  border-radius: 8px;
  padding: 14px 18px;
  min-width: 200px;
  max-width: 280px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  z-index: 200;
  pointer-events: auto;
  color: initial;
}

.marker-popup.align-left {
  left: auto;
  right: 100%;
  transform: translate(-12px, -50%);
}

.marker-popup::before {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border: 10px solid transparent;
  left: -20px;
  border-right-color: #f89838;
  transform: translateY(-50%);
}

.marker-popup.align-left::before {
  right: -20px;
  left: auto;
  border-left-color: #204971;
  border-right-color: transparent;
}

.close-popup {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

.popup-name {
  font-size: 15px;
  font-weight: 600;
  color: #204971;
  margin-bottom: 4px;
}

.popup-address {
  font-size: 11px;
  color: #666;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.popup-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  margin-bottom: 6px;
}

.popup-stallions {
  max-height: 160px;
  overflow-y: auto;
}

.stallion-name {
  padding: 4px 0;
  font-size: 12px;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
}

.stallion-name:last-child {
  border-bottom: none;
}

#hover-tooltip {
  position-anchor: --farm-hover-marker;
  inset-block-end: anchor(top);
  inset-inline-start: anchor(center);
  margin-block-end: 8px;
  transform: translateX(-50%);
  bottom: anchor(top);
  background: #204971;
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 150;
  pointer-events: none;
  min-width: 80px;
  max-width: 220px;
  text-align: center;
}

#hover-tooltip::before {
  content: "";
  position: absolute;
  inset-block-start: 100%;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-block-start-color: #1a472a;
}

#hover-tooltip.flipped {
  inset-block-end: auto;
  inset-block-start: anchor(bottom);
  margin-block-start: 8px;
  margin-block-end: 0;
}

.ftboa-marker {
  anchor-name: --ftboa-marker;
}

/* ==========================================
   Loading
========================================== */
.loading {
  padding: 80px 20px;
  text-align: center;
  font-size: 18px;
  color: #555;
}

/* ==========================================
   Responsive
========================================== */
@media (max-width: 900px) {
  .map-content {
    flex-direction: column;
  }

  .map-area {
    height: 500px;
    flex: 0 0 auto;
  }

  .map-sidebar {
    width: 100%;
    flex: 0 0 auto;
    border-left: none;
    border-top: 1px solid #ddd;
    max-height: 300px;
  }

  .stats {
    gap: 16px;
  }

  .stat-number {
    font-size: 20px;
  }
}