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

html, body {
  height: 100%;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: #111b21;
  color: #e9edef;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ---------- Pairing view ---------- */
.pair-view {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(#008069 0, #008069 130px, #111b21 130px);
}

.pair-card {
  background: #fff;
  color: #111b21;
  border-radius: 12px;
  padding: 40px 48px;
  width: 640px;
  max-width: 92vw;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.brand {
  color: #00a884;
  font-weight: 800;
  letter-spacing: 3px;
  font-size: 14px;
  margin-bottom: 8px;
}

.pair-card h1 { font-size: 26px; font-weight: 400; margin-bottom: 20px; }

.steps { margin: 0 0 24px 20px; color: #3b4a54; font-size: 15px; line-height: 2; }

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}

.qr-box img {
  width: 264px;
  height: 264px;
  border-radius: 8px;
  background: #f0f2f5;
}

.qr-status { margin-top: 12px; color: #667781; font-size: 14px; }

.ghost-btn {
  display: block;
  margin: 8px auto 0;
  padding: 10px 24px;
  border: 1px solid #00a884;
  background: none;
  color: #008069;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
}
.ghost-btn:hover { background: #e7fdf5; }

.server-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e9edef;
  font-size: 13px;
  color: #667781;
}
.server-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d1d7db;
  border-radius: 6px;
  font-size: 13px;
}

.error-text { color: #d22; text-align: center; margin-top: 12px; font-size: 13px; min-height: 18px; }

/* ---------- Chat view ---------- */
.chat-view { height: 100%; display: flex; }

.sidebar {
  width: 30%;
  min-width: 300px;
  max-width: 420px;
  background: #111b21;
  border-right: 1px solid #222d34;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #202c33;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #6b7c85;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.me-info { flex: 1; }
.me-name { font-weight: 600; font-size: 15px; }

.icon-btn {
  background: none;
  border: none;
  color: #aebac1;
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
}
.icon-btn:hover { color: #e9edef; }

.search-box { padding: 8px 12px; background: #111b21; }
.search-box input {
  width: 100%;
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: #202c33;
  color: #e9edef;
  font-size: 14px;
  outline: none;
}

.chat-list { flex: 1; overflow-y: auto; }

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #222d34;
}
.chat-item:hover { background: #202c33; }
.chat-item.active { background: #2a3942; }

.chat-item-info { flex: 1; min-width: 0; }
.chat-item-top { display: flex; justify-content: space-between; align-items: baseline; }
.chat-item-name { font-size: 15px; font-weight: 500; }
.chat-item-time { font-size: 11px; color: #8696a0; }
.chat-item-preview {
  font-size: 13px;
  color: #8696a0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.unread-badge {
  background: #00a884;
  color: #111b21;
  font-size: 12px;
  font-weight: 700;
  border-radius: 12px;
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

/* ---------- Main pane ---------- */
.main-pane { flex: 1; display: flex; flex-direction: column; background: #0b141a; }

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #8696a0;
}
.empty-state h2 { font-weight: 300; font-size: 32px; margin-bottom: 8px; }

.chat-pane { display: flex; flex-direction: column; height: 100%; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #202c33;
}
.chat-name { font-size: 15px; font-weight: 600; }
.chat-status { font-size: 12px; color: #8696a0; }
.chat-status.online { color: #00a884; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 60px;
  background: #0b141a;
}

.bubble {
  max-width: 65%;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  font-size: 14.5px;
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
  clear: both;
}
.bubble.in { background: #202c33; float: left; border-top-left-radius: 0; }
.bubble.out { background: #005c4b; float: right; border-top-right-radius: 0; }

.bubble .meta {
  display: inline-flex;
  float: right;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #8696a0;
  margin: 6px 0 0 10px;
}
.bubble .ticks.read { color: #53bdeb; }

.bubble img.media { max-width: 320px; max-height: 320px; border-radius: 8px; display: block; margin-bottom: 4px; }
.bubble video.media { max-width: 320px; border-radius: 8px; display: block; margin-bottom: 4px; }
.bubble audio.media { width: 260px; display: block; }
.file-link { color: #53bdeb; text-decoration: none; font-size: 14px; }

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #202c33;
}
.composer input[type='text'] {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 15px;
  background: #2a3942;
  color: #e9edef;
  outline: none;
}
.send-btn {
  background: #00a884;
  border: none;
  color: #0b141a;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}
.send-btn:hover { background: #06cf9f; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: #374045; border-radius: 3px; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  background: #111b21;
  border-bottom: 1px solid #222d34;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  color: #8696a0;
  padding: 10px 0;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: #00a884; border-bottom-color: #00a884; }
.tab:hover { color: #e9edef; }

.chat-header-actions { margin-left: auto; display: flex; gap: 4px; }

/* ---------- Call log bubble ---------- */
.call-log { display: flex; align-items: center; gap: 6px; }
.call-log.missed { color: #f15c6d; }

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-card {
  width: 440px;
  max-width: 92vw;
  max-height: 80vh;
  background: #202c33;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-card input[type='text'] {
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: #2a3942;
  color: #e9edef;
  font-size: 14px;
  outline: none;
}
.modal-list { overflow-y: auto; max-height: 320px; }
.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
}
.user-row:hover { background: #2a3942; }
.user-row .avatar { width: 36px; height: 36px; font-size: 14px; }
.user-row-name { font-size: 15px; }
.user-row-sub { font-size: 12px; color: #8696a0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: #005c4b;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip button { background: none; border: none; color: #e9edef; cursor: pointer; }

.primary-btn {
  background: #00a884;
  border: none;
  color: #0b141a;
  padding: 11px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.primary-btn:hover { background: #06cf9f; }

/* ---------- Call overlay ---------- */
.call-overlay {
  position: fixed;
  inset: 0;
  background: #0b141a;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}
.remote-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.local-video {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 180px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #374045;
  background: #000;
  z-index: 2;
}
.call-info {
  position: relative;
  z-index: 2;
  text-align: center;
  padding-top: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.avatar.big { width: 96px; height: 96px; font-size: 40px; }
.call-name { font-size: 26px; font-weight: 600; text-shadow: 0 1px 6px rgba(0,0,0,0.7); }
.call-status-text { font-size: 15px; color: #aebac1; }
.call-timer { font-size: 14px; color: #00a884; font-variant-numeric: tabular-nums; }

.call-actions {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 28px;
  padding-bottom: 48px;
}
.call-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  font-size: 24px;
  cursor: pointer;
  background: #2a3942;
  color: #e9edef;
}
.call-btn:hover { background: #374045; }
.call-btn.accept { background: #00a884; }
.call-btn.accept:hover { background: #06cf9f; }
.call-btn.reject { background: #ea0038; transform: rotate(135deg); }
.call-btn.reject:hover { background: #ff2d55; }
.call-btn.off { background: #ea0038; }
