/* ═══════════════════════════════════════════════════════════
   LOCALGRAM — Main Stylesheet
   ═══════════════════════════════════════════════════════════ */

/* ─── Google Fonts fallback ─────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── Design Tokens ─────────────────────────────────────── */
:root {
  --font: 'Inter', system-ui, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --transition: 0.2s ease;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.12);
  --shadow: 0 4px 24px rgba(0,0,0,.18);
  --shadow-lg: 0 8px 48px rgba(0,0,0,.28);

  --primary: #6c5ce7;
  --primary-light: #a29bfe;
  --primary-dark: #5641e5;
  --primary-glow: rgba(108,92,231,.35);
  --danger: #e17055;
  --success: #00b894;
  --warning: #fdcb6e;

  /* Sidebar width */
  --sidebar-w: 320px;
}

/* ─── Dark Theme (default) ──────────────────────────────── */
[data-theme="dark"] {
  --bg: #0f0f13;
  --bg-2: #16161d;
  --surface: #1e1e2a;
  --surface-2: #252535;
  --surface-3: #2d2d42;
  --border: rgba(255,255,255,.06);
  --border-hover: rgba(255,255,255,.12);
  --text: #e4e4f0;
  --text-2: #9999b3;
  --text-3: #5a5a78;
  --msg-own-bg: #312d6b;
  --msg-own-bg-2: #3d3880;
  --msg-other-bg: #252535;
  --active-item: rgba(108,92,231,.18);
  --active-item-border: rgba(108,92,231,.6);
  --input-bg: #252535;
  --scrollbar: rgba(255,255,255,.08);
  --glass-bg: rgba(20,20,30,.7);
  --glass-border: rgba(255,255,255,.08);
}

/* ─── Light Theme ───────────────────────────────────────── */
[data-theme="light"] {
  --bg: #f0f0f5;
  --bg-2: #e8e8f0;
  --surface: #ffffff;
  --surface-2: #f5f5fa;
  --surface-3: #ebebf5;
  --border: rgba(0,0,0,.07);
  --border-hover: rgba(0,0,0,.14);
  --text: #1a1a2e;
  --text-2: #555570;
  --text-3: #9999b3;
  --msg-own-bg: #6c5ce7;
  --msg-own-bg-2: #7d6df0;
  --msg-other-bg: #ffffff;
  --active-item: rgba(108,92,231,.1);
  --active-item-border: rgba(108,92,231,.5);
  --input-bg: #f5f5fa;
  --scrollbar: rgba(0,0,0,.1);
  --glass-bg: rgba(255,255,255,.72);
  --glass-border: rgba(255,255,255,.5);
}

/* ─── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

ul { list-style: none; }

/* ─── Scrollbars ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ─── Utility ────────────────────────────────────────────── */
.hidden { display: none !important; }
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  outline: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  box-shadow: 0 4px 24px var(--primary-glow);
  transform: translateY(-1px);
}
.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-3); border-color: var(--border-hover); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: rgba(225,112,85,.15); color: var(--danger); }

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  box-shadow: 0 2px 12px var(--primary-glow);
  flex-shrink: 0;
}
.send-btn:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 4px 20px var(--primary-glow);
}
.send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: .02em;
}
.hint {
  color: var(--text-3);
  font-weight: 400;
  font-size: 12px;
}
.form-group input {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-group input::placeholder { color: var(--text-3); }
.form-error {
  font-size: 13px;
  color: var(--danger);
  min-height: 18px;
  margin-bottom: 6px;
}

/* ─── Avatar ─────────────────────────────────────────────── */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  transition: transform var(--transition);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }
.avatar.xl { width: 72px; height: 72px; font-size: 26px; }

.avatar-online::after {
  content: '';
  position: absolute;
  bottom: 1px; right: 1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--surface);
}
.avatar-offline::after {
  content: '';
  position: absolute;
  bottom: 1px; right: 1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-3);
  border: 2px solid var(--surface);
}

/* ─── AUTH SCREEN ─────────────────────────────────────────── */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
.auth-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .35;
  animation: orbFloat 8s ease-in-out infinite;
}
.orb-1 { width: 500px; height: 500px; background: var(--primary); top: -200px; left: -100px; animation-delay: 0s; }
.orb-2 { width: 400px; height: 400px; background: #00b894; bottom: -150px; right: -100px; animation-delay: -3s; }
.orb-3 { width: 300px; height: 300px; background: #fd79a8; top: 40%; left: 60%; animation-delay: -6s; }

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 30px) scale(.95); }
}

.auth-card {
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-xl);
  padding: 36px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-lg);
  animation: cardIn .4s ease;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}
.auth-logo-icon svg { filter: drop-shadow(0 4px 12px var(--primary-glow)); }
.auth-title { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.auth-subtitle { font-size: 13px; color: var(--text-2); }

.auth-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
  gap: 4px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 6px;
  background: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
}
.auth-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

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

.btn-loader {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── APP LAYOUT ─────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* ─── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform var(--transition);
  z-index: 20;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sidebar-actions { display: flex; align-items: center; gap: 4px; }

.me-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.me-card:hover { background: var(--surface-2); }
.me-info { flex: 1; min-width: 0; }
.me-name { font-size: 14px; font-weight: 600; display: block; truncate: ellipsis; white-space: nowrap; overflow: hidden; }
.me-username { font-size: 12px; color: var(--text-3); display: block; }
.online-badge { color: var(--success); font-size: 16px; }

.sidebar-search { padding: 10px 12px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  border: 1px solid var(--border);
  transition: border-color var(--transition);
}
.search-box:focus-within { border-color: var(--primary); }
.search-box svg { color: var(--text-3); flex-shrink: 0; }
.search-box input {
  background: none;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  width: 100%;
}
.search-box input::placeholder { color: var(--text-3); }

.sidebar-section { display: flex; flex-direction: column; overflow: hidden; }
.sidebar-section:last-child { flex: 1; overflow: hidden; }
.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.chat-list {
  overflow-y: auto;
  flex: 1;
  padding: 0 8px 8px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  border: 1.5px solid transparent;
}
.chat-item:hover { background: var(--surface-2); }
.chat-item.active {
  background: var(--active-item);
  border-color: var(--active-item-border);
}
.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item-preview {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.chat-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.chat-item-time {
  font-size: 11px;
  color: var(--text-3);
}
.unread-badge {
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

/* Channel icon */
.channel-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
}

/* ─── CHAT AREA ───────────────────────────────────────────── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  background: var(--bg-2);
  position: relative;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-2);
}
.empty-illustration { animation: float 4s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.empty-state h2 { font-size: 22px; font-weight: 600; color: var(--text); }
.empty-state p { font-size: 14px; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 64px;
  flex-shrink: 0;
  z-index: 5;
}
.mobile-back { display: none; }
.chat-header-avatar {}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-size: 15px; font-weight: 600; }
.chat-header-sub { font-size: 12px; color: var(--text-2); }

/* ─── Messages ───────────────────────────────────────────── */
.messages-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
.messages-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 8px;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}
.load-more-wrapper { display: flex; justify-content: center; margin-bottom: 10px; }

/* Day separator */
.day-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 8px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
}
.day-separator::before, .day-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Message bubble */
.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 4px;
  animation: msgIn .2s ease;
  max-width: 100%;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg.own { flex-direction: row-reverse; }
.msg.grouped .msg-avatar { visibility: hidden; }
.msg.grouped .msg-bubble { margin-top: 0; }

.msg-avatar { flex-shrink: 0; cursor: pointer; }

.msg-content { max-width: min(60%, 540px); display: flex; flex-direction: column; }
.msg.own .msg-content { align-items: flex-end; }

.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
  padding: 0 4px;
}
.msg.own .msg-meta { flex-direction: row-reverse; }
.msg-author { font-size: 12px; font-weight: 600; color: var(--primary-light); }
.msg-time { font-size: 11px; color: var(--text-3); }
.msg.grouped .msg-meta { display: none; }

.msg-bubble {
  padding: 9px 13px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
  transition: background var(--transition);
}
.msg.own .msg-bubble {
  background: linear-gradient(135deg, var(--msg-own-bg), var(--msg-own-bg-2));
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg:not(.own) .msg-bubble {
  background: var(--msg-other-bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

/* Image message */
.msg-image {
  border-radius: var(--radius-sm);
  max-width: 300px;
  max-height: 300px;
  object-fit: cover;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  width: 100%;
}
.msg-image:hover { opacity: .9; transform: scale(1.01); }

/* File message */
.msg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,.08);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
  color: inherit;
  min-width: 180px;
}
.msg-file:hover { background: rgba(255,255,255,.14); }
.msg-file-icon { font-size: 28px; }
.msg-file-info { min-width: 0; }
.msg-file-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.msg-file-size { font-size: 11px; opacity: .7; }

/* Reply preview in bubble */
.msg-reply-preview {
  border-left: 3px solid var(--primary-light);
  padding: 4px 8px;
  margin-bottom: 6px;
  border-radius: 0 4px 4px 0;
  background: rgba(255,255,255,.06);
  font-size: 12px;
  cursor: pointer;
}
.msg-reply-preview .reply-name { font-weight: 600; color: var(--primary-light); }

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 4px;
  font-size: 13px;
  color: var(--text-3);
  font-style: italic;
}
.typing-dots { display: flex; gap: 3px; align-items: center; }
.typing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* ─── INPUT AREA ─────────────────────────────────────────── */
.input-area {
  padding: 10px 12px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  position: relative;
}

.reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.reply-bar { width: 3px; height: 36px; background: var(--primary); border-radius: 2px; flex-shrink: 0; }
.reply-content { flex: 1; min-width: 0; }
.reply-author { font-size: 12px; font-weight: 600; color: var(--primary-light); display: block; }
.reply-text { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.drop-zone {
  position: absolute;
  inset: 0;
  background: var(--surface);
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 10;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  animation: dropPulse 1.5s ease-in-out infinite;
}
@keyframes dropPulse {
  0%, 100% { border-color: var(--primary); }
  50% { border-color: var(--primary-light); }
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.attach-btn { cursor: pointer; }
.message-input-wrap { flex: 1; }
textarea#message-input {
  width: 100%;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  resize: none;
  outline: none;
  max-height: 140px;
  overflow-y: auto;
  line-height: 1.5;
  transition: border-color var(--transition), box-shadow var(--transition);
  display: block;
}
textarea#message-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
textarea#message-input::placeholder { color: var(--text-3); }

/* ─── MODAL ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%;
  max-width: 440px;
  border-radius: var(--radius-xl);
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.92) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 24px; }
.profile-avatar-section {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

/* ─── LIGHTBOX ───────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: zoom-out;
  animation: fadeIn .2s ease;
}
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  line-height: 1;
  opacity: .8;
  transition: opacity var(--transition);
  z-index: 1;
}
.lightbox-close:hover { opacity: 1; }

/* ─── TOAST ──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface-3);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--primary);
  animation: toastIn .3s ease;
  pointer-events: auto;
}
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); }
}

/* ─── RESPONSIVE (Mobile) ────────────────────────────────── */
@media (max-width: 680px) {
  :root { --sidebar-w: 100vw; }

  .app { position: relative; }

  .sidebar {
    position: absolute;
    left: 0; top: 0;
    height: 100%;
    transform: translateX(0);
  }
  .sidebar.mobile-hidden {
    transform: translateX(-100%);
    pointer-events: none;
  }

  .chat-area {
    position: absolute;
    inset: 0;
    transform: translateX(100%);
    transition: transform var(--transition);
  }
  .chat-area.mobile-visible {
    transform: translateX(0);
  }

  .mobile-back { display: flex; }

  .msg-content { max-width: 82%; }

  .auth-card { margin: 16px; padding: 28px 24px; }
}

/* ═══════════════════════════════════════════════════════════
   VERIFIED BADGE
   ═══════════════════════════════════════════════════════════ */

.verified-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  vertical-align: middle;
  position: relative;
  top: -1px;
  animation: badgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.verified-badge svg {
  filter: drop-shadow(0 0 4px rgba(79, 156, 249, 0.6));
  transition: transform 0.2s ease;
}

.verified-badge:hover svg {
  transform: scale(1.2);
}

@keyframes badgePop {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════
   SECTION ADD BUTTON ("+")
   ═══════════════════════════════════════════════════════════ */

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 4px;
}

.section-add-btn {
  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
  padding: 0 !important;
  border-radius: 6px !important;
  color: var(--text-2);
  opacity: 0.6;
  transition: opacity var(--transition), background var(--transition), color var(--transition);
}

.section-add-btn:hover {
  opacity: 1;
  color: var(--primary-light);
  background: rgba(108,92,231,.15) !important;
}

/* ═══════════════════════════════════════════════════════════
   CHANNEL ICONS (broadcast vs group)
   ═══════════════════════════════════════════════════════════ */

.channel-icon-broadcast {
  background: linear-gradient(135deg, #00b894, #00cec9) !important;
}

.channel-icon-group {
  background: linear-gradient(135deg, var(--primary), var(--primary-light)) !important;
}

/* ═══════════════════════════════════════════════════════════
   CREATE CHANNEL MODAL — TYPE SELECTOR
   ═══════════════════════════════════════════════════════════ */

.channel-type-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.channel-type-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  background: var(--surface-2);
  user-select: none;
}

.channel-type-option input[type="radio"] {
  display: none;
}

.channel-type-option:hover {
  border-color: var(--primary-light);
  background: var(--active-item);
  transform: translateY(-1px);
}

.channel-type-option.active {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.12);
  box-shadow: 0 0 0 3px rgba(108,92,231,.15);
}

.type-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--primary-light);
  flex-shrink: 0;
  transition: background var(--transition);
}

.channel-type-option.active .type-icon {
  background: rgba(108,92,231,.2);
  color: var(--primary-light);
}

.type-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 2px;
}

.type-desc {
  font-size: 0.75rem;
  color: var(--text-2);
  line-height: 1.3;
}

/* ═══════════════════════════════════════════════════════════
   ADMIN CONTEXT MENU
   ═══════════════════════════════════════════════════════════ */

.context-menu {
  position: fixed;
  z-index: 9999;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: ctxFadeIn 0.12s ease;
}

@keyframes ctxFadeIn {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.context-menu-item:hover {
  background: var(--active-item);
  color: var(--primary-light);
}

.context-menu-item svg {
  color: var(--success);
  flex-shrink: 0;
}

.context-menu-item--edit svg { color: var(--primary-light); }
.context-menu-item--danger { color: var(--danger) !important; }
.context-menu-item--danger svg { color: var(--danger); }
.context-menu-item--danger:hover { background: rgba(225,112,85,.1) !important; color: var(--danger) !important; }

/* ═══════════════════════════════════════════════════════════
   ADMIN PANEL MODAL
   ═══════════════════════════════════════════════════════════ */

.admin-modal {
  width: min(680px, 96vw) !important;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.admin-modal .modal-body {
  overflow-y: auto;
  padding: 0;
  flex: 1;
}

.admin-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary-light);
}

.admin-modal-title svg { flex-shrink: 0; }

.admin-loading {
  padding: 40px;
  text-align: center;
  color: var(--text-2);
  font-size: 0.9rem;
}

.admin-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.admin-user-row:last-child { border-bottom: none; }
.admin-user-row:hover { background: var(--surface-2); }

.admin-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.admin-user-meta { min-width: 0; }

.admin-user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.admin-user-username {
  font-size: 0.78rem;
  color: var(--text-2);
  margin-top: 1px;
}

.admin-user-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.admin-verify-btn {
  background: rgba(0,184,148,.12) !important;
  color: var(--success) !important;
  border: 1px solid rgba(0,184,148,.3) !important;
  font-size: 0.76rem !important;
}
.admin-verify-btn:hover { background: rgba(0,184,148,.25) !important; }

.admin-delete-btn {
  background: rgba(225,112,85,.12) !important;
  color: var(--danger) !important;
  border: 1px solid rgba(225,112,85,.3) !important;
  font-size: 0.76rem !important;
}
.admin-delete-btn:hover { background: rgba(225,112,85,.25) !important; }

.admin-self-label {
  font-size: 0.75rem;
  color: var(--text-3);
  padding: 4px 8px;
}

.admin-badge {
  font-size: 0.82rem;
  margin-left: 2px;
}

/* ═══════════════════════════════════════════════════════════
   EDIT USER MODAL — TABS
   ═══════════════════════════════════════════════════════════ */

.edit-user-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.edit-tab {
  flex: 1;
  padding: 8px 16px;
  border-radius: calc(var(--radius-sm) - 2px);
  border: none;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.edit-tab:hover { color: var(--text); }

.edit-tab.active {
  background: var(--surface);
  color: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

.edit-panel { display: none; }
.edit-panel.active { display: block; }

