/* ═══════════════════════════════════════════════════════════════════════
   HFSignals.live — "Who Is Louder?" Embeddable Widget  (self-contained)
   Drop-in CSS for whoislouder.js.  All selectors are prefixed with
   .wil-* so they won't collide with host-page styles.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Root container — CSS Grid: title spans both cols, left + right ── */
.wil-root {
  --wil-bg: #0d0d1a;
  --wil-bg2: #1a1a2e;
  --wil-border: rgba(0, 212, 170, 0.32);
  --wil-text: #c8d0e8;
  --wil-dim: #8fa0bf;
  --wil-accent: #00d4aa;
  --wil-input: #10162a;
  --wil-focus: rgba(0, 212, 170, 0.4);
  --wil-dimmed-seg: #1c1c32;
  --wil-err: #ff6060;
  font-family: 'Share Tech Mono', monospace;
  color: var(--wil-text);
  background: linear-gradient(180deg, var(--wil-bg2), var(--wil-bg));
  border: 1px solid var(--wil-border);
  border-radius: 8px;
  padding: 14px;
  max-width: 520px;
  box-sizing: border-box;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2), 0 8px 24px rgba(0,0,0,0.35);
  line-height: 1.4;
  display: grid;
  grid-template-columns: 45% 55%;
  grid-template-rows: auto 1fr;
  gap: 0 10px;
}

/* ── Light theme ── */
.wil-root[data-theme="light"] {
  --wil-bg: #f4f7fb;
  --wil-bg2: #ffffff;
  --wil-border: rgba(0, 136, 106, 0.28);
  --wil-text: #1a1a2e;
  --wil-dim: #5f6f8c;
  --wil-accent: #00886a;
  --wil-input: #eef3f8;
  --wil-focus: rgba(0, 136, 106, 0.25);
  --wil-dimmed-seg: #e2e8f0;
  --wil-err: #cc3030;
}

/* ── Colorblind theme ── */
.wil-root[data-theme="cb"] {
  --wil-bg: #0f1222;
  --wil-bg2: #151a31;
  --wil-border: rgba(79, 215, 255, 0.36);
  --wil-text: #e8f3ff;
  --wil-dim: #9fb0c9;
  --wil-accent: #4fd7ff;
  --wil-input: #121938;
  --wil-focus: rgba(79, 215, 255, 0.30);
  --wil-dimmed-seg: #1a2040;
  --wil-err: #ff8080;
}

/* ── Title row — flex row, title left, brand right ── */
.wil-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--wil-accent);
  font-weight: 700;
  margin-bottom: 10px;
}

.wil-brand {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wil-logo-link {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.wil-logo-link img {
  width: 24px;
  height: 24px;
  object-fit: cover;
  display: block;
}

.wil-site-link {
  font-size: 9px;
  color: var(--wil-dim);
  text-decoration: none;
}

.wil-site-link:hover {
  color: var(--wil-accent);
  text-decoration: underline;
}

/* ── Left column — controls stacked vertically ── */
.wil-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

/* ── Right column — 6 S-meter slots ── */
.wil-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  justify-content: center;
}

/* ── Shared input / select / button styles ── */
.wil-label {
  font-size: 10px;
  color: var(--wil-dim);
  margin-bottom: 2px;
  display: block;
}

.wil-input,
.wil-select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--wil-border);
  background: var(--wil-input);
  color: var(--wil-text);
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 10px;
  font-family: 'Share Tech Mono', monospace;
  box-sizing: border-box;
}

.wil-input:focus,
.wil-select:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--wil-focus);
}

.wil-btn {
  border: 1px solid var(--wil-border);
  background: var(--wil-input);
  color: var(--wil-accent);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 10px;
  font-family: 'Share Tech Mono', monospace;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, color 0.15s;
}

.wil-btn:hover {
  background: var(--wil-accent);
  color: #001a14;
}

/* ── Error text ── */
.wil-error {
  font-size: 9px;
  color: var(--wil-err);
  min-height: 14px;
  line-height: 1.3;
}

/* ── Callsign list (radio buttons) ── */
.wil-call-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 110px;
  overflow-y: auto;
}

.wil-call-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--wil-text);
  cursor: pointer;
}

.wil-call-item input[type="radio"] {
  accent-color: var(--wil-accent);
  width: 12px;
  height: 12px;
  cursor: pointer;
  margin: 0;
}

/* ── Listen From dropdown ── */
.wil-listen-wrap {
  position: relative;
}

.wil-listen-btn {
  width: 100%;
  text-align: left;
}

.wil-listen-drop {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--wil-input);
  border: 1px solid var(--wil-border);
  border-radius: 5px;
  padding: 6px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  max-height: 360px;
  overflow-y: auto;
}

.wil-listen-drop.open {
  display: block;
}

.wil-listen-hdr {
  font-size: 9px;
  color: var(--wil-accent);
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 4px 0 2px;
}

.wil-listen-hdr:first-child {
  margin-top: 0;
}

.wil-listen-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 1px 2px;
  font-size: 10px;
  color: var(--wil-text);
  cursor: pointer;
}

.wil-listen-item input[type="checkbox"] {
  accent-color: var(--wil-accent);
  width: 12px;
  height: 12px;
  cursor: pointer;
  margin: 0;
}

.wil-listen-item.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.wil-listen-item .wil-skim-detail {
  font-size: 8px;
  color: var(--wil-dim);
}

/* ── Bottom brand (left column footer) ── */
.wil-bottom-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
}

/* ── Callsigns to Compare box ── */
.wil-callbox {
  border: 1px solid var(--wil-border);
  border-radius: 5px;
  padding: 6px 8px;
}

.wil-callbox-title {
  font-size: 9px;
  color: var(--wil-accent);
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

/* ── S-meter slot ── */
.wil-slot {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 22px;
}

.wil-slot.inactive .wil-slot-call {
  visibility: hidden;
}

.wil-slot-call {
  font-size: 12px;
  color: var(--wil-text);
  width: 64px;
  min-width: 64px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.wil-slot-bar {
  display: flex;
  gap: 1px;
  flex: 1;
  height: 18px;
  align-items: stretch;
  border: 1px solid var(--wil-border);
  border-radius: 2px;
  padding: 2px;
  background: var(--wil-bg);
}

.wil-seg {
  flex: 1;
  border-radius: 1px;
  min-width: 3px;
  background: var(--wil-dimmed-seg);
  transition: background 0.3s ease;
}

.wil-slot-db {
  font-size: 9px;
  color: var(--wil-dim);
  width: 38px;
  min-width: 38px;
  text-align: left;
  white-space: nowrap;
}

/* ── Scrollbar styling ── */
.wil-listen-drop::-webkit-scrollbar,
.wil-call-list::-webkit-scrollbar {
  width: 4px;
}

.wil-listen-drop::-webkit-scrollbar-track,
.wil-call-list::-webkit-scrollbar-track {
  background: transparent;
}

.wil-listen-drop::-webkit-scrollbar-thumb,
.wil-call-list::-webkit-scrollbar-thumb {
  background: var(--wil-border);
  border-radius: 2px;
}


/* ── Mobile responsive — stack columns vertically ────────────────── */
@media (max-width: 520px) {
  .wil-root {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    max-width: 100%;
    padding: 10px;
  }

  .wil-right {
    margin-top: 10px;
  }

  .wil-slot-call {
    width: 48px;
    min-width: 48px;
    font-size: 8px;
  }

  .wil-slot-db {
    width: 32px;
    min-width: 32px;
    font-size: 8px;
  }

  .wil-title {
    font-size: 11px;
  }
}

/* ── Best SNR label + tooltip ─────────────────────────────────────── */
.wil-best-label {
  text-align: center;
  font-size: 11px;
  font-weight: bold;
  color: var(--wil-accent);
  margin-bottom: 6px;
  cursor: help;
  position: relative;
}

.wil-best-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  background: var(--wil-bg2);
  border: 1px solid var(--wil-border);
  border-radius: 6px;
  padding: 10px;
  font-size: 10px;
  font-weight: normal;
  color: var(--wil-text);
  line-height: 1.5;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  text-align: left;
}

.wil-best-label:hover .wil-best-tooltip {
  display: block;
}

.wil-tooltip-img {
  display: block;
  margin: 8px auto 0;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}


/* ── Listen From toggle + buttons ─────────────────────────────────── */
.wil-listen-togglerow {
  display: flex;
  gap: 4px;
  margin: 2px 6px 4px;
}
.wil-listen-togbtn {
  flex: 1;
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  padding: 3px 4px;
  background: var(--wil-bg2);
  color: var(--wil-dim);
  border: 1px solid var(--wil-border);
  border-radius: 3px;
  cursor: pointer;
}
.wil-listen-togbtn.active {
  background: var(--wil-border);
  color: #fff;
}
.wil-listen-togbtn:hover {
  color: #fff;
}

/* ── Select All / Select None buttons ─────────────────────────────── */
.wil-listen-btnrow {
  display: flex;
  gap: 4px;
  margin: 2px 6px 4px;
}
.wil-listen-selbtn {
  flex: 1;
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  padding: 2px 4px;
  background: var(--wil-bg2);
  color: var(--wil-accent);
  border: 1px solid var(--wil-border);
  border-radius: 3px;
  cursor: pointer;
}
.wil-listen-selbtn:hover {
  background: var(--wil-border);
  color: #fff;
}

.wil-listen-list {
  max-height: 280px;
  overflow-y: auto;
}
