/* Custom content styling */
.chart-creator-custom-content {
  margin-top: 30px;
}

.chart-creator-custom-table-wrapper {
  margin-bottom: 20px;
}

.chart-creator-custom-table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  background-color: #fff;
}

.chart-creator-custom-table-wrapper table th,
.chart-creator-custom-table-wrapper table td {
  padding: 12px;
  text-align: left;
  border: 1px solid #ddd;
}

.chart-creator-custom-table-wrapper table th {
  background-color: #f5f5f5;
  font-weight: 600;
}

.chart-creator-custom-table-wrapper table tbody tr:nth-child(even) {
  background-color: #f9f9f9;
}

.chart-creator-custom-notes {
  margin-top: 20px;
}

.chart-creator-custom-notes p {
  margin: 0;
  line-height: 1.6;
}

/* Chart Creator Public Styles */
.chart-creator-container {
  margin: 20px 0;
  position: relative;
  width: 100%;
  max-width: 100%;
}

.chart-creator-container canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Ensure charts are responsive */
.chart-creator-container {
  position: relative;
  height: 400px;
  max-width: 100%;
}

@media (max-width: 768px) {
  .chart-creator-container {
    height: 300px;
  }
}

/* Chart Data Table */
.chart-creator-data-table-wrapper {
  margin-top: 30px;
  width: 100%;
  overflow-x: auto;
}

.chart-creator-data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
  font-size: 0.8rem;
}

.chart-creator-data-table thead {
  background: #f6f7f7;
}

.chart-creator-data-table th:not(:first-child) {
  text-align: right;
}

.chart-creator-data-table th {
  padding: 12px 15px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid #6febcf;
  color: #404040;
  background-color: #e3eded;
}

.chart-creator-data-table td:not(:first-child) {
  text-align: right;
  padding: 10px 15px;
  border-bottom: 1px solid #e5e5e5;
}

.chart-creator-data-table tbody tr:last-child td {
  border-bottom: none;
}

.chart-creator-data-table tbody tr:hover {
  background: #f9f9f9;
}

.chart-creator-data-table tbody tr:nth-child(even) {
  background: #fafafa;
}

.chart-creator-data-table tbody tr:nth-child(even):hover {
  background: #f0f0f0;
}

@media (max-width: 768px) {
  .chart-creator-data-table {
    font-size: 14px;
  }

  .chart-creator-data-table th,
  .chart-creator-data-table td {
    padding: 8px 10px;
  }
}

/* Hide JSON script tags */
.chart-creator-data,
.chart-creator-settings {
  display: none;
}

/* Chart Group Styles */
.chart-creator-group-wrapper {
  margin: 20px 0;
  width: 100%;
}

.chart-creator-group-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 20px;
  color: #333;
}

.chart-creator-group-tabs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  border-bottom: 2px solid #e5e5e5;
  padding-bottom: 15px;
  margin-bottom: 25px;
}

.chart-creator-group-tab-item {
  flex: 1;
  min-width: 150px;
  padding: 15px 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 4px 4px 0 0;
  position: relative;
}

.chart-creator-group-tab-item:hover {
  background-color: #f9f9f9;
}

.chart-creator-group-tab-item.active {
  background-color: transparent;
}

.chart-creator-group-tab-item.active::after {
  content: "";
  position: absolute;
  bottom: -17px;
  left: 0;
  right: 0;
  height: 3px;
  background-color: #17a2b8;
  border-radius: 2px 2px 0 0;
}

.chart-creator-group-tab-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.chart-creator-group-tab-name {
  font-size: 14px;
  font-weight: 500;
  color: #666;
  transition: color 0.3s ease;
}

.chart-creator-group-tab-item.active .chart-creator-group-tab-name {
  color: #17a2b8;
  font-weight: 600;
}

.chart-creator-group-tab-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: #e5e5e5;
  color: #666;
  font-size: 11px;
  font-weight: 600;
  cursor: help;
  transition: all 0.3s ease;
  position: relative;
}

.chart-creator-group-tab-item.active .chart-creator-group-tab-info {
  background-color: #17a2b8;
  color: #fff;
}

.chart-creator-group-tab-item:hover .chart-creator-group-tab-info {
  background-color: #17a2b8;
  color: #fff;
}

/* Tooltip bubble */
.chart-creator-group-tab-info::after {
  content: attr(data-kpi-tooltip);
  position: absolute;
  left: 50%;
  bottom: 160%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 11px;
  width: 200px;

  max-width: 220px; /* allows wrapping into ~2 rows */
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 10;
}

.chart-creator-group-tab-info::after {
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Small arrow */
.chart-creator-group-tab-info::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 90%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: #333 transparent transparent transparent;
  opacity: 0;
  transition: opacity 0.1s ease;
  z-index: 10;
}

/* Show instantly on hover */
.chart-creator-group-tab-info:hover::after,
.chart-creator-group-tab-info:hover::before {
  opacity: 1;
}

.chart-creator-group-tab-value {
  font-size: 24px;
  font-weight: 600;
  color: #666;
  margin-bottom: 4px;
  transition: color 0.3s ease;
}

.chart-creator-group-tab-item.active .chart-creator-group-tab-value {
  color: #17a2b8;
  font-size: 26px;
}

.chart-creator-group-tab-change {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}

.chart-creator-group-tab-change .change-value {
  font-weight: 600;
}

.chart-creator-group-tab-change .change-value.positive {
  color: #28a745;
}

.chart-creator-group-tab-change .change-value.negative {
  color: #dc3545;
}

.chart-creator-group-charts {
  position: relative;
  min-height: 400px;
}

.chart-creator-group-chart-container {
  display: none;
  width: 100%;
}

.chart-creator-group-chart-container.active {
  display: block;
}

@media (max-width: 768px) {
  .chart-creator-group-tabs-nav {
    flex-direction: column;
    gap: 10px;
  }

  .chart-creator-group-tab-item {
    min-width: 100%;
    border-bottom: 1px solid #e5e5e5;
    padding: 12px 15px;
  }

  .chart-creator-group-tab-item.active::after {
    display: none;
  }

  .chart-creator-group-tab-item.active {
    background-color: #f0f8ff;
    border-left: 3px solid #17a2b8;
  }
}
