@import url('https://fonts.googleapis.com/css?family=Inconsolata|Montserrat');

/*
 * Themeable slim comms bar. Consumers (e.g. a host app) restyle by setting
 * these custom properties on janus-comms-panel rather than overriding rules.
 */
janus-comms-panel {
  --comms-bar-bg: rgba(0,0,0,.5);
  --comms-accent: #4cb96f;              /* usernames, active states, scrollbar */
  --comms-text: #eee;
  --comms-muted: #aaa;
  --comms-font: Inconsolata, monospace;
  --comms-radius: .5em;
  --comms-log-width: 22em;
  --comms-log-max-height: 40vh;
  --comms-show-presence: block;        /* set to none to hide join/part/disconnect lines */
  --comms-status-connected: #0a0;
  --comms-status-connecting: #cc0;
  --comms-status-disconnecting: #999;
  --comms-status-disconnected: #b00;
  --comms-status-private: #aaa;

  position: relative;
  display: inline-block;
  z-index: 100;
  color: var(--comms-text);
  font-family: var(--comms-font);
}

.janus-comms-bar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .25em;
  padding: .2em .35em;
  background: var(--comms-bar-bg);
  border-radius: var(--comms-radius);
  text-shadow: 0 0 3px #000, 0 0 1px #000;
}

/* Shared pill look for the interactive chips in the bar */
.janus-comms-bar>janus-comms-userlist>.comms-roster>summary,
.janus-comms-bar>janus-comms-invite {
  cursor: pointer;
  outline: 0;
  border-radius: var(--comms-radius);
  padding: .15em .4em;
  white-space: nowrap;
  transition: background 120ms linear;
}
.janus-comms-bar>janus-comms-userlist>.comms-roster>summary:hover,
.janus-comms-bar>janus-comms-invite:hover,
.janus-comms-bar>janus-comms-invite.state_active {
  background: rgba(255,255,255,.15);
}

/* ---- Connection status: a single dot in the bar ---- */
janus-comms-status {
  display: flex;
  align-items: center;
  font-size: .8em;
}
janus-comms-status>span {   /* the verbose "Connected as ..." label — hidden in bar mode */
  display: none;
}
janus-comms-status .indicator {
  display: inline-block;
  width: .7em;
  height: .7em;
  border-radius: 50%;
  box-shadow: 0 0 4px #000;
  background: var(--comms-status-disconnected);
  margin: 0 .25em;
}
janus-comms-status .indicator.connecting   { background: var(--comms-status-connecting); }
janus-comms-status .indicator.connected     { background: var(--comms-status-connected); }
janus-comms-status .indicator.disconnecting { background: var(--comms-status-disconnecting); }
janus-comms-status .indicator.private       { background: var(--comms-status-private); }

/* ---- Roster: chip in the bar, roster list floats above ---- */
janus-comms-userlist.comms-roster {
  position: relative;
  display: block;
  font-size: .85em;
  z-index: 20;   /* roster popover layers above the chat transcript (z 5) */
}
.comms-roster>summary {
  list-style: none;
}
.comms-roster>summary::-webkit-details-marker { display: none; }
.comms-roster>summary ui-indicator {
  font-weight: bold;
  color: var(--comms-accent);
}
.comms-roster-popover {
  position: absolute;
  left: 0;
  bottom: 100%;
  margin-bottom: .4em;
  min-width: 12em;
  max-height: var(--comms-log-max-height);
  overflow-y: auto;
  padding: .4em .6em;
  background: rgba(15,15,18,.97);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--comms-radius);
  box-shadow: 0 4px 18px rgba(0,0,0,.55);
}
.comms-roster-popover p {
  margin: 0;
  font-size: .9em;
  color: var(--comms-muted);
  max-width: 16em;
}
ui-list[name="userlist_room"] {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9em, 1fr));
  gap: .1em .6em;
  font-size: .9em;
}

/* ---- Invite hub trigger ---- */
janus-comms-invite {
  display: inline-block;
  font-size: 1.05em;
  line-height: 1;
  user-select: none;
}

/* ---- Chat: input lives in the bar, transcript floats above and fades in ---- */
janus-comms-chat {
  position: static;   /* the transcript anchors to the panel so it left-aligns to the bar */
  display: flex;
  flex: 1 1 15em;
  min-width: 11em;
}
.comms-chat-input {
  display: flex;
  align-items: center;
  flex: 1;
  gap: .2em;
}
janus-comms-chat ui-notificationbutton[name="unread"] {
  cursor: pointer;
  font-size: 1em;
  line-height: 1;
}
janus-comms-chat ui-input {
  flex: 1;
  display: flex;
}
janus-comms-chat ui-input>input {
  flex: 1 1;
  background: rgba(0,0,0,.25);
  color: var(--comms-text);
  font-family: var(--comms-font);
  padding: .25em .5em;
  border: 0;
  border-radius: var(--comms-radius);
}
janus-comms-chat ui-input>input:focus {
  background: rgba(0,0,0,.45);
  outline: 1px solid var(--comms-accent);
}

/*
 * The transcript floats above the bar, left-aligned to the panel (not the
 * input box). It's opaque so nothing behind bleeds through, and sits at a low
 * z within the panel so the roster/invite surfaces layer cleanly above it.
 * Visibility is driven explicitly: pinned (click the badge), a transient flash
 * on new/sent messages, or while the input is focused. No hover trigger — that
 * fought the pin and made show/hide feel random.
 */
janus-comms-chat .comms-log {
  position: absolute;
  left: 0;
  bottom: 100%;
  margin-bottom: .4em;
  width: var(--comms-log-width);
  max-width: 70vw;
  max-height: var(--comms-log-max-height);
  overflow-y: auto;
  padding: .5em .7em;
  background: rgba(15,15,18,.96);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--comms-radius);
  box-shadow: 0 4px 18px rgba(0,0,0,.55);
  font-family: var(--comms-font);
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  /* Empty rotate() forces compositing so rows don't vanish while scrolling */
  transform: translateY(.4em) rotate(0);
  transition: opacity 160ms ease, transform 160ms ease;
}
janus-comms-panel.comms-log-pinned janus-comms-chat .comms-log,
janus-comms-panel.comms-log-flash janus-comms-chat .comms-log,
janus-comms-chat:focus-within .comms-log {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}
janus-comms-chat .comms-log>ui-item {
  padding: 0;
  text-shadow: 0 0 4px #000;
  border: 0;
}

/* ---- Message rows ---- */
janus-comms-chat .message {
  display: block;
  text-indent: -1em;
  padding-left: 1em;
}
janus-comms-chat .join,
janus-comms-chat .part,
janus-comms-chat .disconnect {
  display: var(--comms-show-presence);
  color: var(--comms-muted);
  font-weight: normal;
  font-style: italic;
  font-size: .7em;
}
janus-comms-chat .join .userid::before,
janus-comms-chat .part .userid::before,
janus-comms-chat .disconnect .userid::before {
  content: "-!- ";
  color: var(--comms-muted);
}
janus-comms-chat .join .userid { color: #9ff; }
janus-comms-chat .disconnect .userid,
janus-comms-chat .part .userid { color: #099; }
janus-comms-chat .chat,
janus-comms-chat .selfchat { color: var(--comms-text); font-weight: normal; }
janus-comms-chat .userid { color: var(--comms-accent); font-weight: 900; }
janus-comms-chat .selfchat .userid { color: #fff; font-weight: bold; }
janus-comms-chat .chat .userid::after,
janus-comms-chat .selfchat .userid::after { content: ':'; color: #666; }
janus-comms-chat .print .userid { display: none; }
janus-comms-chat .print { color: white; }

/* Log scrollbar */
janus-comms-chat .comms-log::-webkit-scrollbar,
.comms-roster-popover::-webkit-scrollbar { width: 6px; }
janus-comms-chat .comms-log::-webkit-scrollbar-track,
.comms-roster-popover::-webkit-scrollbar-track { background: rgba(255,255,255,.05); }
janus-comms-chat .comms-log::-webkit-scrollbar-thumb,
.comms-roster-popover::-webkit-scrollbar-thumb { background: var(--comms-accent); border-radius: 3px; }

/* Narrow screens: keep only the essentials */
@media (max-width: 48em) {
  janus-comms-chat { flex-basis: 7em; }
  janus-comms-chat .comms-log { width: 80vw; }
}

/*
 * Popupbutton popups (the invite menu, the mic/device picker) are rendered at
 * the document root, so they must float above the comms panel's stacking
 * context (z 100) — otherwise they render *behind* the bar and its transcript.
 */
ui-window.state_popup {
  z-index: 10000;
}

/* ---- Invite popup menu (rendered at document root, outside the panel) ---- */
ui-window.janus-comms-invite-popup {
  background: rgba(15,15,18,.98);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: .5em;
  box-shadow: 0 6px 24px rgba(0,0,0,.6);
  color: #fff;
}
.janus-comms-invite-menu {
  display: flex;
  flex-direction: column;
  gap: .1em;
  min-width: 13em;
  max-width: 90vw;
  max-height: 80vh;
  overflow-x: hidden;
  overflow-y: auto;
  padding: .3em;
}
/* Reset the site's uppercase/large/faded button look inside the menu */
.janus-comms-invite-popup ui-button {
  display: block;
  box-sizing: border-box;
  width: 100%;
  text-align: left;
  text-transform: none;
  font-size: .95em;
  font-weight: normal;
  line-height: 1.25;
  white-space: nowrap;
  color: #fff;
  opacity: 1;
  padding: .5em .6em;
  border: 0;
  border-radius: .4em;
  box-shadow: none;
  background: transparent;
  cursor: pointer;
  transition: background 120ms linear;
}
.janus-comms-invite-popup ui-button:hover {
  background: rgba(255,255,255,.12);
}
.janus-comms-invite-popup janus-voip-client-callbutton {
  display: block;
}
.janus-comms-invite-popup .janus-comms-schedule {
  display: flex;
  flex-direction: column;
  gap: .3em;
  padding: .5em .6em .3em;
  margin-top: .15em;
  border-top: 1px solid rgba(255,255,255,.15);
}
.janus-comms-invite-popup .janus-comms-schedule label {
  font-size: .8em;
  color: #bbb;
}
.janus-comms-invite-popup .janus-comms-schedule input {
  padding: .35em;
  border-radius: .3em;
  border: 1px solid #555;
  background: #222;
  color: #eee;
  font-size: .9em;
}

janus-voip-picker>ul li {
  display: flex;
  xflex: 1;
  border: 1px solid black;
  border-radius: 10px;
  background: #666;
  box-shadow: 0 0 5px black;
}
janus-voip-picker>ul li button,
janus-voip-picker>ul li ui-togglebutton,
janus-voip-picker ui-button {
  width: 300px;
  xheight: 100px;
  xbackground: #666;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.5em;
  xcolor: white;
  xtext-shadow: 0 0 5px black;
  font-weight: normal;
}
janus-voip-picker ui-button {
  margin-top: 1em;
  border: 1px solid black;
  box-shadow: 0 0 5px black;
  xline-height: 50px;
  xheight: 50px;
}
janus-voip-picker>ul li button:hover {
  xbackground: #777;
}
janus-voip-picker>ul li button:focus {
  background: #6a6;
}
janus-voip-picker>ul li button[disabled] {
  color: #888;
  text-shadow: 0 0 5px #444;
  cursor: not-allowed;
}
