/* ufw-map — Glassmorphism-Sidebar + Leaflet-Karte */

:root {
  --bg-1: #0f0c29;
  --bg-2: #302b63;
  --bg-3: #24243e;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-bg-hover: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-border-hover: rgba(255, 255, 255, 0.18);
  --fg: #e8e8f0;
  --fg-dim: #a8a8b8;
  --fg-faint: #6e6e8a;
  --accent: #ff7043;
  --accent-2: #ffa726;
  --danger: #ef5350;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-3) 100%);
  background-attachment: fixed;
  color: var(--fg);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

body {
  display: grid;
  grid-template-columns: 360px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "header header"
    "sidebar map";
}

/* ---------------------------------------------------------------- HEADER */
header {
  grid-area: header;
  padding: 14px 24px;
  background: rgba(15, 12, 41, 0.6);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 20px;
}

header h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--fg);
  display: flex; align-items: center; gap: 8px;
}
header h1 .logo { font-size: 1.5rem; }

.subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: var(--fg-dim);
  flex: 1;
}
.subtitle strong { color: var(--fg); font-weight: 600; }

.admin-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--fg-dim);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}
.admin-toggle:hover { background: rgba(255, 255, 255, 0.08); color: var(--fg); }
.admin-toggle input { cursor: pointer; }

/* -------------------------------------------------------------- SIDEBAR */
aside {
  grid-area: sidebar;
  padding: 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

aside::-webkit-scrollbar { width: 6px; }
aside::-webkit-scrollbar-track { background: transparent; }
aside::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

/* --------------------------------------------------------------- PANELS */
.panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease;
}
.panel:hover { border-color: var(--glass-border-hover); }

.panel h2 {
  margin: 0 0 14px 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-2);
  font-weight: 600;
}

/* ------------------------------------------------------------- SOURCE PICKER */
.source-select {
  width: 100%;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--fg);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-dim) 50%),
                    linear-gradient(135deg, var(--fg-dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
.source-select:focus {
  outline: none;
  border-color: var(--accent-2);
}
.source-select option {
  background: var(--bg-2);
  color: var(--fg);
}

/* ------------------------------------------------------------- RANGE PICKER */
.range-label {
  font-size: 0.65rem;
  color: var(--fg-dim);
  text-transform: none;
  letter-spacing: 0.04em;
  font-weight: 400;
  margin-left: 6px;
}
.range-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.range-btn {
  flex: 1 1 calc(50% - 3px);
  min-width: 0;
  padding: 7px 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: var(--fg);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.range-btn:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
}
.range-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #1a1a2e;
  font-weight: 600;
}

/* ---------------------------------------------------------- STATS GRID */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.stat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px 12px;
}

.stat-v {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.stat-l {
  font-size: 0.65rem;
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 3px;
}

.stat-meta {
  display: flex; flex-wrap: wrap; gap: 4px 8px;
  font-size: 0.7rem;
  color: var(--fg-dim);
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.stat-meta code {
  font-family: 'JetBrains Mono', monospace;
  color: var(--fg);
}

/* ------------------------------------------------------------- RANK LIST */
.rank-list { display: flex; flex-direction: column; }

.rank-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.rank-item:last-child { border-bottom: none; }

.rank-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--fg-faint);
  text-align: right;
}

.rank-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--danger);
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rank-flag {
  font-size: 0.9rem;
  margin-right: 4px;
}

.anon-hint {
  margin: 10px 0 0 0;
  font-size: 0.7rem;
  color: var(--fg-faint);
  text-align: center;
  font-style: italic;
}

.anon-hint.hidden { display: none; }

/* ---------------------------------------------------------- CONTROLS */
.controls { display: flex; flex-direction: column; gap: 8px; }

button {
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #1a1a1a;
  font-weight: 600;
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  box-shadow: 0 4px 16px rgba(255, 112, 67, 0.25);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
button:hover { box-shadow: 0 6px 20px rgba(255, 112, 67, 0.4); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: wait; }

.btn-icon { font-size: 1rem; line-height: 1; }
.btn-icon.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auto-refresh {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem;
  color: var(--fg-dim);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.auto-refresh input { cursor: pointer; }

.hint {
  font-size: 0.72rem;
  color: var(--fg-faint);
  margin: 4px 0 0 0;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
}

.copyright {
  margin-top: 8px;
  padding: 12px 4px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--fg-faint);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

.copyright a {
  color: var(--accent-2);
  text-decoration: none;
  border-bottom: 1px dotted rgba(255, 167, 38, 0.4);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.copyright a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ------------------------------------------------------------------- MAP */
main { grid-area: map; background: #1a1a2e; }

#map { width: 100%; height: 100%; }

.leaflet-container { background: #2a2a3e; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--bg-2);
  color: var(--fg);
  box-shadow: var(--shadow);
}
.leaflet-popup-content { font-size: 0.85rem; line-height: 1.5; margin: 12px 14px; }
.leaflet-popup-content strong { color: var(--accent-2); font-family: 'JetBrains Mono', monospace; }
.leaflet-popup-content small { color: var(--fg-dim); }
.leaflet-control-attribution {
  background: rgba(0, 0, 0, 0.6) !important;
  color: var(--fg-dim) !important;
}
.leaflet-control-attribution a { color: var(--accent-2) !important; }
.leaflet-control-zoom a {
  background: var(--glass-bg) !important;
  color: var(--fg) !important;
  backdrop-filter: blur(10px);
  border-color: var(--glass-border) !important;
}
.leaflet-control-zoom a:hover { background: var(--glass-bg-hover) !important; }
