:root {
  --bg: #111b21;
  --panel: #1f2c34;
  --panel-alt: #202c33;
  --border: #2a3942;
  --text: #e9edef;
  --text-dim: #8696a0;
  --accent: #00a884;
  --accent-dark: #005c4b;
  --bubble-in: #202c33;
  --bubble-out: #005c4b;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: grid;
  grid-template-columns: 280px 300px 1fr;
  height: 100vh;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar, .chats-panel, .conversation {
    display: none;
  }
  .sidebar.active, .chats-panel.active, .conversation.active {
    display: flex;
  }
}

.sidebar, .chats-panel, .conversation {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.conversation { border-right: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--panel-alt);
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 { font-size: 16px; margin: 0; }

.sidebar-header button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

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

.number-item, .chat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.number-item:hover, .chat-item:hover { background: var(--panel-alt); }
.number-item.selected, .chat-item.selected { background: #2a3942; }

.number-item .name { font-weight: 600; }
.number-item .status, .chat-item .preview {
  font-size: 12px;
  color: var(--text-dim);
}

.status-connected { color: var(--accent) !important; }
.status-qr { color: #e0a300 !important; }
.status-disconnected, .status-logged_out, .status-connecting { color: #e05555 !important; }

.chat-item .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.unread-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  padding: 2px 7px;
}

.panel-header {
  padding: 14px 16px;
  background: var(--panel-alt);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
}

.bubble {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

.bubble.in { align-self: flex-start; background: var(--bubble-in); }
.bubble.out { align-self: flex-end; background: var(--bubble-out); }

.bubble .meta {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  text-align: right;
}

.send-form {
  display: flex;
  padding: 12px;
  gap: 8px;
  background: var(--panel-alt);
  border-top: 1px solid var(--border);
}

.send-form input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 20px;
  border: none;
  background: #2a3942;
  color: var(--text);
  outline: none;
}

.send-form button {
  padding: 10px 18px;
  border-radius: 20px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal {
  background: var(--panel);
  border-radius: 8px;
  width: 320px;
  max-width: 90vw;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.modal-header button {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

.modal-body { padding: 16px; text-align: center; }

.modal-body input {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #2a3942;
  color: var(--text);
  margin-bottom: 12px;
  outline: none;
}

.modal-body button.primary {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.modal-body img { max-width: 100%; border-radius: 8px; }

.back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  margin-right: 8px;
  cursor: pointer;
}

@media (max-width: 900px) {
  .back-btn { display: inline-block; }
}
