/* ============================================================================
   TRADING FONTS - JetBrains Mono for numbers
   ============================================================================ */

/* JetBrains Mono imported via globals.css to satisfy CSS @import ordering rules */

/* Base trading font class - use for all numbers */
.font-trading {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, Consolas, monospace;
  font-feature-settings: 'tnum' 1;
  font-variant-numeric: tabular-nums;
}

/* Price display - current price, order prices */
.price-display {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* Amount display - order amounts, balances */
.amount-display {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Timer/countdown display */
.timer-display {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 500;
  font-variant-numeric: tabular-nums slashed-zero;
}

/* Percentage display */
.percent-display {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ============================================================================
   CHART FONT SIZES - Consistent scale
   ============================================================================ */

.text-chart-2xs { font-size: 9px; line-height: 1.2; }
.text-chart-xs { font-size: 10px; line-height: 1.3; }
.text-chart-sm { font-size: 11px; line-height: 1.4; }
.text-chart-base { font-size: 12px; line-height: 1.5; }
.text-chart-md { font-size: 13px; line-height: 1.5; }
.text-chart-lg { font-size: 14px; line-height: 1.5; }
.text-chart-xl { font-size: 16px; line-height: 1.4; }
.text-chart-2xl { font-size: 18px; line-height: 1.3; }

/* ============================================================================
   CHART COLORS - Consistent palette
   Phase 4: Standardized color system for binary chart components
   ============================================================================ */

/* ============================================================================
   DARK MODE - Backgrounds
   ============================================================================ */
.dark .bg-chart-base { background-color: #09090b; }       /* zinc-950 - Canvas/base */
.dark .bg-chart-primary { background-color: #0d0d0f; }    /* Custom - Main panels */
.dark .bg-chart-secondary { background-color: #18181b; }  /* zinc-900 - Elevated surfaces */
.dark .bg-chart-tertiary { background-color: #27272a; }   /* zinc-800 - Cards, inputs */
.dark .bg-chart-hover { background-color: #3f3f46; }      /* zinc-700 - Hover states */
.dark .bg-chart-active { background-color: #52525b; }     /* zinc-600 - Active states */

/* Dark mode background with opacity variants */
.dark .bg-chart-secondary\/50 { background-color: rgba(24, 24, 27, 0.5); }
.dark .bg-chart-secondary\/80 { background-color: rgba(24, 24, 27, 0.8); }
.dark .bg-chart-tertiary\/50 { background-color: rgba(39, 39, 42, 0.5); }
.dark .bg-chart-tertiary\/80 { background-color: rgba(39, 39, 42, 0.8); }

/* Panel-specific backgrounds */
.dark .bg-chart-panel { background-color: #0d0d0f; }      /* Main panel bg */
.dark .bg-chart-panel-header { background-color: #18181b; }
.dark .bg-chart-panel-footer { background-color: #18181b; }
.dark .bg-chart-input { background-color: #27272a; }      /* Input fields */
.dark .bg-chart-dropdown { background-color: #1c1c1e; }   /* Dropdowns, selects */

/* ============================================================================
   DARK MODE - Text Colors
   ============================================================================ */
.dark .text-chart-primary { color: #fafafa; }    /* zinc-50 - Primary text */
.dark .text-chart-secondary { color: #a1a1aa; }  /* zinc-400 - Secondary text */
.dark .text-chart-muted { color: #71717a; }      /* zinc-500 - Muted/subtle */
.dark .text-chart-dim { color: #52525b; }        /* zinc-600 - Dimmed text */
.dark .text-chart-disabled { color: #3f3f46; }   /* zinc-700 - Disabled text */

/* ============================================================================
   DARK MODE - Border Colors
   ============================================================================ */
.dark .border-chart-default { border-color: #27272a; }    /* zinc-800 */
.dark .border-chart-subtle { border-color: rgba(39, 39, 42, 0.5); }
.dark .border-chart-strong { border-color: #3f3f46; }     /* zinc-700 */

/* ============================================================================
   LIGHT MODE - Backgrounds
   ============================================================================ */
.bg-chart-base { background-color: #ffffff; }
.bg-chart-primary { background-color: #ffffff; }
.bg-chart-secondary { background-color: #f4f4f5; }        /* zinc-100 */
.bg-chart-tertiary { background-color: #e4e4e7; }         /* zinc-200 */
.bg-chart-hover { background-color: #d4d4d8; }            /* zinc-300 */
.bg-chart-active { background-color: #a1a1aa; }           /* zinc-400 */

/* Light mode background with opacity variants */
.bg-chart-secondary\/50 { background-color: rgba(244, 244, 245, 0.5); }
.bg-chart-secondary\/80 { background-color: rgba(244, 244, 245, 0.8); }
.bg-chart-tertiary\/50 { background-color: rgba(228, 228, 231, 0.5); }
.bg-chart-tertiary\/80 { background-color: rgba(228, 228, 231, 0.8); }

/* Panel-specific backgrounds */
.bg-chart-panel { background-color: #ffffff; }
.bg-chart-panel-header { background-color: #f4f4f5; }
.bg-chart-panel-footer { background-color: #f4f4f5; }
.bg-chart-input { background-color: #f4f4f5; }
.bg-chart-dropdown { background-color: #ffffff; }

/* ============================================================================
   LIGHT MODE - Text Colors
   ============================================================================ */
.text-chart-primary { color: #09090b; }          /* zinc-950 */
.text-chart-secondary { color: #52525b; }        /* zinc-600 */
.text-chart-muted { color: #71717a; }            /* zinc-500 */
.text-chart-dim { color: #a1a1aa; }              /* zinc-400 */
.text-chart-disabled { color: #d4d4d8; }         /* zinc-300 */

/* ============================================================================
   LIGHT MODE - Border Colors
   ============================================================================ */
.border-chart-default { border-color: #e4e4e7; }          /* zinc-200 */
.border-chart-subtle { border-color: rgba(228, 228, 231, 0.5); }
.border-chart-strong { border-color: #d4d4d8; }           /* zinc-300 */

/* ============================================================================
   SEMANTIC BACKGROUND COLORS (both modes)
   ============================================================================ */
.bg-chart-success { background-color: rgba(34, 197, 94, 0.1); }
.bg-chart-success-solid { background-color: #22c55e; }
.bg-chart-error { background-color: rgba(239, 68, 68, 0.1); }
.bg-chart-error-solid { background-color: #ef4444; }
.bg-chart-warning { background-color: rgba(245, 158, 11, 0.1); }
.bg-chart-warning-solid { background-color: #f59e0b; }
.bg-chart-info { background-color: rgba(59, 130, 246, 0.1); }
.bg-chart-info-solid { background-color: #3b82f6; }

/* ============================================================================
   TRADING COLORS - Profit/Loss
   ============================================================================ */

/* Bullish/Profit colors */
.text-bullish { color: #22c55e; }
.bg-bullish { background-color: rgba(34, 197, 94, 0.1); }
.border-bullish { border-color: rgba(34, 197, 94, 0.2); }

/* Bearish/Loss colors */
.text-bearish { color: #ef4444; }
.bg-bearish { background-color: rgba(239, 68, 68, 0.1); }
.border-bearish { border-color: rgba(239, 68, 68, 0.2); }

/* Alert colors */
.text-alert { color: #f59e0b; }
.bg-alert { background-color: rgba(245, 158, 11, 0.1); }
.border-alert { border-color: rgba(245, 158, 11, 0.2); }

/* ============================================================================
   CHART BORDER RADIUS - Consistent rounded corners
   Phase 7: Standardized border radius scale
   ============================================================================ */

/* Small elements (badges, tags) - 6px */
.rounded-chart-sm { border-radius: 6px; }

/* Standard elements (buttons, inputs) - 8px */
.rounded-chart-md { border-radius: 8px; }

/* Large elements (panels, cards) - 12px */
.rounded-chart-lg { border-radius: 12px; }

/* Extra large elements - 16px */
.rounded-chart-xl { border-radius: 16px; }

/* ============================================================================
   CHART TRANSITIONS - Consistent animation timing
   Phase 8: Standardized transition durations
   ============================================================================ */

.transition-chart-fast { transition-duration: 100ms; }
.transition-chart-normal { transition-duration: 150ms; }
.transition-chart-slow { transition-duration: 200ms; }

/* Standard easing function */
.ease-chart { transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); }

/* ============================================================================
   ORIGINAL CHART STYLES
   ============================================================================ */

/* Chart specific styles */
.chart-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--chart-bg);
  z-index: 0;
  touch-action: none;
  -webkit-overflow-scrolling: touch;
  border: none !important;
}

.chart-container canvas {
  border: none !important;
  display: block;
}

.chart-controls {
  z-index: 10;
}

/* Progress bar animation */
.progress-bar {
  transition: width 1s linear;
}

/* Profit/loss value change animation */
.value-change {
  transition: color 0.3s ease;
}

/* Trading buttons glow effect */
.trading-button-rise {
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transition: all 0.2s ease;
}

.trading-button-rise:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

.trading-button-fall {
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
  transition: all 0.2s ease;
}

.trading-button-fall:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.5);
  transform: translateY(-1px);
}

/* Ensure the chart panel expands when siblings are collapsed */
.panel-group [data-panel-id="chart"] {
  transition:
    height 0.3s ease-in-out,
    flex-grow 0.3s ease-in-out;
}

/* When a sibling is collapsed, allow the chart to grow */
.panel-group:has(.panel-collapsed) [data-panel-id="chart"] {
  flex-grow: 1;
}

/* Ensure no default margins or borders on canvas elements */
canvas {
  display: block;
  border: none !important;
  margin: 0;
  padding: 0;
}

/* Chart Canvas Styles */
.chart-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* Mobile Touch Optimizations */
@media (max-width: 768px) {
  .chart-canvas {
    /* Allow pinch-to-zoom gestures on mobile */
    touch-action: none;
    /* Enable hardware acceleration */
    transform: translateZ(0);
    will-change: transform;
    /* Improve scrolling performance */
    -webkit-overflow-scrolling: touch;
  }

  /* Hardware acceleration during touch dragging */
  .touch-dragging {
    transform: translate3d(0, 0, 0);
    will-change: transform;
    /* Improve rendering performance during drag */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Reduce paint overhead */
    contain: layout style paint;
  }

  /* Hardware acceleration during pinch zoom */
  .touch-pinching {
    transform: translate3d(0, 0, 0);
    will-change: transform;
    /* Improve rendering performance during pinch */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  /* Optimize canvas rendering on mobile */
  .chart-canvas.touch-dragging {
    /* Force GPU compositing */
    transform: translateZ(0);
    /* Improve rendering quality */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Crosshair styles */
.chart-crosshair {
  pointer-events: none;
  position: absolute;
  z-index: 10;
}

.chart-crosshair-line {
  position: absolute;
  background: rgba(255, 255, 255, 0.3);
  pointer-events: none;
}

.chart-crosshair-horizontal {
  width: 100%;
  height: 1px;
}

.chart-crosshair-vertical {
  width: 1px;
  height: 100%;
}

/* Price line styles */
.chart-price-line {
  stroke: #ffff00;
  stroke-width: 1;
  stroke-dasharray: 5, 5;
  opacity: 0.8;
}

/* Volume bar styles */
.chart-volume-bar {
  opacity: 0.6;
}

.chart-volume-bar.positive {
  fill: #26a69a;
}

.chart-volume-bar.negative {
  fill: #ef5350;
}

/* Candle styles */
.chart-candle-body {
  stroke-width: 1;
}

.chart-candle-body.bullish {
  fill: #26a69a;
  stroke: #26a69a;
}

.chart-candle-body.bearish {
  fill: #ef5350;
  stroke: #ef5350;
}

.chart-candle-wick {
  stroke-width: 1;
}

.chart-candle-wick.bullish {
  stroke: #26a69a;
}

.chart-candle-wick.bearish {
  stroke: #ef5350;
}

/* Loading animation */
.chart-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
}

.chart-loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top: 4px solid #007bff;
  border-radius: 50%;
  animation: chart-spin 1s linear infinite;
}

@keyframes chart-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Chart tooltip */
.chart-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  z-index: 15;
  white-space: nowrap;
}

/* Dark theme adjustments */
.dark .chart-container {
  --chart-bg: #131722;
}

.dark .chart-tooltip {
  background: rgba(255, 255, 255, 0.9);
  color: #131722;
}

/* Prevent text selection during drag */
.dragging * {
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
}

/* Smooth transitions for zoom operations */
.chart-zoom-transition {
  transition: transform 0.1s ease-out;
}

/* Hide scrollbars on chart container */
.chart-container {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.chart-container::-webkit-scrollbar {
  display: none;
}

/* Performance optimizations for mobile */
@media (max-width: 768px) {
  .chart-canvas {
    /* Reduce rendering complexity on mobile */
    image-rendering: optimizeSpeed;
    /* Optimize for touch interactions */
    -webkit-user-drag: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  }

  /* Reduce opacity during drag for better performance */
  .touch-dragging {
    opacity: 0.95;
  }
}
