/**
 * Shared Theme Styles for Bitcoin Charts
 * Use this file to ensure consistent light/dark mode across all charts
 * 
 * Usage: <link rel="stylesheet" href="/shared-theme.css">
 */

:root {
  /* Light theme - Professional White with subtle gradients */
  --bg-gradient-start: #f8fafc;
  --bg-gradient-end: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-inverse: #ffffff;
  
  /* Card backgrounds with transparency for depth */
  --card-bg: rgba(255, 255, 255, 0.9);
  --card-border: rgba(226, 232, 240, 0.8);
  --metric-bg: rgba(248, 250, 252, 0.9);
  --chart-bg: rgba(255, 255, 255, 0.95);
  
  /* Button states */
  --btn-bg: rgba(255, 255, 255, 0.9);
  --btn-hover: rgba(245, 245, 245, 1);
  --btn-active: rgba(59, 130, 246, 0.1);
  
  /* Accent colors */
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  
  /* Chart specific */
  --chart-text: #333333;
  --chart-grid: rgba(197, 203, 206, 0.4);
}

[data-theme="dark"] {
  /* Dark theme - Deep Navy with blue undertones */
  --bg-gradient-start: #0f172a;
  --bg-gradient-end: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-inverse: #ffffff;
  
  /* Card backgrounds with transparency for depth */
  --card-bg: rgba(30, 41, 59, 0.9);
  --card-border: rgba(51, 65, 85, 0.8);
  --metric-bg: rgba(30, 41, 59, 0.9);
  --chart-bg: rgba(31, 41, 59, 0.95);
  
  /* Button states */
  --btn-bg: rgba(51, 65, 85, 0.9);
  --btn-hover: rgba(71, 85, 105, 1);
  --btn-active: rgba(59, 130, 246, 0.2);
  
  /* Accent colors - brighter for dark mode */
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  
  /* Chart specific */
  --chart-text: #e0e0e0;
  --chart-grid: rgba(255, 255, 255, 0.1);
}

/* Base styles that apply to all themes */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Standard metric card styles */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.metric-card {
  background: var(--metric-bg);
  border: 2px solid var(--card-border);
  border-radius: 12px;
  padding: 20px;
  backdrop-filter: blur(10px);
}

.metric-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Standard chart container */
.chart-container {
  position: relative;
  background: var(--chart-bg);
  border: 2px solid var(--card-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 30px;
  backdrop-filter: blur(10px);
}

/* Standard button styles */
.timespan-btn {
  padding: 8px 20px;
  background: var(--btn-bg);
  border: 2px solid var(--card-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.timespan-btn:hover {
  background: var(--btn-hover);
  border-color: var(--accent);
}

.timespan-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Standard Chart Series Styles */
/* IMPORTANT: Always use gradient fill for Bitcoin price series */
/* Bitcoin Price - Orange Gradient (use addAreaSeries) */
.bitcoin-price-series {
  /* Reference for Lightweight Charts addAreaSeries config: */
  topColor: rgba(255, 149, 0, 0.4);
  bottomColor: rgba(255, 149, 0, 0.0);
  lineColor: #FF9500;
  lineWidth: 2;
}

/* Example JavaScript usage:
  btcSeries = chart.addAreaSeries({
    topColor: 'rgba(255, 149, 0, 0.4)',
    bottomColor: 'rgba(255, 149, 0, 0.0)',
    lineColor: '#FF9500',
    lineWidth: 2,
    title: 'Bitcoin Price',
  });
*/

/* Loading Indicator - Unified across all charts */
.chart-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 8px;
  transition: opacity 0.2s ease;
}

[data-theme="dark"] .chart-loading-overlay {
  background: rgba(15, 23, 42, 0.8);
}

.chart-loading-overlay.show {
  display: flex;
  animation: fadeIn 0.2s ease;
}

@media (max-width: 768px) {
  .metrics-grid {
    gap: 12px;
  }

  .metric-card {
    padding: 16px;
  }

  .chart-container {
    padding: 14px;
    margin-bottom: 22px;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.chart-loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 149, 0, 0.2);
  border-top-color: #FF9500;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.chart-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.chart-loading-text {
  margin-top: 15px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

/* JavaScript helper functions to use:
  
  function showChartLoading() {
    const overlay = document.getElementById('chart-loading');
    if (overlay) overlay.classList.add('show');
  }
  
  function hideChartLoading() {
    const overlay = document.getElementById('chart-loading');
    if (overlay) overlay.classList.remove('show');
  }
*/

/* Metrics Card - Standardized across all charts */
.metric-card {
  background: var(--metric-bg);
  border: 2px solid var(--card-border);
  border-radius: 12px;
  padding: 20px;
  backdrop-filter: blur(10px);
}

.metric-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
}
