/* ── Base ── */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background-color: #1a1a1a;
  color: #c8c8c8;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 242px;
  min-width: 242px;
  height: 100vh;
  background-color: #111;
  border-right: 1px solid #333;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* Sidebar branding */
.sidebar-branding {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 11px 4px;
  border-bottom: 1px solid #222;
  gap: 0;
}

.deadside-logo {
  width: 100%;
  max-width: 200px;
  height: auto;
  opacity: 0.9;
  display: block;
}

.wardex-brand {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wardex-icon {
  width: 24px;
  height: 24px;
}

.wardex-title {
  color: #d4a436;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 3px;
}

/* Sidebar categories */
.sidebar-category {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 13px;
  border-bottom: 1px solid #222;
  cursor: pointer;
  transition: background-color 0.15s;
}

.sidebar-category:hover {
  background-color: #222;
}

.sidebar-category.active {
  background-color: #2a2a2a;
  border-left: 3px solid #d4a436;
}

.sidebar-category .cat-icon {
  color: #d4a436;
  font-size: 24px;
  width: 33px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-category .cat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-category .cat-name {
  color: #e0e0e0;
  font-size: 15px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-category .cat-stats {
  color: #888;
  font-size: 13px;
  line-height: 1.4;
}

/* Sidebar search */
.sidebar-search {
  padding: 11px 13px;
  border-bottom: 1px solid #222;
}

.sidebar-search input {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #444;
  color: #c8c8c8;
  padding: 9px 11px;
  font-size: 15px;
  outline: none;
}

.sidebar-search input::placeholder { color: #666; }
.sidebar-search input:focus { border-color: #d4a436; }

/* Sidebar filters */
.sidebar-filters {
  padding: 9px 13px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-filters .filter-group-title {
  color: #e0e0e0;
  font-weight: bold;
  text-transform: uppercase;
  margin-top: 15px;
  margin-bottom: 7px;
  font-size: 14px;
  letter-spacing: 0.5px;
}

.sidebar-filters .filter-group-title:first-child {
  margin-top: 6px;
}

.sidebar-filters label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 0;
  cursor: pointer;
  color: #aaa;
  font-size: 14px;
}

.sidebar-filters label:hover { color: #e0e0e0; }

.sidebar-filters input[type="checkbox"] {
  appearance: none;
  width: 15px;
  height: 15px;
  border: 1px solid #666;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-filters input[type="checkbox"]:checked {
  background-color: #d4a436;
  border-color: #d4a436;
}

/* Sidebar bottom */
.sidebar-bottom {
  border-top: 1px solid #333;
  padding: 11px 13px;
  display: flex;
  gap: 7px;
}

.sidebar-bottom .btn-small {
  flex: 1;
  background: #333;
  border: 1px solid #555;
  color: #ccc;
  padding: 9px;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  text-transform: uppercase;
}

.sidebar-bottom .btn-small:hover { background: #444; }

/* Sidebar CTA */
.sidebar-cta {
  border-top: 1px solid #333;
  padding: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  background: #0d0d0d;
}

.sidebar-cta .cta-label {
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-cta .cta-logo-link {
  display: block;
}

.sidebar-cta .cta-logo {
  height: 40px;
  opacity: 0.9;
  transition: opacity 0.2s;
}

.sidebar-cta .cta-logo-link:hover .cta-logo {
  opacity: 1;
}

.sidebar-cta .cta-button {
  display: block;
  width: 100%;
  background: #d4a436;
  color: #000;
  text-align: center;
  padding: 11px;
  font-size: 15px;
  font-weight: bold;
  text-transform: uppercase;
  text-decoration: none;
  letter-spacing: 0.5px;
  transition: background 0.2s;
}

.sidebar-cta .cta-button:hover {
  background: #e0b340;
}

/* ── Main Content ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Column header bar */
.column-header {
  display: flex;
  align-items: center;
  background-color: #222;
  border-bottom: 1px solid #333;
  padding: 0 16px;
  height: 38px;
  flex-shrink: 0;
  font-size: 13px;
  text-transform: uppercase;
  color: #888;
  letter-spacing: 0.5px;
  user-select: none;
}

.column-header .col { cursor: pointer; }
.column-header .col:hover { color: #d4a436; }
.col-name { flex: 1; padding-left: 40px; }
.col-wipe { width: 160px; text-align: center; }
.col-players { width: 110px; text-align: center; }
.col-sparkline { width: 130px; text-align: center; }
.col-avg { width: 110px; text-align: center; }
.col-rank { width: 60px; text-align: center; }

.sort-arrow {
  font-size: 10px;
  margin-left: 3px;
}

/* List/Detail view containers */
#list-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#detail-view {
  flex: 1;
  overflow-y: auto;
}

/* Server list */
.server-list {
  flex: 1;
  overflow-y: auto;
  background-color: #1a1a1a;
}

/* Individual server row */
.server-row {
  display: flex;
  align-items: flex-start;
  padding: 10px 16px;
  border-bottom: 1px solid #262626;
  cursor: pointer;
  transition: background-color 0.1s;
  min-height: 62px;
}

.server-row:hover {
  background-color: #242424;
}

.server-row:nth-child(even) {
  background-color: #1d1d1d;
}

.server-row:nth-child(even):hover {
  background-color: #242424;
}

/* Star / favorite */
.server-star {
  width: 28px;
  flex-shrink: 0;
  color: #555;
  font-size: 16px;
  padding-top: 3px;
  cursor: pointer;
}

.server-star:hover { color: #d4a436; }

/* Server status dot */
.server-status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.server-status-dot.online {
  background: #4caf50;
  box-shadow: 0 0 4px rgba(76, 175, 80, 0.5);
}

.server-status-dot.offline {
  background: #666;
}

/* Offline row dimmed */
.server-row.row-offline {
  opacity: 0.5;
}

.server-row.row-offline .server-name {
  color: #888;
}

/* Server info (name + map + tags) */
.server-info {
  flex: 1;
  min-width: 0;
  padding-left: 8px;
}

.server-name {
  color: #d4a436;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.server-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
  align-items: center;
}

/* Map badge */
.badge-map {
  background-color: #3a3a3a;
  color: #ccc;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 2px;
  border: 1px solid #555;
  white-space: nowrap;
}

/* Tag badges */
.badge-tag {
  background-color: #d4a436;
  color: #111;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 2px;
  white-space: nowrap;
}

/* Mods badge - distinct purple/blue to stand out */
.badge-mods {
  background-color: #7b68ee;
  color: #fff;
}

/* Right-side columns */
.server-wipe {
  width: 160px;
  text-align: center;
  font-size: 14px;
  color: #aaa;
  padding-top: 8px;
  flex-shrink: 0;
}

.server-players {
  width: 110px;
  text-align: center;
  font-size: 14px;
  color: #ccc;
  padding-top: 8px;
  flex-shrink: 0;
}

.server-sparkline {
  width: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding-top: 4px;
}

.server-sparkline canvas {
  display: block;
}

.server-avg {
  width: 110px;
  text-align: center;
  font-size: 14px;
  color: #d4a436;
  font-weight: 600;
  padding-top: 8px;
  flex-shrink: 0;
}

.server-rank {
  width: 60px;
  text-align: center;
  font-size: 14px;
  color: #666;
  padding-top: 8px;
  flex-shrink: 0;
}

/* Players bar mini visualization */
.players-bar {
  display: inline-block;
  width: 50px;
  height: 5px;
  background: #333;
  border-radius: 2px;
  overflow: hidden;
  vertical-align: middle;
  margin-left: 5px;
}

.players-bar-fill {
  height: 100%;
  background: #d4a436;
  border-radius: 2px;
  transition: width 0.3s;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px;
  background: #222;
  border-top: 1px solid #333;
  flex-shrink: 0;
}

.btn {
  background: #333;
  border: 1px solid #555;
  color: #ccc;
  padding: 8px 20px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover { background: #444; }
.btn:disabled { background: #222; color: #555; cursor: not-allowed; border-color: #333; }

.page-info {
  color: #888;
  font-size: 14px;
}

/* ── Status bar ── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 16px;
  background: #1a1a1a;
  border-bottom: 1px solid #262626;
  font-size: 12px;
  color: #666;
  flex-shrink: 0;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
  margin-right: 4px;
}

/* ── Loading ── */
.loading-row {
  padding: 50px;
  text-align: center;
  color: #666;
  font-size: 16px;
}

/* ── Platform icon in tags ── */
.platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.platform-badge img {
  width: 18px;
  height: 18px;
  vertical-align: middle;
}

/* ── Hidden utility ── */
.hidden { display: none !important; }

/* ── Server Detail Page ── */
.back-link {
  color: #d4a436;
  text-decoration: none;
  font-size: 14px;
  display: inline-block;
  margin-bottom: 16px;
}
.back-link:hover { text-decoration: underline; }

.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.detail-name {
  font-size: 26px;
  font-weight: 600;
  color: #e0e0e0;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 24px;
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: #222;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 18px;
  text-align: center;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: #d4a436;
}

.stat-label {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.chart-section {
  background: #222;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 18px;
  margin-bottom: 28px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.chart-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #ccc;
}

.chart-range-btns {
  display: flex;
  gap: 6px;
}

.btn-range {
  padding: 4px 14px;
  font-size: 12px;
  background: #333;
  border: 1px solid #444;
  color: #aaa;
  cursor: pointer;
  border-radius: 3px;
}

.btn-range:hover { background: #444; }
.btn-range.active {
  background: #d4a436;
  color: #111;
  border-color: #d4a436;
  font-weight: 600;
}

#history-chart {
  width: 100%;
  border-radius: 4px;
}

.info-section {
  background: #222;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 18px;
  margin-bottom: 28px;
}

.info-section h2 {
  font-size: 16px;
  font-weight: 600;
  color: #ccc;
  margin-bottom: 14px;
}

.info-grid {
  display: grid;
  gap: 0;
}

.info-row {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid #2a2a2a;
}

.info-row:last-child { border-bottom: none; }

.info-label {
  width: 160px;
  flex-shrink: 0;
  color: #888;
  font-size: 14px;
}

.info-value {
  color: #ccc;
  font-size: 14px;
}

#server-detail {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(100vh - 20px);
}

/* ── Mods Section ── */
.mods-section {
  background: #222;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 18px;
  margin-bottom: 28px;
}

.mods-section h2 {
  font-size: 16px;
  font-weight: 600;
  color: #ccc;
  margin-bottom: 14px;
}

.mod-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mod-row {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.mod-row:hover {
  border-color: #444;
}

.mod-row-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
}

.mod-thumbnail {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: #333;
}

.mod-info {
  flex: 1;
  min-width: 0;
}

.mod-title {
  font-size: 14px;
  font-weight: 600;
  color: #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mod-stats {
  display: flex;
  gap: 16px;
  margin-top: 4px;
  font-size: 12px;
  color: #888;
}

.mod-expanded {
  display: none;
  padding: 0 14px 14px;
}

.mod-row.expanded .mod-expanded {
  display: block;
}

.mod-row.expanded {
  border-color: #d4a436;
}

.mod-expanded-image {
  max-width: 300px;
  max-height: 200px;
  border-radius: 4px;
  margin-bottom: 10px;
}

.mod-description {
  font-size: 13px;
  color: #aaa;
  line-height: 1.5;
  margin-bottom: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.mod-meta {
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
}

.mod-workshop-link {
  display: inline-block;
  font-size: 12px;
  color: #d4a436;
  text-decoration: none;
}

.mod-workshop-link:hover {
  text-decoration: underline;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #1a1a1a; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ── Hamburger button (hidden on desktop) ── */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  margin-right: 10px;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: #ccc;
  margin: 4px 0;
  border-radius: 1px;
}

/* ── Sidebar overlay (hidden on desktop) ── */
.sidebar-overlay {
  display: none;
}

/* ══════════════════════════════════════════════
   TABLET: <= 1024px — sidebar collapses
   ══════════════════════════════════════════════ */
@media (max-width: 1024px) {
  body {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .main {
    overflow: visible;
    height: auto;
    flex: none;
  }

  #list-view {
    overflow: visible;
    height: auto;
    flex: none;
  }

  .server-list {
    overflow: visible;
    height: auto;
    flex: none;
  }

  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    width: 260px;
    min-width: 260px;
    z-index: 200;
    transition: left 0.25s ease;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .hamburger {
    display: block;
  }

  .main {
    width: 100%;
  }

  /* Hide wipe column on tablet */
  .col-wipe,
  .server-wipe {
    display: none;
  }

  /* Reduce sparkline width */
  .col-sparkline,
  .server-sparkline {
    width: 100px;
  }

  .server-sparkline canvas {
    width: 90px;
  }
}

/* ══════════════════════════════════════════════
   MOBILE: <= 768px — card layout
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Hide column header entirely */
  .column-header {
    display: none;
  }

  /* Status bar compact */
  .status-bar {
    font-size: 11px;
    padding: 6px 10px;
  }

  /* Server rows become cards */
  .server-row {
    flex-wrap: wrap;
    padding: 12px;
    gap: 6px;
  }

  .server-star {
    position: absolute;
    top: 14px;
    left: 12px;
  }

  .server-row {
    position: relative;
    padding-left: 28px;
  }

  .server-info {
    width: 100%;
    flex: none;
  }

  .server-name {
    font-size: 14px;
  }

  /* Hide sparkline and wipe on mobile */
  .server-sparkline,
  .server-wipe {
    display: none;
  }

  /* Players, avg, rank in a row below */
  .server-players {
    width: auto;
    font-size: 13px;
    padding-top: 0;
    text-align: left;
  }

  .server-avg {
    width: auto;
    font-size: 13px;
    padding-top: 0;
  }

  .server-avg::before {
    content: 'Avg: ';
    color: #888;
    font-weight: 400;
  }

  .server-rank {
    width: auto;
    font-size: 13px;
    padding-top: 0;
    color: #888;
  }

  .server-rank::before {
    content: '#';
    color: #666;
  }

  .players-bar {
    width: 50px;
  }

  /* Pagination smaller */
  .pagination {
    gap: 10px;
    padding: 8px;
  }

  .btn {
    padding: 6px 14px;
    font-size: 13px;
  }

  .page-info {
    font-size: 12px;
  }

  /* Detail page responsive */
  .detail-name {
    font-size: 20px;
  }

  .stats-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-value {
    font-size: 24px;
  }

  .stat-label {
    font-size: 11px;
  }

  #server-detail {
    padding: 16px;
  }

  .chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .info-row {
    flex-direction: column;
    gap: 2px;
  }

  .info-label {
    width: auto;
    font-size: 12px;
  }

  .info-value {
    font-size: 14px;
  }

  /* Mod rows compact */
  .mod-thumbnail {
    width: 40px;
    height: 40px;
  }

  .mod-title {
    font-size: 13px;
  }

  .mod-expanded-image {
    max-width: 100%;
  }

  /* Detail tags wrap */
  .detail-tags {
    gap: 4px;
  }

  .badge-tag {
    font-size: 11px;
    padding: 2px 8px;
  }
}
