/**
 * TSG Global Admin — Mobile Responsive Styles
 * Created: February 22, 2026
 * 
 * Addresses: navigation tap targets, table readability,
 * button/form touch targets, modal sizing, stats layout.
 * All rules scoped under @media queries — zero impact on desktop.
 */

/* ============================================================
   TABLET (max-width: 1024px)
   ============================================================ */
@media (max-width: 1024px) {
  /* Stats grid: 2 columns instead of auto-fit */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Health grid: 2 columns */
  .health-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ============================================================
   MOBILE (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {

  /* --- TOP NAV --- */
  .top-nav {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav-brand h1 {
    font-size: 1rem;
  }

  .nav-brand .version {
    display: none;
  }

  .nav-user {
    font-size: 0.8rem;
  }

  .nav-user .btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  /* --- MAIN NAV — scrollable row with bigger tap targets --- */
  .main-nav {
    padding: 6px 8px;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }

  .main-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-btn {
    padding: 10px 12px;
    font-size: 0.75rem;
    min-height: 44px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* --- MAIN CONTENT --- */
  .main-content {
    padding: 12px;
  }

  .section-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
  }

  .section-header h2 {
    font-size: 1.25rem;
  }

  .section-header .btn,
  .section-header button {
    width: 100%;
    justify-content: center;
  }

  /* --- STATS GRID — single column --- */
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  .stat-card {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
  }

  .stat-card h3 {
    font-size: 0.75rem;
    margin-bottom: 0;
  }

  .stat-number {
    font-size: 1.25rem;
    margin: 0;
  }

  /* --- HEALTH GRID — single column --- */
  .health-grid {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }

  /* --- TABLES — horizontal scroll --- */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
  }

  .data-table {
    min-width: 600px;
  }

  .data-table th,
  .data-table td {
    padding: 10px 8px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .table-actions {
    flex-wrap: wrap;
    gap: 4px;
  }

  .table-actions .btn {
    min-height: 36px;
    padding: 6px 10px;
  }

  /* --- BUTTONS — bigger touch targets --- */
  .btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 0.875rem;
  }

  .btn-sm {
    min-height: 36px;
    padding: 8px 12px;
  }

  .btn-lg {
    min-height: 52px;
    padding: 14px 24px;
  }

  /* --- FORMS — full width, touch friendly --- */
  .form-row {
    grid-template-columns: 1fr !important;
  }

  input, select, textarea {
    min-height: 44px;
    font-size: 16px !important; /* Prevents iOS zoom on focus */
    padding: 10px 12px;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  /* --- MODALS — near full screen --- */
  .modal {
    padding: 8px !important;
    align-items: flex-start !important;
  }

  .modal-content {
    max-width: 100% !important;
    max-height: calc(100vh - 16px);
    border-radius: var(--radius-md);
    width: 100%;
  }

  .modal-content.large {
    max-width: 100% !important;
  }

  .modal-header {
    padding: 12px 16px;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
  }

  .modal-header h3 {
    font-size: 1rem;
  }

  .modal-close {
    width: 36px;
    height: 36px;
    font-size: 1.75rem;
  }

  .modal form {
    padding: 12px 16px;
  }

  /* --- CARDS --- */
  .card {
    padding: 12px;
  }

  .card-header {
    padding-bottom: 10px;
    margin-bottom: 10px;
  }

  .card-title {
    font-size: 1rem;
  }

  /* --- CAMPAIGN CARDS (Marketing page) --- */
  .campaign-card {
    padding: 12px;
  }

  /* --- FILTER/SEARCH BARS --- */
  .filter-bar,
  .search-bar,
  .controls-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .filter-bar select,
  .filter-bar input,
  .search-bar input {
    width: 100%;
  }

  /* --- ALERTS --- */
  .alert {
    padding: 10px 12px;
    font-size: 0.8rem;
  }

  /* --- STATUS BADGES --- */
  .status-badge {
    font-size: 0.7rem;
    padding: 3px 6px;
  }

  /* --- PERMISSION GRID --- */
  .permission-grid {
    grid-template-columns: 1fr !important;
  }

  /* --- DASHBOARD SPECIFIC --- */
  #recentTransactions .table-container {
    margin-top: 10px;
  }

  /* --- COUPON/MARKETING ACTION BUTTONS --- */
  .action-buttons,
  .campaign-actions,
  .coupon-actions {
    flex-direction: column;
    gap: 6px;
  }

  .action-buttons .btn,
  .campaign-actions .btn,
  .coupon-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================================
   SMALL PHONE (max-width: 380px)
   ============================================================ */
@media (max-width: 380px) {
  .top-nav {
    padding: 6px 8px;
  }

  .nav-brand h1 {
    font-size: 0.875rem;
  }

  .nav-btn {
    padding: 8px 8px;
    font-size: 0.7rem;
  }

  .nav-btn .icon {
    display: none;
  }

  .main-content {
    padding: 8px;
  }

  .section-header h2 {
    font-size: 1.1rem;
  }

  .stat-card h3 {
    font-size: 0.75rem;
  }

  .stat-number {
    font-size: 1.25rem;
  }

  .modal-header h3 {
    font-size: 0.9rem;
  }
}
