/**
 * Graph Styles for MLS Property History
 *
 * @package MlsHistory
 */

/* Graph Container */
.mlsh-graph-container {
  position: relative;
  width: 100%;
  min-height: 400px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
}

/* Chart Wrapper - contains canvas and scatter plot */
.mlsh-chart-wrapper {
  position: relative;
  width: 100%;
}

/* Chart Canvas for Desktop (Chart.js) */
.mlsh-chart-canvas {
  display: none;
  width: 100%;
  height: 265px;
}

/* CSS Scatter Plot for Mobile */
.mlsh-scatter-plot {
  position: relative;
  width: 100%;
  height: 400px;
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin: 20px 0;
}

/* Scatter Plot Axes */
.mlsh-scatter-plot::before,
.mlsh-scatter-plot::after {
  content: '';
  position: absolute;
  background: #333;
}

/* Y-axis (Price) */
.mlsh-scatter-plot::before {
  left: 40px;
  top: 20px;
  bottom: 40px;
  width: 2px;
}

/* X-axis (Time) */
.mlsh-scatter-plot::after {
  left: 40px;
  bottom: 40px;
  right: 20px;
  height: 2px;
}

/* Axis Labels */
.mlsh-axis-label {
  position: absolute;
  font-size: 12px;
  color: #666;
  font-weight: 500;
}

.mlsh-axis-label.y-axis {
  left: 5px;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: center;
}

.mlsh-axis-label.x-axis {
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
}

/* Data Points */
.mlsh-data-point {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.mlsh-data-point:hover {
  transform: scale(1.5);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  z-index: 100;
}

.mlsh-data-point.active {
  z-index: 100;
}

.mlsh-data-point.is-current {
  width: 16px;
  height: 16px;
  border: 3px solid #333;
  z-index: 5;
}

/* Recency Colors */
.mlsh-recency-recent {
  background: #ff6b35;
}

.mlsh-recency-medium {
  background: #4ecdc4;
}

.mlsh-recency-old {
  background: #45b7d1;
}

.mlsh-recency-very-old {
  background: #95a5a6;
}

/* Tooltip for Mobile */
.mlsh-tooltip {
  position: absolute;
  background: #fff;
  color: #333;
  padding: 2px 3px;
  border-radius: 3px;
  border: 1px solid #999;
  font-size: 6px;
  line-height: 1.3;
  pointer-events: none;
  white-space: nowrap;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mlsh-tooltip.active {
  opacity: 1;
}

/* Left-positioned tooltip */
.mlsh-tooltip-left {
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-right: 6px;
}

/* No pointer/triangle on mobile tooltips */
.mlsh-tooltip-left::after,
.mlsh-tooltip-left::before,
.mlsh-tooltip::after,
.mlsh-tooltip::before {
  display: none;
}

/* Legend */
.mlsh-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 20px;
  padding: 16px;
  background: #f9f9f9;
  border-radius: 4px;
}

.mlsh-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #555;
}

.mlsh-legend-color {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Graph Title */
.mlsh-graph-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0 0 16px 0;
  text-align: center;
}

/* Graph Metadata */
.mlsh-graph-meta {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding: 12px;
  background: #f0f0f0;
  border-radius: 4px;
}

.mlsh-meta-item {
  text-align: center;
}

.mlsh-meta-label {
  display: block;
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.mlsh-meta-value {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

/* Responsive */
@media (min-width: 769px) {
  .mlsh-chart-canvas {
    display: block;
  }

  .mlsh-scatter-plot {
    display: none;
  }

  .mlsh-graph-container {
    min-height: 500px;
  }

  /* Limit inline graph height on desktop */
  .mlsh-chart-wrapper {
    max-height: 265px;
  }

  .mlsh-chart-canvas {
    height: 265px;
    max-height: 265px;
  }
}

@media (max-width: 768px) {
  .mlsh-graph-container {
    padding: 16px;
    min-height: 350px;
  }

  .mlsh-scatter-plot {
    height: 350px;
  }

  .mlsh-graph-title {
    font-size: 16px;
  }

  .mlsh-legend {
    gap: 12px;
    padding: 12px;
  }

  .mlsh-legend-item {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .mlsh-graph-container {
    padding: 12px;
    min-height: 300px;
  }

  .mlsh-scatter-plot {
    height: 300px;
  }

  .mlsh-data-point {
    width: 10px;
    height: 10px;
  }

  .mlsh-data-point.is-current {
    width: 14px;
    height: 14px;
  }

  .mlsh-legend {
    gap: 8px;
    flex-wrap: wrap;
  }

  .mlsh-legend-item {
    font-size: 10px;
    gap: 4px;
  }
}
