/* DirtyTraders Custom CSS */
/* Premium fintech styling with animations and polish */

/* ==========================================================================
   Custom Properties (CSS Variables)
   ========================================================================== */
:root {
  --dirty-green: #10b981;
  --dirty-green-light: #34d399;
  --dirty-green-dark: #059669;
  --dirty-red: #ef4444;
  --dirty-red-light: #f87171;
  --dirty-gold: #f59e0b;
  --dirty-blue: #3b82f6;
  --dirty-purple: #8b5cf6;

  /* Gradients */
  --gradient-green: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-red: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --gradient-dark: linear-gradient(180deg, #1f2937 0%, #111827 100%);
  --gradient-card: linear-gradient(145deg, #1f2937 0%, #1a202c 100%);

  /* Shadows */
  --shadow-glow-green: 0 0 20px rgba(16, 185, 129, 0.3);
  --shadow-glow-red: 0 0 20px rgba(239, 68, 68, 0.3);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-card-hover: 0 8px 40px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Typography
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.font-mono, code, .ticker {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

/* ==========================================================================
   Animations
   ========================================================================== */

/* Fade in with slide */
.fade-in {
  animation: fadeIn 0.4s ease-out;
}

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

/* Staggered fade in for lists */
.stagger-in > * {
  opacity: 0;
  animation: fadeIn 0.4s ease-out forwards;
}

.stagger-in > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-in > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-in > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-in > *:nth-child(8) { animation-delay: 0.4s; }
.stagger-in > *:nth-child(9) { animation-delay: 0.45s; }
.stagger-in > *:nth-child(10) { animation-delay: 0.5s; }

/* Slide in from right */
.slide-in-right {
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Scale in */
.scale-in {
  animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Pulse glow for important elements */
.pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 5px rgba(16, 185, 129, 0.3); }
  50% { box-shadow: 0 0 25px rgba(16, 185, 129, 0.6); }
}

/* ==========================================================================
   Animated Counters (Tier 3)
   ========================================================================== */
.counter {
  display: inline-block;
  transition: transform 0.3s ease;
}

.counter.counting {
  animation: countPop 0.3s ease-out;
}

@keyframes countPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Number highlight on change */
.value-changed {
  animation: valueFlash 0.5s ease-out;
}

@keyframes valueFlash {
  0% { background-color: rgba(16, 185, 129, 0.3); }
  100% { background-color: transparent; }
}

.value-changed-negative {
  animation: valueFlashRed 0.5s ease-out;
}

@keyframes valueFlashRed {
  0% { background-color: rgba(239, 68, 68, 0.3); }
  100% { background-color: transparent; }
}

/* ==========================================================================
   Skeleton Loading (Tier 2)
   ========================================================================== */
.skeleton {
  background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
  border-radius: 6px;
}

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

/* Skeleton variants */
.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
  border-radius: 4px;
}

.skeleton-text-sm {
  height: 0.75em;
  width: 60%;
}

.skeleton-title {
  height: 1.5em;
  width: 40%;
  margin-bottom: 1em;
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.skeleton-card {
  height: 120px;
  border-radius: 8px;
}

.skeleton-stat {
  height: 3rem;
  width: 80%;
  margin: 0 auto;
}

.skeleton-row {
  height: 60px;
  margin-bottom: 8px;
  border-radius: 6px;
}

/* ==========================================================================
   Card Effects (Tier 2)
   ========================================================================== */
.card {
  background: var(--gradient-card);
  border-radius: 12px;
  border: 1px solid rgba(55, 65, 81, 0.5);
  transition: all 0.3s ease;
}

.card-hover {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(16, 185, 129, 0.3);
}

/* Gradient border on hover */
.card-glow:hover {
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.5),
              0 8px 40px rgba(0, 0, 0, 0.3);
}

/* Glassmorphism card */
.glass {
  background: rgba(31, 41, 55, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Stat card with accent */
.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-green);
}

.stat-card.negative::before {
  background: var(--gradient-red);
}

/* ==========================================================================
   Button Effects
   ========================================================================== */
.btn {
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}

.btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
}

.btn:active::after {
  width: 200px;
  height: 200px;
}

.btn-primary {
  background: var(--gradient-green);
  color: black;
  font-weight: 600;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-green);
}

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

/* ==========================================================================
   Data Visualization
   ========================================================================== */

/* Animated progress bar */
.progress-bar {
  height: 8px;
  background: #374151;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-fill.green {
  background: var(--gradient-green);
}

.progress-fill.red {
  background: var(--gradient-red);
}

/* Sparkline placeholder */
.sparkline {
  display: inline-block;
  height: 30px;
  vertical-align: middle;
}

/* P&L coloring with glow */
.pnl-positive {
  color: var(--dirty-green);
}

.pnl-positive.glow {
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.pnl-negative {
  color: var(--dirty-red);
}

.pnl-negative.glow {
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 14px 20px;
  border-radius: 10px;
  color: white;
  font-weight: 500;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  backdrop-filter: blur(10px);
}

.toast.success {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.95), rgba(4, 120, 87, 0.95));
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.toast.error {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.95), rgba(185, 28, 28, 0.95));
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.toast.warning {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.95), rgba(180, 83, 9, 0.95));
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.toast.info {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.95), rgba(29, 78, 216, 0.95));
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.toast-exit {
  animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%) scale(0.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to { opacity: 0; transform: translateX(100%) scale(0.9); }
}

/* ==========================================================================
   Mobile Tables (Tier 3)
   ========================================================================== */
@media (max-width: 768px) {
  /* Convert table to cards on mobile */
  .table-mobile-cards {
    display: block;
  }

  .table-mobile-cards thead {
    display: none;
  }

  .table-mobile-cards tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .table-mobile-cards tbody tr {
    display: block;
    background: #1f2937;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #374151;
  }

  .table-mobile-cards tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border: none;
    border-bottom: 1px solid #374151;
  }

  .table-mobile-cards tbody td:last-child {
    border-bottom: none;
  }

  .table-mobile-cards tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #9ca3af;
    font-size: 0.85em;
  }

  /* Hide less important columns on mobile */
  .hide-mobile {
    display: none !important;
  }
}

/* ==========================================================================
   Page Transitions (Tier 3)
   ========================================================================== */
.page-transition {
  animation: pageIn 0.4s ease-out;
}

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

/* Smooth link transitions */
a {
  transition: color 0.2s ease, opacity 0.2s ease;
}

/* ==========================================================================
   Scrollbar
   ========================================================================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #1f2937;
}

::-webkit-scrollbar-thumb {
  background: #4b5563;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

/* ==========================================================================
   Chart Container
   ========================================================================== */
.chart-container {
  position: relative;
  height: 200px;
  width: 100%;
}

.chart-container canvas {
  max-height: 100%;
}

/* Mini chart for inline use */
.chart-mini {
  height: 60px;
  width: 120px;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Text gradient */
.text-gradient {
  background: linear-gradient(135deg, #10b981, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Truncate with ellipsis */
.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Focus visible (accessibility) */
:focus-visible {
  outline: 2px solid var(--dirty-green);
  outline-offset: 2px;
}

/* Hide scrollbar but keep functionality */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Hover opacity */
.hover-opacity {
  transition: opacity 0.2s ease;
}

.hover-opacity:hover {
  opacity: 0.8;
}

/* ==========================================================================
   Party Badge Colors
   ========================================================================== */
.party-d {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  color: white;
}

.party-r {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: white;
}

.party-i {
  background: linear-gradient(135deg, #6b7280, #4b5563);
  color: white;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
  body {
    background: white;
    color: black;
  }

  nav, footer, .no-print, .toast-container {
    display: none !important;
  }

  .card {
    border: 1px solid #ddd;
    box-shadow: none;
  }
}
