/* ═══════════════════════════════════════════════════════════════════════════
   SimTech Comms — Mobile-first responsive voice chat UI
   Brand: #f38500 (orange), #002c84 (navy), dark backgrounds
   Fonts: Barlow Condensed (headings/UI), Barlow (body)
   Breakpoints: 480 (sm), 768 (md), 1024 (lg)
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@300;400;500;600;700&family=Barlow:wght@300;400;500&display=swap');

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

/* ─── Design Tokens ──────────────────────────────────────────────────────── */

:root {
  --orange:       #f38500;
  --orange-dim:   #b36000;
  --navy:         #002c84;
  --bg-base:      #0d0d0f;
  --bg-surface:   #16161a;
  --bg-elevated:  #1e1e24;
  --bg-hover:     #26262e;
  --border:       rgba(255,255,255,0.08);
  --text-primary: #f0f0f2;
  --text-muted:   #8a8a9a;
  --text-faint:   #4a4a5a;
  --green:        #22c55e;
  --red:          #ef4444;
  --radius-sm:    4px;
  --radius-md:    8px;
  --radius-lg:    12px;
  /* Touch-friendly minimum */
  --touch-min:    44px;
  /* Safe area for notched devices */
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Barlow', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

/* ═══ LAYOUT ═════════════════════════════════════════════════════════════ */

.comms-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height — accounts for mobile browser chrome */
}

.comms-body {
  display: flex;
  flex-direction: column; /* mobile: stack sidebar on top */
  flex: 1;
  overflow: hidden;
}

@media (min-width: 768px) {
  .comms-body { flex-direction: row; } /* tablet+: sidebar on left */
}

/* ═══ HEADER ═════════════════════════════════════════════════════════════ */

.comms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 48px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}

@media (min-width: 768px) {
  .comms-header { padding: 0 20px; height: 52px; }
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0; /* allow shrink */
}

.brand-logo {
  height: 22px;
  width: auto;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .brand-logo { height: 28px; }
}

.brand-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}

.brand-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.brand-accent { color: var(--orange); }

@media (min-width: 480px) {
  .brand-label { font-size: 16px; }
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .header-meta { gap: 16px; font-size: 12px; }
}

.powered-by {
  opacity: 0.5;
  display: none;
}

@media (min-width: 768px) {
  .powered-by { display: inline; }
}

/* Connection status */
.connection-status { white-space: nowrap; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  display: inline-block;
  margin-right: 4px;
  vertical-align: middle;
}

.status-dot.connected  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.disconnected { background: var(--red); }
.status-dot.connecting { background: var(--orange); animation: pulse-dot 1s ease-in-out infinite; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ═══ BUTTONS ════════════════════════════════════════════════════════════ */

.btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  font-size: 16px;
  line-height: 1;
}

.btn-icon--touch {
  min-width: var(--touch-min);
  min-height: var(--touch-min);
}

.btn-icon:hover { background: var(--bg-hover); color: var(--orange); }

.btn-primary {
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 12px 24px;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
  min-height: var(--touch-min);
}

.btn-primary:hover { background: #d97700; }
.btn-primary:disabled { background: var(--bg-hover); color: var(--text-faint); cursor: not-allowed; }
.btn-primary--auto { width: auto; }

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: var(--touch-min);
}

.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--text-muted); }
.btn-secondary--sm { font-size: 11px; padding: 6px 12px; min-height: 32px; }
.btn-secondary--icon { font-size: 18px; padding: 8px 14px; }

.btn-leave {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  border-radius: var(--radius-md);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s;
  min-height: var(--touch-min);
}

.btn-leave:hover { background: rgba(239, 68, 68, 0.22); }

.btn-mute {
  width: var(--touch-min);
  height: var(--touch-min);
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.btn-mute:hover { background: var(--bg-hover); }
.btn-mute.muted { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.btn-mute.ptt-active { border-color: var(--orange); background: rgba(243,133,0,0.15); color: var(--orange); box-shadow: 0 0 8px rgba(243,133,0,0.3); }

/* Focus styles */
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-leave:focus-visible,
.btn-mute:focus-visible,
.btn-icon:focus-visible,
.channel-item:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

/* ═══ FORM ELEMENTS ══════════════════════════════════════════════════════ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: 'Barlow Condensed', sans-serif;
}

.form-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Barlow', sans-serif;
  font-size: 16px; /* prevents iOS zoom on focus */
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  min-height: var(--touch-min);
}

.form-input:focus { border-color: var(--orange); }
.form-input::placeholder { color: var(--text-faint); }

.form-input--code {
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
}

.form-hint { font-size: 11px; color: var(--text-faint); }

.error-msg {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 12px;
  padding: 8px 12px;
}

/* ═══ JOIN SCREEN ════════════════════════════════════════════════════════ */

.join-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

@media (min-width: 480px) {
  .join-screen { padding: 40px; }
}

.join-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

@media (min-width: 480px) {
  .join-card { padding: 36px; gap: 20px; }
}

.join-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.join-logo {
  height: 32px;
  width: auto;
  filter: brightness(0) invert(1); /* render white on dark bg */
}

.join-card-header h2 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.join-card-header h2 span { color: var(--orange); }

.join-actions {
  display: flex;
  gap: 8px;
}

.join-actions .btn-primary { flex: 1; }

.join-toggles {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

/* ═══ SIDEBAR ════════════════════════════════════════════════════════════ */

.sidebar {
  width: 100%;
  max-height: 40vh; /* mobile: sidebar scrolls in limited space */
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .sidebar {
    width: 240px;
    min-width: 240px;
    max-height: none;
    border-bottom: none;
    border-right: 1px solid var(--border);
  }
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 6px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 1;
}

@media (min-width: 768px) {
  .sidebar-section-header { padding: 14px 16px 8px; }
}

/* ─── Channel list ───────────────────────────────────────────────────────── */

.channel-list {
  padding: 0 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

@media (min-width: 768px) {
  .channel-list { padding: 0 8px 8px; }
}

.channel-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  gap: 8px;
  user-select: none;
  min-height: var(--touch-min);
}

.channel-item:hover { background: var(--bg-hover); }
.channel-item.active { background: rgba(243,133,0,0.15); }

.channel-icon { font-size: 16px; opacity: 0.6; flex-shrink: 0; }
.channel-item.active .channel-icon { opacity: 1; color: var(--orange); }

.channel-info { flex: 1; min-width: 0; }

.channel-name {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-item.active .channel-name { color: var(--orange); }

.channel-count { font-size: 11px; color: var(--text-muted); }
.channel-count.has-users { color: var(--green); }

/* ─── Expandable user list under channels ────────────────────────────────── */

.channel-users {
  padding: 0 0 4px 28px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.channel-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
  position: relative;
  min-height: 32px;
}

.channel-user:hover { background: var(--bg-hover); }

.channel-user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.channel-user.speaking .channel-user-avatar {
  outline: 2px solid var(--green);
  outline-offset: 1px;
  color: var(--green);
}

.channel-user-name {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.channel-user.speaking .channel-user-name { color: var(--text-primary); }
.channel-user.is-self .channel-user-name { color: var(--orange); }

.channel-user-badges {
  display: flex;
  gap: 3px;
  align-items: center;
  flex-shrink: 0;
}

.cu-badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.2;
}

.cu-badge.staff { background: rgba(243,133,0,0.15); color: var(--orange); }
.cu-badge.muted-badge { background: rgba(239,68,68,0.1); color: #fca5a5; }

.cu-icon { font-size: 11px; flex-shrink: 0; opacity: 0.5; }
.cu-icon.muted { color: var(--red); opacity: 0.8; }

/* Signal bars */
.signal-bars { display: flex; gap: 1px; align-items: flex-end; height: 10px; flex-shrink: 0; }
.signal-bar { width: 3px; border-radius: 1px; background: var(--text-faint); transition: background 0.3s; }
.signal-bar:nth-child(1) { height: 3px; }
.signal-bar:nth-child(2) { height: 5px; }
.signal-bar:nth-child(3) { height: 7px; }
.signal-bar:nth-child(4) { height: 10px; }
.signal-good .signal-bar { background: var(--green); }
.signal-fair .signal-bar:nth-child(1),
.signal-fair .signal-bar:nth-child(2),
.signal-fair .signal-bar:nth-child(3) { background: #eab308; }
.signal-poor .signal-bar:nth-child(1),
.signal-poor .signal-bar:nth-child(2) { background: var(--red); }

/* Staff hover actions */
.staff-actions {
  display: none;
  gap: 2px;
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  z-index: 2;
}

.channel-user:hover .staff-actions { display: flex; }
.channel-user:hover .channel-user-badges { visibility: hidden; }

.staff-action-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 3px;
  color: var(--text-muted);
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background 0.12s, color 0.12s;
  min-height: 28px;
}

.staff-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.staff-action-btn.danger:hover { background: rgba(239,68,68,0.15); color: #fca5a5; }

/* ═══ CHANNEL VIEW ═══════════════════════════════════════════════════════ */

.channel-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0; /* allow flex shrink in column layout */
}

.channel-view-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 8px;
}

@media (min-width: 768px) {
  .channel-view-header { padding: 14px 24px; }
}

.channel-view-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.channel-view-title h2 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

@media (min-width: 768px) {
  .channel-view-title h2 { font-size: 20px; }
}

.user-count-badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  color: var(--text-muted);
  padding: 2px 10px;
  letter-spacing: 0.05em;
}

.channel-view-actions { display: flex; gap: 8px; }

.active-channel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* No channel state */
.no-channel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  gap: 12px;
  padding: 20px;
}

.no-channel-icon { font-size: 40px; opacity: 0.4; }
.no-channel p {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
}

@media (min-width: 768px) {
  .no-channel-icon { font-size: 48px; }
  .no-channel p { font-size: 16px; }
}

/* ═══ PEER GRID ══════════════════════════════════════════════════════════ */

.peer-grid {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  align-content: flex-start;
}

@media (min-width: 480px) {
  .peer-grid { padding: 16px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}

@media (min-width: 1024px) {
  .peer-grid { padding: 24px; }
}

.peer-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color 0.2s;
}

.peer-card.speaking { border-color: var(--green); box-shadow: 0 0 0 1px rgba(34,197,94,0.3); }
.peer-card.muted { opacity: 0.6; }

.peer-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--orange);
  position: relative;
  flex-shrink: 0;
}

@media (min-width: 480px) {
  .peer-avatar { width: 48px; height: 48px; font-size: 20px; }
}

.speaking-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--green);
  opacity: 0;
  transition: opacity 0.2s;
}

.peer-card.speaking .speaking-ring { opacity: 1; animation: speaking-pulse 0.8s ease-in-out infinite; }

@keyframes speaking-pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.08); opacity: 1; }
}

.peer-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 480px) {
  .peer-name { font-size: 14px; }
}

.peer-status-row { display: flex; gap: 6px; align-items: center; }

.peer-badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.peer-badge.staff { background: rgba(243,133,0,0.15); color: var(--orange); border: 1px solid rgba(243,133,0,0.3); }
.peer-badge.muted { background: rgba(239,68,68,0.1); color: #fca5a5; border: 1px solid rgba(239,68,68,0.25); }

/* Staff badge (channel header) */
.staff-badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 8px;
  background: rgba(243,133,0,0.15);
  color: var(--orange);
  border: 1px solid rgba(243,133,0,0.3);
  border-radius: 20px;
}

/* ═══ CONTROLS BAR ═══════════════════════════════════════════════════════ */

.controls-bar {
  padding: 10px 12px;
  padding-bottom: calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .controls-bar { padding: 14px 24px; gap: 16px; }
}

.self-card {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.self-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(243,133,0,0.15);
  border: 1px solid rgba(243,133,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--orange);
  flex-shrink: 0;
}

@media (min-width: 480px) {
  .self-avatar { width: 36px; height: 36px; font-size: 16px; }
}

.self-info { min-width: 0; }
.self-name { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.self-channel { font-size: 11px; color: var(--text-muted); font-family: 'Barlow Condensed', sans-serif; letter-spacing: 0.04em; }

@media (min-width: 480px) {
  .self-name { font-size: 14px; }
}

.controls-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .controls-actions { gap: 12px; }
}

.volume-group {
  display: none; /* hidden on mobile — save space */
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 16px;
}

@media (min-width: 768px) {
  .volume-group { display: flex; }
}

.volume-slider {
  -webkit-appearance: none;
  width: 80px;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-elevated);
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--orange);
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--orange);
  cursor: pointer;
  border: none;
}

/* PTT label */
.ptt-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: all 0.15s;
  white-space: nowrap;
  display: none; /* hidden by default, shown via JS */
}

.ptt-label.transmitting { color: var(--orange); background: rgba(243,133,0,0.1); border-color: rgba(243,133,0,0.4); }

/* ═══ MODALS ═════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  padding: 16px;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 90vh;
  overflow-y: auto;
}

@media (min-width: 480px) {
  .modal { padding: 28px; gap: 18px; }
}

.modal h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.modal-desc { font-size: 12px; color: var(--text-muted); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Room code display */
.room-code-display {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-align: center;
  color: var(--orange);
}

/* ═══ VOICE MODE + PTT SETTINGS ══════════════════════════════════════════ */

.voice-mode-toggle {
  display: flex;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.mode-btn {
  flex: 1;
  padding: 10px 14px;
  border: none;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  min-height: var(--touch-min);
}

.mode-btn:hover { background: var(--bg-hover); }
.mode-btn.active { background: rgba(243,133,0,0.15); color: var(--orange); }

.ptt-key-capture {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s;
  min-height: var(--touch-min);
}

.ptt-key-capture:hover { border-color: var(--orange); }
.ptt-key-capture.listening { border-color: var(--orange); animation: pulse-border 0.8s ease-in-out infinite; }

@keyframes pulse-border {
  0%, 100% { border-color: var(--orange); }
  50% { border-color: rgba(243,133,0,0.3); }
}

.ptt-key-capture span:first-child {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--orange);
  letter-spacing: 0.05em;
}

.ptt-key-hint {
  font-size: 11px;
  color: var(--text-faint);
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ═══ SCROLLBAR ══════════════════════════════════════════════════════════ */

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ═══ UTILITY ════════════════════════════════════════════════════════════ */

[hidden] { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   INTERCOM UI — Multi-channel talk/listen matrix
   Unity Intercom-style: channel strips with T/L toggles, central PTT
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Intercom Layout ────────────────────────────────────────────────────── */

.intercom-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.intercom-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 768px) {
  .intercom-layout { flex-direction: row; }
}

.intercom-sidebar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  max-height: 30vh;
}

@media (min-width: 768px) {
  .intercom-sidebar {
    width: 220px;
    min-width: 220px;
    max-height: none;
    border-bottom: none;
    border-right: 1px solid var(--border);
  }
}

.intercom-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px;
  gap: 20px;
}

@media (min-width: 768px) {
  .intercom-main { padding: 24px; gap: 28px; }
}

/* ─── Channel Strips Grid ────────────────────────────────────────────────── */

.channel-strips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

@media (min-width: 768px) {
  .channel-strips { gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

.no-channels-msg {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-faint);
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ─── Individual Channel Strip ───────────────────────────────────────────── */

.ch-strip {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
}

.ch-strip.has-activity {
  border-color: rgba(234, 179, 8, 0.3);
  box-shadow: 0 0 0 1px rgba(234, 179, 8, 0.1);
}

/* Channel header row */
.ch-strip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ch-strip-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.ch-strip-abbr {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  padding: 1px 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.ch-strip-count {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* T/L toggle buttons row */
.ch-strip-controls {
  display: flex;
  gap: 6px;
}

.ch-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-faint);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 40px;
  user-select: none;
}

.ch-toggle:hover { background: var(--bg-hover); }

/* Talk active (green) */
.ch-toggle.talk.active {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.5);
  color: var(--green);
}

/* Listen active (blue) */
.ch-toggle.listen.active {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.5);
  color: #3b82f6;
}

/* Activity indicator bar */
.ch-activity-bar {
  height: 3px;
  border-radius: 2px;
  background: var(--bg-elevated);
  overflow: hidden;
}

.ch-activity-fill {
  height: 100%;
  width: 0%;
  background: #eab308;
  border-radius: 2px;
  transition: width 0.15s ease;
}

.ch-strip.has-activity .ch-activity-fill { width: 100%; }

/* Per-channel volume slider */
.ch-volume-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ch-volume-icon {
  font-size: 12px;
  color: var(--text-faint);
}

.ch-volume-slider {
  -webkit-appearance: none;
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--bg-elevated);
  outline: none;
  cursor: pointer;
}

.ch-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s;
}

.ch-volume-slider::-webkit-slider-thumb:hover { background: var(--orange); }

.ch-volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  cursor: pointer;
  border: none;
}

/* ─── Central PTT Section ────────────────────────────────────────────────── */

.ptt-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

.ptt-ring {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

@media (min-width: 768px) {
  .ptt-ring { width: 120px; height: 120px; }
}

.ptt-ring.transmitting {
  border-color: var(--red);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.3), 0 0 40px rgba(239, 68, 68, 0.1);
}

.ptt-ring.latched {
  border-color: var(--orange);
  box-shadow: 0 0 20px rgba(243, 133, 0, 0.3);
  animation: latch-pulse 1.5s ease-in-out infinite;
}

@keyframes latch-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(243, 133, 0, 0.3); }
  50% { box-shadow: 0 0 30px rgba(243, 133, 0, 0.5); }
}

.ptt-button {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

@media (min-width: 768px) {
  .ptt-button { width: 108px; height: 108px; }
}

.ptt-button:hover { background: var(--bg-hover); }

.ptt-button:active,
.ptt-ring.transmitting .ptt-button {
  background: rgba(239, 68, 68, 0.2);
  color: var(--red);
}

.ptt-ring.latched .ptt-button {
  background: rgba(243, 133, 0, 0.2);
  color: var(--orange);
}

.ptt-icon { font-size: 28px; line-height: 1; }
@media (min-width: 768px) { .ptt-icon { font-size: 32px; } }

.ptt-status {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ptt-ring.transmitting .ptt-status { color: var(--red); }
.ptt-ring.latched .ptt-status::after { content: ' (LATCHED)'; }

.ptt-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.ptt-mode-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ptt-key-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

/* ─── User list in sidebar ───────────────────────────────────────────────── */

.user-list {
  padding: 0 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  min-height: 28px;
}

.user-entry-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.user-entry-dot.speaking {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.user-entry-dot.muted { background: var(--red); opacity: 0.6; }

.user-entry-name {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-entry-name.is-self { color: var(--orange); }

.user-entry-badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(243,133,0,0.15);
  color: var(--orange);
  flex-shrink: 0;
}

.user-entry-badge.admin { background: rgba(239,68,68,0.12); color: #fca5a5; }

/* ═══ PHASE 4: PERMISSIONS & ROLES ══════════════════════════════════════ */

/* ─── Priority Call Flash ───────────────────────────────────────────────── */

@keyframes priority-flash {
  0%, 100% { background: var(--bg-surface); }
  25% { background: rgba(239, 68, 68, 0.25); }
  50% { background: rgba(243, 133, 0, 0.2); }
  75% { background: rgba(239, 68, 68, 0.15); }
}

.comms-header.priority-flash {
  animation: priority-flash 0.6s ease-in-out 5;
}

/* ─── Priority Banner ───────────────────────────────────────────────────── */

.priority-banner {
  position: fixed;
  top: 48px;
  left: 0;
  right: 0;
  z-index: 90;
  background: linear-gradient(90deg, rgba(239,68,68,0.9), rgba(243,133,0,0.9));
  color: #fff;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  animation: priority-banner-pulse 1.5s ease-in-out infinite;
}

@keyframes priority-banner-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

.priority-banner-icon { font-size: 18px; }
.priority-banner-label { font-size: 12px; font-weight: 500; opacity: 0.9; letter-spacing: 0.04em; }

@media (min-width: 768px) {
  .priority-banner { top: 52px; font-size: 15px; padding: 12px 20px; }
}

/* ─── Priority Call Button (admin) ──────────────────────────────────────── */

.btn-priority {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 32px;
  white-space: nowrap;
}

.btn-priority:hover { background: rgba(239, 68, 68, 0.2); border-color: rgba(239, 68, 68, 0.5); }

.btn-priority.active {
  background: rgba(239, 68, 68, 0.3);
  border-color: var(--red);
  color: #fff;
  animation: priority-btn-pulse 1s ease-in-out infinite;
}

@keyframes priority-btn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* ─── Channel Lock ──────────────────────────────────────────────────────── */

.ch-strip.locked {
  border-color: rgba(234, 179, 8, 0.2);
}

.ch-strip.locked .ch-strip-name::after {
  content: '\uD83D\uDD12';
  margin-left: 6px;
  font-size: 10px;
  opacity: 0.5;
}

.ch-toggle:disabled,
.ch-toggle[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.lock-toggle {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 3px;
  color: var(--text-faint);
  transition: color 0.15s;
  line-height: 1;
}

.lock-toggle:hover { color: var(--orange); }
.lock-toggle.locked { color: #eab308; }

/* ─── Permission Pills (staff sidebar) ──────────────────────────────────── */

.perm-row {
  display: flex;
  gap: 3px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.perm-pill {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-faint);
  cursor: pointer;
  transition: all 0.12s;
  line-height: 1.2;
}

.perm-pill:hover { border-color: var(--text-muted); }

.perm-pill.talk.active {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--green);
}

.perm-pill.listen.active {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.4);
  color: #3b82f6;
}

/* ─── Role Badge Variants ───────────────────────────────────────────────── */

.role-badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 4px;
  border-radius: 3px;
  flex-shrink: 0;
  cursor: default;
}

.role-badge.admin { background: rgba(239,68,68,0.12); color: #fca5a5; }
.role-badge.staff { background: rgba(243,133,0,0.15); color: var(--orange); }
.role-badge.user  { background: rgba(255,255,255,0.05); color: var(--text-faint); }

/* ─── Template Selector (create channel modal) ──────────────────────────── */

.template-group {
  display: flex;
  gap: 6px;
}

.template-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  min-height: var(--touch-min);
}

.template-option:hover { border-color: var(--text-faint); }

.template-option.selected {
  border-color: var(--orange);
  background: rgba(243, 133, 0, 0.08);
}

.template-option-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.template-option.selected .template-option-label { color: var(--orange); }

.template-option-icon { font-size: 16px; opacity: 0.6; }
.template-option.selected .template-option-icon { opacity: 1; }

/* ═══ PHASE 5: POLISH & MOBILE ═════════════════════════════════════════ */

/* Small phones: single-column channel strips */
@media (max-width: 479px) {
  .channel-strips { grid-template-columns: 1fr; }
  .intercom-sidebar { max-height: 25vh; }
}

/* Touch target fixes — bring all interactive elements to 44px minimum */
.channel-user { min-height: var(--touch-min); }
.staff-action-btn { min-height: var(--touch-min); padding: 8px 12px; }
.user-entry { min-height: var(--touch-min); padding: 6px 8px; }

/* Permission pills — bigger on touch devices */
@media (max-width: 768px) {
  .perm-pill { padding: 4px 8px; font-size: 10px; }
  .perm-row { gap: 4px; }
}

/* Safe area insets for notched devices */
.modal-overlay { padding: env(safe-area-inset-top, 16px) 16px env(safe-area-inset-bottom, 16px); }
.intercom-main { padding-bottom: calc(16px + var(--safe-bottom)); }

/* Sidebar collapse toggle (mobile only) */
.sidebar-collapse-btn {
  display: none;
  border: none;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px;
  cursor: pointer;
  text-align: center;
  border-top: 1px solid var(--border);
  transition: color 0.15s;
}

.sidebar-collapse-btn:hover { color: var(--orange); }

@media (max-width: 767px) {
  .sidebar-collapse-btn { display: block; }
  .intercom-sidebar.collapsed { max-height: 0; overflow: hidden; }
  .intercom-sidebar.collapsed + .sidebar-collapse-btn,
  .intercom-sidebar.collapsed ~ .sidebar-collapse-btn { border-top: none; }
}

/* Connection quality dot */
.ch-quality-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s;
}

.ch-quality-dot.good { background: var(--green); }
.ch-quality-dot.fair { background: #eab308; }
.ch-quality-dot.poor { background: var(--red); }
.ch-quality-dot.unknown { background: var(--text-faint); }
