:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-chat-header: #1e293b;
  --bg-sidebar: #0f172a;
  --bg-bubble-in: #334155;
  --bg-bubble-out: #059669;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #10b981;
  --primary-hover: #059669;
  --accent: #3b82f6;
  --border: #334155;
  --status-blue: #38bdf8;
  --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-y: auto;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}


/* TOP BAR */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background-color: #0b132b;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: #25d366;
}

.logo-icon {
  font-size: 1.6rem;
}

.nav-tabs {
  display: flex;
  gap: 0.5rem;
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.nav-tab.active {
  background-color: var(--bg-card);
  color: var(--primary);
  border: 1px solid var(--border);
}

.badge {
  background: #3b82f6;
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 10px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #ef4444;
}

.status-dot.online {
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
}

/* MAIN LAYOUT */
.main-layout {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.tab-content {
  display: none;
  height: 100%;
}

.tab-content.active {
  display: block;
}

/* CHAT APP */
.chat-app {
  display: flex;
  height: 100%;
}

.chat-sidebar {
  width: 320px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

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

.search-box {
  padding: 0.75rem;
  position: relative;
}

.search-box i {
  position: absolute;
  left: 1.25rem;
  top: 1.25rem;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.5rem 0.5rem 2.2rem;
  color: var(--text-main);
  outline: none;
}

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

.chat-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background 0.2s;
}

.chat-item:hover, .chat-item.active {
  background-color: var(--bg-card);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 0.95rem;
  flex-shrink: 0;
}

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

.chat-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-last-msg {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* CHAT WINDOW */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #0b132b;
}

.chat-header {
  padding: 0.85rem 1.25rem;
  background-color: var(--bg-chat-header);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.messages-container {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.welcome-screen {
  margin: auto;
  text-align: center;
  max-width: 420px;
  color: var(--text-muted);
}

.welcome-icon {
  font-size: 4rem;
  color: #10b981;
  margin-bottom: 1rem;
}

.message-bubble {
  max-width: 65%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.4;
  position: relative;
  word-break: break-word;
}

.message-bubble.inbound {
  align-self: flex-start;
  background-color: var(--bg-bubble-in);
  border-bottom-left-radius: 2px;
}

.message-bubble.outbound {
  align-self: flex-end;
  background-color: var(--bg-bubble-out);
  border-bottom-right-radius: 2px;
}

.msg-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-top: 4px;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.7);
}

.status-icon.read {
  color: var(--status-blue);
}

/* COMPOSER */
.composer-container {
  padding: 1rem;
  background-color: var(--bg-chat-header);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
}

.composer-container input {
  flex: 1;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text-main);
  outline: none;
  font-size: 0.95rem;
}

/* BUTTONS */
.btn {
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover { background-color: var(--primary-hover); }

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background-color: var(--border); }

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
}

.btn-icon {
  padding: 0.5rem;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
}
.btn-icon:hover { color: var(--text-main); background: var(--bg-card); }

/* INSPECTOR TAB */
.inspector-container {
  padding: 1.5rem;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.inspector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.logs-feed {
  flex: 1;
  background-color: #0b132b;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-y: auto;
  font-family: monospace;
}

.log-entry {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
}

.log-entry-header {
  display: flex;
  justify-content: space-between;
  color: var(--accent);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.log-json {
  background: #090d16;
  padding: 0.75rem;
  border-radius: 4px;
  color: #a7f3d0;
  white-space: pre-wrap;
  font-size: 0.82rem;
  overflow-x: auto;
}

/* SETUP TAB */
.setup-container {
  padding: 2rem;
  max-width: 1000px;
  margin: 0 auto;
  overflow-y: auto;
  height: 100%;
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.setup-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.setup-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  position: relative;
}

.card-step {
  position: absolute;
  top: -12px;
  right: 15px;
  background: var(--accent);
  color: white;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: bold;
}

.code-snippet {
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0.75rem 0;
  font-family: monospace;
  font-size: 0.85rem;
}

.copy-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
.copy-btn:hover { color: white; }

.config-field {
  margin-top: 1rem;
}

.config-field label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.config-field input {
  width: 100%;
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  color: var(--primary);
  font-family: monospace;
}

.input-copy-group {
  display: flex;
  gap: 0.5rem;
}

.check-list {
  list-style: none;
  margin-top: 1rem;
}
.check-list li {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.check-list i { color: #10b981; }

.system-health-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.health-item {
  background: #090d16;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.health-label { font-size: 0.8rem; color: var(--text-muted); }
.health-val { font-size: 1.1rem; font-weight: bold; margin-top: 4px; color: var(--primary); }

/* MODALS */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 480px;
  overflow: hidden;
}

.modal-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.form-group input, .form-group select {
  width: 100%;
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem;
  color: var(--text-main);
  outline: none;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
