/* ==========================================
   TENSORTRADE MOBILE REDESIGN
   Complete mobile-first responsive design
   Activates at: max-width: 768px
   
   Design Principles:
   1. Mobile-first approach
   2. Bottom navigation for thumb-reach
   3. Card-based content hierarchy
   4. Progressive disclosure
   5. Touch-optimized (48dp targets)
   6. Gesture-based interactions
   ========================================== */

/* ==========================================
   MOBILE ACTIVATION BREAKPOINT
   ========================================== */
:root {
  --mobile-breakpoint: 768px;
  --mobile-padding: 8px;
  --mobile-card-radius: 16px;
  --mobile-touch-target: 48px;
  --mobile-bottom-nav-height: 64px;
  --mobile-header-height: 56px;
}

/* ==========================================
   MOBILE: CORE RESET & FOUNDATION
   Clean slate for mobile experience
   ========================================== */
@media (max-width: 768px) {
  /* Prevent any horizontal overflow */
  html {
    overflow-x: hidden !important;
    width: 100%;
    scroll-behavior: smooth;
    box-sizing: border-box;
  }
  
  /* Apply box-sizing to all elements */
  *,
  *::before,
  *::after {
    box-sizing: border-box !important;
  }
  
  body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative;
    /* Add padding for bottom nav */
    padding-bottom: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom, 0px)) !important;
    /* Optimize font rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  
  /* Force everything to respect viewport */
  * {
    max-width: 100%;
  }
  
  /* Main container - properly centered with equal spacing */
  #main-content,
  main,
  main.container,
  .container,
  .container-fluid {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding-left: var(--mobile-padding) !important;
    padding-right: var(--mobile-padding) !important;
    padding-bottom: var(--mobile-padding) !important;
    padding-top: 72px !important; /* Space for toggle button */
    margin-left: auto !important;
    margin-right: auto !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    position: relative;
  }
  
  /* Direct children of main-content should be centered */
  #main-content > *,
  main > * {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
  }
  
  /* Ensure rows don't cause overflow and stay centered */
  .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
  }
  
  /* Ensure columns respect container width and stack properly */
  [class*="col-"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    box-sizing: border-box !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}

/* ==========================================
   MOBILE: HEADER - REMOVED, USING TOGGLE ONLY
   Removed mobile header, using existing sidebar toggle
   ========================================== */
@media (max-width: 768px) {
  /* Hide desktop sidebar completely */
  .sidebar {
    display: none !important;
  }
  
  /* Keep the sidebar toggle button visible */
  .sidebar-toggle-mobile {
    display: flex !important;
    z-index: 1060 !important;
    position: relative !important;
  }
  
  /* Hide version controls in their current position */
  .version-controls {
    display: none !important;
  }
  
  /* Adjust body margin for hidden sidebar */
  body {
    margin-left: 0 !important;
  }
}

/* ==========================================
   MOBILE: BOTTOM NAVIGATION BAR
   Primary navigation at thumb-reach
   ========================================== */
@media (max-width: 768px) {
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-bottom-nav-height);
    /* Foggy glass effect - semi-transparent with blur */
    background: rgba(41, 37, 36, 0.75); /* --color-bg-elevated with 75% opacity */
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 8px 8px calc(env(safe-area-inset-bottom, 0px));
    z-index: 1000;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.3), 0 -4px 20px rgba(0, 0, 0, 0.15);
  }
  
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1;
    min-height: var(--mobile-touch-target);
    text-decoration: none;
    color: var(--color-text-tertiary);
    transition: all 0.2s ease;
    border-radius: 12px;
    padding: 4px;
  }
  
  .mobile-nav-item:active {
    transform: scale(0.95);
    background: var(--color-bg-secondary);
  }
  
  .mobile-nav-item.active {
    color: var(--color-primary);
  }
  
  .mobile-nav-icon {
    font-size: 24px;
  }
  
  .mobile-nav-label {
    font-size: 11px;
    font-weight: 500;
  }
  
  /* Keep sidebar overlay for when menu opens */
  .sidebar-overlay {
    display: block;
  }
}

/* ==========================================
   MOBILE: CARD SYSTEM
   Modern card-based layout
   ========================================== */
@media (max-width: 768px) {
  /* All cards use new mobile design */
  .card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    border-radius: var(--mobile-card-radius) !important;
    margin-bottom: 12px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    overflow: hidden !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--color-border-subtle);
    box-sizing: border-box !important;
  }
  
  .card-header {
    padding: 16px;
    background: var(--color-bg-elevated);
    border-bottom: 1px solid var(--color-border-subtle);
    min-height: var(--mobile-touch-target);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  .card-header h5,
  .card-header h4,
  .card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
  }
  
  .card-body {
    padding: 16px;
    overflow-x: hidden;
  }
  
  .card-footer {
    padding: 16px;
    background: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border-subtle);
  }
  
  /* Stock/prediction cards - optimized for mobile */
  .stock-card,
  .prediction-card {
    padding: 16px;
    border-radius: var(--mobile-card-radius);
  }
}

/* ==========================================
   MOBILE: CHARTS
   Maximum width charts that stay within cards
   ========================================== */
@media (max-width: 768px) {
  /* Chart wrap - full width within card */
  .chart-wrap {
    width: 100%;
    margin: 16px 0;
    padding: 0;
  }
  
  /* Chart container - maximize width, responsive height */
  .chart-container {
    width: 100% !important;
    height: 450px !important;
    min-height: 450px !important;
    max-height: 450px !important;
    max-width: 100%;
    border-radius: 0; /* Edge-to-edge within card for max space */
    overflow: visible; /* Allow tooltips */
    background: transparent;
    touch-action: pan-x pan-y;
    position: relative;
  }
  
  /* Specific sizing for different chart types */
  .chart-container-sm {
    height: 380px !important;
    min-height: 380px !important;
    max-height: 380px !important;
  }
  
  .chart-container-md {
    height: 450px !important;
    min-height: 450px !important;
    max-height: 450px !important;
  }
  
  .chart-container-lg {
    height: 520px !important;
    min-height: 520px !important;
    max-height: 520px !important;
  }
  
  /* Override inline styles - Force all chart containers to fixed height on mobile */
  div.chart-container[style*="height"],
  .chart-container[id^="detailed"],
  .chart-container[id*="Chart"],
  .chart-container[id*="chart"] {
    height: 450px !important;
    min-height: 450px !important;
    max-height: 450px !important;
  }
  
  /* Force all chart IDs to same size on mobile */
  [id^="detailed"],
  [id*="Chart"],
  [id*="chart"] {
    width: 100% !important;
    min-height: 450px !important;
    height: 450px !important;
    max-height: 450px !important;
  }
  
  /* Ensure ECharts instances and canvas fill container completely */
  .chart-container > div,
  .chart-container > div > canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    touch-action: pan-x pan-y;
    display: block !important;
  }
  
  /* Make sure chart-wrap doesn't add extra height */
  .chart-wrap {
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* Remove padding from card-body to maximize chart space */
  .card-body .chart-wrap {
    margin: 0 !important;
  }
  
  .card-body {
    padding: 0 !important;
  }
  
  /* Make chart canvas touch-friendly */
  .chart-container canvas {
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
  }
  
  .chart-container canvas:active {
    cursor: grabbing;
  }
  
  /* Chart headers on mobile - optimize for narrow screens */
  .chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
    padding: 0 12px;
  }
  
  .chart-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
  }
  
  /* Chart caption - hide desktop instructions, show mobile */
  .chart-caption {
    font-size: 11px;
    text-align: center;
    padding: 12px 8px;
    color: var(--color-text-tertiary);
    line-height: 1.4;
  }
  
  .chart-caption span {
    display: none !important;
  }
  
  .chart-caption::after {
    content: 'Tap and drag to explore • Pinch to zoom';
    display: block;
  }
  
  /* Optimize chart legends for mobile */
  .chart-legend {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
    padding: 0 12px;
  }
  
  .chart-legend-item {
    font-size: 11px;
    padding: 4px 8px;
    white-space: nowrap;
  }
  
  /* Ensure chart tooltips are visible on mobile */
  div[class*="echarts-tooltip"] {
    max-width: 80vw !important;
    font-size: 12px !important;
    z-index: 10000 !important;
  }
  
  /* Card bodies containing charts - remove side padding for max chart width */
  .card-body:has(.chart-wrap),
  .card-body:has(.chart-container) {
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-top: 16px;
    padding-bottom: 16px;
  }
  
  /* But keep padding for other content in the card */
  .card-body:has(.chart-wrap) > *:not(.chart-wrap),
  .card-body:has(.chart-container) > *:not(.chart-container) {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* ==========================================
   MOBILE: TABLES
   Horizontal scroll with clear indicators
   ========================================== */
@media (max-width: 768px) {
  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    margin-bottom: 16px;
    position: relative;
  }
  
  /* Add scroll shadow indicator */
  .table-responsive::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 100%;
    background: linear-gradient(to left, var(--color-bg-elevated), transparent);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s;
  }
  
  .table-responsive.scrolled-end::after {
    opacity: 0;
  }
  
  table {
    width: 100%;
    min-width: max-content;
    font-size: 13px;
  }
  
  .table th {
    padding: 10px 12px;
    font-size: 11px;
    white-space: nowrap;
    background: var(--color-bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
  }
  
  .table td {
    padding: 10px 12px;
    white-space: nowrap;
  }
}

/* ==========================================
   MOBILE: FORMS
   Touch-optimized form controls
   ========================================== */
@media (max-width: 768px) {
  /* All form inputs - iOS zoom prevention */
  input,
  select,
  textarea,
  .form-control,
  .form-select {
    font-size: 16px !important;
    min-height: var(--mobile-touch-target);
    padding: 12px 16px;
    border-radius: 12px;
    border: 2px solid var(--color-border-default);
    -webkit-appearance: none;
    appearance: none;
  }
  
  input:focus,
  select:focus,
  textarea:focus,
  .form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(var(--color-primary-rgb), 0.1);
    outline: none;
  }
  
  .form-label {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    display: block;
  }
  
  /* Form buttons - full width on mobile */
  .form-actions .btn,
  .card-footer .btn {
    width: 100%;
    margin-bottom: 8px;
  }
  
  .form-actions .btn:last-child {
    margin-bottom: 0;
  }
}

/* ==========================================
   MOBILE: BUTTONS
   Touch-optimized with clear states
   ========================================== */
@media (max-width: 768px) {
  .btn {
    min-height: var(--mobile-touch-target);
    min-width: var(--mobile-touch-target);
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }
  
  .btn:active {
    transform: scale(0.97);
  }
  
  .btn i {
    font-size: 18px;
  }
  
  /* Action buttons - prominent on mobile */
  .action-btn {
    width: 100%;
    justify-content: center;
    margin-bottom: 12px;
  }
}

/* ==========================================
   MOBILE: TYPOGRAPHY
   Optimized for small screens
   ========================================== */
@media (max-width: 768px) {
  body {
    font-size: 15px;
    line-height: 1.6;
  }
  
  h1 {
    font-size: 1.75rem;
    line-height: 1.2;
    margin-bottom: 16px;
  }
  
  h2 {
    font-size: 1.5rem;
    line-height: 1.3;
    margin-bottom: 12px;
  }
  
  h3 {
    font-size: 1.25rem;
    line-height: 1.3;
    margin-bottom: 10px;
  }
  
  h4 {
    font-size: 1.125rem;
    line-height: 1.4;
    margin-bottom: 8px;
  }
  
  p {
    margin-bottom: 16px;
    font-size: 15px;
    line-height: 1.6;
  }
  
  /* Ensure text wraps properly */
  h1, h2, h3, h4, h5, h6, p, span, div, td, th, li {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }
}

/* ==========================================
   MOBILE: GRID SYSTEM
   Simple stacking layout
   ========================================== */
@media (max-width: 768px) {
  .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .row > * {
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 12px !important;
  }
  
  /* Stack all columns */
  [class*="col-"] {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}

/* ==========================================
   MOBILE: STOCK/ETF/MUTUAL FUND CARDS
   Optimized listing view
   ========================================== */
@media (max-width: 768px) {
  .stocks-grid,
  .stocks-grid-enhanced,
  .predictions-grid,
  .predictions-grid-enhanced {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  
  .stock-item-wrapper {
    width: 100%;
  }
  
  /* Stock card compact view */
  .stock-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  
  .stock-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  }
  
  .stock-ticker {
    font-size: 1.25rem;
    font-weight: 700;
  }
  
  .stock-company {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-top: 4px;
  }
}

/* ==========================================
   MOBILE: MODALS
   Full-screen modals for better UX
   ========================================== */
@media (max-width: 768px) {
  .modal {
    padding: 0 !important;
    z-index: 1040 !important; /* Below sidebar toggle (1060) */
    background: rgba(0, 0, 0, 0.5); /* Semi-transparent backdrop */
  }
  
  .modal-dialog {
    position: fixed;
    top: 64px; /* Below the header/toggle button */
    left: 0;
    right: 0;
    bottom: var(--mobile-bottom-nav-height); /* Above bottom nav */
    margin: 0;
    max-width: 100%;
    width: 100%;
    max-height: calc(100vh - 64px - var(--mobile-bottom-nav-height)); /* Account for header and bottom nav */
    display: flex;
    flex-direction: column;
    z-index: 1040; /* Below sidebar toggle */
  }
  
  .modal-content {
    height: auto;
    max-height: 100%;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  
  .modal-header {
    flex-shrink: 0;
    padding: 16px;
    border-bottom: 1px solid var(--color-border-default);
  }
  
  .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
  }
  
  .modal-footer {
    flex-shrink: 0;
    padding: 16px;
    border-top: 1px solid var(--color-border-default);
  }
  
  .modal-footer .btn {
    width: 100%;
    margin: 0 0 8px 0;
  }
  
  .modal-footer .btn:last-child {
    margin-bottom: 0;
  }
}

/* ==========================================
   MOBILE: SEARCH
   Prominent search bar
   ========================================== */
@media (max-width: 768px) {
  .search-bar-container {
    position: relative;
    margin-bottom: 16px;
  }
  
  .search-input {
    width: 100%;
    height: var(--mobile-touch-target);
    padding: 12px 48px 12px 48px;
    font-size: 16px;
    border-radius: 24px;
    border: 2px solid var(--color-border-default);
    background: var(--color-bg-elevated);
  }
  
  .search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(var(--color-primary-rgb), 0.1);
  }
  
  .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: var(--color-text-tertiary);
  }
  
  .search-clear {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-secondary);
    border: none;
    color: var(--color-text-secondary);
  }
}

/* ==========================================
   MOBILE: ALERTS & NOTIFICATIONS
   Toast-style notifications
   ========================================== */
@media (max-width: 768px) {
  .alert {
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
  }
  
  /* Mobile toast notification */
  .mobile-toast {
    position: fixed;
    bottom: calc(var(--mobile-bottom-nav-height) + 16px);
    left: 16px;
    right: 16px;
    background: var(--color-bg-elevated);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    animation: slideUp 0.3s ease;
  }
  
  @keyframes slideUp {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
}

/* ==========================================
   MOBILE: PULL TO REFRESH
   Native-like refresh gesture
   ========================================== */
@media (max-width: 768px) {
  .pull-to-refresh-indicator {
    position: fixed;
    top: 72px; /* Below toggle button */
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: var(--color-bg-elevated);
    padding: 12px 24px;
    border-radius: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 999;
    transition: transform 0.3s ease;
  }
  
  .pull-to-refresh-indicator.active {
    transform: translateX(-50%) translateY(16px);
  }
  
  .refresh-icon {
    animation: spin 1s linear infinite;
  }
  
  @keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }
}

/* ==========================================
   MOBILE: FAB (Floating Action Button)
   Quick access to primary action
   ========================================== */
@media (max-width: 768px) {
  .mobile-fab {
    position: fixed;
    bottom: calc(var(--mobile-bottom-nav-height) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 999;
    transition: all 0.3s ease;
  }
  
  .mobile-fab:active {
    transform: scale(0.9);
  }
  
  .mobile-fab i {
    font-size: 24px;
  }
}

/* ==========================================
   MOBILE: BREADCRUMBS
   Simplified navigation
   ========================================== */
@media (max-width: 768px) {
  .breadcrumb {
    display: none;
  }
  
  .breadcrumb-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 14px;
    color: var(--color-primary);
    text-decoration: none;
  }
  
  .breadcrumb-link i {
    font-size: 18px;
  }
}

/* ==========================================
   MOBILE: PREDICTION SECTIONS
   Collapsible sections with better UX
   ========================================== */
@media (max-width: 768px) {
  /* Draggable sections container - ensure proper centering */
  #draggable-sections-container {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
  }
  
  .draggable-section {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 12px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
  }
  
  /* Ensure rows inside draggable sections are properly constrained */
  .draggable-section .row {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  
  .draggable-section [class*="col-"] {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  /* Hide drag handles on mobile */
  .drag-handle,
  .section-drag-handle {
    display: none !important;
  }
  
  /* Collapsible section header */
  .card-header[data-bs-toggle="collapse"] {
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  
  .card-header[data-bs-toggle="collapse"]:active {
    background: var(--color-bg-secondary);
  }
  
  /* Collapse indicator */
  .card-header[data-bs-toggle="collapse"]::after {
    content: '\F282';
    font-family: 'bootstrap-icons';
    margin-left: auto;
    transition: transform 0.3s ease;
  }
  
  .card-header[data-bs-toggle="collapse"]:not(.collapsed)::after {
    transform: rotate(180deg);
  }
}

/* ==========================================
   MOBILE: PAGE HEADERS
   Simplified page titles
   ========================================== */
@media (max-width: 768px) {
  .page-header-section {
    margin-bottom: 16px;
  }
  
  .page-title {
    font-size: 1.5rem;
    margin-bottom: 8px;
  }
  
  .page-subtitle {
    font-size: 14px;
    color: var(--color-text-secondary);
    line-height: 1.5;
  }
  
  .header-badge {
    display: inline-flex;
    margin-bottom: 12px;
  }
  
  .header-stats {
    display: none; /* Move to card view */
  }
}

/* ==========================================
   MOBILE: EMPTY STATES
   Friendly empty state messages
   ========================================== */
@media (max-width: 768px) {
  .empty-state,
  .empty-state-enhanced {
    padding: 48px 24px;
    text-align: center;
  }
  
  .empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    font-size: 32px;
    color: var(--color-text-tertiary);
    background: var(--color-bg-secondary);
    border-radius: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
  }
  
  .empty-state p {
    font-size: 14px;
    color: var(--color-text-secondary);
  }
}

/* ==========================================
   MOBILE: LOADING STATES
   Skeleton screens and spinners
   ========================================== */
@media (max-width: 768px) {
  .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border-default);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  
  .loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
  }
}

/* ==========================================
   MOBILE: SAFE AREA SUPPORT
   iPhone X+ notch and home indicator
   ========================================== */
@media (max-width: 768px) {
  @supports (padding: max(0px)) {
    .mobile-header {
      padding-top: max(12px, env(safe-area-inset-top));
      height: calc(var(--mobile-header-height) + env(safe-area-inset-top, 0px));
    }
    
    .mobile-bottom-nav {
      padding-bottom: max(8px, env(safe-area-inset-bottom));
      height: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    }
    
    body {
      padding-bottom: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    }
  }
}

/* ==========================================
   MOBILE: PERFORMANCE OPTIMIZATIONS
   ========================================== */
@media (max-width: 768px) {
  /* Reduce motion for better performance */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
  
  /* Enable smooth scrolling */
  * {
    -webkit-overflow-scrolling: touch;
  }
  
  /* GPU acceleration for common elements */
  .card,
  .btn,
  .mobile-bottom-nav,
  .mobile-header {
    will-change: auto;
    transform: translateZ(0);
    backface-visibility: hidden;
  }
}

/* ==========================================
   MOBILE: UTILITY CLASSES
   ========================================== */
@media (max-width: 768px) {
  .mobile-only {
    display: block !important;
  }
  
  .desktop-only {
    display: none !important;
  }
  
  .mobile-hidden {
    display: none !important;
  }
  
  .mobile-full-width {
    width: 100% !important;
  }
  
  .mobile-text-center {
    text-align: center !important;
  }
  
  .mobile-mt-0 { margin-top: 0 !important; }
  .mobile-mt-1 { margin-top: 8px !important; }
  .mobile-mt-2 { margin-top: 16px !important; }
  .mobile-mt-3 { margin-top: 24px !important; }
  
  .mobile-mb-0 { margin-bottom: 0 !important; }
  .mobile-mb-1 { margin-bottom: 8px !important; }
  .mobile-mb-2 { margin-bottom: 16px !important; }
  .mobile-mb-3 { margin-bottom: 24px !important; }
}

/* ==========================================
   MOBILE: MENU MODAL
   Full-screen menu overlay
   ========================================== */
@media (max-width: 768px) {
  .mobile-menu-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--color-border-default);
  }
  
  .mobile-menu-header h3 {
    margin: 0;
    font-size: 1.5rem;
  }
  
  .mobile-menu-items {
    padding: 8px 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  
  .mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    color: var(--color-text-primary);
    text-decoration: none;
    transition: background 0.2s ease;
    min-height: var(--mobile-touch-target);
  }
  
  .mobile-menu-item:active {
    background: var(--color-bg-secondary);
  }
  
  .mobile-menu-item i {
    font-size: 20px;
    width: 24px;
    text-align: center;
    color: var(--color-text-secondary);
  }
  
  .mobile-menu-item span {
    font-size: 16px;
    font-weight: 400;
  }
  
  .mobile-menu-divider {
    margin: 8px 16px;
    border-color: var(--color-border-subtle);
  }
  
  .mobile-menu-section-header {
    padding: 12px 20px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  
  .mobile-theme-picker {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 0 16px 16px;
  }
  
  .mobile-theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--color-bg-secondary);
    border: 2px solid transparent;
    border-radius: 12px;
    color: var(--color-text-primary);
    transition: all 0.2s ease;
    cursor: pointer;
  }
  
  .mobile-theme-option:active {
    transform: scale(0.95);
  }
  
  .mobile-theme-option.active {
    border-color: var(--color-primary);
    background: var(--color-bg-elevated);
  }
  
  .mobile-theme-option i {
    font-size: 24px;
  }
  
  .mobile-theme-option span {
    font-size: 11px;
    font-weight: 500;
  }
}

/* ==========================================
   END OF MOBILE REDESIGN
   ========================================== */

