/* Shared styles for slide-in overlay panels (leaderboard, units, market,
 * alliance, etc). Each panel docks to the right side of the viewport. */

.v2-overlay-panel {
  position: absolute;
  top: 60px;
  right: -380px;
  width: 360px;
  /* Stop above the bottom-right minimap so panels never cover it; opaque and
   * above the queue panel (z-index) so an open panel cleanly hides the queue
   * instead of the two bleeding into an unreadable mash. */
  max-height: calc(100vh - 280px);
  background: rgba(13, 17, 23, 0.98);
  border: 1px solid var(--neon-muted);
  font-family: var(--font-body);
  color: var(--ink);
  font-size: 12px;
  transition: right 220ms ease-out;
  display: flex;
  flex-direction: column;
  /* Vertical scroll only; clamp horizontal so wide content widens nothing and
     never shows a horizontal scrollbar. */
  overflow: hidden auto;
  z-index: 12;
}
.v2-overlay-panel.open {
  right: 16px;
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--neon-muted);
}
.overlay-title {
  color: var(--neon-primary);
  font-family: var(--font-heading);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-size: 12px;
}
.overlay-close {
  background: transparent;
  border: none;
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.overlay-close:hover { color: var(--neon-primary); }

.overlay-tabs {
  display: flex;
  border-bottom: 1px solid var(--neon-muted);
}
.overlay-tab {
  flex: 1;
  /* Let tabs shrink below their text width so a full row (e.g. the market's 5
     view tabs) always fits the panel instead of clipping the last one. */
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  padding: 8px 4px;
  font-family: var(--font-body);
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  border-right: 1px solid var(--neon-muted);
  /* Keep a label on one line; if a row is too tight, ellipsize that tab rather
     than letting its text spill over (or push the last tab off-screen). */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.overlay-tab:last-child { border-right: none; }
.overlay-tab.active {
  color: var(--neon-primary);
  background: rgba(0, 212, 255, 0.05);
}
.overlay-tab:hover { color: var(--ink); }

.overlay-body {
  overflow-y: auto;
  flex: 1;
}
.overlay-empty {
  padding: 20px;
  color: var(--ink-muted);
  text-align: center;
  font-style: italic;
}
.overlay-section { padding: 4px 0; }
.overlay-section-title {
  padding: 6px 12px;
  color: var(--neon-primary);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 1px;
  background: rgba(0, 212, 255, 0.04);
}
.overlay-section-title i {
  color: var(--ink-muted);
  font-style: normal;
}
.overlay-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.overlay-row:hover { background: rgba(0, 212, 255, 0.05); }
.ovr-rank {
  color: var(--neon-primary);
  font-weight: 600;
  width: 50px;
}
.ovr-name {
  flex: 1;
  color: var(--ink);
}
.ovr-score, .ovr-loc {
  color: var(--ink-muted);
  font-size: 11px;
}
.ovr-score { color: var(--success); }

.alliance-chat {
  padding: 8px 12px;
  max-height: 200px;
  overflow-y: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.chat-line {
  padding: 3px 0;
  font-size: 11px;
}
.chat-line b { color: var(--neon-primary); margin-right: 4px; }
.alliance-input {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.alliance-input input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--neon-muted);
  color: var(--ink);
  padding: 4px 8px;
  font-family: var(--font-body);
  font-size: 11px;
}

.market-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px 12px;
}
.market-form input {
  background: var(--bg-primary);
  border: 1px solid var(--neon-muted);
  color: var(--ink);
  padding: 4px 8px;
  font-family: var(--font-body);
  font-size: 11px;
}
.market-form button { width: 100%; }

.ovr-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--neon-primary);
}
.ovr-toggle input { accent-color: var(--neon-primary); }

/* Settings panel: key caps, day/night slider, pinned-tier highlight. */
.ovr-kbd {
  font-family: var(--font-heading);
  font-size: 11px;
  color: var(--neon-primary);
  border: 1px solid var(--neon-muted);
  border-radius: var(--border-radius-sm);
  padding: 1px 6px;
  background: var(--bg-primary);
}
.ovr-range {
  width: 140px;
  accent-color: var(--neon-primary);
}
.ctx-btn.is-active {
  border-color: var(--neon-primary);
  color: var(--neon-primary);
  background: var(--neon-tint);
}

/* Phones: docked overlays (units, market, leaderboard, alliance, …) fill almost
   the full width instead of a fixed 360px that crowds the screen, and slide in
   from the right edge as before. Taller too, since the minimap is hidden here. */
@media (max-width: 640px) {
  .v2-overlay-panel {
    top: calc(60px + env(safe-area-inset-top, 0px));
    width: min(360px, calc(100vw - 16px));
    right: -100vw;            /* fully off-screen when closed */
    max-height: calc(100dvh - 76px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
  .v2-overlay-panel.open { right: 8px; }

  /* Narrow phones: drop the letter-spacing so a 5-tab row (the market views)
     stays fully readable instead of ellipsizing. */
  .overlay-tab {
    padding: 8px 2px;
    letter-spacing: 0;
  }
}

/* Keep the market's order form (qty/price + Buy/Sell) pinned to the bottom of
   the panel so it's reachable without scrolling past the order book, which can
   push it below the fold on short screens. */
.market-place-order {
  position: sticky;
  bottom: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--neon-muted);
}
