/* ============================================
   Modern UI Animations & Transitions
   ============================================ */

/* CSS Variables for consistent theming */
:root {
  --primary-color: #0A2647;
  --secondary-color: #2C5282;
  --gold-color: #D4AF37;
  --light-gold: #F4E4C1;
  --success-color: #059669;
  --warning-color: #D97706;
  --danger-color: #DC2626;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --bg-gradient: linear-gradient(135deg, #0A2647 0%, #2C5282 100%);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
  --transition-fast: 0.15s ease-in-out;
  --transition-normal: 0.3s ease-in-out;
  --transition-slow: 0.5s ease-in-out;
}

/* ============================================
   Smooth Scrolling
   ============================================ */
html {
  scroll-behavior: smooth;
}

* {
  box-sizing: border-box;
}

/* ============================================
   Page Transitions
   ============================================ */
.page-transition {
  animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
  transform: translateY(20px);
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.4s ease-in-out forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.slide-down {
  animation: slideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.scale-in {
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ============================================
   Loading Skeletons
   ============================================ */
.skeleton {
  background: linear-gradient(90deg,
      #f0f0f0 25%,
      #e0e0e0 50%,
      #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 8px;
}

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

  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: 16px;
  border-radius: 4px;
}

.skeleton-card {
  height: 120px;
  border-radius: 12px;
  margin-bottom: 16px;
}

/* ============================================
   Button Enhancements
   ============================================ */
.btn-modern {
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
  border: none;
  cursor: pointer;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow-md);
}

.btn-modern:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-modern:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

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

.btn-modern:active::before {
  width: 300px;
  height: 300px;
}

.btn-gradient {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  background-size: 200% 200%;
  animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {

  0%,
  100% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-color) 0%, var(--light-gold) 100%);
  color: var(--primary-color);
  font-weight: 600;
}

/* ============================================
   Card Hover Effects
   ============================================ */
.card-hover {
  position: relative;
  transition: all var(--transition-normal);
  border-radius: 12px;
  overflow: hidden;
}

.card-hover::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
      transparent,
      rgba(255, 255, 255, 0.2),
      transparent);
  transition: left 0.5s;
}

.card-hover:hover::before {
  left: 100%;
}

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

.card-glow {
  position: relative;
  border-radius: 12px;
}

.card-glow::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg,
      var(--primary-color),
      var(--secondary-color),
      var(--gold-color),
      var(--light-gold));
  background-size: 400% 400%;
  border-radius: 14px;
  z-index: -1;
  opacity: 0;
  transition: opacity var(--transition-normal);
  animation: gradientRotate 3s ease infinite;
}

.card-glow:hover::after {
  opacity: 1;
}

@keyframes gradientRotate {

  0%,
  100% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }
}

/* ============================================
   Stat Cards with Pulse Effect
   ============================================ */
.stat-card {
  position: relative;
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal);
  border: 1px solid rgba(100, 116, 139, 0.1);
}

.stat-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
}

.stat-card-pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(10, 38, 71, 0.4);
  }

  50% {
    box-shadow: 0 0 0 10px rgba(10, 38, 71, 0);
  }
}

/* ============================================
   Tooltips
   ============================================ */
.tooltip {
  position: relative;
  cursor: help;
}

.tooltip::before,
.tooltip::after {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-normal);
}

.tooltip::before {
  content: attr(data-tooltip);
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%) translateY(-5px);
  background: rgba(30, 41, 59, 0.95);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
}

.tooltip::after {
  content: '';
  bottom: 115%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(30, 41, 59, 0.95);
  z-index: 1000;
}

.tooltip:hover::before,
.tooltip:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   Progress Bars
   ============================================ */
.progress-bar {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--gold-color));
  border-radius: 10px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(90deg,
      transparent,
      rgba(255, 255, 255, 0.3),
      transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

/* ============================================
   Micro-interactions
   ============================================ */
.bounce-on-click {
  animation: bounceClick 0.4s ease;
}

@keyframes bounceClick {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(0.95);
  }
}

.shake {
  animation: shake 0.5s ease;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-10px);
  }

  75% {
    transform: translateX(10px);
  }
}

.float {
  animation: float 3s ease-in-out infinite;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

/* ============================================
   Stagger Animation for Lists
   ============================================ */
.stagger-item {
  opacity: 0;
  animation: fadeInUp 0.5s ease-out forwards;
}

.stagger-item:nth-child(1) {
  animation-delay: 0.1s;
}

.stagger-item:nth-child(2) {
  animation-delay: 0.2s;
}

.stagger-item:nth-child(3) {
  animation-delay: 0.3s;
}

.stagger-item:nth-child(4) {
  animation-delay: 0.4s;
}

.stagger-item:nth-child(5) {
  animation-delay: 0.5s;
}

/* ============================================
   Glass Morphism Effect
   ============================================ */
.glass {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}

.glass-dark {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ============================================
   Responsive Utilities
   ============================================ */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   Focus Styles (Accessibility)
   ============================================ */
*:focus {
  outline: 2px solid var(--gold-color);
  outline-offset: 2px;
}

button:focus,
a:focus {
  outline: 2px solid var(--gold-color);
  outline-offset: 2px;
}

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

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--primary-color), var(--gold-color));
  border-radius: 10px;
  border: 2px solid #f1f5f9;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--gold-color), var(--primary-color));
}

/* ============================================
   Category Tabs for Market Leaders
   ============================================ */
.category-tab {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  background: white;
  color: #64748b;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.category-tab:hover {
  border-color: #F4E4C1;
  background: #f8fafc;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.15);
}

.category-tab.active {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  border-color: var(--gold-color);
  color: white;
  box-shadow: 0 4px 12px rgba(10, 38, 71, 0.3);
}

.category-tab.active:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(10, 38, 71, 0.4);
}

/* Leaders Table Styles */
.leaders-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.leaders-table th {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  padding: 1rem;
  text-align: right;
  font-weight: 600;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.leaders-table td {
  padding: 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
}

.leaders-table tr {
  transition: all 0.2s ease;
}

.leaders-table tbody tr:hover {
  background: #f8fafc;
  transform: translateX(-4px);
  box-shadow: 4px 0 8px rgba(212, 175, 55, 0.15);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.875rem;
}

.rank-1 {
  background: linear-gradient(135deg, var(--gold-color) 0%, var(--light-gold) 100%);
  color: var(--primary-color);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4);
  animation: pulse 2s infinite;
}

.rank-2 {
  background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(148, 163, 184, 0.3);
}

.rank-3 {
  background: linear-gradient(135deg, #cd7f32 0%, #b8690d 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(205, 127, 50, 0.3);
}

.rank-other {
  background: #f1f5f9;
  color: #64748b;
}

.yield-positive {
  color: #22c55e;
  font-weight: 600;
}

.yield-negative {
  color: #ef4444;
  font-weight: 600;
}

.yield-neutral {
  color: #64748b;
  font-weight: 600;
}