/* ================================================
   NEXXBURG — style.css
   ================================================ */

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

:root {
  --bg-primary:    #313338;
  --bg-secondary:  #2b2d31;
  --bg-tertiary:   #1e1f22;
  --bg-hover:      #35373c;
  --bg-active:     #404249;
  --bg-input:      #383a40;
  --bg-modal:      rgba(0, 0, 0, 0.7);
  --text-primary:  #dbdee1;
  --text-secondary:#b5bac1;
  --text-muted:    #80848e;
  --accent:        #5865f2;
  --accent-hover:  #4752c4;
  --green:         #23a559;
  --red:           #f23f43;
  --yellow:        #f0b232;
  --border:        #3f4147;
  --scrollbar:     #1a1b1e;
  --font:          'Inter', sans-serif;
}

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

/* ================================================
   SCROLLBAR
   ================================================ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }

/* ================================================
   AUTH SCREEN
   ================================================ */
#authScreen {
  position: fixed;
  inset: 0;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-box {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.auth-box h1 {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  margin-bottom: 8px;
}

.auth-box p.sub {
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 24px;
  font-size: 14px;
}

.auth-tabs {
  display: flex;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: 0.2s;
}

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

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  transition: 0.2s;
  font-family: var(--font);
}

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

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 12px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
  font-family: var(--font);
}

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

.auth-error {
  background: rgba(242, 63, 67, 0.15);
  border: 1px solid var(--red);
  border-radius: 4px;
  padding: 10px;
  font-size: 13px;
  color: #f87171;
  margin-bottom: 12px;
  display: none;
}

/* ================================================
   APP LAYOUT
   ================================================ */
#app {
  display: none;
  width: 100%;
  height: 100vh;
}

#app.visible { display: flex; }

/* ================================================
   SERVER RAIL
   ================================================ */
.server-rail {
  width: 72px;
  min-width: 72px;
  background: var(--bg-tertiary);
  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(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  transition: 0.2s;
  flex-shrink: 0;
}

.server-icon:hover,
.server-icon.active { border-radius: 16px; }

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

/* ================================================
   SIDEBAR
   ================================================ */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 0 16px;
  height: 48px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.channels-section {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.section-label {
  padding: 16px 8px 4px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin: 1px 8px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 15px;
  transition: 0.15s;
  position: relative;
}

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

.channel-item.active { background: var(--bg-active); color: #fff; }

.channel-icon { width: 18px; text-align: center; flex-shrink: 0; }
.channel-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.online-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

/* ================================================
   USER PANEL (bottom of sidebar)
   ================================================ */
.user-panel {
  background: var(--bg-tertiary);
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

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

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

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

.panel-btn {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: 0.15s;
}

.panel-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.panel-btn svg { width: 18px; height: 18px; }

/* ================================================
   CHAT MAIN
   ================================================ */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-primary);
}

.chat-header-name { font-weight: 700; font-size: 16px; color: #fff; }

.chat-header-topic {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================================================
   MESSAGES
   ================================================ */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
}

.welcome-msg {
  padding: 40px 16px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.welcome-msg h2 { font-size: 32px; font-weight: 800; color: #fff; margin-bottom: 8px; }
.welcome-msg p { color: var(--text-secondary); font-size: 15px; }

.message-group {
  padding: 2px 16px;
  display: flex;
  gap: 16px;
  position: relative;
}

.message-group:hover { background: rgba(4, 4, 5, 0.07); }

.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  overflow: hidden;
  cursor: pointer;
}

.msg-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

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

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

.msg-author {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}

.msg-author:hover { text-decoration: underline; }

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

.msg-text {
  font-size: 16px;
  color: var(--text-primary);
  line-height: 1.375;
  word-break: break-word;
}

.msg-img {
  max-width: 400px;
  max-height: 300px;
  border-radius: 4px;
  margin-top: 8px;
  cursor: pointer;
  display: block;
}

/* ================================================
   TYPING INDICATOR
   ================================================ */
.typing-indicator {
  padding: 4px 16px;
  font-size: 13px;
  color: var(--text-muted);
  height: 24px;
  flex-shrink: 0;
}

.typing-dots span {
  display: inline-block;
  animation: typingDot 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 80%, 100% { opacity: 0; }
  40%            { opacity: 1; }
}

/* ================================================
   CHAT INPUT
   ================================================ */
.chat-input-area {
  padding: 0 16px 16px;
  flex-shrink: 0;
  position: relative;
}

.chat-input-box {
  background: var(--bg-input);
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0 16px;
}

.chat-input-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 16px;
  padding: 12px 0;
  font-family: var(--font);
}

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

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

.input-btn:hover { color: var(--text-primary); }
.input-btn svg { width: 20px; height: 20px; }

/* ================================================
   EMOJI PANEL
   ================================================ */
.emoji-panel {
  position: absolute;
  bottom: 64px;
  left: 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  width: 220px;
  z-index: 100;
  display: none;
}

.emoji-panel.open { display: block; }

.emoji-row { display: flex; gap: 4px; flex-wrap: wrap; padding: 4px 0; }

.emoji-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: 0.15s;
}

.emoji-btn:hover { background: var(--bg-hover); }

/* ================================================
   MEMBERS BAR
   ================================================ */
.members-bar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-secondary);
  padding: 16px 0;
  overflow-y: auto;
  flex-shrink: 0;
}

.members-section-label {
  padding: 16px 8px 4px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

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

.member-av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
}

.member-av-img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }

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

.status-ring.online  { background: var(--green); }
.status-ring.offline { background: var(--text-muted); }

.member-name {
  font-size: 15px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

/* ================================================
   MODAL
   ================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-secondary);
  border-radius: 8px;
  width: 100%;
  max-width: 460px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  padding: 16px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 { font-size: 20px; font-weight: 700; color: #fff; }

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 4px;
}

.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 16px; }

/* Profile modal */
.profile-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.profile-avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 28px;
  color: #fff;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.profile-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.avatar-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: 0.2s;
  border-radius: 50%;
  font-size: 12px;
  color: #fff;
  font-weight: 600;
  text-align: center;
}

.profile-avatar-large:hover .avatar-overlay { opacity: 1; }
.profile-form .form-group input { background: var(--bg-tertiary); }

.save-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  font-family: var(--font);
}

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

/* ================================================
   TOAST
   ================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--green);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: 0.3s;
  pointer-events: none;
}

.toast.show  { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); }

/* ================================================
   MOBILE RESPONSIVE — Tablet & Phone
   ================================================ */

/* Tablet (≤768px) — hide members bar */
@media (max-width: 768px) {
  .members-bar { display: none !important; }

  .server-rail {
    width: 56px;
    min-width: 56px;
  }

  .server-icon {
    width: 40px;
    height: 40px;
    font-size: 15px;
  }

  .sidebar {
    width: 200px;
    min-width: 200px;
  }
}

/* Phone (≤540px) — overlay sidebar, full-screen chat */
@media (max-width: 540px) {
  body { overflow: hidden; }

  /* Hide server rail on small phones */
  .server-rail { display: none; }

  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    height: 100vh;
    width: 260px;
    min-width: 260px;
    z-index: 300;
    transition: left 0.25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }

  .sidebar.open { left: 0; }

  /* Overlay behind the open sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 299;
  }

  .sidebar-overlay.visible { display: block; }

  /* Chat takes full width */
  .chat-main {
    width: 100vw;
    min-width: 0;
  }

  /* Mobile chat header — hamburger button */
  .chat-header {
    padding: 0 12px;
    gap: 6px;
  }

  .mobile-menu-btn {
    display: flex !important;
  }

  .chat-header-topic { display: none; }

  /* Messages */
  .message-group { padding: 4px 10px; gap: 10px; }
  .msg-avatar    { width: 34px; height: 34px; font-size: 13px; }
  .msg-author    { font-size: 14px; }
  .msg-text      { font-size: 14px; }
  .msg-img       { max-width: 100%; }

  /* Input area */
  .chat-input-area { padding: 0 8px 12px; }

  .chat-input-box { padding: 0 10px; border-radius: 24px; }
  .chat-input-box input { font-size: 15px; padding: 10px 0; }

  /* Welcome message */
  .welcome-msg { padding: 24px 12px 16px; }
  .welcome-msg h2 { font-size: 22px; }

  /* Profile modal full-screen on phone */
  .modal { max-width: 100%; margin: 0 12px; }

  /* Emoji panel repositioned */
  .emoji-panel { left: 8px; right: 8px; width: auto; bottom: 60px; }

  /* Members bar never shows on phone */
  .members-bar { display: none !important; }
}

/* Mobile menu button — hidden on desktop */
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  flex-shrink: 0;
}

.mobile-menu-btn:hover { color: var(--text-primary); }
.mobile-menu-btn svg   { width: 22px; height: 22px; }