/* Responsive table scroll wrapper */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* Base table styling (optional adoption via class) */
.saf-table {
  border-collapse: collapse;
  width: 100%;
}

.saf-table th {
  border-top: 1px solid black;
  border-bottom: 1px solid black;
  border-right: 1px solid black;
  overflow: hidden;
  padding: 4px 8px;
  white-space: nowrap;
}

.saf-table td {
  border-bottom: 1px solid black;
  border-right: 1px solid black;
  overflow: hidden;
  text-align: center;
  padding: 4px 8px;
}

.saf-table tr {
  line-height: 25px;
}

/* ── Mobile form fixes ── */
@media (max-width: 768px) {
  /* Date filter sections — grid pairs label + input on mobile */
  #date-section {
    display: grid !important;
    grid-template-columns: auto 1fr;
    width: 95% !important;
    gap: 8px;
    align-items: center;
  }

  #date-section label {
    margin-left: 0 !important;
    white-space: nowrap;
  }

  #date-section input[type="date"] {
    min-width: 0;
    width: 100%;
  }

  #date-section .button-small,
  #date-section button {
    grid-column: 1 / -1;
    margin-left: 0 !important;
    width: 100%;
  }

  /* Day Collection Report — arrow + date-selector + arrow layout */
  #date-section:has(#date-selector) {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
  }

  #date-section:has(#date-selector) #date-selector {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
  }

  #date-section:has(#date-selector) #date-selector input[type="date"] {
    flex: 1 1 auto;
    min-width: 0;
  }

  #date-section:has(#date-selector) #date-selector .button-small,
  #date-section:has(#date-selector) #date-selector button {
    margin-left: 0 !important;
    width: auto;
  }

  /* Dialog box (e.g. payment history loan ID prompt) */
  #dialog-box {
    width: 90% !important;
    margin-left: 5% !important;
    margin-right: 5% !important;
    margin-top: 100px !important;
  }

  /* Mentor / category filter sections */
  #mentor-filter-section,
  #category-filter-section {
    display: flex;
    flex-wrap: wrap;
    width: 95% !important;
    gap: 8px;
    padding: 0 8px;
  }

  #mentor-filter-section input,
  #category-filter-section input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
  }

  #mentor-filter-section .button-small,
  #category-filter-section .button-small,
  #mentor-filter-section button,
  #category-filter-section button {
    margin-left: 0 !important;
  }

  /* Action button sections (e.g. Move to Defaulters / Completed) */
  #buttons-section {
    flex-wrap: wrap;
    width: 95% !important;
    gap: 8px;
    padding: 0 8px;
  }

  #buttons-section .button {
    width: auto !important;
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Collection Entry form — center and inline on mobile */
  #loan-details-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 0 8px;
  }

  #loan-details-form #loan-id-label {
    margin-left: 0 !important;
  }

  #loan-details-form #loan-id {
    flex: 1 1 auto;
    min-width: 0;
  }

  #loan-details-form .button {
    margin-left: 0 !important;
  }

  .last-payment-details-label {
    margin-left: 8px !important;
  }
}
