/* Deliberately plain: this UI is for testing the API, not for design. */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font:
    14px/1.4 system-ui,
    sans-serif;
  color: #111;
  background: #fff;
}

.hidden {
  display: none !important;
}

.muted {
  color: #666;
}

.error {
  color: #a00;
  white-space: pre-wrap;
}

button {
  font: inherit;
  padding: 4px 8px;
  border: 1px solid #888;
  background: #f4f4f4;
  cursor: pointer;
}

button:hover {
  background: #e8e8e8;
}

input,
select,
textarea {
  font: inherit;
  padding: 4px;
  border: 1px solid #aaa;
}

/* Auth screen */
#auth {
  max-width: 420px;
  margin: 40px auto;
  padding: 0 16px;
}

#auth label {
  display: block;
  margin: 8px 0;
}

#auth input,
#auth select {
  width: 100%;
  margin-top: 2px;
}

.tabs {
  margin: 16px 0 8px;
}

.tabs button.active {
  background: #ddd;
  font-weight: bold;
}

.auth-form button[type='submit'] {
  margin-top: 8px;
}

/* Application layout */
#topbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid #ccc;
}

#topbar .badge {
  border: 1px solid #aaa;
  padding: 1px 6px;
  font-size: 12px;
}

main {
  display: flex;
  height: calc(100vh - 42px - 140px);
}

#sidebar {
  width: 280px;
  border-right: 1px solid #ccc;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#search-box {
  margin: 6px;
}

#search-results {
  border-bottom: 1px solid #ccc;
  max-height: 45%;
  overflow: auto;
  padding: 4px 6px;
}

#conversation-list,
#message-list,
#event-log,
#panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#conversation-list {
  overflow: auto;
  flex: 1;
}

#conversation-list li {
  padding: 6px 8px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}

#conversation-list li.active {
  background: #eee;
}

.row-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.unread {
  border: 1px solid #333;
  padding: 0 5px;
  font-size: 12px;
}

/* Chat column */
#chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #ccc;
}

.spacer {
  flex: 1;
}

#messages {
  flex: 1;
  overflow: auto;
  padding: 8px 10px;
}

#message-list li {
  margin: 6px 0;
  padding: 4px 6px;
  border: 1px solid #ddd;
  max-width: 70%;
}

#message-list li.mine {
  margin-left: auto;
  background: #f4f4f4;
}

#message-list li.system {
  margin: 6px auto;
  max-width: 80%;
  border: none;
  color: #666;
  text-align: center;
  font-size: 12px;
}

#message-list li.pending {
  opacity: 0.6;
}

.meta {
  font-size: 11px;
  color: #666;
  display: flex;
  gap: 6px;
  justify-content: space-between;
}

#composer {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid #ccc;
}

#composer-input {
  flex: 1;
}

#typing {
  padding: 0 10px;
  height: 18px;
  font-size: 12px;
}

/* Right panel */
#panel {
  width: 320px;
  border-left: 1px solid #ccc;
  padding: 8px;
  overflow: auto;
}

#panel h3 {
  margin: 12px 0 6px;
  font-size: 14px;
}

#panel li {
  padding: 4px 0;
  border-bottom: 1px solid #eee;
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
}

#panel label {
  display: block;
  margin: 4px 0;
}

/* Event log */
#log-bar {
  height: 140px;
  border-top: 1px solid #ccc;
  padding: 4px 8px;
  overflow: auto;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

#event-log li {
  border-bottom: 1px solid #f0f0f0;
  padding: 1px 0;
  white-space: pre-wrap;
  word-break: break-all;
}

#event-log li.err {
  color: #a00;
}

.avatar {
  max-width: 120px;
  max-height: 120px;
  border: 1px solid #ccc;
  display: block;
  margin: 4px 0;
}

.avatar.small {
  width: 24px;
  height: 24px;
  margin: 0;
  object-fit: cover;
}

/* ------------------------------------------------------------------- calls */

#call-ui,
#call-incoming {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  background: #fff;
  border: 1px solid #888;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
}

#call-incoming {
  bottom: auto;
  top: 16px;
}

#call-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.call-tile {
  display: flex;
  flex-direction: column;
}

/* Audio-only calls have nothing to show, but the element must stay in the DOM to play */
.call-tile audio {
  width: 180px;
}

.call-tile video {
  width: 180px;
  background: #000;
}

.call-controls {
  display: flex;
  gap: 6px;
}

.call-controls .danger {
  border-color: #a00;
  color: #a00;
}
