@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  /* Modern Dark Palette */
  --bg-dark: #090b10;
  --bg-gradient: radial-gradient(circle at 10% 20%, rgba(93, 62, 188, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(31, 191, 117, 0.08) 0%, transparent 40%);

  --glass-bg: rgba(23, 26, 43, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  --backdrop-blur: 12px;

  --text-primary: #ffffff;
  --text-secondary: #a0aec0;
  --text-tertiary: #718096;

  --accent-primary: #6c8cff;
  --accent-hover: #5a75db;
  --accent-glow: rgba(108, 140, 255, 0.3);

  --success: #10b981;
  --danger: #ef4444;

  --border-radius-lg: 16px;
  --border-radius-md: 12px;
  --border-radius-sm: 8px;

  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background: var(--bg-dark);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(108, 140, 255, 0.4);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(108, 140, 255, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(108, 140, 255, 0);
  }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Navigation */
nav {
  background: rgba(9, 11, 16, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

nav .logo {
  font-weight: 800;
  font-size: 20px;
  background: linear-gradient(135deg, #fff, var(--accent-primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

nav ul {
  display: flex;
  gap: 32px;
  list-style: none;
}

nav ul li a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

nav ul li a:hover {
  color: var(--text-primary);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* Main Container */
.container {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 20px;
  animation: fadeIn 0.6s ease-out;
}

/* Cards & Glassmorphism */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--backdrop-blur));
  -webkit-backdrop-filter: blur(var(--backdrop-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--glass-shadow);
}

.hero-card {
  background: linear-gradient(145deg, rgba(23, 26, 43, 0.6) 0%, rgba(23, 26, 43, 0.3) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 28px;
  position: relative;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(20px);
}

.hero-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(108, 140, 255, 0.2);
}

/* Glowing orb effect behind */
.hero-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
      rgba(108, 140, 255, 0.06), transparent 40%);
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
}

.hero-card:hover::after {
  opacity: 1;
}

.hero-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  z-index: 2;
  position: relative;
}

.hero-price {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 12px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  z-index: 2;
  position: relative;
  letter-spacing: -1px;
}

.hero-change {
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(4px);
  z-index: 2;
  position: relative;
}

.hero-change.up {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.2);
  box-shadow: 0 0 15px rgba(74, 222, 128, 0.1);
}

.hero-change.down {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.2);
  box-shadow: 0 0 15px rgba(248, 113, 113, 0.1);
}

/* Large decorative icon */
.hero-bg-icon {
  position: absolute;
  right: -25px;
  bottom: -25px;
  width: 140px;
  height: 140px;
  opacity: 0.12;
  transform: rotate(-15deg);
  pointer-events: none;
  filter: grayscale(100%) contrast(120%);
  transition: all 0.5s ease;
  z-index: 1;
}

.hero-card:hover .hero-bg-icon {
  transform: rotate(0deg) scale(1.1);
  opacity: 0.2;
  filter: grayscale(0%);
}

/* Info Section */
.info-section {
  padding: 24px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.info-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
  opacity: 0.5;
}

.info-section h2 {
  font-size: 22px;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.info-section p {
  color: var(--text-secondary);
  font-size: 15px;
  max-width: 800px;
}

/* Header & Controls */
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 20px;
}

.title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
}

.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.control {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 0.2s;
}

.control:focus-within {
  border-color: var(--accent-primary);
  background: rgba(255, 255, 255, 0.05);
}

.control label {
  color: var(--text-tertiary);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

select,
input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  outline: none;
}

select option {
  background: #1a1d2d;
  color: var(--text-primary);
}

input#search {
  min-width: 220px;
}

button.action {
  background: var(--accent-primary);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: var(--border-radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px var(--accent-glow);
}

button.action:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

button.action:active {
  transform: translateY(0);
}

/* Table Area */
.card {
  /* Inherits glass-panel properties via HTML class if added, otherwise keep specific styles */
  background: var(--glass-bg);
  backdrop-filter: blur(var(--backdrop-blur));
  -webkit-backdrop-filter: blur(var(--backdrop-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
}

.status {
  padding: 12px 24px;
  border-bottom: 1px solid var(--glass-border);
  font-size: 13px;
  color: var(--text-tertiary);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
}

.status::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--success);
}

/* Responsive Table Wrapper */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  /* Prevent wrapping essentially */
}

thead th {
  text-align: left;
  padding: 16px 24px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--glass-border);
}

tbody tr {
  transition: background 0.2s;
  cursor: pointer;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

tbody td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--glass-border);
  font-size: 14px;
  color: var(--text-primary);
}

tbody tr:last-child td {
  border-bottom: none;
}

img {
  vertical-align: middle;
  margin-right: 8px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-tertiary);
  transition: all 0.2s;
  margin-right: 8px;
  padding: 4px;
}

.star-btn:hover {
  transform: scale(1.2);
  color: var(--text-secondary);
}

.star-btn.active {
  color: #fbbf24;
  /* Gold */
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.footer {
  padding: 16px 24px;
  text-align: right;
  font-size: 12px;
  color: var(--text-tertiary);
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--glass-border);
}

.footer a {
  color: var(--accent-primary);
  text-decoration: none;
}

/* Dashboard Modal */
#coin-dashboard {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(9, 11, 16, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  /* Flex when active handled by js or specific class */
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#coin-dashboard.show {
  display: flex !important;
  /* Override JS inline styles if any or ensure visibility */
  opacity: 1;
}

/* Actual Modal Content Container */
.dashboard-content {
  background: #131620;
  /* Solid enough background for charts */
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 30px;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

#close-dashboard {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
  padding: 0;
  /* Override previous */
}

#close-dashboard:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.coin-info {
  margin-bottom: 30px;
}

.coin-info h2 {
  font-size: 32px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.coin-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.detail-item {
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
}

.detail-label {
  color: var(--text-tertiary);
  font-size: 12px;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-wrapper {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 16px;
  /* Slightly reduced padding */
  margin-bottom: 24px;
  position: relative;
  height: 300px;
  /* Force height so maintainAspectRatio: false works */
  display: flex;
  flex-direction: column;
}

.chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-wrapper h3 {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-weight: 500;
}

.prediction-box {
  margin-top: 24px;
  padding: 20px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(108, 140, 255, 0.1), transparent);
  border-left: 4px solid var(--accent-primary);
}

.prediction-box h3 {
  color: var(--accent-primary);
  margin-bottom: 8px;
  font-size: 16px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  nav {
    padding: 12px 16px;
  }

  nav ul {
    gap: 16px;
  }

  .container {
    padding: 0 16px;
    margin: 20px auto;
  }

  /* --- Hero Section Horizontal Scroll --- */
  #hero-section {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 4px;
    /* Space for scrollbar if visible */
    margin-bottom: 24px;
    /* Hide scrollbar for cleaner look on some devices */
    scrollbar-width: none;
  }

  #hero-section::-webkit-scrollbar {
    display: none;
  }

  .hero-card {
    min-width: 80%;
    /* Show part of next card to hint scroll */
    flex-shrink: 0;
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 0;
    /* Remove bottom margin since it's a row now */
  }

  .hero-title {
    font-size: 12px;
    margin-bottom: 8px;
  }

  .hero-price {
    font-size: 24px;
    margin-bottom: 8px;
  }

  .hero-change {
    font-size: 12px;
    padding: 4px 10px;
  }

  .hero-bg-icon {
    width: 80px;
    height: 80px;
    right: -10px;
    bottom: -10px;
  }

  /* --- Header Controls --- */
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .title {
    text-align: center;
    font-size: 22px;
    margin-bottom: 4px;
  }

  .controls {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
  }

  /* Currency & Rows: Side by Side */
  .control:nth-of-type(1),
  .control:nth-of-type(2) {
    flex: 1 1 calc(50% - 6px);
    width: auto;
    font-size: 12px;
    padding: 8px;
  }

  .control label {
    font-size: 10px;
    margin-right: 4px;
  }

  /* Search: Full width */
  .control:nth-of-type(3) {
    flex: 1 1 100%;
    order: 3;
    width: 100%;
  }

  input#search {
    width: 100%;
    font-size: 14px;
  }

  /* Gainers/Losers Buttons: Full Width Group */
  .control:nth-of-type(4) {
    flex: 1 1 100%;
    order: 4;
    display: flex;
    gap: 8px;
    padding: 0;
    border: none;
    background: transparent;
  }

  .control:nth-of-type(4) button {
    flex: 1;
    font-size: 12px;
    padding: 10px;
    text-align: center;
    justify-content: center;
  }

  /* Watchlist & Refresh: Side by Side */
  #watchlist-toggle,
  #refresh {
    flex: 1 1 calc(50% - 6px);
    order: 5;
    font-size: 12px;
    padding: 10px;
    justify-content: center;
  }

  /* --- Table --- */
  .table-wrapper {
    margin: 0 -16px;
    width: calc(100% + 32px);
    padding: 0;
  }

  .card {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  table {
    width: 100%;
  }

  thead th {
    padding: 10px 8px;
    font-size: 11px;
    letter-spacing: 0.5px;
  }

  tbody td {
    padding: 10px 8px;
    font-size: 12px;
  }

  img {
    width: 18px;
    height: 18px;
  }

  .star-btn {
    font-size: 14px;
    margin-right: 2px;
    padding: 4px;
  }

  .dashboard-content {
    padding: 16px;
    border-radius: 0;
    height: 100%;
    max-height: 100%;
    width: 100%;
  }

  /* Details in dashboard mobile */
  .coin-info h2 {
    font-size: 24px;
  }

  .detail-value {
    font-size: 16px;
  }
}

.timeframe-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.timeframe-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.timeframe-btn.active {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}