:root {
  --bg-darkest: #1a1b1e;
  --bg-dark: #232428;
  --bg-medium: #2b2d31;
  --bg-light: #383a40;
  --bg-hover: #404249;
  --accent: #5865F2;
  --accent-hover: #4752c4;
  --accent-light: #5865F2;
  --accent-glow: rgba(88, 101, 242, 0.35);
  --green: #23a559;
  --green-hover: #1a833a;
  --red: #f23f43;
  --yellow: #f0b232;
  --text: #f2f3f5;
  --text-muted: #949ba4;
  --text-faint: #80848e;
  --border: #3f4147;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --transition: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 0.1s cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.45);
  --shadow-glow: 0 0 20px var(--accent-glow);
}

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

body {
  font-family: 'gg sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--bg-darkest);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }

/* Auth Screen */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #5865F2 0%, #1a1b1e 60%, #232428 100%);
  position: relative;
  overflow: hidden;
}

.auth-screen::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(88,101,242,0.15) 0%, transparent 70%);
  top: -200px;
  right: -100px;
  border-radius: 50%;
  animation: float 8s ease-in-out infinite;
}

.auth-screen::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(235,69,158,0.1) 0%, transparent 70%);
  bottom: -100px;
  left: -50px;
  border-radius: 50%;
  animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translateY(0) translateX(0); }
  50% { transform: translateY(-30px) translateX(20px); }
}

.auth-card {
  background: var(--bg-medium);
  padding: 32px;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  animation: cardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.auth-logo h1 {
  font-size: 24px;
  font-weight: 700;
}

.auth-tabs {
  display: flex;
  margin-bottom: 24px;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.auth-tab.active {
  background: var(--bg-medium);
  color: var(--text);
}

.auth-form { display: none; }
.auth-form.active { display: block; }

.auth-form input, .modal-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
  transition: var(--transition);
}

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

.auth-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

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

.btn-primary:hover { 
  background: var(--accent-hover); 
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:active { 
  transform: translateY(0); 
  box-shadow: 0 1px 4px var(--accent-glow);
}

.btn-secondary {
  padding: 8px 16px;
  background: var(--bg-hover);
  color: var(--text);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover { background: var(--border); }

.btn-danger {
  padding: 8px 16px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-danger:hover { background: #c0392b; }

/* Main App Layout */
.main-app {
  display: grid;
  grid-template-columns: 72px 240px 1fr;
  grid-template-rows: 1fr 52px;
  height: 100vh;
}

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

.server-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text);
  flex-shrink: 0;
  position: relative;
}

.server-icon::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 4px;
  height: 40px;
  background: var(--text);
  border-radius: 0 4px 4px 0;
  transition: var(--transition);
}

.server-icon.active::before {
  transform: translateY(-50%) scaleY(1);
}

.server-icon:hover {
  border-radius: var(--radius-lg);
  background: var(--accent);
  box-shadow: var(--shadow-glow);
}

.server-icon.active {
  border-radius: var(--radius-lg);
  background: var(--accent);
  box-shadow: var(--shadow-glow);
}

.server-icon.home-icon.active {
  background: var(--accent);
}

.server-icon.add-server:hover {
  background: var(--green);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 20px rgba(35, 165, 89, 0.35);
}

.server-icon.add-server {
  background: var(--bg-dark);
  color: var(--green);
}

.server-icon.add-server::before {
  display: none;
}

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

/* Channel Sidebar */
.channel-sidebar {
  grid-column: 2;
  grid-row: 1 / 3;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.2);
  box-shadow: 0 1px 0 rgba(4,4,5,0.2);
}

.sidebar-header span {
  font-size: 16px;
  font-weight: 700;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.friend-section {
  margin-bottom: 8px;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 8px 4px;
  letter-spacing: 0.5px;
}

/* Friend/DM List Items */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  position: relative;
}

.list-item:hover {
  background: var(--bg-hover);
  transform: translateX(2px);
}

.list-item.active {
  background: var(--bg-medium);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
  position: relative;
}

.avatar-large {
  width: 40px;
  height: 40px;
  font-size: 16px;
}

.avatar-small {
  width: 24px;
  height: 24px;
  font-size: 12px;
}

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

.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--text-faint); }

.list-item-info {
  flex: 1;
  overflow: hidden;
}

.list-item-name {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-sub {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.action-btn {
  background: var(--bg-hover);
  border: none;
  color: var(--text);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: var(--transition);
}

.action-btn:hover { 
  background: var(--accent); 
  transform: scale(1.05);
}
.action-btn.accept:hover { background: var(--green); }
.action-btn.decline:hover { background: var(--red); }

/* Channel Items */
.channel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 2px;
  position: relative;
}

.channel-item:hover {
  background: var(--bg-hover);
  color: var(--text);
  transform: translateX(2px);
}

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

.channel-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--text);
  border-radius: 0 3px 3px 0;
}

.channel-icon {
  opacity: 0.7;
}

.voice-channel-item .channel-name {
  color: var(--text-muted);
}

.voice-participant {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 36px;
  font-size: 14px;
  color: var(--text-muted);
}

/* Chat Area */
.chat-area {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-medium);
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.2);
  box-shadow: 0 1px 0 rgba(4,4,5,0.2);
  flex-shrink: 0;
}

.chat-header span {
  font-size: 16px;
  font-weight: 700;
}

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

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

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.empty-state h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.message-group {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  margin-top: 12px;
  animation: msgIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-group:first-child {
  margin-top: 0;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  font-size: 16px;
}

.message-content {
  flex: 1;
}

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

.message-sender {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

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

.message-text {
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
}

/* Message Input */
.message-input-container {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
  flex-shrink: 0;
}

#message-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-light);
  border: none;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: var(--transition);
}

#message-input:focus {
  background: var(--bg-hover);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

#send-btn {
  width: auto;
  padding: 0 24px;
}

/* Voice Panel */
.voice-panel {
  padding: 12px 16px;
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.voice-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.voice-panel-header span:first-child {
  color: var(--green);
  font-size: 14px;
  font-weight: 600;
}

.voice-panel-header span:last-child {
  color: var(--text-muted);
  font-size: 13px;
}

.voice-participants {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.voice-participant-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-medium);
  border-radius: 20px;
  font-size: 13px;
}

.voice-participant-item.muted {
  opacity: 0.6;
}

.voice-controls {
  display: flex;
  gap: 8px;
}

.voice-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-medium);
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.voice-btn:hover { background: var(--bg-hover); }
.voice-btn.active { background: var(--red); }
.voice-btn.disconnect:hover { background: var(--red); }

/* User Panel */
.user-panel {
  grid-column: 3;
  grid-row: 2;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.user-info:hover { background: var(--bg-hover); }

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

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

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

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

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: overlayIn 0.2s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-medium);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-large {
  max-width: 800px;
}

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

.modal-input {
  margin-bottom: 12px;
}

.search-results {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Admin Panel */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.admin-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--bg-dark);
  padding: 16px;
  border-radius: var(--radius-sm);
  flex: 1;
  min-width: 120px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.admin-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

.admin-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.admin-content { display: none; }
.admin-content.active { display: block; }

.admin-table {
  width: 100%;
  font-size: 13px;
}

.admin-table th {
  text-align: left;
  padding: 8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 8px;
  border-bottom: 1px solid var(--bg-dark);
}

.admin-table .btn-secondary {
  padding: 4px 10px;
  font-size: 12px;
}

.admin-table .btn-danger {
  padding: 4px 10px;
  font-size: 12px;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-dark);
  color: var(--text);
  padding: 14px 20px;
  border-radius: var(--radius);
  border-left: 4px solid var(--accent);
  font-size: 14px;
  animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-md);
  max-width: 360px;
}

.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }

@keyframes toastIn {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { 
  background: rgba(255,255,255,0.08); 
  border-radius: 4px; 
  transition: var(--transition);
}
::-webkit-scrollbar-thumb:hover { 
  background: rgba(255,255,255,0.15); 
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

/* Typing indicator */
.typing-indicator {
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 16px;
  font-style: italic;
  min-height: 20px;
}

/* Responsive */
@media (max-width: 768px) {
  .main-app {
    grid-template-columns: 56px 200px 1fr;
  }
  .server-icon { width: 40px; height: 40px; }
}
