/* ==========================================================
   Pizza-Doom shared server lists
   PD_SERVER_TABLES_SHARED_V4

   Common visual system:
   - servers.html       -> live operational data
   - my-servers.html    -> personal active/history list
   - user-servers.html  -> selected-user active/history list

   Column visibility and sizing are intentionally page-specific.
   When the viewport is too small, the table scrolls horizontally:
   columns are never hidden, compressed into each other or turned
   into flex items.
   ========================================================== */

body.pd-dark.pd-server-list-page{
  --pd-table-bg:#020617;
  --pd-table-row:#071022;
  --pd-table-row-alt:rgba(15,23,42,.72);
  --pd-table-row-hover:rgba(30,64,175,.38);
  --pd-table-border:rgba(51,83,160,.58);
  --pd-table-muted:#94a3b8;
  --pd-table-text:#e5e7eb;
  overflow-x:hidden;
}

body.pd-server-list-page .container{
  box-sizing:border-box;
  width:min(1840px, calc(100vw - 32px)) !important;
  max-width:none !important;
  margin:76px auto 36px !important;
  padding:0 0 28px !important;
}

body.pd-server-list-page .pd-header{
  display:flex !important;
  align-items:center !important;
  gap:10px !important;
  min-height:40px;
  margin:0 0 14px !important;
}

body.pd-server-list-page .pd-header > .btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:40px;
  padding:8px 14px;
  border-radius:10px;
  line-height:1.1;
}

body.pd-server-list-page .card{
  box-sizing:border-box;
  width:100% !important;
  background:var(--panel, #111827);
  border:1px solid var(--border, rgba(148,163,184,.35));
  border-radius:14px;
  padding:18px 18px 20px;
  box-shadow:0 18px 45px rgba(15,23,42,.65);
}

body.servers-page:not(.my-servers-page) .servers-hero-card,
body.my-servers-page #myServersHeaderCard,
body.user-servers-page .user-servers-hero-card{
  width:100% !important;
  max-width:none !important;
  margin:0 0 16px !important;
}

body.servers-page .servers-container h1,
body.user-servers-page .user-servers-hero h1{
  margin:0 0 4px;
  font-size:22px;
  line-height:1.2;
}

body.servers-page .servers-container p,
body.user-servers-page .user-servers-hero p{
  color:var(--muted, #9ca3af);
  font-size:13px;
  line-height:1.35;
}

/* ==========================================================
   Filters
   ========================================================== */

body.servers-page:not(.my-servers-page) .filters,
body.user-servers-page .filters{
  display:grid !important;
  grid-template-columns:
    minmax(320px, 1.8fr)
    minmax(160px, .7fr)
    minmax(160px, .7fr)
    auto !important;
  gap:10px !important;
  align-items:center !important;
}

body.my-servers-page .filters{
  display:grid !important;
  grid-template-columns:minmax(340px, 1.8fr) minmax(190px, .7fr) auto !important;
  gap:10px !important;
  align-items:center !important;
}

body.pd-server-list-page .filters .pd-input{
  width:100% !important;
  min-width:0 !important;
}

body.pd-server-list-page .filters .pd-input,
body.pd-server-list-page .filters .btn{
  box-sizing:border-box;
  min-height:40px;
}

/* ==========================================================
   Table shell and table geometry
   ========================================================== */

body.pd-server-list-page .pd-server-table-shell{
  width:100% !important;
  max-width:100% !important;
  margin:0 !important;
  border:1px solid var(--border, rgba(148,163,184,.35));
  border-radius:12px !important;
  background:var(--pd-table-bg);
  overflow-x:auto !important;
  overflow-y:hidden !important;
  overscroll-behavior-inline:contain;
  scrollbar-gutter:auto;
  scrollbar-color:rgba(100,116,139,.72) rgba(2,6,23,.72);
  box-shadow:0 12px 28px rgba(0,0,0,.35);
}

body.pd-server-list-page .pd-server-table{
  width:100% !important;
  max-width:none !important;
  margin:0 !important;
  table-layout:fixed !important;
  border-collapse:separate !important;
  border-spacing:0 !important;
  color:var(--pd-table-text);
  font-size:12.5px !important;
}

body.pd-server-list-page .pd-server-table col{
  display:table-column !important;
  visibility:visible !important;
}

body.servers-page:not(.my-servers-page) #serversTable{
  min-width:1760px !important;
}

body.my-servers-page #myServersTable{
  min-width:1680px !important;
}

body.user-servers-page #userServersTable{
  min-width:1700px !important;
}

/*
 * A previous responsive layer hid detail columns and changed the Actions
 * cell to flex. Both behaviours corrupt native table column calculation.
 */
body.pd-server-list-page .pd-server-table > thead > tr > th,
body.pd-server-list-page .pd-server-table > tbody > tr > td{
  display:table-cell !important;
  visibility:visible !important;
  box-sizing:border-box;
  padding:7px 9px !important;
  border:0 !important;
  border-right:1px solid rgba(51,83,160,.42) !important;
  border-bottom:1px solid var(--pd-table-border) !important;
  text-align:left;
  vertical-align:middle !important;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

body.pd-server-list-page .pd-server-table > thead > tr > th:last-child,
body.pd-server-list-page .pd-server-table > tbody > tr > td:last-child{
  border-right:0 !important;
}

body.pd-server-list-page .pd-server-table thead{
  background:var(--pd-table-bg);
}

body.pd-server-list-page .pd-server-table thead th{
  position:sticky;
  top:0;
  z-index:3;
  height:38px;
  background:var(--pd-table-bg);
  color:var(--pd-table-muted);
  font-size:11.5px;
  font-weight:800;
  line-height:1.1;
  text-transform:uppercase;
  letter-spacing:.035em;
}

body.pd-server-list-page .pd-server-table tbody tr{
  height:44px;
  background:var(--pd-table-row);
}

body.pd-server-list-page .pd-server-table tbody tr:nth-child(even){
  background:var(--pd-table-row-alt);
}

body.pd-server-list-page .pd-server-table tbody tr:hover{
  background:var(--pd-table-row-hover);
}

body.pd-server-list-page .pd-server-table tbody tr:last-child td{
  border-bottom:0 !important;
}

body.pd-server-list-page .pd-server-table td{
  font-variant-numeric:tabular-nums;
}

/* ==========================================================
   Semantic cells
   ========================================================== */

body.pd-server-list-page .pd-server-table th.sv-col-name,
body.pd-server-list-page .pd-server-table td.sv-col-name{
  white-space:normal !important;
  overflow:visible !important;
  text-overflow:clip !important;
}

body.pd-server-list-page .pd-server-table td.sv-col-name{
  color:#f8fafc;
  font-weight:650;
  line-height:1.28;
  overflow-wrap:anywhere;
  word-break:normal;
}

body.pd-server-list-page .pd-server-table .pd-server-hostname{
  min-width:0;
  color:#f8fafc;
  font-weight:650;
  line-height:1.28;
  overflow-wrap:anywhere;
}

body.pd-server-list-page .pd-server-table th.sv-col-reason,
body.pd-server-list-page .pd-server-table td.sv-col-reason{
  white-space:normal !important;
  overflow:visible !important;
  text-overflow:clip !important;
  line-height:1.28;
}

body.pd-server-list-page .pd-server-table tr[data-online="0"] td.sv-col-reason{
  color:#fcd34d;
}

body.pd-server-list-page .pd-server-table tr[data-online="1"] td.sv-col-status{
  color:#86efac;
  font-weight:750;
}

body.pd-server-list-page .pd-server-table tr[data-online="0"] td.sv-col-status{
  color:#fca5a5;
  font-weight:750;
}

body.pd-server-list-page .pd-server-table td.sv-col-start,
body.pd-server-list-page .pd-server-table td.sv-col-stop,
body.pd-server-list-page .pd-server-table td.sv-col-uptime,
body.pd-server-list-page .pd-server-table td.sv-col-last,
body.pd-server-list-page .pd-server-table td.sv-col-iwad,
body.pd-server-list-page .pd-server-table td.sv-col-gamemode,
body.pd-server-list-page .pd-server-table td.sv-col-address,
body.pd-server-list-page .pd-server-table td.sv-col-cpu,
body.pd-server-list-page .pd-server-table td.sv-col-mem{
  font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size:12px;
}

body.pd-server-list-page .pd-server-table th.sv-col-engine,
body.pd-server-list-page .pd-server-table td.sv-col-engine,
body.pd-server-list-page .pd-server-table th.sv-col-country,
body.pd-server-list-page .pd-server-table td.sv-col-country,
body.pd-server-list-page .pd-server-table th.sv-col-players,
body.pd-server-list-page .pd-server-table td.sv-col-players,
body.pd-server-list-page .pd-server-table th.sv-col-location,
body.pd-server-list-page .pd-server-table td.sv-col-location{
  text-align:center !important;
}

body.pd-server-list-page .pd-server-table td.sv-col-hoster{
  white-space:normal;
  line-height:1.2;
}

/* ==========================================================
   Sticky actions without changing <td> display semantics
   ========================================================== */

body.pd-server-list-page .pd-server-table th.sv-col-actions,
body.pd-server-list-page .pd-server-table td.sv-col-actions{
  position:sticky;
  right:0;
  white-space:nowrap !important;
  overflow:visible !important;
  text-overflow:clip !important;
}

body.pd-server-list-page .pd-server-table th.sv-col-actions{
  z-index:5;
  background:var(--pd-table-bg);
  box-shadow:-10px 0 16px rgba(0,0,0,.24);
}

body.pd-server-list-page .pd-server-table td.sv-col-actions{
  z-index:2;
  background:#071022;
  box-shadow:-10px 0 16px rgba(0,0,0,.30);
}

body.pd-server-list-page .pd-server-table tbody tr:nth-child(even) td.sv-col-actions{
  background:#0c1528;
}

body.pd-server-list-page .pd-server-table tbody tr:hover td.sv-col-actions{
  background:#14254d;
}

body.pd-server-list-page .pd-server-table td.sv-col-actions .btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:34px;
  height:30px;
  margin:0 2px;
  padding:4px 7px;
  border-radius:7px;
  font-size:12px;
  line-height:1;
  vertical-align:middle;
}

body.pd-server-list-page .pd-server-table td.sv-col-actions .btn:first-child{
  margin-left:0;
}

body.pd-server-list-page .pd-server-table td.sv-col-actions .btn:last-child{
  margin-right:0;
}

/* ==========================================================
   Stable column widths: public servers
   ========================================================== */

body.servers-page:not(.my-servers-page) #serversTable col.col-id{ width:72px !important; }
body.servers-page:not(.my-servers-page) #serversTable col.col-engine{ width:46px !important; }
body.servers-page:not(.my-servers-page) #serversTable col.col-country{ width:50px !important; }
body.servers-page:not(.my-servers-page) #serversTable col.col-name{ width:360px !important; }
body.servers-page:not(.my-servers-page) #serversTable col.col-players{ width:108px !important; }
body.servers-page:not(.my-servers-page) #serversTable col.col-hoster{ width:112px !important; }
body.servers-page:not(.my-servers-page) #serversTable col.col-address{ width:148px !important; }
body.servers-page:not(.my-servers-page) #serversTable col.col-iwad{ width:112px !important; }
body.servers-page:not(.my-servers-page) #serversTable col.col-start{ width:154px !important; }
body.servers-page:not(.my-servers-page) #serversTable col.col-uptime{ width:102px !important; }
body.servers-page:not(.my-servers-page) #serversTable col.col-last{ width:160px !important; }
body.servers-page:not(.my-servers-page) #serversTable col.col-cpu{ width:90px !important; }
body.servers-page:not(.my-servers-page) #serversTable col.col-mem{ width:100px !important; }
body.servers-page:not(.my-servers-page) #serversTable col.col-actions{ width:132px !important; }

/* ==========================================================
   Stable column widths: selected user
   ========================================================== */

body.user-servers-page #userServersTable col.col-id{ width:72px !important; }
body.user-servers-page #userServersTable col.col-engine{ width:46px !important; }
body.user-servers-page #userServersTable col.col-country{ width:50px !important; }
body.user-servers-page #userServersTable col.col-name{ width:350px !important; }
body.user-servers-page #userServersTable col.col-players{ width:108px !important; }
body.user-servers-page #userServersTable col.col-status{ width:104px !important; }
body.user-servers-page #userServersTable col.col-reason{ width:180px !important; }
body.user-servers-page #userServersTable col.col-start{ width:150px !important; }
body.user-servers-page #userServersTable col.col-stop{ width:150px !important; }
body.user-servers-page #userServersTable col.col-uptime{ width:100px !important; }
body.user-servers-page #userServersTable col.col-iwad{ width:110px !important; }
body.user-servers-page #userServersTable col.col-gamemode{ width:138px !important; }
body.user-servers-page #userServersTable col.col-actions{ width:126px !important; }

/* Fallback when the shared renderer does not add semantic td classes. */
body.user-servers-page #userServersTable th:nth-child(1),
body.user-servers-page #userServersTable td:nth-child(1){ width:72px; }
body.user-servers-page #userServersTable th:nth-child(2),
body.user-servers-page #userServersTable td:nth-child(2){ width:46px; text-align:center !important; }
body.user-servers-page #userServersTable th:nth-child(3),
body.user-servers-page #userServersTable td:nth-child(3){ width:50px; text-align:center !important; }
body.user-servers-page #userServersTable th:nth-child(4),
body.user-servers-page #userServersTable td:nth-child(4){
  white-space:normal !important;
  overflow:visible !important;
  text-overflow:clip !important;
  line-height:1.28;
  overflow-wrap:anywhere;
}
body.user-servers-page #userServersTable th:nth-child(7),
body.user-servers-page #userServersTable td:nth-child(7){
  white-space:normal !important;
  overflow:visible !important;
  text-overflow:clip !important;
  line-height:1.28;
}
body.user-servers-page #userServersTable th:nth-child(13),
body.user-servers-page #userServersTable td:nth-child(13){
  position:sticky;
  right:0;
  display:table-cell !important;
  white-space:nowrap !important;
  overflow:visible !important;
  text-overflow:clip !important;
}
body.user-servers-page #userServersTable th:nth-child(13){
  z-index:5;
  background:var(--pd-table-bg);
  box-shadow:-10px 0 16px rgba(0,0,0,.24);
}
body.user-servers-page #userServersTable td:nth-child(13){
  z-index:2;
  background:#071022;
  box-shadow:-10px 0 16px rgba(0,0,0,.30);
}
body.user-servers-page #userServersTable tbody tr:nth-child(even) td:nth-child(13){
  background:#0c1528;
}
body.user-servers-page #userServersTable tbody tr:hover td:nth-child(13){
  background:#14254d;
}
body.user-servers-page #userServersTable td:nth-child(13) .btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:34px;
  height:30px;
  margin:0 2px;
  padding:4px 7px;
  vertical-align:middle;
}
body.user-servers-page #userServersTable tr[data-online="1"] td:nth-child(6){
  color:#86efac;
  font-weight:750;
}
body.user-servers-page #userServersTable tr[data-online="0"] td:nth-child(6){
  color:#fca5a5;
  font-weight:750;
}
body.user-servers-page #userServersTable tr[data-online="0"] td:nth-child(7){
  color:#fcd34d;
}
body.user-servers-page #userServersTable td:nth-child(n+8):nth-child(-n+12){
  font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size:12px;
}

/* ==========================================================
   Stable column widths: my servers
   ========================================================== */

body.my-servers-page #myServersTable col.col-rownum{ width:46px !important; }
body.my-servers-page #myServersTable col.col-id{ width:72px !important; }
body.my-servers-page #myServersTable col.col-country{ width:50px !important; }
body.my-servers-page #myServersTable col.col-name{ width:330px !important; }
body.my-servers-page #myServersTable col.col-players{ width:108px !important; }
body.my-servers-page #myServersTable col.col-status{ width:106px !important; }
body.my-servers-page #myServersTable col.col-reason{ width:190px !important; }
body.my-servers-page #myServersTable col.col-start{ width:150px !important; }
body.my-servers-page #myServersTable col.col-stop{ width:150px !important; }
body.my-servers-page #myServersTable col.col-uptime{ width:100px !important; }
body.my-servers-page #myServersTable col.col-iwad{ width:110px !important; }
body.my-servers-page #myServersTable col.col-gamemode{ width:132px !important; }
body.my-servers-page #myServersTable col.col-actions{ width:126px !important; }

/* ==========================================================
   Sortable headers
   ========================================================== */

body.pd-server-list-page .pd-server-table thead th.is-sortable{
  position:sticky;
  cursor:pointer;
  user-select:none;
  -webkit-user-select:none;
  transition:color .14s ease, background-color .14s ease, box-shadow .14s ease;
}

body.pd-server-list-page .pd-server-table thead th.is-sortable:hover{
  color:#f8fafc;
  background:rgba(249,115,22,.11);
}

body.pd-server-list-page .pd-server-table thead th.is-sortable:focus-visible{
  outline:2px solid rgba(249,115,22,.65);
  outline-offset:-2px;
}

body.pd-server-list-page .pd-server-table thead th.is-sort-active{
  color:#fff7ed;
  background:linear-gradient(180deg, rgba(249,115,22,.30), rgba(124,45,18,.24) 48%, #020617 100%);
  box-shadow:inset 0 -2px 0 rgba(249,115,22,.95);
}

body.pd-server-list-page .pd-server-table thead th.is-sortable::after{
  content:"↕";
  display:inline-block;
  margin-left:5px;
  font-size:10px;
  line-height:1;
  opacity:.48;
  transform:translateY(-1px);
}

body.pd-server-list-page .pd-server-table thead th.is-sortable:hover::after,
body.pd-server-list-page .pd-server-table thead th.is-sort-active::after{
  opacity:.95;
}

body.pd-server-list-page .pd-server-table thead th.sv-col-engine.is-sortable::after,
body.pd-server-list-page .pd-server-table thead th.sv-col-country.is-sortable::after{
  content:"" !important;
  display:none !important;
}

/* ==========================================================
   Engine, country, host and players
   ========================================================== */

body.pd-server-list-page .pd-engine-cell{
  display:inline-flex !important;
  align-items:center;
  justify-content:center;
  width:28px !important;
  height:28px !important;
  min-width:28px !important;
  gap:0 !important;
}

body.pd-server-list-page .pd-engine-logo{
  display:block;
  width:24px !important;
  height:24px !important;
  object-fit:contain;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,.55));
  transition:transform .12s ease, filter .12s ease;
}

body.pd-server-list-page .pd-engine-cell:hover .pd-engine-logo{
  transform:scale(1.08);
  filter:drop-shadow(0 2px 4px rgba(0,0,0,.65));
}

body.pd-server-list-page .pd-engine-text,
body.pd-server-list-page .pd-engine-name,
body.pd-server-list-page .pd-engine-sub{
  display:none !important;
}

body.pd-server-list-page .pd-country-flag-cell{
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  min-height:18px;
}

body.pd-server-list-page .pd-country-flag{
  display:inline-flex;
  width:25px;
  height:17px;
  overflow:hidden;
  border:1px solid rgba(226,232,240,.38);
  border-radius:2px;
  background:#fff;
  box-shadow:0 0 0 1px rgba(2,6,23,.76), 0 2px 5px rgba(0,0,0,.34);
}

body.pd-server-list-page .pd-country-flag svg{
  display:block;
  width:100%;
  height:100%;
}

body.pd-server-list-page .pd-host-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:34px;
  height:20px;
  padding:0 8px;
  border:1px solid rgba(148,163,184,.30);
  border-radius:999px;
  background:rgba(15,23,42,.72);
  color:#cbd5e1;
  font-size:11px;
  font-weight:850;
  line-height:1;
  letter-spacing:.045em;
  text-transform:uppercase;
}

body.pd-server-list-page .pd-host-badge--it{
  color:#fed7aa;
  border-color:rgba(249,115,22,.44);
  background:rgba(154,52,18,.30);
}

body.pd-server-list-page .pd-host-badge--fr,
body.pd-server-list-page .pd-host-badge--uk{
  color:#bfdbfe;
  border-color:rgba(96,165,250,.42);
  background:rgba(30,64,175,.32);
}

/* PD_SERVER_LIST_PLAYER_DETAILS_POPOVER_V1 */
/* Detailed player information shared by all server-list pages. */
body.pd-server-list-page .pd-server-table .pd-players-tooltip{
  position:absolute;
  left:calc(100% + 10px);
  top:50%;
  bottom:auto;
  display:block !important;
  min-width:154px;
  padding:8px 10px;
  border:1px solid rgba(148,163,184,.24);
  border-radius:10px;
  background:rgba(3,7,18,.97);
  box-shadow:0 14px 28px rgba(0,0,0,.45);
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  transform:translateY(-50%) translateX(-4px);
  transition:opacity .14s ease, transform .14s ease, visibility .14s ease;
  z-index:80;
}

body.pd-server-list-page .pd-server-table .pd-players-tooltip::before{
  content:"";
  position:absolute;
  left:-5px;
  top:50%;
  width:10px;
  height:10px;
  border-left:1px solid rgba(148,163,184,.24);
  border-bottom:1px solid rgba(148,163,184,.24);
  background:rgba(3,7,18,.97);
  transform:translateY(-50%) rotate(45deg);
}

body.pd-server-list-page .pd-server-table .pd-players-chip:hover .pd-players-tooltip,
body.pd-server-list-page .pd-server-table .pd-players-chip:focus-visible .pd-players-tooltip,
body.pd-server-list-page .pd-server-table .pd-players-chip:focus .pd-players-tooltip{
  opacity:1;
  visibility:visible;
  transform:translateY(-50%) translateX(0);
}

body.pd-server-list-page .pd-server-table .pd-players-tip-row{
  display:grid;
  grid-template-columns:1fr auto;
  gap:10px;
  align-items:center;
  color:#dbe6f3;
  font-size:12px;
  line-height:1.25;
  white-space:nowrap;
}

body.pd-server-list-page .pd-server-table .pd-players-tip-row + .pd-players-tip-row{
  margin-top:4px;
}

body.pd-server-list-page .pd-server-table .pd-players-tip-row span{
  color:#a8b6c9;
}

body.pd-server-list-page .pd-server-table .pd-players-tip-row strong{
  color:#fff;
  font-weight:800;
}

body.pd-server-list-page .pd-server-table .pd-players-chip{
  width:86px !important;
  max-width:86px !important;
  cursor:help;
}

body.pd-server-list-page .pd-server-table td.sv-col-players{
  position:relative;
  overflow:visible !important;
  z-index:1;
}

body.pd-server-list-page .pd-server-table tbody tr:hover td.sv-col-players,
body.pd-server-list-page .pd-server-table td.sv-col-players:focus-within{
  z-index:20;
}

/* ==========================================================
   Responsive controls: tables keep their columns and scroll
   ========================================================== */

@media (max-width:1180px){
  body.servers-page:not(.my-servers-page) .filters,
  body.user-servers-page .filters,
  body.my-servers-page .filters{
    grid-template-columns:1fr 1fr !important;
  }

  body.pd-server-list-page .filters > :first-child{
    grid-column:1 / -1;
  }

  body.pd-server-list-page .filters .btn{
    width:100% !important;
  }
}

@media (max-width:720px){
  body.pd-server-list-page .container{
    width:calc(100vw - 16px) !important;
    margin-top:72px !important;
    padding:0 0 24px !important;
  }

  body.servers-page:not(.my-servers-page) .filters,
  body.user-servers-page .filters,
  body.my-servers-page .filters{
    grid-template-columns:1fr !important;
  }

  body.pd-server-list-page .filters > *{
    grid-column:auto !important;
  }

  body.pd-server-list-page .card{
    padding:15px 14px 17px;
  }
}
