/* Chart-specific styles */

/* Chart tooltip styling */
.tooltip, .card-tooltip-text, .chartjs-tooltip {
  text-transform: none !important;
}

/* Ensure all chart tooltips use proper text case */
.chart-tooltip, 
.apexcharts-tooltip, 
.chartjs-tooltip-body-item,
canvas [data-tooltip-id] {
  text-transform: none !important;
}

/* Make chart containers more responsive */
[style*="height"] canvas {
  max-height: 100%;
  width: 100% !important;
}

/* Chart hover improvements */
canvas {
  cursor: pointer;
}

/* Tooltip styling override - FIXED */
.chartjs-tooltip {
  background: rgba(0, 0, 0, 0.75) !important;
  color: white !important;
  border-radius: 4px !important;
  padding: 8px !important;
  font-size: 13px !important;
  pointer-events: none !important;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) !important;
  z-index: 1100 !important; /* Ensure tooltip is on top */
  max-width: 95% !important; /* Prevent overflow on mobile */
  user-select: none !important; /* Prevent text selection */
}

/* Clock face chart styling */
#clockFaceChart {
  max-width: 400px;
  margin: 0 auto;
}

/* Distribution chart styling */
.distribution-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.distribution-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.distribution-legend .color-box {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

/* Time of day heatmap */
.time-heatmap {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 1px;
}

.time-heatmap .cell {
  width: 100%;
  height: 20px;
  border-radius: 2px;
}

.time-heatmap .row-label {
  grid-column: 1;
  text-align: right;
  padding-right: 0.5rem;
  font-size: 0.75rem;
}

.time-heatmap .col-label {
  grid-row: 1;
  font-size: 0.75rem;
  text-align: center;
  padding-bottom: 0.25rem;
}

/* Chart help indicator */
.chart-help {
  position: absolute;
  top: 0;
  right: 0;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  color: #6c757d;
  cursor: help;
}

/* Charts with title bars */
.chart-container {
  position: relative;
}

.chart-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.chart-actions {
  display: flex;
  gap: 0.5rem;
}

/* Pattern confidence indicators */
.confidence-high {
  color: #2fb344;
}

.confidence-medium {
  color: #206bc4;
}

.confidence-low {
  color: #6c757d;
}

/* Analysis tab styles */
.analysis-tabs .nav-tabs {
  margin-bottom: 1rem;
}

/* Collapsible trend section - FIXED */
.collapsible-section {
  margin-bottom: 1rem !important;
}

.collapsible-header {
  transition: background-color 0.2s;
}

.collapsible-content {
  transition: max-height 0.3s ease-out;
  max-height: 0; /* Initial collapsed state */
  overflow: hidden;
}

/* Dark mode chart adjustments */
@media (prefers-color-scheme: dark) {
  /* Better visibility for chart elements in dark mode */
  .chartjs-tooltip {
    background: rgba(0, 0, 0, 0.9) !important;
  }
  
  /* Better contrast for clock face chart */
  #clockFaceChart {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    padding: 0.5rem;
  }
  
  /* Better contrast for time heatmap */
  .time-heatmap {
    background-color: rgba(255, 255, 255, 0.05);
    padding: 0.5rem;
    border-radius: 0.25rem;
  }
  
  /* Chart title bar in dark mode */
  .chart-title-bar {
    border-bottom-color: rgba(255, 255, 255, 0.05);
  }
  
  /* Chart background for better contrast */
  .chart-container canvas {
    background-color: rgba(255, 255, 255, 0.02);
    border-radius: 0.25rem;
  }
}

/* Mobile specific chart adjustments - ADDED */
@media (max-width: 767.98px) {
  /* Better tooltip positioning for mobile */
  .chartjs-tooltip {
    font-size: 11px !important;
    padding: 6px !important;
    max-width: 90% !important;
  }
  
  /* Make trend chart container not take space when collapsed */
  .collapsible-content {
    max-height: 0 !important;
  }
  
  /* Ensure collapsible toggle is easy to tap */
  .collapsible-header {
    padding: 8px;
  }
  
  /* Make sure charts remain responsive */
  .chart-container {
    touch-action: pan-y; /* Improve touch scrolling */
  }
  
  /* More room for fingers on mobile */
  canvas {
    padding-bottom: 4px;
  }
}