/* Responsive table wrapper + mobile "card" view when data-label exists */

/* Make table containers horizontally scrollable on small screens */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Default table look (keeps desktop behaviour) */
.table-responsive table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0; /* changed from 640px */
}

/* Nice spacing */
.table-responsive th,
.table-responsive td {
  padding: 0.75rem 1rem;
  vertical-align: top;
  border-bottom: 1px solid #eef2f6;
}

/* Optional sticky header for better UX when scrolling horizontally */
.table-responsive thead th {
  background: #fafafa;
  position: sticky;
  top: 0;
  z-index: 3;
}

/* MOBILE: switch to card-like rows if data-label attributes are present.
   Fallback: horizontal scroll remains available for tables without data-label. */
@media (max-width: 700px) {
  /* hide header to use labels inside cells */
  .table-responsive thead {
    display: none;
  }

  .table-responsive table,
  .table-responsive tbody,
  .table-responsive tr,
  .table-responsive td {
    display: block;
    width: 100%;
  }

  .table-responsive tr {
    margin-bottom: 0.9rem;
    border: 1px solid #f1f5f9;
    border-radius: 8px;
    padding: 0.5rem;
    background: #fff;
  }

  .table-responsive td {
    padding: 0.6rem 1rem 0.6rem 45%;
    text-align: left;
    position: relative;
    border: none;
    min-height: 38px;
    display: flex;
    align-items: center;
  }

  /* if a cell provides a data-label attribute, show it before the value */
  .table-responsive td::before {
    content: attr(data-label);
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 40%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    color: #6b7280; /* gray-500 */
    font-size: 0.85rem;
  }

  /* Make action buttons wrap nicely */
  .table-responsive td .btn,
  .table-responsive td a,
  .table-responsive td button {
    margin: 0.15rem 0.25rem 0.15rem 0;
    flex-shrink: 0;
  }

  /* ensure long texts break and don't overflow */
  .table-responsive td span,
  .table-responsive td p {
    word-break: break-word;
    white-space: normal;
  }
}

/* Small visual polish for scrollbars (optional) */
.table-responsive::-webkit-scrollbar {
  height: 8px;
}
.table-responsive::-webkit-scrollbar-thumb {
  background: rgba(99,102,241,0.35); /* indigo-ish */
  border-radius: 8px;
}