/* ============================================
   CryptoVision — Modern Dark Theme
   ============================================ */

:root {
  --bg-primary: #060712;
  --bg-secondary: #0d0f1a;
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-bg-hover: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-hover: rgba(255, 255, 255, 0.15);

  --accent-cyan: #00e5ff;
  --accent-purple: #a855f7;
  --accent-pink: #ec4899;
  --accent-green: #22c55e;
  --accent-red: #ef4444;

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

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  --shadow-glow-cyan: 0 0 30px rgba(0, 229, 255, 0.15);
  --shadow-glow-purple: 0 0 30px rgba(168, 85, 247, 0.15);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

a { color: var(--accent-cyan); text-decoration: none; }

/* ---- Animated Background Orbs ---- */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
  animation: orbFloat 20s ease-in-out infinite alternate;
}

.orb-1 {
  width: 400px; height: 400px;
  background: var(--accent-purple);
  top: -10%; left: -10%;
  animation-delay: 0s;
}

.orb-2 {
  width: 350px; height: 350px;
  background: var(--accent-cyan);
  bottom: -10%; right: -10%;
  animation-delay: -7s;
}

.orb-3 {
  width: 250px; height: 250px;
  background: var(--accent-pink);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
}

@keyframes orbFloat {
  0%   { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(30px, -40px) scale(1.1); }
  66%  { transform: translate(-20px, 20px) scale(0.95); }
  100% { transform: translate(10px, -10px) scale(1.05); }
}

/* ---- App Container ---- */
.app-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
}

/* ---- Header ---- */
.header {
  text-align: center;
  margin-bottom: 24px;
  animation: fadeSlideDown 0.6s ease-out;
}

@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.logo-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 4px;
}

.logo-icon {
  font-size: 2rem;
  filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.4));
}

h1 {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple), var(--accent-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ---- Controls Bar ---- */
.controls-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.control-group {
  position: relative;
}

.control-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.control-btn:hover, .control-btn.active {
  background: var(--glass-bg-hover);
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-glow-cyan);
}

.btn-icon { font-size: 1rem; }
.chevron { font-size: 0.65rem; opacity: 0.6; margin-left: 2px; }

/* Dropdown */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 6px;
  min-width: 180px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  z-index: 100;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.dropdown-item.selected {
  color: var(--accent-cyan);
  font-weight: 600;
}

/* Search */
.search-box {
  position: relative;
  flex: 1;
  min-width: 140px;
  max-width: 280px;
}

.search-box input {
  width: 100%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 9px 14px 9px 36px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  outline: none;
  transition: all var(--transition-fast);
}

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

.search-box input:focus {
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-glow-cyan);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  opacity: 0.5;
}

/* ---- Stats Bar ---- */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  margin-bottom: 16px;
  animation: fadeSlideDown 0.6s ease-out 0.1s backwards;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

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

.stat-divider {
  width: 1px;
  height: 32px;
  background: var(--glass-border);
}

/* ---- Refresh Bar ---- */
.refresh-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  animation: fadeSlideDown 0.6s ease-out 0.15s backwards;
}

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  border: none;
  color: #000;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all var(--transition-fast);
}

.refresh-btn:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-glow-cyan);
}

.refresh-icon {
  transition: transform 0.4s ease;
}

.refresh-btn:hover .refresh-icon {
  transform: rotate(180deg);
}

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

/* ---- Coin Grid ---- */
.coin-grid {
  display: grid;
  gap: 12px;
}

/* ---- Coin Card (List Style for Mobile) ---- */
.coin-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition-normal);
  animation: cardFadeIn 0.4s ease-out backwards;
}

.coin-card:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

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

.coin-rank {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 700;
  min-width: 24px;
  text-align: center;
}

.coin-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.coin-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.coin-details {
  overflow: hidden;
}

.coin-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.coin-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
}

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

/* Right side */
.coin-price-area {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 100px;
}

.coin-price {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: nowrap;
}

.coin-change-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.coin-change-badge.positive {
  background: rgba(34, 197, 94, 0.12);
  color: var(--accent-green);
}

.coin-change-badge.negative {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
}

/* Mini sparkline placeholder */
.sparkline-container {
  grid-column: 1 / -1;
  height: 40px;
  margin-top: 4px;
  opacity: 0.6;
}

.sparkline-container svg {
  width: 100%;
  height: 100%;
}

/* ---- Skeleton Loading ---- */
.skeleton-grid {
  display: grid;
  gap: 12px;
}

.skeleton-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.skeleton-circle {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--glass-bg-hover) 25%, rgba(255,255,255,0.08) 50%, var(--glass-bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-line {
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--glass-bg-hover) 25%, rgba(255,255,255,0.08) 50%, var(--glass-bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-line.w30 { width: 30%; }

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

/* ---- Status Boxes (Error / Empty) ---- */
.status-box {
  text-align: center;
  padding: 60px 20px;
  animation: fadeSlideDown 0.4s ease-out;
}

.error-icon { font-size: 3rem; margin-bottom: 12px; }

.status-box h3 {
  font-size: 1.2rem;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.status-box p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.retry-btn {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  border: none;
  color: #000;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.retry-btn:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-glow-cyan);
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.3s ease-out;
}

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

.modal-overlay.hidden { display: none !important; }

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  animation: modalSlideUp 0.3s ease-out;
}

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

.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--glass-bg-hover);
  border-color: var(--accent-cyan);
}

/* Modal inner content */
.modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.modal-coin-img {
  width: 56px; height: 56px;
  border-radius: 50%;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.modal-coin-name h2 {
  font-size: 1.3rem;
  font-weight: 800;
}

.modal-coin-name span {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  font-weight: 600;
}

.modal-price-big {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.modal-change-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.modal-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-stat {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.modal-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.modal-stat-value {
  font-size: 0.95rem;
  font-weight: 700;
}

/* ---- Footer ---- */
.footer {
  text-align: center;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--glass-border);
}

.footer p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.auto-refresh-note {
  margin-top: 4px !important;
  font-style: italic;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .app-container { padding: 16px 12px 32px; }

  .controls-bar { gap: 6px; }

  .control-btn {
    padding: 7px 10px;
    font-size: 0.75rem;
  }

  .search-box input {
    padding: 8px 12px 8px 34px;
    font-size: 0.8rem;
  }

  .stats-bar { gap: 10px; padding: 10px 14px; }
  .stat-value { font-size: 0.85rem; }

  .coin-card { padding: 12px; gap: 10px; }
  .coin-img { width: 32px; height: 32px; }
  .coin-name { font-size: 0.85rem; }
  .coin-price { font-size: 0.9rem; }

  .modal-content { padding: 18px; margin: 12px; }
  .modal-price-big { font-size: 1.6rem; }
}

@media (min-width: 768px) {
  .app-container { padding: 30px 24px 50px; }
  .coin-grid { gap: 14px; }
  .coin-card { padding: 16px 20px; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Utility ---- */
.hidden { display: none !important; }

.positive-text { color: var(--accent-green) !important; }
.negative-text { color: var(--accent-red) !important; }
