/* mobile-enhancements.css - Global mobile optimizations for CRM */

/* ======================================
   Mobile Breakpoints
   ====================================== */
@media (max-width: 768px) {
  
  /* ======================================
     Global Typography & Spacing
     ====================================== */
  body {
    font-size: 14px;
  }
  
  h1 {
    font-size: 1.75rem !important;
  }
  
  h2 {
    font-size: 1.5rem !important;
  }
  
  h3 {
    font-size: 1.25rem !important;
  }
  
  .container {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  
  /* ======================================
     Touch Targets (Minimum 44x44px)
     ====================================== */
  button,
  .btn,
  .btn-primary,
  .btn-secondary,
  .btn-outline,
  a.btn,
  input[type="submit"],
  input[type="button"],
  select {
    min-height: 44px !important;
    padding: 0.75rem 1rem !important;
  }
  
  /* Checkbox and Radio Touch Targets */
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 24px;
    min-height: 24px;
    transform: scale(1.5);
    margin-right: 0.5rem;
  }
  
  /* ======================================
     Navigation & Headers
     ====================================== */
  .page-header {
    flex-direction: column !important;
    text-align: center;
    gap: 1rem;
  }
  
  .page-header > div {
    width: 100%;
  }
  
  .page-header .btn-primary {
    width: 100%;
    justify-content: center;
  }
  
  /* ======================================
     Tables - Horizontal Scroll
     ====================================== */
  .table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.5rem;
  }
  
  .table-wrap table {
    min-width: 800px; /* Force horizontal scroll for complex tables */
  }
  
  /* Sticky first column for better mobile table navigation */
  .table-wrap.sticky-column td:first-child,
  .table-wrap.sticky-column th:first-child {
    position: sticky !important;
    left: 0;
    background: white;
    z-index: 10;
    box-shadow: 2px 0 4px rgba(0,0,0,0.1);
  }
  
  /* Reduce table cell padding on mobile */
  table th,
  table td {
    padding: 0.75rem 0.5rem !important;
    font-size: 0.875rem;
  }
  
  /* Hide less critical columns on small screens */
  .table-hide-mobile {
    display: none !important;
  }
  
  /* ======================================
     Forms - Stack on Mobile
     ====================================== */
  .grid {
    display: block !important;
  }
  
  .grid > * {
    width: 100% !important;
    margin-bottom: 1rem;
  }
  
  .field,
  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  input[type="tel"],
  textarea,
  select {
    width: 100% !important;
    font-size: 16px !important; /* Prevents zoom on iOS */
  }
  
  /* ======================================
     Filters - Collapsible by Default
     ====================================== */
  .filters {
    margin-bottom: 1rem;
  }
  
  .filters .grid {
    gap: 0.75rem;
  }
  
  /* Advanced filters collapsed on mobile */
  #advancedFilters {
    display: none;
  }
  
  #advancedFilters.active {
    display: block;
  }
  
  /* ======================================
     Cards & Metrics
     ====================================== */
  .metric-card,
  .card {
    margin-bottom: 1rem;
  }
  
  /* Stack metric cards vertically */
  .metric-card {
    width: 100% !important;
  }
  
  /* ======================================
     Modals
   ====================================== */
  .modal-content {
    width: 95% !important;
    max-width: 95% !important;
    margin: 1rem;
    max-height: 85vh !important;
  }
  
  .modal-header {
    font-size: 1.25rem;
  }
  
  /* ======================================
     Action Buttons - Stack Vertically
     ====================================== */
  .action a,
  .action button,
  .action form {
    display: block !important;
    width: 100%;
    margin-bottom: 0.25rem;
  }
  
  /* ======================================
     Bulk Actions
     ====================================== */
  .bulk-actions {
    width: 100%;
  }
  
  .bulk-actions .flex {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  
  .bulk-actions select,
  .bulk-actions button {
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  /* ======================================
     Dashboard Specific
     ====================================== */
  .dash-hero {
    padding: 1.5rem !important;
  }
  
  /* Stack dashboard grid items */
  .lg\\:grid-cols-2,
  .lg\\:grid-cols-3,
  .lg\\:grid-cols-4,
  .md\\:grid-cols-2,
  .md\\:grid-cols-3,
  .md\\:grid-cols-4 {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }
  
  /* ======================================
     Email Preview
     ====================================== */
  .email-preview {
    font-size: 0.875rem;
    padding: 0.75rem;
  }
  
  /* ======================================
     Analytics Charts
     ====================================== */
  .chart-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* ======================================
     Utility Classes
     ====================================== */
  .mobile-hidden {
    display: none !important;
  }
  
  .mobile-full-width {
    width: 100% !important;
  }
  
  .mobile-text-center {
    text-align: center !important;
  }
  
  /* Reduce gap in flex containers */
  .flex {
    gap: 0.5rem !important;
  }
  
  .gap-6 {
    gap: 1rem !important;
  }
  
  /* ======================================
     Status Chips & Badges
     ====================================== */
  .chip,
  .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
  
  /* ======================================
     Tooltips - Disable on Touch
     ====================================== */
  [title]:hover::after {
    display: none;
  }
}

/* ======================================
   Tablet Optimizations (768px - 1024px)
   ====================================== */
@media (min-width: 768px) and (max-width: 1024px) {
  .container {
    max-width: 100%;
    padding-left: 2rem;
    padding-right: 2rem;
  }
  
  /* 2-column grid for tablets */
  .lg\\:grid-cols-3,
  .lg\\:grid-cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  
  table th,
  table td {
    padding: 0.875rem !important;
  }
}

/* ======================================
   Landscape Phone Optimizations
   ====================================== */
@media (max-width: 768px) and (orientation: landscape) {
  .modal-content {
    max-height: 75vh !important;
  }
  
  .page-header {
    padding: 1rem !important;
  }
}

/* ======================================
   Print Optimizations
   ====================================== */
@media print {
  .bulk-actions,
  .filters,
  .btn,
  button,
  nav,
  .action {
    display: none !important;
  }
  
  table {
    width: 100%;
    page-break-inside: avoid;
  }
  
  .table-wrap {
    overflow: visible !important;
    border: 1px solid #000;
  }
}
