/**
 * SporeSwaps Accessibility & Enlarged Font Responsive Enhancements
 * 
 * IMPORTANT: All rules in this file are STRICTLY SCOPED under `html.user-font-enlarged`.
 * Standard devices with normal font sizes (16px baseline) DO NOT have this class,
 * guaranteeing zero visual change or regressions on standard screens.
 */

/* ==========================================================================
   1. Modals & Dialogs on Enlarged Font Screens
   ========================================================================== */
@media (max-width: 768px) {
  html.user-font-enlarged .modal-backdrop {
    padding: 6px !important;
    align-items: flex-start !important;
    overflow-y: auto !important;
  }

  html.user-font-enlarged .modal-dialog {
    width: 100% !important;
    max-width: 100% !important;
    margin: 6px auto !important;
    max-height: calc(100vh - 12px) !important;
    border-radius: 10px !important;
  }

  html.user-font-enlarged .modal-header {
    padding: 10px 12px !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  html.user-font-enlarged .modal-header h3,
  html.user-font-enlarged .modal-header h4 {
    font-size: 1.05rem !important;
    line-height: 1.3 !important;
  }

  html.user-font-enlarged .modal-body {
    padding: 12px 10px !important;
    gap: 12px !important;
    overflow-x: hidden !important;
  }

  html.user-font-enlarged .modal-footer {
    padding: 10px 12px !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
}

/* ==========================================================================
   2. Activity & Redemption Audit Trail (Responsive Card Transformation)
   ========================================================================== */
/* Defensive container scrolling at all viewport widths for enlarged font users */
html.user-font-enlarged .audit-trail-table-wrap {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  box-sizing: border-box !important;
}

/* On mobile portrait (<= 768px), convert rigid 5-column table into thumb-friendly data cards */
@media (max-width: 768px) {
  html.user-font-enlarged .audit-trail-table-wrap {
    max-height: 380px !important;
    border: none !important;
    background: transparent !important;
  }

  html.user-font-enlarged .audit-trail-table-wrap table.audit-trail-table,
  html.user-font-enlarged .audit-trail-table-wrap table {
    display: block !important;
    width: 100% !important;
    border: none !important;
  }

  html.user-font-enlarged .audit-trail-table-wrap thead {
    display: none !important;
  }

  html.user-font-enlarged .audit-trail-table-wrap tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
  }

  html.user-font-enlarged .audit-trail-table-wrap tr {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    padding: 12px 14px !important;
    border: 1px solid var(--color-border, rgba(255, 255, 255, 0.12)) !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.03) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }

  [data-theme="light"] html.user-font-enlarged .audit-trail-table-wrap tr {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
  }

  html.user-font-enlarged .audit-trail-table-wrap td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 3px 0 !important;
    border: none !important;
    font-size: 0.9rem !important;
    line-height: 1.35 !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }

  html.user-font-enlarged .audit-trail-table-wrap td::before {
    content: attr(data-label);
    font-weight: 700 !important;
    font-size: 0.72rem !important;
    text-transform: uppercase !important;
    color: var(--color-text-dim, #8b949e) !important;
    letter-spacing: 0.5px !important;
    margin-right: 12px !important;
    flex-shrink: 0 !important;
  }

  /* Full-width formatting for multiline Notes / Date */
  html.user-font-enlarged .audit-trail-table-wrap td[data-label="Notes / Date"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
    margin-top: 4px !important;
    padding-top: 8px !important;
    border-top: 1px dashed var(--color-border, rgba(255, 255, 255, 0.1)) !important;
  }

  html.user-font-enlarged .audit-trail-table-wrap td[data-label="Notes / Date"]::before {
    margin-bottom: 2px !important;
  }
}

/* Tablet & Desktop with Enlarged Font: Ensure table never squishes below readable width */
@media (min-width: 769px) {
  html.user-font-enlarged .audit-trail-table-wrap table {
    min-width: 580px !important;
  }
}

/* ==========================================================================
   3. Store Credit / Gift Card Attribute Grid Adjustments
   ========================================================================== */
@media (max-width: 768px) {
  /* Prevent tight columns from breaking or wrapping awkwardly */
  html.user-font-enlarged #gift-card-attributes-modal-body div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  html.user-font-enlarged #gift-card-attributes-modal-body .badge {
    white-space: normal !important;
    line-height: 1.3 !important;
    text-align: left !important;
  }
}

/* ==========================================================================
   4. Universal Admin & Dashboard Tables for Enlarged Fonts
   ========================================================================== */
html.user-font-enlarged .table-responsive,
html.user-font-enlarged .data-table-wrap,
html.user-font-enlarged .admin-table-container {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  width: 100% !important;
}

@media (max-width: 900px) {
  html.user-font-enlarged .table-responsive > table,
  html.user-font-enlarged .data-table-wrap > table,
  html.user-font-enlarged .admin-table-container > table {
    min-width: 680px !important;
  }

  html.user-font-enlarged table.data-table th,
  html.user-font-enlarged table.data-table td,
  html.user-font-enlarged table.admin-table th,
  html.user-font-enlarged table.admin-table td {
    padding: 8px 10px !important;
    line-height: 1.4 !important;
  }
}

/* Prevent action buttons or status badges from breaking awkwardly */
html.user-font-enlarged .btn-sm,
html.user-font-enlarged .btn-xs {
  white-space: nowrap !important;
  min-height: 32px !important;
}
