:root{
  --bg:#0B1026;
  --surface:#1B2240;
  --muted:#9aa6b2;
  --accent:#a0191c;
  --accent-2:#2E8B57;
  --card:#1B2240;
  --glass: rgba(255,255,255,0.05);
  --danger:#ff6b6b;
  --bs-body-bg: #0B1026;
  --bs-body-color: #e6eef6;
  --bs-border-color: rgba(255,255,255,0.1);
  
  /* Map page colors (old theme) */
  --map-bg: #0B1026;
  --map-surface: #1B2240;
  --map-accent: #a0191c;
  --map-accent-2: #2E8B57;
}

*{box-sizing:border-box}

body{
  background: var(--bg);
  color:#e6eef6;
  font-family:Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  padding:32px 16px;
  min-height:100vh;
}

/* Bootstrap overrides */
.card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.03);
  border-radius: 12px;
}

.card-body {
  color: #e6eef6;
}

.form-control, .form-select {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.1);
  color: #e6eef6;
}

.form-control:focus, .form-select:focus {
  background: rgba(255,255,255,0.05);
  border-color: var(--accent);
  color: #e6eef6;
  box-shadow: 0 0 0 0.25rem rgba(77, 184, 148, 0.15);
}

.form-control::placeholder {
  color: var(--muted);
}

.form-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.btn-gradient {
  background: var(--accent);
  border: none;
  color: #042028;
  font-weight: 600;
}

.btn-gradient:hover {
  background: var(--accent-2);
  color: #042028;
}

.btn-outline-accent {
  color: var(--muted);
  border-color: rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
}

.btn-outline-accent:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: #e6eef6;
}

.btn-outline-accent.active {
  background: var(--accent);
  border-color: transparent;
  color: #042028;
  font-weight: 600;
}

.btn-outline-secondary {
  color: var(--muted);
  border-color: rgba(255,255,255,0.1);
}

.btn-outline-secondary:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.15);
  color: #e6eef6;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.brand {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 0.6px;
  font-weight: 700;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Status */
.status-left {
  color: #e6eef6;
}

.status-right {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}

/* Chart */
.chart-container {
  position: relative;
  height: 220px;
  width: 100%;
}

#online-history {
  width: 100%;
  max-width: 100%;
  display: block;
}

.history-heading {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--muted);
}

/* Table */
.table-dark {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: rgba(255,255,255,0.02);
  --bs-table-hover-bg: rgba(255,255,255,0.04);
  --bs-table-border-color: rgba(255,255,255,0.03);
  color: #e6eef6;
  table-layout: fixed;
  width: 100%;
}

.table-dark tbody tr {
  background-color: transparent;
}

.table-dark tbody tr:nth-of-type(odd):not(.unreachable-header):not(.unreachable-row) {
  background-color: rgba(255,255,255,0.02);
}

.table-dark tbody tr:hover:not(.unreachable-header) {
  background-color: rgba(255,255,255,0.04) !important;
}

.table-dark thead {
  background: rgba(10, 14, 18, 0.123);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.table-dark th {
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding: 12px;
}

.table-dark th:nth-child(1) { width: 25%; } /* Name */
.table-dark th:nth-child(2) { width: 20%; } /* Address */
.table-dark th:nth-child(3) { width: 8%; }  /* Port */
.table-dark th:nth-child(4) { width: 10%; } /* Users */
.table-dark th:nth-child(5) { width: 12%; } /* Region */
.table-dark th:nth-child(6) { width: 12%; } /* Country */
.table-dark th:nth-child(7) { width: 13%; } /* Actions */

.table-dark td {
  padding: 12px;
  vertical-align: middle;
  border-top: 1px solid rgba(255,255,255,0.03);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-dark td:first-child {
  white-space: normal;
  word-break: break-word;
}

.sortable {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap;
}

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

.sort-icon {
  font-size: 0.75rem;
  opacity: 0.5;
  margin-left: 4px;
}

.sortable.active .sort-icon {
  opacity: 1;
  color: var(--accent);
}

/* Server row highlighting */
.server-row-highlight {
  background: rgba(77, 184, 148, 0.15) !important;
  animation: highlight-fade 2s ease-out;
}

@keyframes highlight-fade {
  0% { background: rgba(77, 184, 148, 0.25) !important; }
  100% { background: rgba(77, 184, 148, 0.05) !important; }
}

/* Unreachable servers */
.unreachable-header {
  background: #2d1f1f !important;
  font-weight: 500;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.unreachable-header:hover {
  background: #3d2525 !important;
}

.unreachable-header td {
  color: #d19a9a !important;
  padding: 12px;
}

.unreachable-row {
  background: #331a1a !important;
}

.unreachable-row:hover {
  background: #3d2020 !important;
}

.unreachable-row td {
  color: #b89090;
  padding: 12px;
  border-top: 1px solid #442222 !important;
}

#unreachable-toggle {
  display: inline-block;
  width: 20px;
  font-size: 12px;
}

/* Utility classes */
.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.flag {
  opacity: 0.95;
  margin-right: 6px;
}

.server-actions {
  display: flex;
  gap: 6px;
}

.server-actions .btn {
  font-size: 0.8rem;
  padding: 4px 10px;
}

.footer {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 32px;
}

.footer a {
  color: var(--accent-2);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 16px 8px;
  }
  
  .brand {
    font-size: 1.4rem;
  }
  
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ========================================
   MAP PAGE STYLES
   ======================================== */

/* Map-specific body override */
body.map-page {
  overflow: hidden;
  padding: 0;
  background: var(--map-bg);
}

/* Full-screen map container */
#map {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  background: var(--map-bg);
}

/* Floating home button */
.home-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background: var(--map-accent);
  color: #042028;
  border: none;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.2s;
}

.home-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
  filter: brightness(1.15);
}

/* Stats overlay */
.stats-overlay {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
  background: var(--map-surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 16px 20px;
  min-width: 200px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  color: var(--bs-body-color);
}

.stats-overlay h3 {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.stat-item:last-child {
  margin-bottom: 0;
}

.stat-label {
  color: var(--muted);
}

.stat-value {
  font-weight: 600;
  color: var(--map-accent);
  font-size: 1rem;
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
  background: var(--map-surface) !important;
  color: var(--bs-body-color) !important;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
}

.leaflet-popup-content {
  margin: 12px;
  min-width: 200px;
}

.leaflet-popup-tip {
  background: var(--map-surface) !important;
  border: 1px solid rgba(255,255,255,0.1);
}

.popup-server-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 8px;
  color: var(--map-accent);
}

.popup-server-name a {
  color: var(--map-accent);
  text-decoration: none;
}

.popup-server-name a:hover {
  text-decoration: underline;
}

.popup-info {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 4px 0;
}

.popup-users {
  color: var(--map-accent-2);
  font-weight: 600;
}

/* Map page mobile responsive */
@media (max-width: 768px) {
  .home-btn {
    top: 10px;
    right: 10px;
    padding: 10px 16px;
    font-size: 0.85rem;
  }
  
  .stats-overlay {
    bottom: 10px;
    left: 10px;
    padding: 12px 16px;
    min-width: 160px;
  }
  
  .stats-overlay h3 {
    font-size: 0.75rem;
  }
  
  .stat-item {
    font-size: 0.8rem;
  }
  
  .stat-value {
    font-size: 0.9rem;
  }
}

/* Snow Effect */
.snow-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.app {
  position: relative;
  z-index: 1;
}

.snowflake {
  position: absolute;
  top: -10px;
  color: #fff;
  font-size: 1em;
  font-family: Arial;
  text-shadow: 0 0 1px #000;
  -webkit-user-select: none;
  user-select: none;
  cursor: default;
  animation-name: fall, shake-opacity;
  animation-timing-function: linear, ease-in-out;
  animation-iteration-count: infinite, infinite;
  animation-play-state: running, running;
}

@keyframes fall {
  0% { top: -10%; }
  100% { top: 100%; }
}

@keyframes shake-opacity {
  0% { transform: translateX(0px); opacity: 0.8; }
  50% { transform: translateX(80px); opacity: 0.4; }
  100% { transform: translateX(0px); opacity: 0.8; }
}
