:root {
  /* Light theme colors */
  --primary-color: #ff6b35;
  --secondary-color: #f7931e;
  --accent-color: #ffca28;
  --background-primary: #ffffff;
  --background-secondary: #f8fafc;
  --background-tertiary: #e2e8f0;
  --text-primary: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --border-color: #e2e8f0;
  --shadow-light: rgba(0, 0, 0, 0.1);
  --shadow-medium: rgba(0, 0, 0, 0.15);
  --shadow-heavy: rgba(0, 0, 0, 0.25);
  
  /* Glass morphism */
  --glass-bg: rgba(255, 255, 255, 0.15);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
  --gradient-secondary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-accent: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-surface: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
}

[data-theme="dark"] {
  --background-primary: #0f172a;
  --background-secondary: #1e293b;
  --background-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --shadow-light: rgba(0, 0, 0, 0.3);
  --shadow-medium: rgba(0, 0, 0, 0.4);
  --shadow-heavy: rgba(0, 0, 0, 0.6);
  --glass-bg: rgba(15, 23, 42, 0.15);
  --glass-border: rgba(255, 255, 255, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--background-primary);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-x: hidden;
}

/* Enhanced background with moving particles */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 50%, rgba(255, 107, 53, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(247, 147, 30, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 40% 80%, rgba(255, 202, 40, 0.1) 0%, transparent 50%);
  z-index: -1;
  animation: backgroundShift 20s ease-in-out infinite;
}

@keyframes backgroundShift {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Header improvements */
.header-controls {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  gap: 12px;
}

.theme-toggle, .menu-toggle {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--glass-shadow);
}

.theme-toggle:hover, .menu-toggle:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 40px rgba(31, 38, 135, 0.5);
}

/* Hero section redesign */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--gradient-primary);
}

.hero-image {
  position: absolute;
  width: 120%;
  height: 120%;
  object-fit: cover;
  filter: blur(2px) brightness(0.3) contrast(1.2);
  animation: slowZoom 30s ease-in-out infinite alternate;
}

@keyframes slowZoom {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

.hero-content {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 900px;
  padding: 0 2rem;
  animation: fadeInUp 1s ease-out;
}

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

.hero-content h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 800;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  line-height: 1.2;
}

.hero-content p {
  font-size: clamp(1.1rem, 2.5vw, 1.3rem);
  margin-bottom: 2rem;
  color: rgba(255, 255, 255, 0.9);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 3rem;
  flex-wrap: wrap;
}

.stat-item {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 1.5rem;
  text-align: center;
  min-width: 140px;
  animation: fadeInUp 1s ease-out;
  animation-delay: 0.3s;
  animation-fill-mode: both;
}

.stat-number {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-color);
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
}

/* Navigation */
.nav-menu {
  position: fixed;
  top: 0;
  right: -300px;
  width: 300px;
  height: 100vh;
  background: var(--glass-bg);
  backdrop-filter: blur(30px);
  border-left: 1px solid var(--glass-border);
  z-index: 999;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 2rem;
}

.nav-menu.active {
  right: 0;
}

.nav-menu ul {
  list-style: none;
  padding-top: 2rem;
}

.nav-menu li {
  margin-bottom: 1rem;
}

.nav-menu a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  display: block;
  transition: all 0.3s ease;
}

.nav-menu a:hover {
  background: var(--gradient-primary);
  color: white;
  transform: translateX(5px);
}

/* Container and sections */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

.section {
  margin-bottom: 6rem;
  animation: fadeInUp 0.8s ease-out;
}

.section-header {
  text-align: center;
  margin-bottom: 3rem;
}

.section h2 {
  font-size: clamp(2rem, 4vw, 2.5rem);
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
  position: relative;
}

.section h2::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 4px;
  background: var(--gradient-primary);
  border-radius: 2px;
}

/* Cards and glass morphism */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--glass-shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-primary);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 60px rgba(31, 38, 135, 0.4);
}

.card:hover::before {
  transform: translateX(0);
}

/* Enhanced tables */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px var(--shadow-light);
  background: var(--background-primary);
}

.data-table th {
  background: var(--gradient-primary);
  color: white;
  padding: 1rem;
  font-weight: 600;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.data-table tr:hover td {
  background: var(--background-secondary);
  transform: scale(1.01);
}

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

/* Price indicators */
.price {
  font-weight: 600;
  color: var(--primary-color);
  position: relative;
}

.price.high {
  color: #e53e3e;
}

.price.low {
  color: #38a169;
}

.price.medium {
  color: var(--secondary-color);
}

.price-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  margin-left: 0.5rem;
}

.trend-up {
  color: #e53e3e;
}

.trend-down {
  color: #38a169;
}

/* Charts container */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
  margin: 2rem 0;
}

.chart-container {
  position: relative; /* Required for chart.js responsiveness */
  height: 400px; /* Set an explicit height to prevent vertical stretching */
  background: var(--background-primary);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px var(--shadow-light);
  display: flex; /* Using flex to manage children */
  flex-direction: column; /* Stack title and chart vertically */
}

.chart-container h3 {
  margin-bottom: 1rem;
  text-align: center;
  flex-shrink: 0; /* Prevent title from shrinking */
}

/* New wrapper for the canvas for better size control */
.canvas-wrapper {
  position: relative;
  flex-grow: 1; /* Allow canvas wrapper to fill remaining space */
}

/* Search and filters */
.search-filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  align-items: center;
}

.search-input, .filter-select {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--background-primary);
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.3s ease;
  min-width: 200px;
}

.search-input:focus, .filter-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
  transform: translateY(-1px);
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
}

.btn-secondary {
  background: var(--background-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 107, 53, 0.3);
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.btn:hover::before {
  left: 100%;
}

/* Currency converter widget */
.currency-widget {
  background: var(--gradient-secondary);
  border-radius: 20px;
  padding: 2rem;
  color: white;
  margin: 2rem 0;
}

.currency-converter {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

.currency-input {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 1rem;
  color: white;
  font-size: 1.1rem;
  text-align: center;
}

.currency-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.swap-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.swap-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(180deg);
}

/* Details/Accordion enhanced */
details {
  margin: 1rem 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--background-primary);
  box-shadow: 0 2px 10px var(--shadow-light);
  transition: all 0.3s ease;
}

details[open] {
  box-shadow: 0 8px 30px var(--shadow-medium);
}

details summary {
  padding: 1.5rem;
  background: var(--gradient-surface);
  cursor: pointer;
  font-weight: 600;
  font-size: 1.1rem;
  border: none;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.3s ease;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::after {
  content: '▶';
  transition: transform 0.3s ease;
  color: var(--primary-color);
}

details[open] summary::after {
  transform: rotate(90deg);
}

details summary:hover {
  background: var(--gradient-primary);
  color: white;
}

/* Footer */
footer {
  background: var(--background-secondary);
  padding: 3rem 0;
  text-align: center;
  border-top: 1px solid var(--border-color);
  margin-top: 4rem;
}

/* Animations */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.pulse {
  animation: pulse 2s infinite;
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Loading spinner */
.loading {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive design */
@media (max-width: 768px) {
  .container {
    padding: 2rem 1rem;
  }
  
  .hero-stats {
    flex-direction: column;
    align-items: center;
  }
  
  .search-filters {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-input, .filter-select {
    min-width: unset;
    width: 100%;
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .currency-converter {
    grid-template-columns: 1fr;
  }
  
  .data-table {
    font-size: 0.9rem;
  }
  
  .data-table th,
  .data-table td {
    padding: 0.75rem 0.5rem;
  }
}

@media (max-width: 480px) {
  .header-controls {
    top: 10px;
    right: 10px;
  }
  
  .hero-content {
    padding: 0 1rem;
  }
  
  .data-table {
    font-size: 0.8rem;
  }
}