/* Chart Detail Page Styles - Enhanced responsive fixes */

/* Chart Detail Section */
.chart-detail-section {
  padding: var(--space-md) 0 0 0; /* Removed bottom padding */
  background-color: var(--color-background);
}

/* Chart Title Styling - matches blog-title style but aligned left for chart pages */
.chart-detail-section .h2-for-titles-style {
  color: #115151;
  font-weight: 500;
  font-size: var(--text-xl);
  margin-bottom: 0.5em; /* Further reduced for tighter spacing */
  text-align: left; /* Left aligned for chart pages */
}

/* Chart Entry Description - Reusable style for chart page descriptions */
.chart-entry-description {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: #2d2d2d;
  font-size: 0.875em; /* 14px equivalent */
  line-height: 1.5;
  margin-bottom: 2.5em; /* Reduced from 3.5em to 2.5em */
  text-align: left;
  max-width: 100%;
  display: none; /* Hide the paragraph */
}

/* Chart Title Styling - matches blog-title style */
.chart-detail-section .blog-title {
  color: #115151;
  font-weight: 500;
  font-size: var(--text-xl);
  margin-bottom: 2em;
  text-align: center;
}

/* Alternative chart title class */
.chart-page-title {
  color: #115151;
  font-weight: 500;
  font-size: var(--text-xl);
  margin-bottom: 2em;
  text-align: center;
}

.chart-title {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

.chart-main-card {
  background-color: var(--color-background);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  width: 100%;
  margin-bottom: 0;
  overflow: hidden; /* Prevent overflow */
  box-sizing: border-box;
}

/* Chart Controls Section */
.chart-controls {
  margin-bottom: var(--space-md);
  padding: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.chart-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem; /* Keep more compact than original 0.5rem */
  margin-bottom: 0.8rem; /* Keep more compact than original 1rem */
  align-items: center;
}

.category-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem; /* Returned to original */
  padding: 0.5rem 0.75rem; /* Returned to original */
  border: 1px solid #dfe1e1;
  border-radius: var(--radius-sm);
  background-color: var(--color-background);
  color: #686868;
  font-size: 0.75em; /* Returned to 0.75em */
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-button:hover {
  background-color: var(--color-light-gray);
}

.category-button.active {
  background-color: var(--color-background);
  border-color: var(--color-text);
}

.category-button.inactive {
  /* Remove: opacity: 0.6; background-color: #f8f8f8; */
}

.category-button.inactive .category-indicator {
  background-color: #f1f1f1 !important;
}

.category-button.active .category-indicator {
  /* Color will be set dynamically through JavaScript */
  /* Don't use !important here to allow dynamic overriding */
}

.category-indicator {
  width: 12px; /* Returned to original */
  height: 12px; /* Returned to original */
  border-radius: 2px;
  flex-shrink: 0;
}

.show-more-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem; /* Returned to original */
  padding: 0.5rem 0.75rem; /* Returned to original */
  border: 1px solid #dfe1e1;
  border-radius: var(--radius-sm);
  background-color: var(--color-background);
  color: #686868;
  font-size: 0.75em; /* Returned to original */
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s ease;
}

.show-more-button:hover {
  background-color: var(--color-light-gray);
}

.show-more-arrow {
  width: 16px; /* Returned to original */
  height: 16px; /* Returned to original */
  transition: transform 0.2s ease;
}

.show-more-arrow.expanded {
  transform: rotate(90deg);
}

.additional-categories {
  display: none;
  flex-wrap: wrap;
  gap: 0.4rem; /* Keep more compact */
  margin-top: 0.8rem; /* Keep more compact */
  padding-top: 0.8rem; /* Keep more compact */
  border-top: 1px solid var(--color-border);
}

.additional-categories.visible {
  display: flex;
}

.chart-container {
  height: 300px;
  position: relative;
  width: 100%;
  overflow: hidden; /* Critical: prevent chart overflow */
  box-sizing: border-box;
  max-width: 100%; /* Ensure it never exceeds container */
}

.chart-description {
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-md);
  display: none; /* Hide the section */
}

.chart-description h3 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-sm);
  color: var(--color-text);
}

.chart-description p {
  color: var(--color-text-light);
  margin-bottom: var(--space-sm);
  font-size: var(--text-md);
}

.read-more {
  display: flex;
  align-items: center;
  color: var(--color-accent);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  margin-left: auto;
  width: fit-content;
}

.read-more svg {
  margin-left: 0.25rem;
  transition: transform 0.2s ease;
}

.read-more:hover svg {
  transform: translateX(3px);
}

/* Related Content Section */
.related-content-section {
  padding: var(--space-md) 0 var(--space-xl);
  background-color: var(--color-background);
}

/* Related Content Section */
.blog {
  background-color: #eceeee;
}

.related-title {
  font-size: var(--text-lg);
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

/* Add hover effect to blog cards in chart detail page */
.related-content-section .blog-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.related-content-section .blog-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.btn-other-content {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-normal);
  border: none;
  font-size: var(--text-sm);
  background-color: var(--color-accent);
  color: var(--color-background);
}

.btn-other-content:hover {
  background-color: var(--color-accent-light);
  transform: translateY(-2px);
}

/* NEW SECTION: Chart Info Section */
.chart-info-section {
  padding: 0.5rem 0 var(--space-md) 0; /* Significantly reduced top padding */
  background-color: var(--color-background);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.chart-info-container {
  /* Use the same container as the chart section */
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 3rem); /* Same padding as .container */
}

.chart-full-question {
  margin-bottom: var(--space-md);
}

.chart-full-question h4 {
  font-size: 1rem;
  font-weight: 500;
  color: #19807e;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.chart-full-question p {
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

.chart-info-divider {
  height: 1px;
  background-color: #dfe1e1;
  margin: var(--space-md) 0;
  width: 100%;
}

.chart-info-columns {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

@media (min-width: 768px) {
  .chart-info-columns {
    flex-direction: row;
  }

  .chart-info-left {
    flex: 1;
    padding-right: var(--space-md);
  }

  .chart-info-right {
    flex: 1;
    padding-left: var(--space-md);
  }
}

.chart-info-left h5,
.chart-info-right h5 {
  font-size: 1rem;
  font-weight: 500;
  color: #19807e;
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
}

.chart-info-item {
  display: flex;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.chart-info-icon {
  margin-right: 0.75rem;
  color: #686868;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.chart-info-text {
  font-size: 0.875rem;
  color: var(--color-text);
}

.chart-related-content {
  margin-bottom: var(--space-md);
}

.chart-related-item {
  display: flex;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background-color: #f9f9f9;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease;
}

.chart-related-item:hover {
  background-color: #f1f1f1;
}

.chart-related-image {
  width: 80px;
  height: 60px;
  background-color: #ddd;
  margin-right: 0.75rem;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: #888;
  text-align: center;
  line-height: 1.2;
}

.chart-related-image::after {
  content: "Image placeholder";
}

.chart-related-content-info {
  flex: 1;
}

.chart-related-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.chart-related-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: #686868;
}

.chart-related-category {
  padding: 0.15rem 0.5rem;
  background-color: #f1f1f1;
  border-radius: 2px;
}

.chart-share {
  margin-top: var(--space-md);
}

.chart-share h5 {
  font-size: 0.875rem;
  font-weight: 500;
  color: #19807e; /* Changed to match other titles */
  margin-bottom: 0.75rem;
  text-transform: uppercase;
}

.chart-share-buttons {
  display: flex;
  gap: 0.75rem;
}

.chart-share-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #f1f1f1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #686868;
  transition: all 0.2s ease;
  cursor: pointer;
}

.chart-share-button:hover {
  transform: translateY(-2px);
}

.chart-share-button.facebook:hover {
  background-color: #1877f2;
  color: white;
}

.chart-share-button.twitter:hover {
  background-color: #1da1f2;
  color: white;
}

.chart-share-button.linkedin:hover {
  background-color: #0a66c2;
  color: white;
}

.chart-share-button.email:hover {
  background-color: #ea4335;
  color: white;
}

/* Image placeholder styles for blog section */
.blog-image-placeholder {
  width: 100%;
  height: 0;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  border-radius: var(--radius-blog);
  overflow: hidden;
  margin-bottom: 0.75rem;
  background-color: #ddd;
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.blog-image-placeholder::after {
  content: "Image placeholder";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.875rem;
  color: #888;
  text-align: center;
}

/* New styles for subtitle and specific titles */
.chart-subtitle {
  font-size: 1rem;
  font-weight: 500;
  color: #19807e;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.chart-explore-more {
  font-size: 1rem;
  font-weight: 500;
  color: #19807e;
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* Documentation of styles for future use */
/* 
  Specific colors for chart elements:
  --chart-subtitle-color: #19807E; (Color for chart subtitles)
  --chart-explore-more-color: #19807E; (Color for exploration titles)
  
  Reusable classes:
  .chart-subtitle - For subtitles in chart sections
  .chart-explore-more - For titles in exploration sections
  .chart-info-text - For informative text in chart sections
  .chart-info-item - For information elements with icon and text
*/

/* Ensure all elements use Helvetica Neue */
.chart-info-section,
.chart-full-question,
.chart-info-left,
.chart-info-right,
.chart-info-text,
.chart-related-title,
.chart-related-meta,
.chart-share h5 {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* Media Queries */

/* 320px - Extra Small Mobile */
@media (min-width: 320px) {
  .chart-container {
    height: 250px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .chart-title {
    font-size: var(--text-xl);
  }

  .chart-description h3 {
    font-size: var(--text-lg);
  }

  .chart-description p {
    font-size: var(--text-sm);
  }

  .chart-categories {
    gap: 0.3rem; /* More compact on mobile */
  }

  .category-button {
    padding: 0.4rem 0.6rem; /* Slightly more compact on mobile */
    font-size: 0.75em; /* Keep at 0.75em */
  }

  .show-more-button {
    font-size: 0.75em; /* Keep at 0.75em */
    padding: 0.4rem 0.6rem; /* Slightly more compact on mobile */
  }

  /* Responsive adjustments for chart entry description */
  .chart-entry-description {
    font-size: 0.875em; /* Maintain 14px equivalent on mobile */
    line-height: 1.4; /* Slightly tighter line height on mobile */
  }

  /* Chart info responsive adjustments */
  .chart-full-question h4 {
    font-size: 0.875rem;
  }

  .chart-full-question p {
    font-size: 1rem;
  }

  .chart-info-item {
    margin-bottom: 0.75rem;
  }

  /* Reduce spacing even more on mobile */
  .chart-info-section {
    padding: 0.25rem 0 var(--space-md) 0;
  }
}

/* 390px - Small Mobile */
@media (min-width: 390px) {
  .chart-container {
    height: 260px;
  }

  .chart-categories {
    gap: 0.35rem;
  }

  .category-button {
    padding: 0.45rem 0.65rem;
    font-size: 0.75em;
  }

  .show-more-button {
    font-size: 0.75em;
    padding: 0.45rem 0.65rem;
  }
}

/* 430px - Medium Mobile */
@media (min-width: 430px) {
  .chart-container {
    height: 270px;
  }
}

/* 540px - Large Mobile */
@media (min-width: 540px) {
  .chart-container {
    height: 280px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .chart-title {
    font-size: var(--text-2xl);
  }

  .chart-categories {
    gap: 0.4rem;
  }

  .category-button {
    padding: 0.5rem 0.75rem;
    font-size: 0.75em;
  }

  .show-more-button {
    font-size: 0.75em;
    padding: 0.5rem 0.75rem;
  }

  /* Restore normal line height on larger screens */
  .chart-entry-description {
    line-height: 1.5;
  }

  /* Chart info responsive adjustments */
  .chart-full-question h4 {
    font-size: 1rem;
  }

  .chart-full-question p {
    font-size: 1.125rem;
  }
}

/* 620px - Small Tablet */
@media (min-width: 620px) {
  .chart-container {
    height: 300px;
  }

  .chart-description h3 {
    font-size: var(--text-xl);
  }

  .chart-description p {
    font-size: var(--text-md);
  }
}

/* 728px - Tablet */
@media (min-width: 728px) {
  .chart-container {
    height: 350px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .chart-main-card {
    padding: var(--space-lg);
  }
}

/* 1024px - Small Desktop */
@media (min-width: 1024px) {
  .chart-container {
    height: 400px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .chart-title {
    margin-bottom: var(--space-lg);
  }
}

/* 1280px - Medium Desktop */
@media (min-width: 1280px) {
  .chart-container {
    height: 450px;
  }
}

/* 1440px - Large Desktop */
@media (min-width: 1440px) {
  .chart-container {
    height: 500px;
  }
}

/* Adjust style for all h5 in chart-info-right */
.chart-info-right h5 {
  font-size: 1rem;
  font-weight: 500;
  color: #19807e;
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* Adjustment for the share block when in the left column */
.chart-info-left .chart-share {
  margin-top: var(--space-md);
  margin-bottom: 0;
}

.chart-info-left .chart-share h5 {
  color: #19807e; /* Updated to match other titles */
}

/* ===== UNIFIED CHART STYLES (CONSOLIDATED) ===== */
/* Base Chart Container Styles - Enhanced from charts-unified.css */
.chart-container {
  position: relative;
  width: 100%;
  min-height: 250px;
  height: 300px;
  margin-bottom: 1rem;
  background-color: #ffffff;
  border-radius: var(--radius-md);
}

/* Chart Canvas Element */
.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
  border-radius: var(--radius-md);
}

/* Chart Card Styles (for homepage grid) */
.chart-card {
  background-color: var(--color-background);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  width: 100%;
  display: flex;
  flex-direction: column;
  min-width: 300px;
}

.chart-card h4 {
  color: #4d4f4f;
  font-weight: 500;
  font-size: var(--text-md);
  margin-bottom: 0.5rem;
  margin-top: 0;
}

/* Grid System Integration */
.grid-sixty-thirty-item .chart-container {
  height: 300px;
  width: 100%;
  min-height: 250px;
}

.grid-two-columns-item .chart-container {
  height: 280px;
  width: 100%;
  min-height: 220px;
}

/* ===== CHART LOADING STATES ===== */
.chart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #686868;
  font-size: 0.875rem;
}

.chart-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #dc2626;
  font-size: 0.875rem;
  text-align: center;
  padding: 1rem;
}

/* ===== CHART LEGEND CUSTOMIZATION ===== */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-text);
}

.chart-legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ===== ACCESSIBILITY ===== */
.chart-container:focus-within {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.category-button:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.show-more-button:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ===== PRINT STYLES ===== */
@media print {
  .chart-controls {
    display: none;
  }

  .chart-container {
    height: 400px !important;
    page-break-inside: avoid;
  }
}

/* ===== ENHANCED RESPONSIVE BREAKPOINTS FOR UNIFIED CHARTS ===== */

/* Mobile (320px - 539px) - Enhanced */
@media (max-width: 539px) {
  .chart-container,
  .grid-sixty-thirty-item .chart-container,
  .grid-two-columns-item .chart-container {
    height: 250px;
    min-height: 200px;
  }

  .chart-card {
    min-width: 280px;
    padding: var(--space-sm);
  }
}

/* Tablet (540px - 1023px) - Enhanced */
@media (min-width: 540px) and (max-width: 1023px) {
  .grid-sixty-thirty-item .chart-container {
    height: 280px;
    min-height: 220px;
  }

  .grid-two-columns-item .chart-container {
    height: 260px;
    min-height: 200px;
  }

  .chart-card {
    min-width: 320px;
  }
}

/* Desktop (1024px+) - Enhanced */
@media (min-width: 1024px) {
  .grid-sixty-thirty-item .chart-container {
    height: 300px;
    min-height: 250px;
  }

  .grid-two-columns-item .chart-container {
    height: 280px;
    min-height: 220px;
  }

  .chart-card {
    min-width: 400px;
  }
}

/* Large Desktop (1440px+) - Enhanced */
@media (min-width: 1440px) {
  .grid-sixty-thirty-item .chart-container {
    height: 350px;
    min-height: 300px;
  }

  .grid-two-columns-item .chart-container {
    height: 320px;
    min-height: 280px;
  }
}

/* Enhanced responsive breakpoints for chart detail page */
@media (min-width: 700px) and (max-width: 750px) {
  .chart-detail-section .container {
    overflow-x: hidden;
  }

  .chart-main-card {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
  }

  .chart-container {
    width: 100% !important;
    max-width: 100% !important;
    height: 280px !important;
    overflow: hidden;
    box-sizing: border-box;
  }

  .chart-container canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
  }
}
