/* ==========================================
   TIMESERIES CHART - GLASSMORPHIC STYLE
   ========================================== */

.timeseries-container {
  width: 100%;
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
  align-items: center;
}

/* ==========================================
   CONTROLS PANEL
   ========================================== */

.controls-panel {
  width: 100%;
  max-width: 950px;
  background: var(--bgGlass);
  backdrop-filter: blur(var(--blur-lg));
  -webkit-backdrop-filter: blur(var(--blur-lg));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: 0 4px 24px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.control-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--textSecondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.button-group {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.filter-button {
  padding: var(--spacing-sm) var(--spacing-lg);
  background: var(--bgGlassDark);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--textSecondary);
  font-size: 14px;
  font-weight: 500;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
}

.filter-button:hover {
  background: var(--bgGlassHover);
  border-color: var(--borderHover);
  color: var(--textPrimary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow);
}

.filter-button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.filter-button:active {
  transform: translateY(0);
}

.year-controls {
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.year-selector {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.year-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--textSecondary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.year-select {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bgGlassDark);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--textPrimary);
  font-size: 14px;
  font-weight: 500;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  min-width: 80px;
}

.year-select:hover {
  background: var(--bgGlassHover);
  border-color: var(--borderHover);
}

.year-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.year-select option {
  background: var(--bgPrimary);
  color: var(--textPrimary);
}

/* ==========================================
   CHART AND DETAILS LAYOUT
   ========================================== */

.chart-and-details {
  width: 100%;
  max-width: 950px;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.chart-wrapper {
  background: var(--bgGlass);
  backdrop-filter: blur(var(--blur-lg));
  -webkit-backdrop-filter: blur(var(--blur-lg));
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  box-shadow: 0 8px 32px var(--shadow);
  transition: all 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.chart-wrapper:hover {
  background: var(--bgGlassHover);
  border-color: var(--borderHover);
  box-shadow: 0 12px 48px var(--shadow);
}

/* ==========================================
   DETAILS PANEL
   ========================================== */

.details-panel {
  background: var(--bgGlass);
  backdrop-filter: blur(var(--blur-lg));
  -webkit-backdrop-filter: blur(var(--blur-lg));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: 0 8px 32px var(--shadow);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.details-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border);
}

.details-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--textPrimary);
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  flex: 1;
}

.details-color-indicator {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: 0 0 12px currentColor;
}

.details-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.stat-card {
  background: var(--bgGlassDark);
  padding: var(--spacing-md);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  transition: all 0.3s ease;
}

.stat-card:hover {
  background: var(--bgGlassHover);
  border-color: var(--borderHover);
  transform: translateY(-2px);
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--textMuted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--textPrimary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.details-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.details-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.details-table thead {
  background: var(--bgGlassDark);
}

.details-table th {
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--textSecondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.details-table td {
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 14px;
  color: var(--textSecondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.details-table tbody tr {
  transition: all 0.2s ease;
}

.details-table tbody tr:hover {
  background: var(--bgGlassHover);
}

.details-table tbody tr.highlighted {
  background: rgba(99, 102, 241, 0.2);
  color: var(--textPrimary);
}

.details-table tbody tr.highlighted td {
  color: var(--textPrimary);
  font-weight: 500;
}

.close-details-button {
  width: 100%;
  margin-top: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bgGlassDark);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--textSecondary);
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
}

.close-details-button:hover {
  background: var(--bgGlassHover);
  border-color: var(--borderHover);
  color: var(--textPrimary);
}

/* ==========================================
   SVG CHART ELEMENTS
   ========================================== */

.chart-svg {
  display: block;
  max-width: 100%;
  height: auto;
}

.chart-background {
  fill: url(#chartBg);
  opacity: 0.3;
}

.gradient-stop-start {
  stop-color: var(--bgSecondary);
  stop-opacity: 0.1;
}

.gradient-stop-end {
  stop-color: var(--bgPrimary);
  stop-opacity: 0.05;
}

.interaction-area {
  fill: transparent;
  cursor: crosshair;
}

/* ==========================================
   AXES & GRID
   ========================================== */

.axis-line {
  stroke: var(--border);
  stroke-width: 2;
  opacity: 0.6;
}

.tick-line {
  stroke: var(--border);
  stroke-width: 1.5;
  opacity: 0.5;
}

.tick-label {
  fill: var(--textSecondary);
  font-size: 11px;
  font-weight: 500;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  user-select: none;
}

.grid-line {
  stroke: var(--border);
  stroke-width: 1;
  opacity: 0.15;
  stroke-dasharray: 4 4;
}

/* ==========================================
   DATA LINES
   ========================================== */

.line-group {
  transition: opacity 0.3s ease;
}

.line-path-glow {
  fill: none;
  stroke-width: 8;
  opacity: 0.2;
  filter: blur(4px);
  transition: opacity 0.3s ease;
}

.line-path-glow.highlighted {
  opacity: 0.4;
  stroke-width: 10;
}

.line-path {
  fill: none;
  stroke-width: 3;
  opacity: 0.9;
  transition: all 0.3s ease;
  filter: drop-shadow(0 0 4px currentColor);
}

.line-path:hover,
.line-path.highlighted {
  stroke-width: 4;
  opacity: 1;
  filter: drop-shadow(0 0 8px currentColor);
}

/* ==========================================
   TOOLTIP
   ========================================== */

.tooltip-group {
  pointer-events: none;
  animation: tooltipFadeIn 0.2s ease;
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tooltip-circle-outer {
  opacity: 0.3;
  filter: blur(2px);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    r: 6;
    opacity: 0.3;
  }
  50% {
    r: 8;
    opacity: 0.5;
  }
}

.tooltip-circle-inner {
  filter: drop-shadow(0 0 6px currentColor);
}

.tooltip-background {
  fill: var(--bgGlass);
  stroke: var(--border);
  stroke-width: 1.5;
  rx: var(--radius-md);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  filter: drop-shadow(0 4px 16px var(--shadow));
}

.tooltip-text-title {
  fill: var(--textPrimary);
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  user-select: none;
}

.tooltip-text-detail {
  fill: var(--textSecondary);
  font-size: 12px;
  font-weight: 400;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  user-select: none;
}

/* ==========================================
   STATUS MESSAGES
   ========================================== */

.loading-message,
.error-message,
.no-data-message {
  padding: var(--spacing-xl);
  border-radius: var(--radius-lg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  border: 1px solid var(--border);
}

.loading-message {
  background: var(--bgGlass);
  color: var(--textSecondary);
  animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

.error-message {
  background: rgba(220, 38, 38, 0.1);
  color: #fca5a5;
  border-color: rgba(220, 38, 38, 0.3);
}

.no-data-message {
  background: var(--bgGlass);
  color: var(--textMuted);
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 1024px) {
  .timeseries-container {
    padding: var(--spacing-md);
  }

  .controls-panel {
    padding: var(--spacing-md);
  }

  .chart-wrapper {
    padding: var(--spacing-lg);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .details-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .timeseries-container {
    padding: var(--spacing-sm);
  }

  .controls-panel {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
  }

  .button-group {
    width: 100%;
  }

  .filter-button {
    flex: 1;
    min-width: 70px;
  }

  .year-controls {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  .year-selector {
    width: 100%;
  }

  .year-select {
    flex: 1;
  }

  .chart-wrapper {
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .chart-svg {
    min-width: 600px;
  }

  .tick-label {
    font-size: 10px;
  }

  .tooltip-text-title {
    font-size: 12px;
  }

  .tooltip-text-detail {
    font-size: 11px;
  }

  .details-panel {
    padding: var(--spacing-md);
  }

  .details-title {
    font-size: 16px;
  }

  .details-stats {
    grid-template-columns: 1fr;
  }

  .stat-value {
    font-size: 18px;
  }

  .details-table th,
  .details-table td {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 12px;
  }
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */

@media (prefers-reduced-motion: reduce) {
  .chart-wrapper,
  .line-path,
  .line-path-glow,
  .tooltip-group {
    transition: none;
    animation: none;
  }

  .tooltip-circle-outer {
    animation: none;
  }

  .loading-message {
    animation: none;
  }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
  .chart-wrapper {
    background: white;
    border: 1px solid #000;
    box-shadow: none;
  }

  .chart-background {
    fill: white;
  }

  .axis-line,
  .tick-line {
    stroke: #000;
  }

  .tick-label {
    fill: #000;
  }
}
