/* ============================================================
   WEBBURNS CHAT — LAYOUT
   Discord-like 3-column layout system
   ============================================================ */

/* ── App Shell ─────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 72px 260px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Server Rail (Left Icon Bar) ───────────────────────────── */
.server-rail {
  background: var(--color-base-900);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 10;
}

.server-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-lg);
  color: var(--color-base-100);
  background: var(--color-base-700);
  border: 1px solid var(--glass-border);
  transition: all var(--dur-normal) var(--ease-out);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}

.server-icon:hover, .server-icon.active {
  border-radius: var(--radius-lg);
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.server-icon.active::before {
  content: '';
  position: absolute; left: -16px; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 36px;
  background: #fff;
  border-radius: 0 4px 4px 0;
}

.server-icon.home-icon {
  background: var(--gradient-primary);
  color: #fff;
  margin-bottom: 4px;
}

.server-separator {
  width: 32px; height: 2px;
  background: var(--glass-border);
  border-radius: 1px;
  margin: 4px 0;
  flex-shrink: 0;
}

.server-icon.add-server {
  color: var(--accent-emerald);
  background: rgba(16,185,129,0.1);
  border-color: rgba(16,185,129,0.2);
}

.server-icon.add-server:hover {
  background: var(--accent-emerald);
  color: #fff;
}

/* ── Channel Sidebar ───────────────────────────────────────── */
.channel-sidebar {
  background: var(--color-base-800);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
}

.sidebar-header h2 {
  font-size: var(--text-lg);
  font-weight: 700;
}

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

.sidebar-header .header-action-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-base-100);
  transition: all var(--dur-fast) var(--ease-out);
}

.sidebar-header .header-action-btn:hover {
  background: var(--color-base-600);
  color: #fff;
}

/* Sidebar Scrollable Content */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* Channel Categories */
.channel-category {
  margin-bottom: 16px;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-base-200);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
}

.category-header:hover {
  color: var(--color-base-white);
}

.category-header i.chevron {
  font-size: 10px;
  transition: transform var(--dur-fast) var(--ease-out);
}

.category-header.collapsed i.chevron {
  transform: rotate(-90deg);
}

/* Channel Items */
.channel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--color-base-200);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  position: relative;
}

.channel-item:hover {
  background: var(--color-base-700);
  color: var(--color-base-white);
}

.channel-item.active {
  background: var(--color-base-600);
  color: var(--color-base-white);
}

.channel-item i {
  font-size: var(--text-sm);
  opacity: 0.6;
  width: 20px;
  text-align: center;
}

.channel-item.active i {
  opacity: 1;
}

.channel-item .unread-badge {
  margin-left: auto;
  background: var(--color-danger);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

/* DM Items */
.dm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}

.dm-item:hover {
  background: var(--color-base-700);
}

.dm-item.active {
  background: var(--color-base-600);
}

.dm-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm);
  font-weight: 600;
  color: #fff;
  position: relative;
  flex-shrink: 0;
}

.dm-avatar .status-dot {
  position: absolute; bottom: -1px; right: -1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--color-base-800);
}

.dm-avatar .status-dot.online { background: var(--color-success); }
.dm-avatar .status-dot.idle { background: var(--color-warning); }
.dm-avatar .status-dot.dnd { background: var(--color-danger); }
.dm-avatar .status-dot.offline { background: var(--color-base-400); }

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

.dm-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-base-100);
}

.dm-item.active .dm-name,
.dm-item:hover .dm-name {
  color: var(--color-base-white);
}

.dm-preview {
  font-size: var(--text-xs);
  color: var(--color-base-400);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* User Panel (Bottom of Sidebar) */
.user-panel {
  padding: 8px;
  border-top: 1px solid var(--glass-border);
  background: rgba(0,0,0,0.2);
}

.user-panel-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  transition: background var(--dur-fast) var(--ease-out);
}

.user-panel-inner:hover {
  background: var(--color-base-700);
}

.user-panel-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: var(--text-sm); color: #fff;
  position: relative; flex-shrink: 0;
}

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

.user-panel-name {
  font-size: var(--text-sm); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.user-panel-status {
  font-size: var(--text-xs);
  color: var(--color-base-200);
}

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

.user-panel-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-base-200);
  font-size: var(--text-sm);
  transition: all var(--dur-fast) var(--ease-out);
}

.user-panel-btn:hover {
  background: var(--color-base-600);
  color: #fff;
}

/* ── Main Content Area ─────────────────────────────────────── */
.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-base-900);
  position: relative;
}

/* Main Header */
.main-header {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--glass-border);
  background: var(--color-base-800);
  gap: 12px;
  flex-shrink: 0;
}

.main-header .channel-name {
  font-size: var(--text-base);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.main-header .channel-name i {
  color: var(--color-base-200);
}

.main-header .channel-topic {
  font-size: var(--text-sm);
  color: var(--color-base-200);
  border-left: 1px solid var(--glass-border);
  padding-left: 12px;
  margin-left: 4px;
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.main-header .header-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.header-tool-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-base-100);
  transition: all var(--dur-fast) var(--ease-out);
}

.header-tool-btn:hover {
  background: var(--color-base-600);
  color: #fff;
}

.header-tool-btn.active {
  color: var(--accent-indigo);
}

/* Header Search */
.header-search {
  display: flex;
  align-items: center;
  background: var(--color-base-900);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  gap: 6px;
  width: 200px;
  transition: all var(--dur-normal) var(--ease-out);
}

.header-search:focus-within {
  border-color: var(--glass-border-active);
  width: 280px;
}

.header-search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-base-white);
  font-size: var(--text-sm);
  width: 100%;
}

.header-search input::placeholder {
  color: var(--color-base-400);
}

.header-search i {
  color: var(--color-base-400);
  font-size: var(--text-sm);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 72px 220px 1fr; }
  .header-search { width: 160px; }
  .header-search:focus-within { width: 200px; }
}

@media (max-width: 768px) {
  /* ── App Shell: single column ── */
  .app-shell { grid-template-columns: 1fr; }
  .server-rail { display: none; }

  /* ── Channel sidebar: off-canvas drawer ── */
  .channel-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 280px; z-index: var(--z-overlay);
    transform: translateX(-100%);
    transition: transform var(--dur-slow) var(--ease-out);
  }
  .channel-sidebar.open { transform: translateX(0); }

  /* ── Mobile overlay ── */
  .mobile-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: calc(var(--z-overlay) - 1);
    opacity: 0; pointer-events: none;
    transition: opacity var(--dur-normal) var(--ease-out);
  }
  .mobile-overlay.show { opacity: 1; pointer-events: all; }

  /* ── Show hamburger menu button ── */
  .mobile-menu-btn { display: flex !important; }

  /* ── Main header: compact ── */
  .main-header { padding: 0 8px; gap: 6px; }
  .main-header .channel-topic { display: none; }
  .main-header .header-tools { gap: 2px; }

  /* ── Hide non-essential header buttons on mobile ── */
  .header-search { display: none; }
  #call-btn, #video-call-btn, #pinned-btn, #theme-toggle-btn { display: none; }

  /* ── Chat messages: less padding ── */
  .chat-messages { padding: 8px; }
  .msg-group { padding: 4px 8px; gap: 10px; }
  .msg-group.start { padding-top: 8px; }
  .msg-avatar { width: 32px; height: 32px; font-size: var(--text-xs); }

  /* ── Chat input area ── */
  .chat-input-area { padding: 0 8px 8px; }
  .chat-input-row { padding: 6px 8px; gap: 4px; }
  .chat-input-field { font-size: var(--text-sm); }
  .chat-input-action { width: 32px; height: 32px; }
  .chat-send-btn { width: 32px; height: 32px; }

  /* ── Emoji/GIF picker: full width ── */
  .emoji-picker-popup {
    position: fixed !important; bottom: 60px !important;
    left: 8px !important; right: 8px !important;
    width: auto !important; max-width: none;
    max-height: 300px !important;
  }

  /* ── Voice room: compact ── */
  .voice-room-content { padding: 24px 16px; }
  .voice-room-header { margin-bottom: 24px; }
  .voice-room-icon { width: 56px; height: 56px; font-size: 22px; }
  .voice-room-header h2 { font-size: var(--text-xl); }
  .voice-room-users { gap: 12px; margin-bottom: 24px; }
  .voice-room-user { padding: 10px; min-width: 90px; }
  .voice-room-user-avatar { width: 44px; height: 44px; font-size: 14px; }
  .voice-ctrl-btn { width: 40px; height: 40px; }

  /* ── Voice connected panel ── */
  .voice-connected-panel { padding: 8px 10px; }
  .vc-panel-btn { height: 36px; min-width: 36px; }

  /* ── Call overlay ── */
  .call-videos { grid-template-columns: 1fr; gap: 8px; padding: 8px; }
  .call-controls { gap: 8px; padding: 12px; }
  .call-ctrl-btn { width: 44px; height: 44px; font-size: var(--text-base); }
  .call-ctrl-btn.end-call { width: 52px; height: 52px; }

  /* ── Context menu: fit mobile screen ── */
  #user-context-menu { max-width: calc(100vw - 16px); }

  /* ── Profile modal: full width ── */
  #profile-modal-overlay > div { max-width: calc(100vw - 32px) !important; }

  /* ── Toast notifications ── */
  .toast-container { left: 8px; right: 8px; top: 8px; }
  .toast { min-width: auto; max-width: 100%; }

  /* ── Info panel ── */
  .info-panel { width: 100% !important; max-width: none !important; }

  /* ── User panel touch targets ── */
  .user-panel-btn { width: 36px; height: 36px; }
  .dm-item { padding: 10px; }
  .channel-item { padding: 10px; }
}

/* ── Settings panel responsive ── */
@media (max-width: 768px) {
  .settings-panel {
    flex-direction: column;
  }
  .settings-sidebar {
    width: 100%; border-right: none;
    border-bottom: 1px solid var(--glass-border);
    padding: 12px 8px;
    display: flex; flex-wrap: wrap; gap: 4px;
    overflow-x: auto; overflow-y: hidden;
    min-height: auto; max-height: none;
  }
  .settings-sidebar h3 { width: 100%; padding: 4px 8px !important; }
  .settings-nav-item {
    padding: 8px 12px; font-size: var(--text-xs);
    white-space: nowrap;
  }
  .settings-content {
    flex: 1; padding: 16px; overflow-y: auto;
    max-width: 100%;
  }
  .settings-section h2 { font-size: var(--text-lg); }
  .settings-close { top: 8px; right: 8px; z-index: 10; }
  .settings-row { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* ── Theme grid compact ── */
  .theme-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .theme-card { padding: 10px; }
}

/* ── Extra small screens (< 380px) ── */
@media (max-width: 380px) {
  .auth-card { padding: 24px 20px; margin: 8px; }
  .auth-logo h1 { font-size: var(--text-xl); }
  .auth-social-btns { flex-direction: column; }
  .auth-tabs { font-size: var(--text-xs); }

  .channel-sidebar { width: 260px; }
  .chat-input-row { gap: 2px; }
  .voice-room-user { min-width: 80px; }
  .voice-room-controls { flex-wrap: wrap; justify-content: center; }
}

.mobile-menu-btn { display: none; }