/* CryptoTracker Design System */
:root {
  /* Dark theme (default) */
  --bg-primary: #0a0f1e;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.8);
  --bg-hover: rgba(17, 24, 39, 0.6);
  --bg-glass: rgba(17, 24, 39, 0.6);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #22d3ee;
  --accent-secondary: #06b6d4;
  --accent-glow: rgba(34, 211, 238, 0.3);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --danger: #f43f5e;
  --danger-bg: rgba(244, 63, 94, 0.15);

  --border-color: rgba(148, 163, 184, 0.1);
  --border-focus: var(--accent-primary);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px var(--accent-glow);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-hover: rgba(6, 182, 212, 0.1);
  --bg-glass: rgba(255, 255, 255, 0.7);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --accent-primary: #0891b2;
  --accent-secondary: #06b6d4;
  --accent-glow: rgba(6, 182, 212, 0.2);

  --border-color: rgba(15, 23, 42, 0.1);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-secondary);
}

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

img {
  max-width: 100%;
  height: auto;
}

/* Typography */
h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.5rem); }

/* Utility Classes */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}

@media (min-width: 768px) {
  .container { padding: 0 2rem; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: var(--bg-primary);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 40px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem;
}

.btn-ghost:hover {
  color: var(--accent-primary);
  background: var(--bg-hover);
}

/* ========== LANDING PAGE ========== */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-primary);
}

.hero-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.hero-gradient {
  position: absolute;
  width: 150%;
  height: 150%;
  top: -25%;
  left: -25%;
  background: 
    radial-gradient(ellipse at 30% 20%, rgba(34, 211, 238, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(6, 182, 212, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(34, 211, 238, 0.05) 0%, transparent 70%);
  animation: pulse-bg 8s ease-in-out infinite;
}

@keyframes pulse-bg {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

.hero-grid {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(34, 211, 238, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  animation: grid-move 20s linear infinite;
}

@keyframes grid-move {
  0% { transform: translateY(0); }
  100% { transform: translateY(60px); }
}

.hero-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--accent-primary);
  border-radius: 50%;
  opacity: 0.6;
  animation: float-up 15s linear infinite;
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; animation-duration: 12s; }
.particle:nth-child(2) { left: 20%; animation-delay: 2s; animation-duration: 14s; }
.particle:nth-child(3) { left: 30%; animation-delay: 4s; animation-duration: 11s; }
.particle:nth-child(4) { left: 40%; animation-delay: 1s; animation-duration: 16s; }
.particle:nth-child(5) { left: 50%; animation-delay: 3s; animation-duration: 13s; }
.particle:nth-child(6) { left: 60%; animation-delay: 5s; animation-duration: 15s; }
.particle:nth-child(7) { left: 70%; animation-delay: 2s; animation-duration: 12s; }
.particle:nth-child(8) { left: 80%; animation-delay: 4s; animation-duration: 14s; }
.particle:nth-child(9) { left: 90%; animation-delay: 1s; animation-duration: 11s; }

@keyframes float-up {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 0.6;
  }
  90% {
    opacity: 0.6;
  }
  100% {
    transform: translateY(-100px) scale(1);
    opacity: 0;
  }
}

.hero-content {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 2rem;
  max-width: 800px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  backdrop-filter: blur(10px);
  animation: fade-in-up 0.8s ease-out;
}

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

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

.hero-title {
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 1.5rem;
  animation: fade-in-up 0.8s ease-out 0.2s backwards;
}

.hero-title-gradient {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary), #fff);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 5s ease infinite;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.hero-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
  animation: fade-in-up 0.8s ease-out 0.4s backwards;
}

.hero-cta {
  animation: fade-in-up 0.8s ease-out 0.6s backwards;
}

.hero-cta .btn {
  padding: 1rem 2.5rem;
  font-size: 1.125rem;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-crypto-icons {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.crypto-icon-float {
  position: absolute;
  width: 50px;
  height: 50px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  backdrop-filter: blur(5px);
  animation: float 6s ease-in-out infinite;
}

.crypto-icon-float:nth-child(1) { top: 15%; left: 10%; animation-delay: 0s; }
.crypto-icon-float:nth-child(2) { top: 25%; right: 15%; animation-delay: 1s; }
.crypto-icon-float:nth-child(3) { bottom: 30%; left: 8%; animation-delay: 2s; }
.crypto-icon-float:nth-child(4) { bottom: 20%; right: 10%; animation-delay: 1.5s; }
.crypto-icon-float:nth-child(5) { top: 60%; left: 15%; animation-delay: 0.5s; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(5deg); }
}

/* ========== HEADER ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
}

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

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

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-primary);
  font-weight: 700;
}

.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  transition: all var(--transition-fast);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

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

.theme-toggle {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* ========== MARKETS PAGE ========== */
.page-markets {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.markets-content {
  flex: 1;
  padding: 1.5rem 0 3rem;
}

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

.markets-title {
  font-size: 1.5rem;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  background: var(--success-bg);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  color: var(--success);
  font-weight: 500;
}

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

.last-updated {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.rate-limit-warning {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--danger-bg);
  border: 1px solid rgba(244, 63, 94, 0.3);
  border-radius: var(--radius-md);
  color: var(--danger);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* Table Styles */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.crypto-table {
  width: 100%;
  border-collapse: collapse;
}

.crypto-table th,
.crypto-table td {
  padding: 1rem;
  text-align: left;
}

.crypto-table th {
  background: var(--bg-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.crypto-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.crypto-table tbody tr:last-child {
  border-bottom: none;
}

.crypto-table tbody tr:hover {
  background: var(--bg-hover);
}

.crypto-table tbody tr:focus-within {
  background: var(--bg-hover);
}

.coin-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.coin-rank {
  font-size: 0.875rem;
  color: var(--text-muted);
  min-width: 24px;
}

.coin-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-secondary);
}

.coin-info {
  display: flex;
  flex-direction: column;
}

.coin-name {
  font-weight: 600;
  color: var(--text-primary);
}

.coin-symbol {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.coin-price {
  font-weight: 600;
  font-family: var(--font-mono);
}

.coin-change {
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

.coin-change.positive {
  color: var(--success);
  background: var(--success-bg);
}

.coin-change.negative {
  color: var(--danger);
  background: var(--danger-bg);
}

.coin-marketcap {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

/* Responsive Table */
@media (max-width: 768px) {
  .crypto-table th:nth-child(4),
  .crypto-table td:nth-child(4) {
    display: none;
  }

  .crypto-table th,
  .crypto-table td {
    padding: 0.75rem 0.5rem;
  }

  .coin-icon {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 480px) {
  .coin-rank {
    display: none;
  }
}

/* Load More */
.load-more-wrapper {
  display: flex;
  justify-content: center;
  padding: 2rem 0;
}

.btn-load-more {
  min-width: 200px;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 0%,
    var(--bg-hover) 50%,
    var(--bg-secondary) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

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

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.skeleton-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.skeleton-text {
  height: 16px;
}

.skeleton-text-sm {
  height: 12px;
}

/* Error State */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.error-icon {
  width: 64px;
  height: 64px;
  background: var(--danger-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  color: var(--danger);
}

.error-title {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.error-message {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* ========== COIN DETAILS PAGE ========== */
.page-coin {
  min-height: 100vh;
  padding: 2rem 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-bottom: 2rem;
  transition: color var(--transition-fast);
}

.back-link:hover {
  color: var(--accent-primary);
}

.coin-header {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.coin-header-icon {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

.coin-header-info {
  flex: 1;
}

.coin-header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.coin-header-name {
  font-size: 2rem;
  font-weight: 800;
}

.coin-header-symbol {
  padding: 0.25rem 0.75rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.coin-header-price {
  font-size: 2.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
  margin-top: 0.5rem;
}

.coin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  backdrop-filter: blur(10px);
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.coin-description {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(10px);
}

.coin-description h3 {
  margin-bottom: 1rem;
}

.coin-description-text {
  color: var(--text-secondary);
  line-height: 1.8;
}

.coin-description-text a {
  color: var(--accent-primary);
}

.coin-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

/* ========== FOOTER ========== */
.footer {
  padding: 2rem 0;
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.footer a {
  color: var(--text-secondary);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .logo {
    justify-content: center;
  }

  .search-wrapper {
    max-width: none;
    order: 3;
  }

  .header-actions {
    justify-content: center;
  }

  .hero-title {
    font-size: 2.5rem;
  }

  .crypto-icon-float {
    display: none;
  }

  .coin-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .coin-header-title {
    justify-content: center;
  }
}

/* ========== ACCESSIBILITY ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Hidden but accessible */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
