/* ===== RESPONSIVE DESIGN IMPROVEMENTS ===== */

/* Base container improvements */
.max-w-full {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Table container responsive wrapper */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
}

/* Improved table responsiveness */
table {
  min-width: 800px; /* Minimum width to prevent cramping */
  width: 100%;
  white-space: nowrap;
}

/* Better mobile table cells */
table th,
table td {
  min-width: 80px; /* Minimum cell width */
  padding: 8px 12px;
  font-size: clamp(0.75rem, 2vw, 0.875rem); /* Responsive font size */
}

/* Sticky header for better UX */
table thead th {
  position: sticky;
  top: 0;
  background-color: inherit;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Mobile-first responsive breakpoints */
@media screen and (max-width: 768px) {
  /* Reduce padding on mobile */
  main {
    margin: 1em;
  }
  
  /* Stack buttons vertically on mobile */
  .mt-4.flex.flex-wrap.gap-4 {
    flex-direction: column;
    align-items: stretch;
  }
  
  .mt-4.flex.flex-wrap.gap-4 button {
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  /* Improve tab navigation */
  .tabs {
    padding: 0.5em 1em;
    gap: 0.5em;
  }
  
  .tab {
    padding: 0.5em 1em;
    font-size: 0.9em;
    flex: 1;
    text-align: center;
  }
  
  /* Better mobile table scrolling */
  .table-responsive {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  
  /* Adjust input sizes for mobile */
  table input,
  table select {
    min-width: 60px;
    font-size: 0.8rem;
    padding: 0.25rem;
  }
  
  /* Better mobile headings */
  h1 {
    font-size: 1.8rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
}

@media screen and (max-width: 480px) {
  /* Extra small screens */
  table th,
  table td {
    padding: 6px 8px;
    min-width: 60px;
  }
  
  /* Smaller buttons on very small screens */
  .btn-add,
  .btn-save,
  .btn-dup,
  .btn-delete {
    padding: 0.4em 0.8em;
    font-size: 0.85rem;
  }
  
  /* Compact search input */
  input[type="text"]:not(table input) {
    padding: 0.5rem;
    font-size: 0.9rem;
  }
}

@media screen and (min-width: 769px) and (max-width: 1024px) {
  /* Tablet adjustments */
  main {
    margin: 1.5em 1.5em 3em 1.5em;
  }
  
  .tabs {
    padding: 0.5em 1.5em;
  }
}

@media screen and (min-width: 1025px) {
  /* Desktop improvements */
  .table-responsive {
    overflow-x: visible; /* No horizontal scroll needed on desktop */
  }
  
  table {
    min-width: auto; /* Allow natural table width */
  }
}

/* Improved card layout for totals (Second Project) */
@media screen and (max-width: 768px) {
  #secondTotals {
    flex-direction: column !important;
    gap: 1rem !important;
  }
  
  #secondTotals > div {
    width: 100% !important;
    min-width: auto !important;
  }
}

/* Better loading states and accessibility */
@media (prefers-reduced-motion: reduce) {
  .tab-content {
    animation: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  table,
  table th,
  table td {
    border-color: #000;
  }
  
  .btn-add,
  .btn-save,
  .btn-dup {
    border: 2px solid currentColor;
  }
}

/* Print styles */
@media print {
  .tabs,
  .mt-4.flex.flex-wrap.gap-4,
  button {
    display: none !important;
  }
  
  main {
    margin: 0 !important;
  }
  
  table {
    min-width: auto !important;
    font-size: 12px !important;
  }
}
