/* Base Styles */
:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 270 95% 65%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 270 95% 65%;
  --radius: 0.75rem;
  --positive: 142 76% 36%;
  --negative: 0 84% 60%;
}

.dark {
  --background: 0 0% 0%;
  --foreground: 0 0% 98%;
  --card: 0 0% 0%;
  --card-foreground: 0 0% 98%;
  --popover: 0 0% 0%;
  --popover-foreground: 0 0% 98%;
  --primary: 270 95% 65%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --ring: 270 95% 65%;
  --positive: 142 70% 45%;
  --negative: 0 70% 45%;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Vazirmatn", sans-serif;
  line-height: 1.5;
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  transition: background-color 0.3s, color 0.3s;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Header Styles */
header {
  margin-bottom: 2rem;
}

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

.header-title {
  flex: 1;
  min-width: 200px;
}

.gradient-text {
  font-size: 2.5rem;
  font-weight: bold;
  background: linear-gradient(to right, #a855f7, #ec4899, #eab308);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: hsl(var(--muted-foreground));
}

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

.countdown {
  display: flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  animation: pulse 2s infinite;
}

.countdown .icon {
  margin-left: 0.25rem;
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--border));
  background-color: transparent;
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
}

.icon-button:hover {
  background-color: hsl(var(--accent));
}

.icon-button:active {
  transform: translateY(1px);
}

.last-updated {
  display: flex;
  align-items: center;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.status-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: hsl(var(--positive));
  margin-right: 0.5rem;
  animation: pulse 2s infinite;
}

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

/* Section Styles */
.section {
  margin-bottom: 2.5rem;
}

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

.section-title {
  display: flex;
  align-items: center;
  font-size: 1.25rem;
  font-weight: 600;
}

.section-marker {
  width: 0.25rem;
  height: 1.5rem;
  background: linear-gradient(to bottom, #a855f7, #ec4899);
  border-radius: 0.25rem;
  margin-left: 0.5rem;
}

.section-actions {
  display: flex;
  gap: 0.5rem;
}

/* Featured Coins */
.featured-coins {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}

.coin-card {
  position: relative;
  border-radius: 0.75rem;
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--background) / 0.15);
  overflow: hidden;
  transition: transform 0.3s;
}

.coin-card:hover {
  transform: translateY(-5px);
}

.coin-card-gradient {
  position: absolute;
  inset: 0;
  border-radius: 0.75rem;
  pointer-events: none;
}

.coin-card-content {
  position: relative;
  padding: 0.75rem;
}

.coin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.coin-info {
  display: flex;
  align-items: center;
}

.coin-icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  margin-left: 0.25rem;
  object-fit: cover;
}

.coin-symbol {
  font-weight: bold;
}

.coin-change {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  border: 1px solid;
}

.top{
  border-radius: 0 0 10px 10px;
  background: linear-gradient(-45deg, hsl(var(--background)), #984be0);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: -10;
}

.positive {
  color: hsl(var(--positive));
  direction: ltr;
  border-color: hsl(var(--positive));
}

.negative {
  color: hsl(var(--negative));
  direction: ltr;
  border-color: hsl(var(--negative));
}

.coin-price {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

.coin-secondary-price {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

/* Currency Toggle */
.currency-toggle {
  display: flex;
  align-items: center;
  background: linear-gradient(to right, rgba(168, 85, 247, 0.2), rgba(236, 72, 153, 0.2));
  border-radius: 9999px;
  padding: 0.25rem;
  position: relative;
  border: 1px solid hsl(var(--border));
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.currency-button {
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  z-index: 1;
  color: hsl(var(--foreground));
  transition: color 0.3s;
}

.currency-button.active {
  color: white;
  font-weight: 600;
}

.currency-slider {
  position: absolute;
  height: calc(100% - 0.5rem);
  width: 50%;
  border-radius: 9999px;
  background: linear-gradient(to right, #a855f7, #ec4899);
  top: 0.25rem;
  right: 0.25rem;
  transition: transform 0.3s;
}

.currency-slider.irt {
  transform: translateX(calc(-100% + 8px));
}

/* Coins Table */
.coins-table-container {
  border-radius: 0.75rem;
  border: 1px solid hsl(var(--border));
  background-color: hsla(var(--card), 0.3);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

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

.coins-table th,
.coins-table td {
  padding: 0.75rem;
  text-align: right;
}

.coins-table th {
  cursor: pointer;
}

.th-content {
  display: flex;
  align-items: center;
}

.sort-indicator {
  margin-right: 0.25rem;
}

.coins-table tbody tr {
  border-bottom: 1px solid hsl(var(--border));
}

.coins-table tbody tr:hover {
  background-color: hsla(var(--muted), 0.2);
}

.coin-row-info {
  display: flex;
  align-items: center;
}

.coin-row-name {
  display: flex;
  flex-direction: column;
}

.coin-row-name-fa {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

/* Loading */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 0;
}

.loading .icon {
  margin-left: 0.5rem;
}

.spinning {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.loading-cell {
  text-align: center;
}

/* Show More Button */
.show-more-container {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.gradient-button {
  background: linear-gradient(to right, #a855f7, #ec4899);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
}

.gradient-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Dialog */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  display: none;
}

.dialog {
  background-color: hsl(var(--background));
  border-radius: 0.75rem;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

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

.close-button {
  background: none;
  border: none;
  color: hsl(var(--foreground));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialog-content {
  padding: 1rem;
  overflow-y: auto;
  max-height: 60vh;
}

.dialog-footer {
  padding: 1rem;
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid hsl(var(--border));
}

.primary-button {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
}

/* Coin Grid in Dialog */
.coins-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.coin-checkbox-item {
  display: flex;
  align-items: center;
}

.coin-checkbox {
  margin-left: 0.5rem;
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 2.75rem;
  height: 1.5rem;
  margin-left: 0.5rem;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: hsl(var(--input));
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 1.25rem;
  width: 1.25rem;
  right: 0.125rem;
  bottom: 0.125rem;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: hsl(var(--primary));
}

input:checked + .slider:before {
  transform: translateX(-1.25rem);
}

/* Drag Mode */
.drag-mode .coin-card {
  cursor: grab;
}

.drag-mode .coin-card:active {
  cursor: grabbing;
}

.dragging {
  opacity: 0.5;
}

/* Edit Mode */
.edit-mode .coin-card .remove-button {
  display: flex;
}

.remove-button {
  display: none;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0.25rem;
  background: transparent;
  border: none;
  color: hsl(var(--foreground));
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* SVG Icons */
.icon {
  display: inline-block;
  vertical-align: middle;
}

/* Responsive */
@media (max-width: 768px) {
  .hide-mobile {
    display: none;
  }

  .featured-coins {
    grid-template-columns: repeat(2, 1fr);
  }

  .coins-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .gradient-text {
    font-size: 1.75rem;
  }

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

  .header-title {
    width: 100%;
    text-align: center;
    margin-bottom: 1rem;
  }

  .section-header {
    align-items: flex-start;
  }

  .currency-toggle {
    justify-content: space-around;
  }
}

@media (max-width: 480px) {
  .coins-grid {
    grid-template-columns: 1fr;
  }

  .gradient-text {
    font-size: 1.5rem;
  }

  .header-actions {
    width: 100%;
    justify-content: center;
  }

  .countdown {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
  }

  .icon-button {
    width: 2.25rem;
    height: 2.25rem;
  }
}
