/*
  Reusable table styles for Bootstrap tables with server-side pagination and search
  Usage (HTML structure suggestion):
  <div class="table-toolbar">
    <div class="table-actions-left">
      <!-- optional buttons -->
    </div>
    <div class="table-actions-right">
      <div class="input-group table-search">
        <span class="input-group-text"><i class="fas fa-search"></i></span>
        <input type="search" class="form-control" placeholder="Buscar..." />
      </div>
    </div>
  </div>
  <div class="table-responsive table-responsive-wrap">
    <table class="table table-hover align-middle table-modern table-sticky">
      ...
    </table>
  </div>
  <nav class="table-pagination">
    <ul class="pagination justify-content-center"></ul>
  </nav>
*/

:root{
  --tbl-bg: #ffffff;
  --tbl-surface: #ffffff;
  --tbl-border: rgba(0,0,0,0.1);
  --tbl-hover: rgba(0,0,0,0.03);
  --tbl-head: #f8f9fa;
  --tbl-head-text: #212529;
  --tbl-text: #212529;
  --tbl-accent: #0d6efd; /* Bootstrap primary */
}

/* Wrapper that avoids horizontal overflow on mobile */
.table-responsive-wrap{
  width: 100%;
  overflow-x: auto;
}

/* Toolbar (search + actions) */
.table-toolbar{
  display: flex;
  gap: .75rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: .5rem 0 1rem 0;
}
.table-toolbar .table-actions-left,
.table-toolbar .table-actions-right{ display: flex; align-items: center; gap: .5rem; }
.table-toolbar .table-search{ min-width: 220px; max-width: 420px; }
.table-toolbar .table-search .form-control{ border-left: 0; }
.table-toolbar .table-search .input-group-text{ background: var(--tbl-head); color: #6c757d; border-color: var(--tbl-border); }

/* Table look & feel (compatible with Bootstrap) */
.table-modern{
  border-color: var(--tbl-border) !important;
  color: var(--tbl-text);
}
.table-modern > :not(caption) > * > *{
  border-bottom-color: var(--tbl-border) !important;
}
.table-modern thead th{
  background: var(--tbl-head);
  color: var(--tbl-head-text);
  font-weight: 600;
  border-bottom: 1px solid var(--tbl-border);
}
.table-modern tbody tr:hover{ background: var(--tbl-hover); }

/* Optional sticky header on scroll. Add .table-sticky to the table */
.table-sticky thead th{
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Compact density variant */
.table-compact td, .table-compact th{ padding-top: .4rem; padding-bottom: .4rem; }

/* Empty state */
.table-empty{
  text-align: center;
  color: #94a3b8;
  padding: 1rem 0;
}

/* Loading overlay (optional) */
.table-loading{
  position: relative;
}
.table-loading::after{
  content: "";
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.35);
  backdrop-filter: blur(2px);
}
.table-loading::before{
  content: "Cargando...";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: #212529;
  font-weight: 600;
}

/* Pagination look, reusing Bootstrap markup */
.table-pagination .pagination{ gap: .25rem; }
.table-pagination .page-item .page-link{
  color: #212529; background: #ffffff; border-color: var(--tbl-border);
}
.table-pagination .page-item .page-link:hover{ background: var(--tbl-hover); color: #212529; }
.table-pagination .page-item.active .page-link{ background: var(--tbl-accent); border-color: var(--tbl-accent); color: #fff; }
.table-pagination .page-item.disabled .page-link{ opacity: .6; cursor: not-allowed; }

/* Search + pagination alignment helpers */
.table-footer{
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: .75rem; margin-top: .75rem;
}
.table-footer .table-pagination{ margin-left: auto; }

/* Make cells truncate nicely on small screens */
.table-modern td, .table-modern th{
  vertical-align: middle;
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px){
  .table-modern td, .table-modern th{ max-width: 200px; }
}
