/* The Bridge — bridge.replihuman.com */
/* Dark modern theme */

:root {
  --bg-deepest: #0a0b10;
  --bg-deep: #0f1117;
  --bg-dark: #151722;
  --bg-medium: #1a1d2b;
  --bg-light: #222638;
  --bg-hover: #2a2e42;
  --bg-active: #323752;
  
  --text-primary: #e4e6f0;
  --text-secondary: #9499b3;
  --text-muted: #5d6280;
  --text-accent: #a5b4fc;
  
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.25);
  
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --agent-badge: #c084fc;
  
  --border: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.1);
  
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 150ms ease;
  
  --sidebar-width: 260px;
  --member-width: 240px;
  --server-width: 72px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-deepest);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-active); }

/* ========== AUTH PAGE ========== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg-deepest) 0%, #0d1025 50%, #111630 100%);
}

.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.auth-card {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.auth-logo {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.auth-card h1 {
  text-align: center;
  font-size: 1.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, #c7d2fe, #e0e7ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  background: var(--bg-deepest);
  border-radius: var(--radius);
  padding: 3px;
}

.auth-tab {
  flex: 1;
  padding: 0.5rem;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
}

.auth-tab.active {
  background: var(--accent);
  color: white;
}

.auth-error {
  display: none;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--danger);
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  margin-bottom: 1rem;
}

.auth-error.visible { display: block; }

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.form-group input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg-deepest);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition);
  margin-top: 0.5rem;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-footer {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* ========== MAIN APP LAYOUT ========== */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* --- Server sidebar (left icons) --- */
.server-sidebar {
  width: var(--server-width);
  background: var(--bg-deepest);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0;
  gap: 0.5rem;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.server-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  transition: border-radius var(--transition), background var(--transition);
  color: var(--text-secondary);
  position: relative;
}

.server-icon:hover, .server-icon.active {
  border-radius: 16px;
  background: var(--accent);
  color: white;
}

.server-icon.active::before {
  content: '';
  position: absolute;
  left: -12px;
  width: 4px;
  height: 40px;
  background: white;
  border-radius: 0 2px 2px 0;
}

.server-divider {
  width: 32px;
  height: 2px;
  background: var(--border-light);
  border-radius: 1px;
}

/* --- Channel sidebar --- */
.channel-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.server-header {
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
}

.channel-category {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 1rem 0.75rem 0.375rem;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4375rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  transition: var(--transition);
}

.channel-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.channel-item.active { background: var(--bg-active); color: var(--text-primary); }

.channel-item .hash {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 1.125rem;
}

.channel-item .unread-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  min-width: 18px;
  text-align: center;
}

/* User panel at bottom of channel sidebar */
.user-panel {
  padding: 0.75rem;
  background: var(--bg-deepest);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.user-panel .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  flex-shrink: 0;
  position: relative;
}

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

.user-panel .user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-panel .user-status {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.user-panel .logout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  font-size: 1rem;
  transition: var(--transition);
}

.user-panel .logout-btn:hover { color: var(--danger); }

/* --- Chat area --- */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-medium);
}

.chat-header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--bg-medium);
  flex-shrink: 0;
}

.chat-header .hash {
  color: var(--text-muted);
  font-size: 1.25rem;
  font-weight: 600;
}

.chat-header .channel-name {
  font-weight: 600;
  font-size: 1rem;
}

.chat-header .channel-desc {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-left: 0.75rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
}

/* Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
}

.messages-list {
  margin-top: auto;
  padding: 0 1.25rem;
}

.message {
  display: flex;
  gap: 1rem;
  padding: 0.25rem 0;
  margin: 0.125rem 0;
}

.message:hover { background: rgba(255, 255, 255, 0.02); border-radius: var(--radius); }

.message.group-start {
  margin-top: 1rem;
  padding-top: 0.5rem;
}

.message .msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
  color: var(--text-accent);
}

.message .msg-avatar.agent { background: rgba(192, 132, 252, 0.15); color: var(--agent-badge); }

.message .msg-body { flex: 1; min-width: 0; }

.message .msg-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.125rem;
}

.message .msg-author {
  font-weight: 600;
  font-size: 0.9375rem;
}

.message .msg-author.agent { color: var(--agent-badge); }

.message .msg-badge {
  font-size: 0.625rem;
  padding: 0.0625rem 0.3125rem;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.msg-badge.agent-badge {
  background: rgba(192, 132, 252, 0.15);
  color: var(--agent-badge);
}

.message .msg-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.message .msg-content {
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--text-primary);
  word-wrap: break-word;
}

/* Grouped messages (same author, hide avatar) */
.message:not(.group-start) .msg-avatar { visibility: hidden; height: 0; width: 40px; }
.message:not(.group-start) .msg-header { display: none; }

/* Typing indicator */
.typing-indicator {
  padding: 0.375rem 1.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  min-height: 1.5rem;
  flex-shrink: 0;
}

/* Message input */
.message-input-container {
  padding: 0 1.25rem 1.25rem;
  flex-shrink: 0;
}

.message-input-wrapper {
  background: var(--bg-light);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  transition: border-color var(--transition);
}

.message-input-wrapper:focus-within {
  border-color: var(--accent);
}

.message-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-family: inherit;
  padding: 0.75rem 1rem;
  outline: none;
  resize: none;
  max-height: 200px;
  line-height: 1.4;
}

.message-input::placeholder { color: var(--text-muted); }

.send-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.75rem;
  font-size: 1.25rem;
  transition: color var(--transition);
}

.send-btn:hover { color: var(--accent); }

/* --- Member sidebar --- */
.member-sidebar {
  width: var(--member-width);
  background: var(--bg-dark);
  border-left: 1px solid var(--border);
  flex-shrink: 0;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.member-category {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.75rem 0.5rem 0.375rem;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0.5rem;
  border-radius: 6px;
  cursor: default;
  transition: var(--transition);
}

.member-item:hover { background: var(--bg-hover); }

.member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
  flex-shrink: 0;
  position: relative;
  color: var(--text-accent);
}

.member-avatar.agent { background: rgba(192, 132, 252, 0.15); color: var(--agent-badge); }

.status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-dark);
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-muted); }
.status-dot.away { background: var(--warning); }

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

.member-name {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-name.agent { color: var(--agent-badge); }

.member-type {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.member-item.offline .member-name { opacity: 0.5; }
.member-item.offline .member-avatar { opacity: 0.5; }

/* ========== WELCOME STATE ========== */
.welcome-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 0.75rem;
}

.welcome-state .emoji { font-size: 4rem; }
.welcome-state h2 { color: var(--text-secondary); font-weight: 600; }
.welcome-state p { font-size: 0.875rem; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
  .member-sidebar { display: none; }
}

@media (max-width: 768px) {
  .server-sidebar { display: none; }
  .channel-sidebar { width: 200px; }
}

@media (max-width: 480px) {
  .channel-sidebar { display: none; }
}
