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

:root {
  --bg-primary: #1a1f2e;
  --bg-secondary: #252b3b;
  --bg-tertiary: #1e2330;
  --bg-hover: #2d3548;
  --bg-active: #363d52;
  --accent-primary: #6366f1;
  --accent-hover: #818cf8;
  --accent-secondary: #8b5cf6;
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #3d4659;
  --online: #22c55e;
  --offline: #64748b;
  --error: #ef4444;
  --success: #22c55e;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-columns: 72px 240px 1fr 240px;
  height: 100vh;
}

/* Server Sidebar */
.server-sidebar {
  background: var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
  overflow-y: auto;
}

.server-home {
  width: 48px;
  height: 48px;
  background: var(--bg-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
}

.server-home:hover {
  background: var(--accent-primary);
  color: white;
  border-radius: 16px;
}

.server-home svg {
  width: 24px;
  height: 24px;
}

.server-divider {
  width: 32px;
  height: 2px;
  background: var(--border-color);
  margin: 4px 0;
}

.server-item {
  width: 48px;
  height: 48px;
  background: var(--bg-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-secondary);
  position: relative;
}

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

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

.server-add {
  width: 48px;
  height: 48px;
  background: var(--bg-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--success);
  font-size: 24px;
  font-weight: 300;
}

.server-add:hover {
  background: var(--success);
  color: white;
  border-radius: 16px;
}

/* Channel Sidebar */
.channel-sidebar {
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
}

.channel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.channel-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.channel-section {
  padding: 16px 8px;
}

.section-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 0 8px 8px;
  letter-spacing: 0.5px;
}

.channel-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  margin: 2px 0;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 15px;
  transition: all 0.15s;
}

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

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

.channel-icon {
  margin-right: 6px;
  font-size: 18px;
  color: var(--text-muted);
}

.channel-item.active .channel-icon {
  color: var(--text-secondary);
}

.voice-channel .channel-icon {
  font-size: 14px;
}

/* User Controls */
.user-controls {
  margin-top: auto;
  padding: 8px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--accent-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
}

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

.user-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-status {
  font-size: 12px;
  color: var(--text-secondary);
}

.user-actions {
  display: flex;
  gap: 4px;
}

.user-actions button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  font-size: 14px;
}

.user-actions button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

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

.chat-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.chat-header .channel-icon {
  color: var(--text-muted);
}

.typing-indicator {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 12px;
}

.message-avatar {
  width: 40px;
  height: 40px;
  background: var(--accent-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

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

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.message-author {
  font-weight: 600;
  color: var(--text-primary);
}

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

.message-text {
  color: var(--text-secondary);
  line-height: 1.5;
  word-wrap: break-word;
}

.message-text code {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
}

.message-text pre {
  background: var(--bg-secondary);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}

.message-text pre code {
  background: none;
  padding: 0;
}

.message-text strong {
  font-weight: 700;
}

.message-text em {
  font-style: italic;
}

.chat-input-container {
  padding: 0 16px 24px;
}

.chat-input-wrapper {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 12px;
}

.chat-input-wrapper input {
  width: 100%;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
}

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

/* Member Sidebar */
.member-sidebar {
  background: var(--bg-secondary);
  padding: 16px 8px;
}

.member-section {
  margin-bottom: 24px;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

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

.member-avatar {
  width: 32px;
  height: 32px;
  background: var(--accent-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  position: relative;
}

.member-avatar::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: var(--online);
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}

.member-avatar.offline::after {
  background: var(--offline);
}

.member-name {
  font-size: 14px;
  color: var(--text-secondary);
}

.member-item:hover .member-name {
  color: var(--text-primary);
}

.member-role {
  font-size: 11px;
  color: var(--accent-primary);
  margin-top: 2px;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  padding: 24px;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
}

.modal-content h3 {
  margin-bottom: 16px;
  font-size: 20px;
}

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

.modal-content input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 16px;
}

.modal-content input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.modal-content button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent-primary);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
}

.modal-content button:hover {
  background: var(--accent-hover);
}

.modal-content .close-modal {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.modal-content .close-modal:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-color);
}

/* Empty State */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

/* Voice users in channel */
.voice-users {
  padding-left: 24px;
  margin-top: 4px;
}

.voice-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.voice-user::before {
  content: '🔊';
  font-size: 11px;
}

/* Responsive */
@media (max-width: 1200px) {
  #app {
    grid-template-columns: 72px 200px 1fr;
  }
  
  .member-sidebar {
    display: none;
  }
}

@media (max-width: 768px) {
  #app {
    grid-template-columns: 60px 1fr;
  }
  
  .channel-sidebar {
    display: none;
  }
}
