/* ═══════════════════════════════════════════════════
   Przemienniki PL — dark theme
═══════════════════════════════════════════════════ */

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

:root {
  --bg:       #0a0a0a;
  --surface:  #111;
  --surface2: #1a1a1a;
  --border:   #222;
  --accent:   #4ade80;
  --accent-d: #166534;
  --text:     #f0f0f0;
  --muted:    #888;
  --working:  #4ade80;
  --inactive: #f43f5e;
  --sidebar:  280px;

  --fm:     #4ade80;
  --dmr:    #60a5fa;
  --dstar:  #f97316;
  --c4fm:   #a78bfa;
  --atv:    #f43f5e;
  --tetra:  #fbbf24;
  --other:  #94a3b8;
}

html, body { height: 100%; overflow: hidden; font-family: system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ── Layout ── */
body { display: flex; }

#sidebar {
  width: var(--sidebar);
  min-width: var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
}

#map-container {
  flex: 1;
  position: relative;
}

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

/* ── Sidebar header ── */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo { font-weight: 700; font-size: 15px; }

#btn-locate {
  background: var(--accent-d);
  color: var(--accent);
  border: none;
  border-radius: 6px;
  width: 32px; height: 32px;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

#btn-locate:hover { background: var(--accent); color: #000; }

/* ── Search ── */
.search-wrap { padding: 10px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }

#search {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
#search:focus { border-color: var(--accent); }

/* ── Filters ── */
#filters-panel {
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#filters-panel summary {
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
#filters-panel summary::-webkit-details-marker { display: none; }

#filter-count {
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  display: none;
}
#filter-count.visible { display: inline; }

.filter-group { padding: 6px 12px 10px; }
.filter-label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  padding: 4px 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { background: var(--accent-d); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
}

.toggle input[type=checkbox] {
  accent-color: var(--accent);
  width: 15px; height: 15px;
}

.btn-ghost {
  margin: 6px 12px 10px;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ── List header ── */
#list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#list-count { color: var(--muted); font-size: 12px; }

#btn-refresh {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  transition: transform .3s;
}
#btn-refresh:hover { color: var(--accent); }
#btn-refresh.spinning { animation: spin .8s linear infinite; }

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

/* ── Repeater list ── */
#repeater-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
}

#repeater-list::-webkit-scrollbar { width: 4px; }
#repeater-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.rep-item {
  display: flex;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.rep-item:hover { background: var(--surface2); }
.rep-item.active { background: var(--surface2); border-left: 3px solid var(--accent); }

.rep-mode-bar { width: 4px; flex-shrink: 0; }

.rep-body { flex: 1; padding: 9px 10px; min-width: 0; }

.rep-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }

.rep-qra { font-family: monospace; font-weight: 700; font-size: 15px; }

.rep-badges { display: flex; gap: 4px; flex-shrink: 0; }

.badge-mode {
  font-size: 10px; font-weight: 700;
  padding: 2px 5px; border-radius: 3px;
}

.badge-band {
  font-size: 10px; color: var(--muted);
  padding: 2px 5px; border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.rep-freq { font-family: monospace; color: var(--accent); font-size: 12px; margin-top: 3px; }

.rep-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; }

.rep-qth { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rep-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.rep-dist { color: var(--accent); font-size: 11px; font-weight: 600; }

.status-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.working  { background: var(--working); }
.status-dot.inactive { background: var(--inactive); }

/* ── Status bar ── */
#status-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: #000c;
  color: var(--text);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  pointer-events: none;
  transition: opacity .3s;
  white-space: nowrap;
}
#status-bar.hidden { opacity: 0; }

/* ── Detail panel ── */
#detail-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 340px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 1000;
  overflow-y: auto;
  padding: 20px;
  transition: transform .25s ease;
}
#detail-panel.hidden { transform: translateX(100%); }

#detail-close {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  width: 30px; height: 30px;
  cursor: pointer;
  font-size: 16px;
}
#detail-close:hover { color: var(--text); border-color: var(--text); }

/* Detail content */
.d-header { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.d-qra { font-size: 26px; font-weight: 800; font-family: monospace; }
.d-qth { color: var(--muted); margin-top: 2px; }

.d-badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.d-status {
  padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; border: 1px solid;
}
.d-status.working  { color: var(--working);  border-color: var(--working);  background: #16653420; }
.d-status.inactive { color: var(--inactive); border-color: var(--inactive); background: #f43f5e20; }

.d-section { margin-bottom: 14px; }
.d-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--muted); margin-bottom: 6px;
}
.d-table { background: var(--surface2); border-radius: 8px; overflow: hidden; }
.d-row { display: flex; justify-content: space-between; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.d-row:last-child { border-bottom: none; }
.d-key { color: var(--muted); }
.d-val { font-weight: 500; text-align: right; }
.d-val.mono { font-family: monospace; }
.d-val.accent { color: var(--accent); }

.d-link {
  display: block; color: var(--accent); font-size: 13px;
  text-decoration: none; padding: 10px 12px;
  background: var(--surface2); border-radius: 8px;
  text-align: center; margin-top: 8px;
}
.d-link:hover { background: var(--accent-d); }

/* ── Leaflet popup dark ── */
.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 20px #0008 !important;
}
.leaflet-popup-tip { background: var(--surface) !important; }
.leaflet-popup-content { margin: 12px 16px !important; }

.popup-qra { font-family: monospace; font-weight: 700; font-size: 16px; }
.popup-sub { color: var(--muted); font-size: 12px; margin: 2px 0 6px; }
.popup-freq { color: var(--accent); font-family: monospace; font-size: 12px; }
.popup-btn {
  display: block; margin-top: 8px; padding: 6px 12px;
  background: var(--accent-d); color: var(--accent);
  border: none; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 600; width: 100%;
}
.popup-btn:hover { background: var(--accent); color: #000; }

/* ── Responsive ── */
@media (max-width: 640px) {
  #sidebar { width: 100%; min-width: 100%; position: absolute; z-index: 20; top: 0; bottom: 50%; }
  #map-container { position: absolute; top: 50%; left: 0; right: 0; bottom: 0; }
  #detail-panel { width: 100%; }
}
