/* Modern CSS with CSS Custom Properties for theming */
:root {
  /* Light theme colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --accent-primary: #3b82f6;
  --accent-secondary: #06b6d4;
  --success: #10b981;
  --border: #e2e8f0;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-accent: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
}

[data-theme="dark"] {
  /* Dark theme colors */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --accent-primary: #60a5fa;
  --accent-secondary: #22d3ee;
  --success: #34d399;
  --border: #334155;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
  --gradient-primary: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  --gradient-accent: linear-gradient(135deg, #60a5fa 0%, #22d3ee 100%);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: all 0.3s ease;
}

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

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-image {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.logo-image:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
}

.logo-text {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.theme-toggle {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.2rem;
}

.theme-toggle:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-toggle {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.2rem;
}

.info-toggle:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow);
}

/* Main Content */
.main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

/* Hero Section */
.hero {
  text-align: center;
  margin-bottom: 4rem;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-weight: 500;
}

/* Currency Toggle */
.currency-toggle {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  background: var(--bg-primary);
  padding: 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  max-width: 200px;
  margin-left: auto;
  margin-right: auto;
}

.currency-btn {
  background: transparent;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
}

.currency-btn:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.currency-btn.active {
  background: var(--accent-primary);
  color: white;
  box-shadow: var(--shadow);
}

.hidden {
  display: none;
}

/* Price Card */
.price-card {
  background: var(--bg-primary);
  border-radius: 24px;
  padding: 2rem;
  margin: 0 auto 2rem;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.price-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-accent);
}

.price-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

.price-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.price-label {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.price-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--success);
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.price-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.price-value {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.price-currency {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.price-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.price-source {
  background: var(--bg-secondary);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-weight: 500;
}

/* Price Cards Container */
.price-cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  max-width: 1000px;
  margin: 0 auto;
}

/* BCV Price Card Specific Styling */
#bcv-price-card::before {
  background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
}

.bcv-dot {
  background: var(--success) !important;
}

.bcv-dot::after {
  background: var(--success) !important;
}

/* Average Price Card Specific Styling */
#average-price-card::before {
  background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
}

.average-dot {
  background: #f59e0b !important;
}

.average-dot::after {
  background: #f59e0b !important;
}

/* Loading skeleton */
.loading-skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 8px;
  display: inline-block;
  min-width: 200px;
  height: 1em;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Chart Section */
.chart-section {
  margin-bottom: 4rem;
}

.chart-container {
  background: var(--bg-primary);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.chart-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-controls {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-secondary);
  padding: 0.25rem;
  border-radius: 12px;
}

.chart-btn {
  background: transparent;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.chart-btn:hover {
  color: var(--text-primary);
  background: var(--bg-primary);
}

.chart-btn.active {
  background: var(--accent-primary);
  color: white;
}

.chart-wrapper {
  position: relative;
  height: 400px;
}

#priceChart {
  border-radius: 12px;
}

.chart-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border-radius: 12px;
  gap: 1rem;
  color: var(--text-secondary);
}

.chart-loading.hidden {
  display: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-secondary);
  border-top: 3px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Footer */
.footer {
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
}

.footer-content p {
  color: var(--text-tertiary);
  margin-bottom: 0.5rem;
}

.footer-content a {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 500;
}

.footer-content a:hover {
  text-decoration: underline;
}

.footer-note {
  font-size: 0.875rem;
  opacity: 0.8;
  margin-bottom: 1rem;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.social-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: var(--bg-secondary);
}

.social-link:hover {
  color: var(--accent-primary);
  background: var(--bg-tertiary);
  transform: translateY(-1px);
  text-decoration: none;
}

.social-icon {
  font-size: 1rem;
}

/* Info Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: 12px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.info-section {
  margin-bottom: 2rem;
}

.info-section:last-child {
  margin-bottom: 0;
}

.info-section h4 {
  margin: 0 0 0.75rem 0;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-section p {
  margin: 0 0 0.75rem 0;
  color: var(--text-secondary);
  line-height: 1.6;
}

.info-section ul {
  margin: 0;
  padding-left: 1.5rem;
  color: var(--text-secondary);
}

.info-section li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.info-section li:last-child {
  margin-bottom: 0;
}

.search-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.term {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border);
}

/* Modal responsive design */
@media (max-width: 768px) {
  .modal-content {
    margin: 1rem;
    max-height: 95vh;
  }
  
  .modal-header,
  .modal-body {
    padding: 1rem;
  }
  
  .info-section {
    margin-bottom: 1.5rem;
  }
  
  .search-terms {
    gap: 0.25rem;
  }
  
  .term {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .main {
    padding: 1rem;
  }
  
  .header-content {
    padding: 1rem;
  }
  
  .logo-image {
    width: 36px;
    height: 36px;
  }
  
  .logo-text {
    font-size: 1.4rem;
  }
  
  .price-cards-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .price-card {
    margin: 0 0 2rem;
    padding: 1.5rem;
  }
  
  .chart-container {
    padding: 1rem;
  }
  
  .chart-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .chart-controls {
    justify-content: center;
  }
  
  .chart-wrapper {
    height: 300px;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 2rem;
  }
  
  .logo-image {
    width: 32px;
    height: 32px;
  }
  
  .logo-text {
    font-size: 1.2rem;
  }
  
  .price-cards-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .price-card {
    padding: 1rem;
    margin: 0 0 1.5rem;
  }
  
  .price-value {
    font-size: 2.5rem;
  }
  
  .chart-wrapper {
    height: 250px;
  }
}

/* Smooth transitions for theme switching */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Performance optimizations */
.price-card,
.chart-container {
  will-change: transform;
}

/* Focus styles for accessibility */
.theme-toggle:focus,
.chart-btn:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
