/* Chart.js Controls Styling */

/* Manual Retry Button for Failed Accessibility Initialization */
.chart-accessibility-retry-button {
  font-size: 0.9em;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  margin-right: 8px;
}

/* Ensure button text wraps nicely on smaller screens */
@media (max-width: 768px) {
  .chart-accessibility-retry-button {
    font-size: 0.85em;
    padding: 6px 10px;
  }
}

.chart-palette-label {
  padding: 0.37rem;
  background: #00131d;
  color: #fffff4 !important;
  border-radius: 4px;
}

/* Chart export controls */
.copy-html {
  /*display: none !important; */
}
.chart-export-feedback.success {
  background-color: #e6f7e6;
  color: #2e7d32;
}

.chart-export-feedback.error {
  background-color: #fdecea;
  color: #d32f2f;
}

.chart-export-feedback.visible {
  border: 1px solid currentcolor;
}

.chart-export-controls {
  margin-top: 1.5rem;
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chart-export-group,
.mermaid-export-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chart-export-group-label,
.mermaid-export-group-label {
  font-weight: bold;
  font-size: 0.9rem;
}

.chart-export-buttons,
.mermaid-export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chart-export-button,
.mermaid-export-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-colour 0.2s, border-colour 0.2s;
}

.chart-export-button svg {
  width: 16px;
  height: 16px;
}

.chart-export-feedback {
  margin-top: 0.5rem;
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.3s;
  height: 0;
  overflow: hidden;
}

.chart-export-feedback.visible {
  opacity: 1;
  height: auto;
  overflow: visible;
}

.chart-figure {
  margin: 1.5rem 0;
  padding: 0;
  width: 100%;
  position: relative;
}

.chart-description,
.mermaid-description {
  border: 1px solid currentColor;
  border-radius: 4px;
  max-width: 70%;
  margin: 0 auto;
  padding: 1.5rem;
  transition: all 0.3s ease;
  position: relative;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .chart-description,
  .chart-figcaption {
    max-width: 100%;
  }
}

.chart-figcaption {
  padding: 0.5rem;
  line-height: 1.5;
  color: currentColor;
  max-width: 70%;
  margin: 0 auto;
}

/* Headings */
.chart-short-description-heading,
.chart-details-heading,
.mermaid-short-description-heading {
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.chart-short-description-heading,
h3.chart-details-heading,
.mermaid-short-description-heading,
h3.mermaid-details-heading {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
}

h4.chart-details-heading {
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  padding: 10px;
}

h4.chart-details-heading::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  background-color: #d5007f;
  margin-right: 0.5rem;
  border-radius: 50%;
}

/* Short description style */
.chart-short-description {
  font-size: 1.1rem;
  padding-left: 1rem;
  margin: 1rem 0;
  font-weight: 500;
}

.chart-detailed-description p,
.chart-detailed-description li {
  font-size: 1rem;
  margin-bottom: 1rem;
}

/* Section styling */
.chart-section {
  padding: 1.25rem;
  margin: 1.25rem 0;
  border-radius: 4px;
}

/* Lists */
.chart-detailed-description ul {
  margin: 0.75rem 0;
}

.chart-detailed-description li {
  margin-bottom: 0.5rem;
  position: relative;
}

/* Disclaimer */
.chart-disclaimer {
  font-size: 0.8rem;
  text-align: center;
  margin-top: 2rem;
  padding-top: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .chart-description {
    padding: 1rem;
    margin: 1rem;
  }

  .chart-short-description-heading,
  h3.chart-details-heading {
    font-size: 1.3rem;
  }

  h4.chart-details-heading {
    font-size: 1.1rem;
  }

  .chart-section {
    padding: 1rem;
  }
}

/* Print styles */
@media print {
  .chart-description {
    box-shadow: none;
  }
  .chart-export-controls {
    display: none;
  }

  .chart-detailed-description {
    display: block;
    padding-left: 0;
  }

  .chart-figcaption {
    font-size: 1.1rem;
    margin-bottom: 2rem;
  }

  /* Ensure sr-only content is visible in print */
  .sr-only {
    position: static;
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }
}

.chart-container {
  position: relative;
  margin: 1.5rem 0;
  border-radius: 4px;
  overflow: visible; /* Changed from hidden to allow controls to extend beyond */
  padding-bottom: 5rem; /* Space for controls */
}

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  position: absolute; /* Position absolutely */
  bottom: 0; /* Align to bottom */
  left: 0;
  right: 0;
  justify-content: flex-end;
  align-items: center;
  border-radius: 0 0 4px 4px; /* Round bottom corners to match container */
}

.chart-control-button {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
}

.chart-control-button svg {
  width: 14px;
  height: 14px;
}

/* Palette selector styles */
.chart-palette-container {
  display: flex;
  align-items: center;
  margin-right: auto; /* Push to the left */
  gap: 0.5rem;
}

.chart-palette-label {
  font-size: 0.85rem;
}

/* Loading spinner animation */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-spinner {
  animation: spin 1.5s linear infinite;
}

/* Prevent animation if reduced motion is preferred */
@media (prefers-reduced-motion: reduce) {
  .loading-spinner {
    animation: none;
  }
}

/* Add media query for the problematic mid-range width */
@media (max-width: 1200px) and (min-width: 769px) {
  .chart-container {
    padding-bottom: 7rem; /* More space for potentially two rows of controls */
  }

  .chart-palette-container {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

/* Adjust for smaller screens */
@media (max-width: 768px) {
  .chart-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .chart-container {
    padding-bottom: 12rem; /* Much more padding for mobile with multiple rows of controls */
  }

  .chart-palette-container {
    margin-right: 0;
    margin-bottom: 0.5rem;
    width: 100%;
  }

  .chart-palette-select {
    flex-grow: 1;
  }

  .chart-control-button {
    width: 100%;
    justify-content: flex-start;
  }
}

/* Additional very small screen adjustments */
@media (max-width: 480px) {
  .chart-container {
    padding-bottom: 14rem; /* Even more padding for very small screens */
  }
}
