/*
 * lod-tables.css  —  Shared dark DataTables theme
 * League of Destruction  |  include on every page using a .lod-table
 * Requires: jquery.dataTables.min.css loaded BEFORE this file
 * Assumes: header.php CSS variables are available
 */

/* ── Card wrapper ───────────────────────────────────────────── */
.lod-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 4px 24px rgba(0,0,0,.3);
  overflow: hidden;
  margin-bottom: 30px;
}
.lod-card-head {
  background: #162032;
  color: var(--text);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.lod-card-head h2 { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--text); }
.lod-card-head .meta { font-size: 0.78rem; color: var(--text-muted); }
.lod-card-body { padding: 18px 20px 22px; background: var(--bg-card); }

/* ── Filter bar ─────────────────────────────────────────────── */
.lod-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--bg-raised);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-bottom: 14px;
}
.lod-filters .flabel {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted); white-space: nowrap;
}
.lod-filters input,
.lod-filters select {
  background: var(--bg-card); border: 1px solid var(--border-md);
  color: var(--text); border-radius: var(--r-sm);
  padding: 5px 9px; font-size: 0.8rem; outline: none;
  transition: border-color .15s; min-width: 0;
}
.lod-filters input::placeholder { color: var(--text-dim); }
.lod-filters input:focus,
.lod-filters select:focus { border-color: var(--accent); }
.lod-filters .fsep { width: 1px; height: 18px; background: var(--border-md); flex-shrink: 0; }
.lod-fbtn {
  padding: 5px 13px; border-radius: var(--r-sm); border: none;
  font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: background .15s; white-space: nowrap;
}
.lod-fbtn.p { background: var(--accent); color: #000; }
.lod-fbtn.p:hover { background: var(--accent-hover); }
.lod-fbtn.g { background: var(--bg-raised); color: var(--text); border: 1px solid var(--border-md); }
.lod-fbtn.g:hover { background: var(--border-md); }

/* Position pills */
.pos-pills { display: flex; gap: 5px; flex-wrap: wrap; }
.pos-pill {
  padding: 3px 11px; border-radius: 20px; border: 1.5px solid transparent;
  font-size: 0.72rem; font-weight: 700; cursor: pointer; transition: all .15s; user-select: none;
}
.pos-pill.F { background:rgba(234,179,8,.15);  color:#fcd34d; border-color:#92400e; }
.pos-pill.D { background:rgba(59,130,246,.15); color:#7dd3fc; border-color:#1e40af; }
.pos-pill.G { background:rgba(34,197,94,.15);  color:#86efac; border-color:#166534; }
.pos-pill.off { background:var(--bg-raised)!important; color:var(--text-muted)!important; border-color:var(--border)!important; }

/* ── DataTable core overrides ───────────────────────────────── */
.dataTables_wrapper { font-family: inherit; color: var(--text); overflow: visible !important; position: relative; }

/* DataTables scrollX moves <thead> into a new <table> with no id, so page-specific
   id-based th rules never reach it. Force consistent padding here so column widths
   measure the same in header and body. */
.dataTables_scrollHeadInner thead th { padding: 9px 10px !important; }

/* Hide sort arrows on unsorted columns; show only when active */
table.dataTable thead th.sorting:not(.sorting_asc):not(.sorting_desc)::before,
table.dataTable thead th.sorting:not(.sorting_asc):not(.sorting_desc)::after { opacity: 0 !important; }

table.lod-table {
  width: 100% !important;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}

/* Header */
table.lod-table thead th {
  background: var(--bg-card) !important;
  color: var(--text-muted) !important;
  font-weight: 600; font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: .5px;
  padding: 10px 24px 10px 11px !important;
  border-bottom: 2px solid var(--accent) !important;
  border-right: 1px solid var(--border) !important;
  white-space: nowrap; cursor: pointer; user-select: none;
}
table.lod-table thead th:last-child { border-right: none !important; }
table.lod-table thead th.sorting_asc,
table.lod-table thead th.sorting_desc { background: var(--bg-raised) !important; color: var(--text) !important; }

/* Body */
table.lod-table tbody tr:nth-child(odd)  td { background: var(--bg-table-odd); }
table.lod-table tbody tr:nth-child(even) td { background: var(--bg-table-even); }
table.lod-table tbody tr:hover td { background: var(--bg-hover) !important; }
table.lod-table tbody td {
  padding: 8px 11px !important;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  color: var(--text); vertical-align: middle; white-space: nowrap;
}
table.lod-table tbody td:last-child { border-right: none; }

/* ── Frozen first column ─────────────────────────────────────── */
table.lod-table thead th:first-child,
table.lod-table tbody td:first-child {
  position: sticky; left: 0; z-index: 2;
  box-shadow: 2px 0 5px rgba(0,0,0,.3);
}
table.lod-table thead th:first-child { z-index: 3; }
table.lod-table tbody tr:nth-child(odd)  td:first-child { background: var(--bg-table-odd); }
table.lod-table tbody tr:nth-child(even) td:first-child { background: var(--bg-table-even); }
table.lod-table tbody tr:hover td:first-child { background: var(--bg-hover) !important; }

/* ── Controls row ────────────────────────────────────────────── */
.lod-ctrl {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-bottom: 10px;
}
.lod-ctrl-l, .lod-ctrl-r { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Length + search (built-in DT controls) */
.dataTables_wrapper .dataTables_filter label,
.dataTables_wrapper .dataTables_length label { color: var(--text-muted); font-size: 0.8rem; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  background: var(--bg-raised); border: 1px solid var(--border-md);
  color: var(--text); border-radius: var(--r-sm);
  padding: 5px 8px; font-size: 0.8rem; margin: 0 5px; outline: none;
}
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--accent); }

/* Pagination */
.dataTables_wrapper .dataTables_paginate { margin-top: 10px; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
  background: var(--bg-raised); border: 1px solid var(--border-md) !important;
  border-radius: var(--r-sm) !important; color: var(--text-muted) !important;
  padding: 4px 10px !important; margin: 0 2px; font-size: 0.78rem; cursor: pointer;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--border-md) !important; color: var(--text) !important; border-color: var(--border-md) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--accent) !important; border-color: var(--accent) !important;
  color: #000 !important; font-weight: 700;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  color: var(--text-dim) !important; background: var(--bg-raised) !important; cursor: default;
}
.dataTables_wrapper .dataTables_info { color: var(--text-muted); font-size: 0.78rem; padding-top: 12px; }

/* ColVis button */
.dt-button.buttons-colvis {
  background: var(--bg-raised) !important; color: var(--text) !important;
  border: 1px solid var(--border-md) !important; border-radius: var(--r-sm) !important;
  padding: 5px 13px !important; font-size: 0.78rem !important; font-weight: 600 !important; cursor: pointer;
}
.dt-button.buttons-colvis:hover { background: var(--border-md) !important; color: var(--text) !important; }

/* ColVis dropdown */
.dt-button-collection {
  background: var(--bg-card) !important; border: 1px solid var(--border-md) !important;
  border-radius: var(--r-md) !important; box-shadow: 0 8px 24px rgba(0,0,0,.5) !important;
  padding: 5px !important; z-index: 2002 !important;
}
.dt-button-collection .dt-button {
  background: transparent !important; color: var(--text-muted) !important;
  border: none !important; border-radius: var(--r-sm) !important;
  padding: 6px 12px !important; font-size: 0.8rem !important;
  display: block; width: 100%; text-align: left;
}
.dt-button-collection .dt-button:hover { background: var(--bg-raised) !important; color: var(--text) !important; }
.dt-button-collection .dt-button.active { background: var(--bg-raised) !important; color: var(--text) !important; font-weight: 600 !important; }
.dt-button-collection .dt-button.active:before { content: '✓ '; color: var(--accent); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 0.68rem; font-weight: 700; white-space: nowrap;
}
.bdg-F  { background:rgba(234,179,8,.2);   color:#fcd34d; }
.bdg-D  { background:rgba(59,130,246,.2);  color:#93c5fd; }
.bdg-G  { background:rgba(34,197,94,.2);   color:#86efac; }
.bdg-p1 { background:rgba(255,215,0,.2);   color:#fbbf24; border:1px solid rgba(255,215,0,.4); }
.bdg-p2 { background:rgba(148,163,184,.2); color:#cbd5e1; border:1px solid rgba(148,163,184,.4); }
.bdg-p3 { background:rgba(251,191,36,.15); color:#d97706; border:1px solid rgba(251,191,36,.35); }
.bdg-lo { background:rgba(239,68,68,.2);   color:#fca5a5; border:1px solid rgba(239,68,68,.4); }
.bdg-md { background:var(--bg-raised);     color:var(--text-muted); border:1px solid var(--border-md); }

/* ── Cell helpers ────────────────────────────────────────────── */
table.lod-table a { color: var(--accent); text-decoration: none; font-weight: 600; }
table.lod-table a:hover { color: var(--accent-hover); text-decoration: underline; }
.num { text-align: right !important; }
.tbl-portrait {
  width: 24px !important; height: 24px !important;
  max-width: 24px !important; max-height: 24px !important;
  min-width: 24px; border-radius: 50%; object-fit: cover;
  object-position: top center; vertical-align: middle;
  margin-right: 7px; flex-shrink: 0; display: inline-block; overflow: hidden;
}
.tbl-logo {
  width: 24px !important; height: 24px !important;
  max-width: 24px !important; max-height: 24px !important;
  object-fit: contain; vertical-align: middle;
  margin-right: 6px; flex-shrink: 0; display: inline-block;
}
.tbl-name {
  display: inline-flex; align-items: center;
  white-space: nowrap; max-width: 200px; overflow: hidden;
}
.tbl-name a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Lock row height on both player and owner tables */
#playersTable tbody tr,
#ownersTable  tbody tr { height: 38px; max-height: 38px; }
#playersTable tbody td,
#ownersTable  tbody td { overflow: hidden; }
#playersTable tbody td:first-child,
#ownersTable  tbody td:first-child { min-width: 160px; max-width: 240px; }

/* Scroll shell */
.lod-tscroll, .tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Responsive column hiding ────────────────────────────────── */
@media (max-width: 768px) {
  .lod-card-body { padding: 10px 12px 14px; }
  .lod-filters   { gap: 6px; padding: 8px 10px; }
  table.lod-table thead th,
  table.lod-table tbody td { padding: 7px 8px !important; font-size: 0.76rem; }
  .hide-md { display: none !important; }
}
@media (max-width: 480px) {
  .hide-sm { display: none !important; }
  table.lod-table { font-size: 0.73rem; }
}

/* Team-colored rows */
tr.tcr:hover td { filter: brightness(.85); }
