/* Mobile Dashboard Optimization Styles */

/* Mobile Dashboard Container */
@media (max-width: 768px) {
  .dashboard-container {
    padding: 10px;
    min-height: calc(100vh - 60px); /* Account for mobile navigation */
  }

  .dashboard-header {
    margin-bottom: 20px;
    text-align: center;
  }

  .dashboard-title {
    font-size: 1.8rem;
    font-weight: 400;
    margin-bottom: 8px;
  }

  .dashboard-subtitle {
    font-size: 0.95rem;
    line-height: 1.4;
  }

  /* Mobile metrics grid - single column */
  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
  }

  .metric-card {
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: transform 0.2s ease;
  }

  .metric-card:active {
    transform: scale(0.98);
  }

  .metric-title {
    font-size: 0.8rem;
    margin-bottom: 4px;
  }

  .metric-value {
    font-size: 1.6rem;
    font-weight: 700;
  }

  .metric-subtitle {
    font-size: 0.75rem;
  }

  /* Mobile charts container - single column */
  .charts-container {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
  }

  .chart-card {
    padding: 16px;
    border-radius: 12px;
  }

  .chart-title {
    font-size: 1rem;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .chart-container {
    height: 250px; /* Reduced height for mobile */
    position: relative;
    margin: 0 -8px; /* Extend chart to edges for more space */
  }

  /* Mobile controls bar */
  .controls-bar {
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    background: white;
  }

  .status-indicator {
    margin-bottom: 12px;
  }

  .btn-group {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }

  .btn-dashboard {
    padding: 8px 14px;
    font-size: 0.85rem;
    border-radius: 8px;
    flex: 1;
    min-width: 100px;
  }

  .last-updated {
    font-size: 0.75rem;
    text-align: center;
    margin-top: 12px;
  }

  /* Mobile analytics section */
  .analytics-section {
    margin-top: 24px;
  }

  .analytics-section h2 {
    font-size: 1.4rem;
    margin-bottom: 16px;
    text-align: center;
  }

  /* Mobile recommendations */
  .recommendation-item {
    padding: 12px;
    margin: 8px 0;
    border-radius: 8px;
  }

  .recommendation-title {
    font-size: 0.95rem;
    margin-bottom: 6px;
  }

  .recommendation-description {
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 8px;
  }

  .recommendation-actions {
    margin-top: 8px;
  }

  .recommendation-actions ul {
    margin: 4px 0 0 16px;
    font-size: 0.85rem;
  }

  .recommendation-impact {
    font-size: 0.85rem;
    margin-top: 6px;
  }

  /* Mobile anomaly items */
  .anomaly-item {
    padding: 10px;
    margin: 6px 0;
    border-radius: 8px;
    font-size: 0.85rem;
  }

  .anomaly-timestamp {
    font-size: 0.75rem;
    margin-bottom: 4px;
  }

  .anomaly-metrics {
    font-size: 0.8rem;
    line-height: 1.4;
  }

  /* Mobile executive metrics */
  .executive-metric {
    padding: 6px 10px;
    margin: 3px;
    font-size: 0.85rem;
    border-radius: 6px;
  }

  /* Mobile loading states */
  .loading-placeholder {
    padding: 16px;
    font-size: 0.9rem;
  }

  .loading-spinner {
    width: 16px;
    height: 16px;
  }

  /* Mobile buttons */
  .btn-small {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
  }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 576px) {
  .dashboard-container {
    padding: 8px;
  }

  .dashboard-title {
    font-size: 1.5rem;
  }

  .dashboard-subtitle {
    font-size: 0.85rem;
  }

  .metric-card {
    padding: 14px;
  }

  .metric-value {
    font-size: 1.4rem;
  }

  .chart-container {
    height: 200px;
  }

  .btn-dashboard {
    font-size: 0.8rem;
    padding: 6px 12px;
  }

  /* Stack all buttons vertically on very small screens */
  .btn-group {
    flex-direction: column;
    width: 100%;
  }

  .btn-dashboard {
    width: 100%;
  }
}

/* Landscape optimizations */
@media (max-width: 900px) and (orientation: landscape) {
  .dashboard-container {
    padding: 8px;
  }

  .dashboard-header {
    margin-bottom: 12px;
  }

  .dashboard-title {
    font-size: 1.4rem;
  }

  /* Two column layout for metrics in landscape */
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .metric-card {
    padding: 12px;
  }

  .metric-value {
    font-size: 1.3rem;
  }

  .chart-container {
    height: 180px;
  }
}

/* Touch-friendly enhancements for dashboard */
@media (hover: none) and (pointer: coarse) {
  /* Add visual feedback for touch */
  .metric-card:active,
  .chart-card:active,
  .recommendation-item:active {
    background-color: #f8f9fa;
  }

  /* Ensure touch targets are large enough */
  .btn-dashboard,
  .btn-small {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Improve chart touch interactions */
  .chart-container canvas {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
}

/* Performance optimizations */
@media (max-width: 768px) {
  /* Use CSS containment for better performance */
  .metric-card,
  .chart-card {
    contain: layout style;
  }

  /* Optimize animations for mobile */
  * {
    animation-duration: 0.2s !important;
  }

  /* Disable hover effects on mobile */
  .metric-card:hover,
  .chart-card:hover,
  .btn-dashboard:hover {
    transform: none;
    background-color: inherit;
  }
}

/* Accessibility improvements for mobile */
@media (max-width: 768px) {
  /* High contrast mode support */
  @media (prefers-contrast: high) {
    .metric-card,
    .chart-card {
      border: 2px solid currentColor;
    }
  }

  /* Reduced motion support */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0s !important;
      transition-duration: 0s !important;
    }
  }
}
