/* ===== Reset / base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: #f4f6fa;
  color: #1a1a2e;
  min-height: 100vh;
  overflow-x: hidden;            /* brak poziomego przewijania na wąskich ekranach */
  -webkit-text-size-adjust: 100%;
}

/* ===== Header ===== */
header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: #1a1a2e;
  color: #fff;
  flex-wrap: wrap;
}

h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

h1 small {
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.7;
  margin-left: 0.4rem;
}

/* ===== Conditions bar ===== */
.cond {
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
  background: rgba(255,255,255,0.12);
  border-radius: 4px;
  letter-spacing: 0.04em;
  color: #e0e8ff;
}

/* ===== Workability label colours (shared with spot cards) ===== */
.Excellent { background: #b7f5b7; color: #1a4d1a; }
.Good      { background: #d9f5b7; color: #2a4a10; }
.Fair      { background: #fff2b2; color: #5a4a00; }
.Poor      { background: #f5c6c6; color: #5a1a1a; }

/* ===== Filter bar ===== */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: #fff;
  border-bottom: 1px solid #dde1ea;
}

.filters label {
  font-size: 0.78rem;
  color: #555;
  white-space: nowrap;
}

.filters select,
.filters input[type="checkbox"] {
  font-size: 0.78rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid #c0c8d8;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.filters select:focus {
  outline: 2px solid #4a90d9;
  outline-offset: 1px;
}

.filter-sep {
  width: 1px;
  height: 1.4rem;
  background: #dde1ea;
  flex-shrink: 0;
}

/* Program buttons */
.prog-btn {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid #c0c8d8;
  border-radius: 4px;
  background: #f4f6fa;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.prog-btn.active,
.prog-btn:hover {
  background: #1a1a2e;
  color: #fff;
  border-color: #1a1a2e;
}

/* Band toggles */
.band-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.band-btn {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid #c0c8d8;
  border-radius: 3px;
  background: #f4f6fa;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}

.band-btn.active {
  background: #4a90d9;
  color: #fff;
  border-color: #2a70b9;
}

.band-btn:hover:not(.active) {
  background: #e0e8f8;
  border-color: #4a90d9;
}

/* ===== Layout ===== */
main {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 1rem;
  align-items: flex-start;
}

/* ===== Feed ===== */
.feed {
  flex: 1;
  overflow-y: auto;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.feed > p {
  padding: 2rem;
  text-align: center;
  color: #888;
  font-size: 0.9rem;
}

/* ===== Spot cards ===== */
.card {
  border: 1px solid #dde1ea;
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
  background: #fff;
  border-left: 4px solid transparent;
}

.card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  transform: translateX(2px);
}

.card.Excellent { border-left-color: #3aad3a; }
.card.Good      { border-left-color: #7ab83a; }
.card.Fair      { border-left-color: #d4b800; }
.card.Poor      { border-left-color: #d45555; }

.card .call {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #1a1a2e;
}

.card .ref {
  font-size: 0.78rem;
  color: #4a4a6a;
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card .qrg {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1a3a6e;
  margin-top: 0.25rem;
  letter-spacing: 0.03em;
}

.card .badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.age {
  font-size: 0.72rem;
  color: #888;
  margin-left: auto;
}

.card .score {
  font-size: 0.7rem;
  color: #666;
  margin-top: 0.2rem;
  font-style: italic;
}

/* ===== Pills ===== */
.pill {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  text-transform: uppercase;
}

.pill.pl  { background: #d0e8ff; color: #1a4a80; }
.pill.s2s { background: #ffe0b0; color: #7a3a00; }
.pill.p2p { background: #e0d0ff; color: #4a1a80; }
.pill.tf  { background: #d0ffd8; color: #1a6a30; }

/* ===== Map aside ===== */
#map {
  width: 40%;
  min-height: 70vh;
  border-radius: 6px;
  border: 1px solid #dde1ea;
  background: #e8ecf4;
  overflow: hidden;
  flex-shrink: 0;
}

/* ===== Drawer (reference panel) ===== */
.drawer {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 360px;
  max-width: 100%;
  background: #fff;
  border: 1px solid #dde1ea;
  border-radius: 8px 8px 0 0;
  padding: 1rem;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
  z-index: 1000;
}

.drawer h2 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: #1a1a2e;
}

.drawer p {
  font-size: 0.82rem;
  color: #333;
  margin-top: 0.35rem;
  line-height: 1.4;
}

.drawer a {
  color: #2a70d9;
  text-decoration: none;
}

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

.drawer button {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-size: 1.1rem;
  line-height: 1;
  border: none;
  background: #f4f6fa;
  border-radius: 50%;
  width: 1.8rem;
  height: 1.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
}

.drawer button:hover {
  background: #e0e8f8;
}

/* ===== Top bar (back link + language switcher) ===== */
.topbar {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back {
  color: #cdd6f4;
  text-decoration: none;
  font-size: 0.8rem;
}

.back:hover { text-decoration: underline; }

/* ===== "OTWARTE TERAZ" matrix ===== */
.open {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.open-h {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: #cdd6f4;
}

.open-chip {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

.open-chip.o { background: #b7f5b7; color: #14401a; }  /* open */
.open-chip.m { background: #fff2b2; color: #5a4a00; }  /* marginal */
.open-chip.c { background: #f5c6c6; color: #5a1a1a; }  /* closed/poor */
.open-chip.u { background: #dfe3ec; color: #555; }     /* unknown */

/* ===== Feed + alerts column ===== */
.col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ===== Planned activations (alerts) ===== */
.alerts {
  background: #fff;
  border: 1px solid #dde1ea;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  max-height: 30vh;
  overflow-y: auto;
}

.alerts-h {
  font-size: 0.82rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 0.3rem;
}

.alert {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.76rem;
  padding: 0.18rem 0;
  border-top: 1px solid #eef0f5;
}

.alert .a-when { color: #666; font-variant-numeric: tabular-nums; }
.alert .a-call { font-weight: 700; color: #1a1a2e; }
.alert .a-ref  { color: #4a4a6a; }
.alert .a-freq { margin-left: auto; color: #1a3a6e; font-weight: 600; }

.muted { color: #888; font-size: 0.8rem; }

/* ===== Responsive ===== */
@media (max-width: 800px) {
  main {
    flex-direction: column;
    padding: 0.5rem 0.6rem;
    gap: 0.6rem;
  }

  .col { order: 1; }              /* lista spotów najpierw */
  #map {
    order: 2;                     /* mapa pod listą */
    width: 100%;
    min-height: unset;
    height: 42vh;
  }

  .feed { max-height: 58vh; }     /* lista przewija się wewnętrznie, mapa pozostaje dostępna */
  .alerts { max-height: 24vh; }

  .drawer {
    left: 0;
    right: 0;
    width: 100%;
    max-height: 78vh;
    overflow-y: auto;
    border-radius: 12px 12px 0 0;
    padding: 1rem 1rem 1.5rem;
  }
}

@media (max-width: 600px) {
  body { font-size: 15px; }                          /* czytelniej na telefonie */
  header { padding: 0.5rem 0.7rem; gap: 0.45rem; }
  h1 { font-size: 1.05rem; }
  h1 small { display: block; margin: 0.1rem 0 0; }

  .filters { padding: 0.5rem 0.6rem; gap: 0.35rem 0.5rem; }
  .filter-sep { display: none; }                     /* mniej szumu przy zawijaniu */
  .filters label { font-size: 0.82rem; }

  /* dotykowe kontrolki (cel >=34-38px) */
  .filters select { font-size: 0.85rem; padding: 0.4rem 0.5rem; min-height: 38px; }
  .prog-btn { font-size: 0.85rem; padding: 0.4rem 0.7rem; min-height: 38px; }

  /* pasma jako przewijany poziomo pasek — oszczędza pionu, nie zawija na 3 rzędy */
  .band-toggles {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.3rem;
    padding-bottom: 3px;
    scrollbar-width: thin;
  }
  .band-btn { flex: 0 0 auto; font-size: 0.8rem; padding: 0.35rem 0.6rem; min-height: 34px; }

  /* karty: większy obszar dotyku i czytelność, pełna nazwa referencji */
  .card { padding: 0.7rem 0.85rem; }
  .card .call { font-size: 1.15rem; }
  .card .qrg { font-size: 0.95rem; }
  .card .ref { white-space: normal; }

  .cond, .open { font-size: 0.74rem; }
  .alert { font-size: 0.82rem; }

  .drawer button { width: 2.2rem; height: 2.2rem; font-size: 1.3rem; top: 0.8rem; right: 0.8rem; }
  .drawer p { font-size: 0.9rem; }
}
