/* Fix for mobile browser viewport and system navigation bar */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  html, body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}
/* Mobile bottom nav fixed positioning */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
}
/* Add spacing for fixed bottom nav */
.has-bottom-nav {
  padding-bottom: 80px;
}
@media (min-width: 768px) {
  .has-bottom-nav {
    padding-bottom: 0;
  }
}

/* Mobile Card Table: converts tables to card views on small screens */
@media (max-width: 767px) {
  .mobile-card-table thead { display: none; }
  .mobile-card-table tbody tr {
    display: block;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  }
  .mobile-card-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    border: none;
  }
  .mobile-card-table tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.7rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-right: 0.5rem;
    flex-shrink: 0;
  }
  .mobile-card-table tbody td.mobile-card-actions {
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    border-top: 1px solid #f3f4f6;
  }
  .mobile-card-table tbody td.mobile-card-actions::before { display: none; }
  .mobile-hide { display: none !important; }
}

/* Modal Responsive: full-screen modals on mobile */
@media (max-width: 767px) {
  .modal-responsive > div {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  .modal-responsive {
    padding: 0 !important;
  }
}

/* Virtualized count item rows */
.count-vheader {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
}
.count-vrow {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 8px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 12px;
  box-sizing: border-box;
}
.count-vrow:hover { background-color: #f9fafb; }
.count-vrow-item { flex: 1; min-width: 0; overflow: hidden; padding: 4px 0; }
.count-vrow-num { width: 52px; text-align: center; flex-shrink: 0; }
.count-vrow-act { width: 36px; text-align: center; flex-shrink: 0; }

@media (max-width: 767px) {
  .count-vheader { display: none; }
  .count-vrow {
    flex-wrap: wrap;
    align-content: center;
    padding: 6px 10px;
    gap: 2px;
  }
  .count-vrow-item {
    flex-basis: 100%;
    flex-shrink: 0;
    padding: 0 0 2px 0;
  }
  .count-vrow-num {
    flex: 1;
    width: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
  }
  .count-vrow-num::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 9px;
    color: #9ca3af;
    text-transform: uppercase;
  }
  .count-vrow-act {
    flex: 0 0 auto;
    width: auto;
    display: flex;
    align-items: center;
  }
}

/* Touch feedback utility */
.touch-active { transition: transform 0.1s, opacity 0.1s; }
.touch-active:active { transform: scale(0.97); opacity: 0.85; }

/* Touch target minimum size */
.touch-target { min-height: 44px; min-width: 44px; }
