/* Mobile-First Optimized Styles - Progressive Enhancement */

/* ========================================
   PHASE 1: CRITICAL MOBILE OPTIMIZATIONS
   ======================================== */

/* Base Variables for Mobile */
:root {
  --mobile-touch-target: 44px;
  --mobile-font-size: 16px;
  --mobile-line-height: 1.4;
  --mobile-spacing: 0.75rem;
  --mobile-border-radius: 8px;
  
  /* Performance-optimized animations */
  --fast-transition: 0.15s ease-out;
  --medium-transition: 0.3s ease-out;
  
  /* Mobile-first colors */
  --mobile-text-primary: #ffffff;
  --mobile-text-secondary: #e2e8f0;
  --mobile-bg-card: rgba(15, 23, 42, 0.8);
  --mobile-border: rgba(148, 163, 184, 0.2);
}

/* ========================================
   MOBILE-FIRST BASE STYLES
   ======================================== */

/* Reset and base optimization */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* Mobile-optimized body */
body {
  font-size: var(--mobile-font-size);
  line-height: var(--mobile-line-height);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Touch-friendly navigation */
.navbar {
  padding: 0.5rem 1rem;
  min-height: 56px;
}

.navbar-brand {
  font-size: 1.1rem;
  font-weight: 600;
}

.navbar-toggler {
  border: none;
  padding: 0.5rem;
  min-width: var(--mobile-touch-target);
  min-height: var(--mobile-touch-target);
}

/* Mobile-first cards */
.card {
  border-radius: var(--mobile-border-radius);
  margin-bottom: 1rem;
  border: 1px solid var(--mobile-border);
  background: var(--mobile-bg-card);
  backdrop-filter: blur(10px);
}

.card-body {
  padding: 1rem;
}

.card-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--mobile-border);
}

/* Mobile-optimized buttons */
.btn {
  min-height: var(--mobile-touch-target);
  min-width: var(--mobile-touch-target);
  padding: 0.75rem 1rem;
  border-radius: var(--mobile-border-radius);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--fast-transition);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left var(--medium-transition);
}

.btn:active::before {
  left: 100%;
}

/* Touch feedback */
.btn:active {
  transform: scale(0.98);
}

/* Mobile-first forms */
.form-control,
.form-select {
  font-size: var(--mobile-font-size);
  min-height: var(--mobile-touch-target);
  padding: 0.75rem;
  border-radius: var(--mobile-border-radius);
  border: 1px solid var(--mobile-border);
  background: rgba(15, 23, 42, 0.5);
  color: var(--mobile-text-primary);
  transition: all var(--fast-transition);
}

.form-control:focus,
.form-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  outline: none;
}

/* Mobile-optimized tables */
.table-responsive {
  -webkit-overflow-scrolling: touch;
  border-radius: var(--mobile-border-radius);
}

.table {
  margin-bottom: 0;
  font-size: 0.875rem;
}

.table th,
.table td {
  padding: 0.75rem 0.5rem;
  border-color: var(--mobile-border);
  white-space: nowrap;
}

/* Performance-optimized charts */
.chart-container {
  height: 280px;
  position: relative;
  margin-bottom: 1rem;
  background: var(--mobile-bg-card);
  border-radius: var(--mobile-border-radius);
  padding: 1rem;
}

.mini-chart-container {
  height: 180px;
  background: var(--mobile-bg-card);
  border-radius: var(--mobile-border-radius);
  padding: 0.75rem;
  margin-bottom: 1rem;
}

/* Mobile metric cards */
.metric-card {
  text-align: center;
  padding: 1rem;
  background: var(--mobile-bg-card);
  border-radius: var(--mobile-border-radius);
  margin-bottom: 1rem;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--mobile-text-primary);
  margin: 0.5rem 0;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--mobile-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Loading states optimized for mobile */
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(59, 130, 246, 0.3);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Trading Stats */
.trading-stat {
  text-align: center;
  padding: 0.75rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(148, 163, 184, 0.1);
  transition: all 0.3s ease;
}

@media (max-width: 768px) {
  .trading-stat {
    padding: 0.5rem 0.25rem;
  }
  
  .stat-value {
    font-size: 0.9rem !important;
  }
  
  .stat-label {
    font-size: 0.75rem !important;
  }
  
  .stat-value.small {
    font-size: 0.8rem !important;
  }
  
  .stat-label.small {
    font-size: 0.7rem !important;
  }
}

/* ========================================
   PROGRESSIVE ENHANCEMENT - TABLET
   ======================================== */

@media (min-width: 576px) {
  .card-body {
    padding: 1.25rem;
  }
  
  .chart-container {
    height: 320px;
  }
  
  .mini-chart-container {
    height: 200px;
  }
  
  .metric-value {
    font-size: 1.75rem;
  }
  
  .btn {
    padding: 0.75rem 1.25rem;
  }
}

/* ========================================
   PROGRESSIVE ENHANCEMENT - DESKTOP
   ======================================== */

@media (min-width: 768px) {
  :root {
    --mobile-spacing: 1rem;
  }
  
  .navbar {
    padding: 0.75rem 1rem;
  }
  
  .card-body {
    padding: 1.5rem;
  }
  
  .chart-container {
    height: 400px;
  }
  
  .mini-chart-container {
    height: 250px;
  }
  
  .metric-value {
    font-size: 2rem;
  }
  
  /* Desktop hover effects */
  .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
  
  .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  }
  
  /* Desktop-specific animations */
  .btn,
  .card {
    transition: all var(--medium-transition);
  }
}

/* ========================================
   LARGE DESKTOP ENHANCEMENTS
   ======================================== */

@media (min-width: 1200px) {
  .chart-container {
    height: 500px;
  }
  
  .mini-chart-container {
    height: 280px;
  }
  
  .metric-value {
    font-size: 2.25rem;
  }
  
  /* High-resolution displays */
  @media (min-resolution: 1.5dppx) {
    .chart-container {
      height: 550px;
    }
  }
}

/* ========================================
   TOUCH DEVICE OPTIMIZATIONS
   ======================================== */

@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .btn:hover,
  .card:hover {
    transform: none;
    box-shadow: none;
  }
  
  /* Larger touch targets */
  .btn-close {
    width: var(--mobile-touch-target);
    height: var(--mobile-touch-target);
  }
  
  /* Touch feedback */
  .btn:active {
    background-color: rgba(59, 130, 246, 0.8);
  }
  
  /* Optimize scrolling */
  .table-responsive {
    scroll-behavior: smooth;
  }
}

/* ========================================
   REDUCED MOTION SUPPORT
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .loading-spinner {
    animation: none;
    border-top-color: transparent;
  }
}

/* ========================================
   HIGH CONTRAST MODE
   ======================================== */

@media (prefers-contrast: high) {
  :root {
    --mobile-border: #ffffff;
    --mobile-text-primary: #ffffff;
    --mobile-bg-card: #000000;
  }
  
  .card,
  .form-control,
  .form-select,
  .btn {
    border-width: 2px;
  }
}

/* ========================================
   DARK MODE OPTIMIZATIONS
   ======================================== */

@media (prefers-color-scheme: dark) {
  :root {
    --mobile-text-primary: #f8fafc;
    --mobile-text-secondary: #cbd5e1;
    --mobile-bg-card: rgba(15, 23, 42, 0.9);
  }
}

/* ========================================
   LANDSCAPE MODE MOBILE
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
  .navbar {
    padding: 0.25rem 1rem;
    min-height: 48px;
  }
  
  .chart-container {
    height: 200px;
  }
  
  .mini-chart-container {
    height: 140px;
  }
  
  .card-body {
    padding: 0.75rem;
  }
  
  /* Hide breadcrumbs in landscape mobile */
  .breadcrumb {
    display: none;
  }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* Optimize rendering for mobile */
.chart-container,
.mini-chart-container {
  contain: layout style paint;
  will-change: transform;
}

/* Optimize images */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Optimize fonts */
@media (max-width: 768px) {
  body {
    font-display: swap;
  }
}

/* Critical path optimization */
.above-fold {
  contain: layout style;
}

.below-fold {
  contain: layout style paint;
}