@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --surface: #f8f9fa;
  --surface-hover: #f1f3f5;
  --border: #e9ecef;
  --border-strong: #dee2e6;
  --text: #212529;
  --text-muted: #6c757d;
  --text-light: #adb5bd;
  --accent: #2d6a4f;
  --accent-light: #e8f5ee;
  --accent-hover: #1b4332;
  --online: #2d9d5e;
  --online-bg: #eaf7ef;
  --offline: #dc3545;
  --offline-bg: #fdf0f1;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --sans: 'DM Sans', -apple-system, sans-serif;
  --mono: 'DM Mono', monospace;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  height: 64px;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(45,106,79,0.35);
  overflow: hidden;
  background: transparent;
}

.logo-icon svg {
  width: 22px;
  height: 22px;
}

.logo-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.logo-tagline {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 4px;
  display: none;
}

@media (min-width: 640px) { .logo-tagline { display: inline; } }

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.badge-count {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: var(--mono);
}

.nav-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg);
  cursor: pointer;
  color: var(--text);
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.nav-menu-btn:hover { background: var(--surface); border-color: var(--accent); }
.nav-menu-btn svg { pointer-events: none; }

.nav-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  min-width: 200px;
  padding: 6px;
  z-index: 200;
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  transform-origin: top right;
}
.nav-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background .12s;
}
.nav-dropdown-item:hover { background: var(--surface); }
.nav-dropdown-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.nav-dropdown-item.discord { color: #5865F2; }
.nav-dropdown-item.discord:hover { background: #eef0ff; }

.nav-dropdown-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  flex-shrink: 0;
}
.nav-dropdown-icon svg { width: 15px; height: 15px; }
.nav-dropdown-item.discord .nav-dropdown-icon { background: #eef0ff; }

.nav-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 5px 6px;
}

.hero {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.hero p {
  color: var(--text-muted);
  font-size: 16px;
  max-width: 520px;
}

.stats-row {
  display: flex;
  gap: 24px;
  margin-top: 24px;
  flex-wrap: wrap;
}

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

.stat-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--text);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.main {
  padding: 32px 0 64px;
}

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

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  font-family: var(--sans);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.refresh-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.refresh-btn svg { width: 14px; height: 14px; stroke: currentColor; transition: transform 0.4s; }
.refresh-btn.spinning svg { animation: spin 0.8s linear infinite; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--sans);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.2px;
}
.filter-btn:hover { background: var(--accent-light); color: var(--accent); border-color: rgba(45,106,79,0.3); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 2px 8px rgba(45,106,79,0.25); }

.motd-canvas-slot {
  margin-top: 10px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #2a2a2a;
  line-height: 0;
}
.motd-canvas-slot:empty {
  display: none;
}

.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.server-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  transition: box-shadow 0.25s, border-color 0.25s, transform 0.25s;
  animation: fadeIn 0.35s ease both;
  position: relative;
}

.server-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 14px;
  border: 1.5px solid transparent;
  background: linear-gradient(135deg, rgba(45,106,79,0.18) 0%, rgba(45,106,79,0) 60%) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.server-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.09), 0 2px 6px rgba(0,0,0,0.05);
  border-color: rgba(45,106,79,0.22);
  transform: translateY(-2px);
}

.server-card:hover::after {
  opacity: 1;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.server-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.server-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.server-icon-placeholder {
  font-size: 22px;
}

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

.card-name-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 3px;
}

.card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.2px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.server-tag {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.server-card:hover .server-tag {
  background: var(--accent-light);
  color: var(--accent);
  border-color: rgba(45,106,79,0.25);
}

.card-ip {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-light);
  margin-top: 1px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.status-badge.online {
  background: #f0faf5;
  color: #1a7f4b;
  border: 1px solid rgba(26,127,75,0.15);
}

.status-badge.offline {
  background: #fff2f2;
  color: #c0392b;
  border: 1px solid rgba(192,57,43,0.15);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-dot.pulse {
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}

.card-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--text-muted);
}

.chip svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  flex-shrink: 0;
}

.chip.highlight {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-muted);
}

.server-card.clickable {
  cursor: pointer;
}

.server-card.clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}






.loading-state { padding: 0; }

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding: 4px 0 32px;
}

.skeleton-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow: hidden;
}

.sk {
  background: linear-gradient(90deg, var(--surface) 25%, var(--border) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes sk-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.sk-icon { width: 48px; height: 48px; border-radius: 10px; flex-shrink: 0; }
.sk-line { height: 12px; margin-bottom: 8px; }
.sk-line-lg { height: 16px; width: 60%; }
.sk-line-sm { height: 10px; width: 40%; }
.sk-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sk-info { flex: 1; }

.spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-copy {
  font-size: 13px;
  color: var(--text-muted);
}

.footer-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-link:hover { color: var(--accent); }

@media (max-width: 600px) {
  .server-grid { grid-template-columns: 1fr; }
  .stats-row { gap: 16px; }
  .hero { padding: 32px 0 24px; }
}

.lb-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 13px;
  border-radius: 8px;
  border: 1px solid rgba(45,106,79,0.3);
  background: var(--accent-light);
  transition: all 0.15s;
  white-space: nowrap;
}
.lb-nav-btn:hover { background: var(--accent); color: #fff; }
.lb-nav-btn svg { stroke: currentColor; }

/* ── Card footer row (Copy IP + View stats) ── */
.card-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}

.copy-ip-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--sans);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.12s;
  flex-shrink: 0;
  letter-spacing: 0.1px;
}
.copy-ip-btn svg { width: 12px; height: 12px; stroke: currentColor; flex-shrink: 0; }
.copy-ip-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: rgba(45,106,79,0.28);
  transform: scale(1.03);
}
.copy-ip-btn:active { transform: scale(0.97); }
.copy-ip-btn.copied {
  background: #eaf7ef;
  color: #1a7f4b;
  border-color: rgba(26,127,75,0.25);
  transform: scale(1);
}

.card-view-stats {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-light);
  text-decoration: none;
  transition: color 0.15s;
  letter-spacing: 0.1px;
}
.server-card:hover .card-view-stats { color: var(--accent); }
.card-view-stats svg { width: 13px; height: 13px; stroke: currentColor; }

/* ── Ping / Latency badge ── */
.ping-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.ping-badge svg { width: 11px; height: 11px; stroke: currentColor; flex-shrink: 0; }

.ping-excellent {
  background: #f0faf5;
  color: #1a7f4b;
  border-color: rgba(26,127,75,0.15);
}
.ping-good {
  background: #f0f6ff;
  color: #2563c7;
  border-color: rgba(37,99,199,0.15);
}
.ping-fair {
  background: #fffbf0;
  color: #b86e00;
  border-color: rgba(184,110,0,0.15);
}
.ping-poor {
  background: #fff2f2;
  color: #c0392b;
  border-color: rgba(192,57,43,0.15);
}

/* ── Lazy load sentinel ── */
.load-sentinel {
  height: 1px;
  margin-top: 8px;
}

/* ── Search box ── */
.search-wrap {
  margin-bottom: 12px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 15px;
  height: 15px;
  stroke: var(--text-light);
  pointer-events: none;
  flex-shrink: 0;
  transition: stroke 0.15s;
}

.search-input {
  width: 100%;
  padding: 10px 40px 10px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input::placeholder {
  color: var(--text-light);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.1);
}

.search-input:focus + .search-clear,
.search-box:focus-within .search-icon {
  stroke: var(--accent);
}

.search-clear {
  position: absolute;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: var(--surface);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  padding: 0;
}

.search-clear:hover {
  background: var(--border-strong);
  color: var(--text);
}

.search-clear svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
}

/* Thông báo không tìm thấy kết quả */
.search-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.search-empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.search-empty p {
  font-size: 14px;
  line-height: 1.6;
}

.search-empty strong {
  color: var(--text);
}

/* ── MOTD offline placeholder ──────────────────────────────────────────── */
.motd-offline {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(220, 53, 69, 0.06);
  border: 1px solid rgba(220, 53, 69, 0.14);
  font-size: 12px;
  color: #a55;
  font-style: italic;
}

/* ── Offline card subtle tint ─────────────────────────────────────────── */
.server-card.card-offline {
  opacity: 0.82;
}
.server-card.card-offline:hover {
  opacity: 1;
}
