/* ===== CHART SECTION - FINANCIAL TERMINAL AESTHETIC ===== */

/* Chart Section Container */
.chart-section {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
  border: 1px solid rgba(184, 134, 11, 0.12);
  box-shadow: var(--shadow-elevated);
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.6s ease-out 0.3s both;
}

/* Animated top border - gold pulse effect */
.chart-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--gold-400) 15%,
    var(--gold-500) 50%,
    var(--gold-400) 85%,
    transparent 100%
  );
  animation: chart-border-pulse 3s ease-in-out infinite;
}

@keyframes chart-border-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Chart Header */
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--bg-tertiary);
  position: relative;
  z-index: 2;
}

.chart-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: var(--space-xs);
}

.chart-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.chart-period-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(135deg,
    rgba(184, 134, 11, 0.1),
    rgba(184, 134, 11, 0.05)
  );
  border: 1px solid rgba(184, 134, 11, 0.25);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gold-700);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  box-shadow: 0 2px 8px rgba(184, 134, 11, 0.08);
  transition: all 0.3s ease;
}

.chart-period-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(184, 134, 11, 0.15);
}

/* Chart Metrics Grid */
.chart-metrics {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  position: relative;
  z-index: 2;
}

/* Primary Metric (Current Price) */
.metric-primary {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: linear-gradient(135deg,
    rgba(184, 134, 11, 0.06) 0%,
    rgba(184, 134, 11, 0.02) 100%
  );
  border-radius: var(--radius-lg);
  border: 1px solid rgba(184, 134, 11, 0.12);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.metric-primary:hover {
  border-color: rgba(184, 134, 11, 0.2);
  box-shadow: 0 4px 16px rgba(184, 134, 11, 0.1);
}

/* Decorative corner accent */
.metric-primary::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, transparent 50%, rgba(184, 134, 11, 0.08) 50%);
  border-bottom-right-radius: var(--radius-lg);
  pointer-events: none;
}

.metric-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.metric-value-large {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 700;
  background: linear-gradient(135deg,
    var(--gold-800) 0%,
    var(--gold-600) 50%,
    var(--gold-500) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  letter-spacing: -0.03em;
  animation: metric-reveal 0.8s ease-out;
}

@keyframes metric-reveal {
  from {
    opacity: 0;
    transform: translateY(10px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

.metric-change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.875rem;
  font-weight: 700;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  width: fit-content;
  letter-spacing: 0.02em;
  transition: all 0.3s ease;
}

.metric-change.positive {
  color: var(--accent-success);
  background: linear-gradient(135deg,
    rgba(45, 122, 62, 0.12),
    rgba(45, 122, 62, 0.06)
  );
  border: 1px solid rgba(45, 122, 62, 0.2);
}

.metric-change.negative {
  color: var(--accent-danger);
  background: linear-gradient(135deg,
    rgba(197, 48, 48, 0.12),
    rgba(197, 48, 48, 0.06)
  );
  border: 1px solid rgba(197, 48, 48, 0.2);
}

.metric-change:hover {
  transform: scale(1.05);
}

/* Secondary Metrics (High/Low) */
.metric-secondary {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: var(--space-lg);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--bg-tertiary);
  transition: all 0.3s ease;
}

.metric-secondary:hover {
  background: var(--bg-primary);
  border-color: rgba(184, 134, 11, 0.1);
}

.metric-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  flex: 1;
  transition: transform 0.3s ease;
}

.metric-item:hover {
  transform: scale(1.05);
}

.metric-value {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  transition: color 0.3s ease;
}

.metric-item:hover .metric-value {
  color: var(--gold-700);
}

.metric-divider {
  width: 1px;
  height: 44px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(184, 134, 11, 0.25) 50%,
    transparent 100%
  );
}

/* Chart Visual Wrapper */
.chart-visual-wrapper {
  position: relative;
  margin-bottom: var(--space-md);
  z-index: 2;
}

.chart-canvas {
  width: 100%;
  height: 220px;
  background: linear-gradient(180deg,
    var(--bg-secondary) 0%,
    var(--bg-primary) 100%
  );
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--bg-tertiary);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-canvas:hover {
  border-color: rgba(184, 134, 11, 0.15);
  box-shadow: 0 4px 20px rgba(184, 134, 11, 0.08);
}

/* Grid lines for financial chart look */
.chart-canvas::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    linear-gradient(to right, rgba(184, 134, 11, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(184, 134, 11, 0.04) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 1;
}

/* SVG Chart Styles */
.chart-svg {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 2;
  display: block;
}

.chart-line {
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 2000;
  stroke-dashoffset: 2000;
  animation: chart-line-draw 2s ease-out forwards;
}

@keyframes chart-line-draw {
  to {
    stroke-dashoffset: 0;
  }
}

.chart-area {
  opacity: 0;
  animation: chart-area-fade-in 1s ease-out 0.8s forwards;
}

@keyframes chart-area-fade-in {
  to {
    opacity: 1;
  }
}

.chart-point {
  fill: #fff;
  stroke: #b8860b;
  stroke-width: 2.5;
  opacity: 0;
  animation: chart-point-appear 0.5s ease-out forwards;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.chart-point:nth-last-child(5) { animation-delay: 1.2s; }
.chart-point:nth-last-child(4) { animation-delay: 1.3s; }
.chart-point:nth-last-child(3) { animation-delay: 1.4s; }
.chart-point:nth-last-child(2) { animation-delay: 1.5s; }

@keyframes chart-point-appear {
  from {
    opacity: 0;
    transform: scale(0);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.chart-point:hover {
  r: 8;
  stroke-width: 3;
  filter: drop-shadow(0 4px 12px rgba(184, 134, 11, 0.5));
}

.chart-point-final {
  animation: chart-point-final-appear 0.6s ease-out 1.6s forwards;
  opacity: 0;
  transform-origin: center;
  filter: drop-shadow(0 2px 8px rgba(184, 134, 11, 0.4));
  transition: all 0.3s ease;
}

@keyframes chart-point-final-appear {
  from {
    opacity: 0;
    transform: scale(0);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.chart-point-final:hover {
  r: 9;
  stroke-width: 4;
  filter: drop-shadow(0 4px 16px rgba(184, 134, 11, 0.6));
}

/* Chart Footer */
.chart-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-md);
  border-top: 1px solid var(--bg-tertiary);
  position: relative;
  z-index: 2;
}

.chart-legend {
  display: flex;
  gap: var(--space-md);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: transform 0.2s ease;
}

.legend-item:hover {
  transform: translateX(4px);
}

.legend-dot {
  width: 8px;
  height: 8px;
  background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
  border-radius: var(--radius-full);
  box-shadow: 0 0 10px rgba(184, 134, 11, 0.4);
  animation: legend-pulse 2s ease-in-out infinite;
}

@keyframes legend-pulse {
  0%, 100% {
    box-shadow: 0 0 10px rgba(184, 134, 11, 0.4);
  }
  50% {
    box-shadow: 0 0 16px rgba(184, 134, 11, 0.6);
  }
}

.legend-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chart-trend {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(135deg,
    rgba(184, 134, 11, 0.06),
    rgba(184, 134, 11, 0.02)
  );
  border-radius: var(--radius-md);
  border: 1px solid rgba(184, 134, 11, 0.1);
  transition: all 0.3s ease;
}

.chart-trend:hover {
  border-color: rgba(184, 134, 11, 0.2);
  transform: translateY(-1px);
}

.trend-icon {
  font-size: 1rem;
  font-weight: bold;
  transition: transform 0.3s ease;
}

.chart-trend:hover .trend-icon {
  transform: scale(1.2);
}

.trend-icon.up {
  color: var(--accent-success);
}

.trend-icon.down {
  color: var(--accent-danger);
}

.trend-icon.neutral {
  color: var(--text-muted);
}

.trend-text {
  font-size: 0.8125rem;
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Responsive Design */
@media (max-width: 600px) {
  .chart-metrics {
    grid-template-columns: 1fr;
  }

  .metric-secondary {
    padding: var(--space-md);
  }

  .metric-value-large {
    font-size: 1.875rem;
  }

  .chart-canvas {
    height: 180px;
  }

  .chart-title {
    font-size: 1.25rem;
  }

  .chart-footer {
    flex-direction: column;
    gap: var(--space-sm);
    align-items: flex-start;
  }

  .chart-header {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .metric-value {
    font-size: 1.125rem;
  }
}

/* Loading State */
.chart-canvas.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg,
    var(--bg-secondary) 0%,
    var(--bg-primary) 100%
  );
}

.chart-canvas.loading::before {
  display: none;
}

.chart-canvas.loading::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--gold-500);
  border-radius: 50%;
  animation: chart-loading-spin 0.8s linear infinite;
}

@keyframes chart-loading-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Empty State */
.chart-canvas:empty:not(.loading) {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.chart-canvas:empty:not(.loading)::before {
  content: 'No chart data available';
  color: var(--text-muted);
  font-size: 0.875rem;
}
