/* ==========================================================================
   PRATEEK JEWELLERS - PRECIOUS METALS LIVE TRADING TERMINAL
   Framer Motion StatsCard recreation:
   - Full-screen trading modal overlay
   - Spring numerical animated values
   - 7-session dynamic trading histograms with --bar-height CSS properties
   - Interactive hover lift & spring physics
   - Real-time tick animations & unit switcher
   ========================================================================== */

/* ── 1. Modal Overlay & Stacking Context ── */
.live-rates-modal {
  position: fixed;
  inset: 0;
  z-index: 99999999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  isolation: isolate;
}

.live-rates-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.live-rates-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 11, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  cursor: pointer;
  transition: background 0.35s ease;
}

.live-rates-modal-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1060px;
  max-height: 94vh;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 55, 0.3) rgba(15, 18, 24, 0.6);
}

.live-rates-modal-container::-webkit-scrollbar {
  width: 6px;
}
.live-rates-modal-container::-webkit-scrollbar-track {
  background: rgba(15, 18, 24, 0.6);
  border-radius: 4px;
}
.live-rates-modal-container::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.3);
  border-radius: 4px;
}

/* ── 2. Modal Dialog Window ── */
.live-rates-modal-dialog {
  position: relative;
  width: 100%;
  background: linear-gradient(155deg, rgba(20, 24, 32, 0.98) 0%, rgba(10, 13, 18, 0.99) 100%);
  border: 1px solid rgba(212, 175, 55, 0.26);
  border-radius: 24px;
  padding: 28px 32px;
  box-shadow: 0 28px 75px rgba(0, 0, 0, 0.8),
              0 0 50px rgba(212, 175, 55, 0.12),
              inset 0 1px 0 rgba(255, 235, 163, 0.2);
  transform: translateY(24px) scale(0.96);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.live-rates-modal.is-open .live-rates-modal-dialog {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* ── 3. Terminal Header ── */
.live-rates-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.live-rates-header-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.live-rates-badge-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.live-rates-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 100px;
  color: #34D399;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.live-rates-pulse-dot {
  width: 7px;
  height: 7px;
  background: #10B981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10B981;
  animation: ratePulse 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes ratePulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.35);
    opacity: 0.6;
  }
}

.live-rates-market-status {
  font-size: 11.5px;
  font-weight: 500;
  color: #94A3B8;
  letter-spacing: 0.02em;
}

.live-rates-title {
  margin: 0;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #F8FAFC;
  line-height: 1.2;
}

.live-rates-title em {
  font-style: italic;
  background: linear-gradient(135deg, #FFE58F 0%, #D4AF37 50%, #F59E0B 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.live-rates-subtitle {
  margin: 0;
  font-size: 12.5px;
  color: #8E9BAE;
  line-height: 1.4;
}

/* Header Action Controls */
.live-rates-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.live-rates-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 100px;
  color: #E2E8F0;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

.live-rates-refresh-btn:hover {
  background: rgba(212, 175, 55, 0.15);
  border-color: rgba(212, 175, 55, 0.35);
  color: #FFE58F;
  transform: translateY(-1px);
}

.live-rates-refresh-btn svg {
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.live-rates-refresh-btn.is-spinning svg {
  transform: rotate(360deg);
}

.live-rates-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: #94A3B8;
  cursor: pointer;
  transition: all 0.25s ease;
}

.live-rates-close-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.35);
  color: #F87171;
  transform: scale(1.08) rotate(90deg);
}

/* ── 4. Benchmark Unit Bar ── */
.live-rates-unit-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 22px;
  flex-wrap: wrap;
}

.unit-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: #94A3B8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.unit-bar-buttons {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 100px;
  padding: 3px;
  gap: 3px;
}

.unit-btn {
  padding: 6px 14px;
  background: transparent;
  border: none;
  border-radius: 100px;
  color: #94A3B8;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.22s ease;
}

.unit-btn:hover {
  color: #F8FAFC;
}

.unit-btn.is-active {
  background: linear-gradient(135deg, #FFE58F 0%, #D4AF37 100%);
  color: #0B0E14;
  box-shadow: 0 2px 10px rgba(212, 175, 55, 0.35);
  font-weight: 700;
}

/* ── 5. StatsCard Grid Layout ── */
.live-rates-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

/* Replicating React MotionCard & whileHover physics */
.stats-card {
  position: relative;
  background: linear-gradient(165deg, rgba(22, 27, 36, 0.95) 0%, rgba(12, 15, 21, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.3s ease,
              border-color 0.3s ease;
  will-change: transform;
}

/* whileHover={{ scale: 1.03, y: -5 }} */
.stats-card:hover {
  transform: scale(1.03) translateY(-5px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6),
              0 0 28px rgba(212, 175, 55, 0.18);
  border-color: rgba(212, 175, 55, 0.38);
}

.stats-card--gold24:hover {
  border-color: rgba(255, 215, 0, 0.45);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6),
              0 0 30px rgba(255, 215, 0, 0.2);
}

.stats-card--gold22:hover {
  border-color: rgba(234, 179, 8, 0.45);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6),
              0 0 30px rgba(234, 179, 8, 0.18);
}

.stats-card--silver:hover {
  border-color: rgba(203, 213, 225, 0.45);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6),
              0 0 30px rgba(203, 213, 225, 0.22);
}

/* Card Header */
.stats-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
}

.stats-card-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stats-card-metal-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  width: fit-content;
}

.gold-24k-badge {
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.25);
  color: #FFD700;
}

.gold-22k-badge {
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.25);
  color: #EAB308;
}

.silver-badge {
  background: rgba(203, 213, 225, 0.12);
  border: 1px solid rgba(203, 213, 225, 0.25);
  color: #E2E8F0;
}

.stats-card-title {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: #94A3B8;
  line-height: 1.3;
}

/* Trend Pill Badge (Gain / Loss) */
.stats-card-trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.stats-card-trend-badge.positive {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34D399;
}

.stats-card-trend-badge.negative {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #F87171;
}

/* Card Content & Animated Price */
.stats-card-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stats-card-price-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stats-card-price {
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #F8FAFC;
  display: flex;
  align-items: baseline;
  gap: 2px;
  line-height: 1.1;
  transition: color 0.3s ease;
}

.price-prefix {
  font-size: 20px;
  font-weight: 600;
  color: #D4AF37;
}

.price-value {
  display: inline-block;
  font-variant-numeric: tabular-nums;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.price-postfix {
  font-size: 13px;
  font-weight: 500;
  color: #64748B;
  margin-left: 2px;
}

/* Flash Ticker Effect on live change */
.stats-card.flash-up .price-value {
  color: #34D399;
  transform: translateY(-2px);
}

.stats-card.flash-down .price-value {
  color: #F87171;
  transform: translateY(2px);
}

.stats-card-desc {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: #8E9BAE;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.desc-change.positive {
  color: #34D399;
  font-weight: 600;
}

.desc-change.negative {
  color: #F87171;
  font-weight: 600;
}

.range-vals {
  color: #CBD5E1;
  font-weight: 500;
}

/* ── 6. 7-Session Trading Bar Chart (StatsCard Replication) ── */
.stats-card-chart-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 10px 10px 8px;
}

.stats-card-chart-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748B;
}

/* Flex h-20 w-full items-end gap-3 */
.stats-card-bars {
  display: flex;
  height: 76px;
  width: 100%;
  align-items: flex-end;
  gap: 7px;
  position: relative;
}

.stats-bar-column {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  position: relative;
}

/* motion.div w-full rounded-t-lg */
.stats-bar-fill {
  width: 100%;
  min-width: 8px;
  border-radius: 5px 5px 1px 1px;
  height: 0%;
  position: relative;
  transition: height 0.75s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 0.3s ease,
              box-shadow 0.3s ease;
  will-change: height;
}

.stats-card.is-visible .stats-bar-fill {
  height: var(--bar-height, 0%);
}

/* Default Bar Colors */
.stats-card--gold24 .stats-bar-fill.bar-default {
  background: rgba(255, 215, 0, 0.18);
}
.stats-card--gold24 .stats-bar-fill.bar-highlighted {
  background: linear-gradient(180deg, #FFE58F 0%, #D4AF37 100%);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
}

.stats-card--gold22 .stats-bar-fill.bar-default {
  background: rgba(234, 179, 8, 0.18);
}
.stats-card--gold22 .stats-bar-fill.bar-highlighted {
  background: linear-gradient(180deg, #FDE047 0%, #CA8A04 100%);
  box-shadow: 0 0 12px rgba(234, 179, 8, 0.5);
}

.stats-card--silver .stats-bar-fill.bar-default {
  background: rgba(203, 213, 225, 0.18);
}
.stats-card--silver .stats-bar-fill.bar-highlighted {
  background: linear-gradient(180deg, #FFFFFF 0%, #94A3B8 100%);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.45);
}

/* Bar Tooltip on Hover */
.stats-bar-column:hover .stats-bar-fill {
  filter: brightness(1.25);
}

.stats-bar-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: rgba(10, 13, 18, 0.95);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 700;
  color: #FFE58F;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.stats-bar-column:hover .stats-bar-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Day Label */
.stats-bar-label {
  font-size: 9.5px;
  font-weight: 600;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.stats-bar-column.is-today .stats-bar-label {
  color: #FFE58F;
  font-weight: 700;
}

/* ── 7. Terminal Footer ── */
.live-rates-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
}

.live-rates-footer-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #94A3B8;
  max-width: 540px;
  line-height: 1.4;
}

.live-rates-footer-info strong {
  color: #FFE58F;
  margin-right: 4px;
}

.live-rates-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.live-rates-calc-btn,
.live-rates-lock-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.25s ease;
}

.live-rates-calc-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #E2E8F0;
}

.live-rates-calc-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.live-rates-lock-btn {
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: #FFFFFF;
  border: none;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
}

.live-rates-lock-btn:hover {
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5);
  transform: translateY(-2px);
}

/* ── 8. Responsive Design ── */
@media (max-width: 992px) {
  .live-rates-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  
  .live-rates-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .live-rates-header-right {
    justify-content: space-between;
  }
}

@media (max-width: 600px) {
  .live-rates-modal-container {
    padding: 12px;
  }

  .live-rates-modal-dialog {
    padding: 20px 16px;
    border-radius: 18px;
  }

  .live-rates-title {
    font-size: 22px;
  }

  .stats-card-price {
    font-size: 26px;
  }

  .live-rates-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .live-rates-footer-actions {
    flex-direction: column;
    width: 100%;
  }

  .live-rates-calc-btn,
  .live-rates-lock-btn {
    justify-content: center;
    width: 100%;
  }
}
