/* ═══ P19: Mobile-friendly responsive overrides (2026-04-27) ═══
   Loaded last so overrides win without !important.
   Breakpoints:
     768px — tablet portrait & below
     480px — phones
*/

/* Touch-target minimums (WCAG 2.5.5 AAA: 44×44 px) */
@media (max-width: 768px) {
  button,
  .btn,
  a.btn,
  .tab,
  .badge[role="button"],
  input[type="submit"],
  input[type="button"] {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
  }

  /* Stack metric grids vertically on narrow screens */
  .metric-row,
  .metric-grid,
  .grid-cards,
  [style*="grid-template-columns:repeat(auto-fit"] {
    grid-template-columns: 1fr !important;
    gap: var(--space-2) !important;
  }

  /* Top widget: stack futures/spot side-by-side ratio panels */
  .header-widget {
    flex-direction: column;
    gap: var(--space-2);
  }

  /* Metric card: full-width, larger tap targets */
  .metric-card {
    padding: var(--space-3);
  }
  .metric-card__value {
    font-size: var(--text-xl);
  }

  /* Tables: horizontal scroll wrapper */
  .data-table {
    font-size: var(--text-xs);
    min-width: 600px;
  }
  .data-table th,
  .data-table td {
    padding: 8px 6px;
  }

  /* Tabs: horizontally scrollable instead of overflow */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  .tab {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Diagnostics widget — collapse on mobile */
  #diag-rejects-list,
  #diag-ensemble-list {
    max-height: 120px;
  }

  /* Notifications and modals — full-screen on phone */
  .modal,
  .notification-panel {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
}

/* Phone-only: even tighter spacing */
@media (max-width: 480px) {
  .card {
    margin-left: calc(-1 * var(--space-2));
    margin-right: calc(-1 * var(--space-2));
    border-radius: var(--radius-sm);
  }
  .card__header {
    padding: var(--space-2) var(--space-3);
  }
  .card__title {
    font-size: var(--text-sm);
  }

  /* Hide non-critical columns in tables on phone */
  .data-table .hide-mobile {
    display: none;
  }

  /* Diagnostics: compact font */
  #diag-rejects-list,
  #diag-ensemble-list {
    font-size: 10px;
    line-height: 1.4;
  }

  /* Stack form rows */
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  /* Status bar — wrap into 2 lines */
  .status-bar {
    flex-wrap: wrap;
    gap: var(--space-1);
    font-size: var(--text-xs);
  }
}

/* Reduce motion (accessibility) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
