:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --success: #22c55e;
  --danger: #ef4444;
  --bubble-me: #2563eb;
  --bubble-other: #1e293b;
  --bubble-system: rgba(148, 163, 184, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 32px;
  border-radius: 16px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.logo-circle {
  width: 56px;
  height: 56px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
}

.modal-header h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.modal-header p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

.modal-header a {
  color: var(--accent);
  text-decoration: none;
}

.input-group {
  text-align: left;
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.input-group input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: var(--accent);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

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

.modal-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.download-link {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 500;
}

.download-link:hover {
  text-decoration: underline;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
}

/* App Header */
.app-header {
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  font-size: 20px;
}

.app-name {
  font-weight: 700;
  font-size: 16px;
}

.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-muted);
  font-weight: 500;
}

.badge.connected {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.badge.disconnected {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-download {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}

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

.btn-portfolio {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.btn-portfolio:hover {
  color: var(--text-primary);
}

/* App Body */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.user-profile {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 15px;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.username {
  font-weight: 600;
  font-size: 14px;
}

.user-status {
  font-size: 11px;
  color: var(--success);
}

.channels-section {
  padding: 16px 12px;
  overflow-y: auto;
  flex: 1;
}

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin: 12px 0 8px 8px;
  letter-spacing: 0.5px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  position: relative;
}

.channel-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.channel-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  font-weight: 600;
}

.channel-icon {
  font-size: 16px;
  color: var(--text-muted);
}

.unread-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.empty-users {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 12px;
  font-style: italic;
}

/* Chat Main */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.chat-header {
  height: 56px;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
}

.chat-header-info h3 {
  font-size: 16px;
  font-weight: 600;
}

.chat-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.messages-container {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-row {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}

.message-row.me {
  align-self: flex-end;
  align-items: flex-end;
}

.message-row.other {
  align-self: flex-start;
  align-items: flex-start;
}

.message-row.system {
  align-self: center;
  max-width: 90%;
  margin: 6px 0;
}

.msg-sender {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding: 0 4px;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.message-row.me .msg-bubble {
  background: var(--bubble-me);
  color: white;
  border-bottom-right-radius: 2px;
}

.message-row.other .msg-bubble {
  background: var(--bubble-other);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 2px;
}

.message-row.system .msg-bubble {
  background: var(--bubble-system);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 16px;
}

.msg-time {
  font-size: 10px;
  opacity: 0.7;
  margin-left: 8px;
}

/* Typing Bar */
.typing-bar {
  height: 22px;
  padding: 0 24px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Input Bar */
.message-input-bar {
  padding: 14px 24px 20px;
  display: flex;
  gap: 10px;
}

.message-input-bar input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

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

.send-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

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

@media (max-width: 768px) {
  .sidebar {
    width: 72px;
  }
  .username, .user-status, .section-title, .channel-name, .empty-users, .chat-subtitle {
    display: none;
  }
  .channel-item {
    justify-content: center;
  }
  .header-right .btn-download {
    display: none;
  }
}
