@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --card: #ffffff;
  --card-hover: #f9fafb;
  --border: #e5e7eb;
  --text: #0f172a;
  --text-secondary: #64748b;
  --shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg:
    0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.dark {
  --bg: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  --card: #1e293b;
  --card-hover: #334155;
  --border: #334155;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg:
    0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 100vh;
}

/* NAV */
nav {
  background: var(--card);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

nav h1 {
  font-size: 1.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: -0.5px;
}

nav h1 i {
  color: var(--primary);
  font-size: 1.5rem;
}

nav h1 span {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.icon-btn {
  width: 45px;
  height: 45px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.icon-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

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

/* LAYOUT */
.container {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 30px;
}

/* STATS */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin-bottom: 35px;
}

.stat {
  background: var(--card);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 20px;
  border: 1px solid var(--border);
}

.stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
}

.stat:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  background: var(--card-hover);
}

.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  flex-shrink: 0;
}

.stat-balance .stat-icon {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  box-shadow: 0 8px 16px rgba(59, 130, 246, 0.3);
}

.stat-portfolio .stat-icon {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: white;
  box-shadow: 0 8px 16px rgba(139, 92, 246, 0.3);
}

.stat-profit .stat-icon {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 8px 16px rgba(16, 185, 129, 0.3);
}

.stat-content {
  flex: 1;
}

.stat-content p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-content h2 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

/* CARD */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  margin-bottom: 32px;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border);
}

.card-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}

.card-header i {
  color: var(--primary);
}

.market-indicators {
  display: flex;
  align-items: center;
  gap: 12px;
}

.market-trend {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.market-trend.bullish {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid var(--success);
}

.market-trend.bearish {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.market-trend.neutral {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border: 1px solid var(--primary);
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--success);
  background: rgba(16, 185, 129, 0.1);
  padding: 6px 14px;
  border-radius: 20px;
}

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

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

/* TABLE */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

thead {
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.1),
    rgba(37, 99, 235, 0.1)
  );
}

th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

thead th:first-child {
  border-radius: 12px 0 0 12px;
}

thead th:last-child {
  border-radius: 0 12px 12px 0;
}

td {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

tbody tr {
  transition: all 0.2s ease;
}

tbody tr:hover {
  background: var(--card-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

button {
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.buy {
  background: linear-gradient(135deg, var(--success), #059669);
  margin-right: 8px;
}

.buy:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.sell {
  background: linear-gradient(135deg, var(--danger), #dc2626);
}

.sell:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* PORTFOLIO */
.portfolio-content,
.history-content {
  max-height: 400px;
  overflow-y: auto;
  padding-right: 8px;
}

.portfolio-content::-webkit-scrollbar,
.history-content::-webkit-scrollbar {
  width: 8px;
}

.portfolio-content::-webkit-scrollbar-track,
.history-content::-webkit-scrollbar-track {
  background: var(--border);
  border-radius: 10px;
}

.portfolio-content::-webkit-scrollbar-thumb,
.history-content::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 10px;
}

.portfolio-content::-webkit-scrollbar-thumb:hover,
.history-content::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

/* PROFIT */
.profit {
  color: var(--success);
  font-weight: 700;
}

.loss {
  color: var(--danger);
  font-weight: 700;
}

footer {
  text-align: center;
  padding: 25px;
  color: var(--muted);
}

/* Price change indicators */
.positive {
  color: var(--success);
  font-weight: 700;
  background: rgba(16, 185, 129, 0.1);
  padding: 4px 8px;
  border-radius: 6px;
}

.negative {
  color: var(--danger);
  font-weight: 700;
  background: rgba(239, 68, 68, 0.1);
  padding: 4px 8px;
  border-radius: 6px;
}

/* Portfolio items */
.portfolio-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  margin-bottom: 14px;
  background: var(--card-hover);
  border-radius: 16px;
  border-left: 4px solid var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.portfolio-item:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* News Feed */
.news-content {
  max-height: 300px;
  overflow-y: auto;
  padding-right: 8px;
}

.news-content::-webkit-scrollbar {
  width: 8px;
}

.news-content::-webkit-scrollbar-track {
  background: var(--border);
  border-radius: 10px;
}

.news-content::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 10px;
}

.news-item {
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--card-hover);
  border-radius: 12px;
  border-left: 3px solid var(--warning);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.news-item:hover {
  transform: translateX(4px);
  border-left-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.news-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.news-message {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
}

.portfolio-info {
  flex: 1;
}

.portfolio-info strong {
  font-size: 1.2em;
  font-weight: 700;
  color: var(--text);
  display: block;
  margin-bottom: 6px;
}

.portfolio-info small {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}

.portfolio-value {
  text-align: right;
}

.portfolio-value > div {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.portfolio-value small {
  display: block;
  margin-top: 6px;
  font-size: 0.875rem;
  font-weight: 600;
}

/* History items */
.history-item {
  padding: 16px;
  margin-bottom: 12px;
  background: var(--card-hover);
  border-radius: 12px;
  font-size: 0.9rem;
  border-left: 3px solid var(--text-secondary);
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.history-item:hover {
  border-left-color: var(--primary);
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Table improvements */
table td strong {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}

table td small {
  display: block;
  margin-top: 6px;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Footer */
footer {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }

  .stats {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .stat {
    padding: 20px;
  }

  .card {
    padding: 20px;
  }

  .portfolio-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .portfolio-value {
    text-align: left;
    width: 100%;
  }

  nav h1 {
    font-size: 1.25rem;
  }

  table {
    font-size: 0.85rem;
  }

  th,
  td {
    padding: 12px 8px;
  }

  button {
    padding: 8px 16px;
    font-size: 0.8rem;
  }
}

/* Loading animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card,
.stat {
  animation: fadeIn 0.5s ease-out;
}

.stat:nth-child(1) {
  animation-delay: 0.1s;
}
.stat:nth-child(2) {
  animation-delay: 0.2s;
}
.stat:nth-child(3) {
  animation-delay: 0.3s;
}
