/* Chart-specific styles */
.plotly-chart {
  background-color: transparent !important;
}

/* Custom Plotly theme overrides */
.js-plotly-plot .plotly {
  background-color: transparent !important;
}

/* Plotly modebar styling - simplified to ensure visibility */
.modebar {
  background-color: rgba(51, 65, 85, 0.9) !important;
  border: 1px solid rgba(71, 85, 105, 0.8) !important;
  border-radius: 8px !important;
  padding: 4px !important;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3) !important;
  z-index: 1000 !important;
  position: relative !important;
}

.modebar-btn {
  background-color: transparent !important;
  border: none !important;
  border-radius: 4px !important;
  color: #cbd5e1 !important;
  padding: 3px !important;
  margin: 1px !important;
  width: 24px !important;
  height: 24px !important;
  cursor: pointer !important;
}

.modebar-btn:hover {
  background-color: rgba(71, 85, 105, 0.8) !important;
  color: #f1f5f9 !important;
}

.modebar-btn.active {
  background-color: #3b82f6 !important;
  color: white !important;
}

/* Fullscreen chart styles */
.chart-card:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  background-color: var(--bg-primary) !important;
  border: none !important;
  border-radius: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}

.chart-card:fullscreen .chart-card__header {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-primary);
}

.chart-card:fullscreen .chart-card__content {
  flex: 1;
  display: flex;
  flex-direction: row !important; /* Горизонтальное расположение вместо колонки */
  padding: var(--space-2);
  min-height: 0;
  height: calc(100vh - 80px); /* Вычитаем высоту header и meta */
  gap: var(--space-4);
}

.chart-card:fullscreen .chart-card__plot {
  flex: 1 !important;
  width: calc(100% - 270px) !important; /* Учитываем ширину настроек + gap */
  height: 100% !important;
  min-height: 0 !important;
}

.chart-card:fullscreen .chart-card__settings {
  width: 250px !important;
  flex-shrink: 0 !important;
  height: 100% !important; /* Занимает всю доступную высоту */
  max-height: none !important; /* Убираем ограничение высоты */
  overflow-y: auto !important;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
}

.chart-card:fullscreen .chart-card__plot .js-plotly-plot {
  width: 100% !important;
  height: 100% !important;
}

.chart-card:fullscreen .chart-card__plot .plotly .svg-container {
  width: 100% !important;
  height: 100% !important;
}

/* Plotly specific fullscreen adjustments */
.chart-card:fullscreen .chart-card__plot .plotly {
  width: 100% !important;
  height: 100% !important;
}

/* Force Plotly to use full available height in fullscreen */
.chart-card:fullscreen .chart-card__plot .js-plotly-plot,
.chart-card:fullscreen .chart-card__plot .js-plotly-plot > div {
  height: calc(100vh - 120px) !important; /* Вычитаем высоту header + padding + meta */
  min-height: calc(100vh - 120px) !important;
}

.chart-card:fullscreen .chart-card__meta {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border-primary);
}

/* Chart loading state */
.chart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  flex-direction: column;
  gap: var(--space-4);
}

.chart-loading__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-primary);
  border-top: 3px solid var(--color-primary-500);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
}

.chart-loading__text {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
}

/* Chart error state */
.chart-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  flex-direction: column;
  gap: var(--space-3);
  text-align: center;
  padding: var(--space-6);
}

.chart-error__icon {
  width: 48px;
  height: 48px;
  color: var(--color-error-500);
}

.chart-error__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.chart-error__message {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  max-width: 300px;
  line-height: var(--line-height-relaxed);
}

/* Chart animations */
@keyframes chartFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chart-card--animated {
  animation: chartFadeIn 0.5s ease;
}

/* Plotly theme customization */
.chart-card .js-plotly-plot {
  border-radius: 0;
  overflow: hidden;
}

/* Custom scrollbar for chart containers */
.chart-card__content::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.chart-card__content::-webkit-scrollbar-track {
  background-color: var(--bg-primary);
  border-radius: var(--radius-full);
}

.chart-card__content::-webkit-scrollbar-thumb {
  background-color: var(--border-secondary);
  border-radius: var(--radius-full);
  border: 1px solid var(--bg-primary);
}

.chart-card__content::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-tertiary);
}

/* Responsive chart adjustments */
@media (max-width: 768px) {
  .chart-card__plot {
    height: 320px !important;
    min-height: 300px;
  }

  .chart-card__content {
    min-height: 350px;
  }

  .chart-loading,
  .chart-error {
    min-height: 320px;
  }
}

/* Chart grid responsive behavior */
@media (max-width: 1200px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1400px) {
  .charts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1800px) {
  .charts-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Print styles */
@media print {
  .chart-card__header,
  .chart-card__meta,
  .modebar {
    display: none !important;
  }

  .chart-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .chart-card__content {
    padding: 0;
  }
}
/* Keyboard shortcuts display */
.chart-card__shortcuts {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.chart-card__shortcuts kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 10px;
  font-family: 'Monaco', 'Courier New', monospace;
  font-weight: 600;
  line-height: 1;
  color: #1e293b;
  background: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 100%);
  border: 1px solid #94a3b8;
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 0 0 2px #1e293b inset;
  white-space: nowrap;
}
