/* ============================================
   TalkBuzz v3.0 — 3-Tab Mobile-First Layout
   Home | Search | Profile + Chat Overlay
   ============================================ */

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #273548;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --accent: #22d3ee;
  --online: #22c55e;
  --sent: #94a3b8;
  --read: #22d3ee;
  --danger: #ef4444;
  --border: #334155;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --font: 'Inter', -apple-system, sans-serif;
  --transition: 0.2s ease;
  --header-height: 56px;
  --tab-bar-height: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, textarea, button { font-family: inherit; }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.hidden { display: none !important; }

/* === Loading Screen === */
.loading-screen { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--bg); }
.loading-logo { animation: pulse 1.5s ease-in-out infinite; }
.loading-text { font-size: 28px; font-weight: 700; margin-top: 16px; background: linear-gradient(135deg, #6366f1, #22d3ee); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.loading-dots { display: flex; gap: 6px; margin-top: 20px; }
.loading-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: bounce 1.4s ease-in-out infinite; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* === Auth Screen === */
#auth-screen { display: flex; align-items: center; justify-content: center; height: 100vh; height: 100dvh; overflow-y: auto; }
.auth-container { text-align: center; padding: 40px 20px; max-width: 400px; width: 100%; margin: 0 auto; }
.auth-logo { margin-bottom: 24px; }
.auth-title { font-size: 32px; font-weight: 700; background: linear-gradient(135deg, #6366f1, #22d3ee); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 8px; }
.auth-subtitle { color: var(--muted); font-size: 16px; margin-bottom: 32px; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 24px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.auth-tab { flex: 1; padding: 12px; border: none; background: var(--surface); color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; transition: all var(--transition); }
.auth-tab.active { background: var(--primary); color: white; }
.auth-tab:not(.active):hover { background: var(--surface-hover); }
.auth-form { text-align: left; }
.auth-input-group { margin-bottom: 14px; }
.auth-input-group label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.auth-input-wrapper { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 14px; transition: border-color var(--transition); }
.auth-input-wrapper:focus-within { border-color: var(--primary); }
.auth-input-icon { color: var(--muted); flex-shrink: 0; }
.auth-input-wrapper input { flex: 1; border: none; background: none; color: var(--text); font-size: 14px; padding: 12px 0; outline: none; }
.auth-input-wrapper input::placeholder { color: var(--muted); }
.auth-hint { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.password-toggle { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; display: flex; align-items: center; transition: color var(--transition); flex-shrink: 0; }
.password-toggle:hover { color: var(--text); }
.username-status { font-size: 12px; font-weight: 600; }
.username-status.success { color: var(--online); }
.username-status.error { color: var(--danger); }
.password-strength { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.pw-bar { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.pw-fill { height: 100%; border-radius: 2px; transition: width 0.3s ease; }
.pw-label { font-size: 11px; font-weight: 600; white-space: nowrap; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-divider span { color: var(--muted); font-size: 13px; }
.auth-link-btn { background: none; border: none; color: var(--primary); font-size: 13px; font-weight: 500; cursor: pointer; margin-top: 8px; text-align: center; width: 100%; }
.auth-buttons { display: flex; flex-direction: column; gap: 10px; }
.auth-btn { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px 24px; border-radius: var(--radius); font-size: 15px; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; transition: all var(--transition); }
.auth-btn:hover { background: var(--surface-hover); border-color: var(--primary); transform: translateY(-1px); }
.google-btn:hover { border-color: #4285F4; }
.anonymous-btn { border-style: dashed; }
.auth-footer { color: var(--muted); font-size: 12px; margin-top: 28px; }
.primary-btn { width: 100%; background: var(--primary); color: white; border: none; border-radius: var(--radius-sm); padding: 14px 24px; font-size: 15px; font-weight: 600; cursor: pointer; transition: all var(--transition); display: flex; align-items: center; justify-content: center; gap: 10px; }
.primary-btn:hover { background: var(--primary-hover); transform: translateY(-1px); }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: var(--radius-sm); border: none; background: var(--primary); color: white; font-weight: 600; cursor: pointer; transition: all var(--transition); }
.btn-sm:hover { background: var(--primary-hover); }
.btn-spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; }
.forgot-status { margin-top: 12px; font-size: 13px; text-align: center; }

/* === Offline Banner === */
.offline-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 999; padding: 8px 16px; background: #f59e0b; color: #000; text-align: center; font-size: 13px; font-weight: 600; animation: slideDown 0.3s ease; }
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }

/* === Main App Layout === */
.screen { height: 100vh; height: 100dvh; }
.app-container { position: relative; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

/* === Tab Panels === */
.tab-panel { display: none; flex-direction: column; flex: 1; min-height: 0; }
.tab-panel.active { display: flex; }
.tab-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.tab-title { font-size: 22px; font-weight: 700; background: linear-gradient(135deg, #6366f1, #22d3ee); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.icon-btn { width: 40px; height: 40px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; transition: all var(--transition); }
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

/* === Tab Search Bar === */
.tab-search { padding: 8px 16px; background: var(--surface); flex-shrink: 0; }
.search-bar { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 24px; padding: 10px 16px; transition: border-color var(--transition); }
.search-bar:focus-within { border-color: var(--primary); }
.search-bar input { flex: 1; border: none; background: none; color: var(--text); font-size: 14px; outline: none; }
.search-bar input::placeholder { color: var(--muted); }

/* === Chat List (Home Tab) === */
.chat-list { flex: 1; overflow-y: auto; padding: 8px; }
.chat-list .chat-item { animation: listItemIn 0.25s ease both; }
.chat-list .chat-item:nth-child(1) { animation-delay: 0ms; }
.chat-list .chat-item:nth-child(2) { animation-delay: 30ms; }
.chat-list .chat-item:nth-child(3) { animation-delay: 60ms; }
.chat-list .chat-item:nth-child(4) { animation-delay: 90ms; }
.chat-list .chat-item:nth-child(5) { animation-delay: 120ms; }
.chat-list .chat-item:nth-child(n+6) { animation-delay: 150ms; }
@keyframes listItemIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius);
  cursor: pointer; transition: background var(--transition);
  position: relative;
}
.chat-item:hover { background: var(--surface-hover); }
.chat-item:active { background: rgba(99,102,241,0.1); }
.chat-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1, #22d3ee);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: white; overflow: hidden;
  position: relative;
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-avatar .dm-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--bg);
}
.chat-avatar .dm-dot.online { background: var(--online); }
.chat-avatar .dm-dot.offline { background: var(--muted); }
.chat-content { flex: 1; min-width: 0; }
.chat-top { display: flex; justify-content: space-between; align-items: baseline; }
.chat-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 11px; color: var(--muted); white-space: nowrap; flex-shrink: 0; margin-left: 8px; }
.chat-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.chat-last-msg { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.chat-typing { font-size: 13px; color: var(--accent); font-weight: 500; font-style: italic; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: typingPulse 1.5s ease-in-out infinite; }
@keyframes typingPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.chat-badge { min-width: 20px; height: 20px; border-radius: 10px; background: var(--primary); color: white; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 6px; flex-shrink: 0; margin-left: 8px; animation: badgePop 0.2s ease; }
@keyframes badgePop { 0% { transform: scale(0); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }
.tab-btn-icon-wrap { position: relative; display: inline-flex; }
.tab-badge {
  position: absolute; top: -6px; right: -10px;
  min-width: 16px; height: 16px; border-radius: 8px;
  background: var(--danger); color: white;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; line-height: 1;
  animation: badgePop 0.2s ease;
}

/* === People List (Search Tab) === */
.people-list { flex: 1; overflow-y: auto; padding: 8px; }
.people-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius);
  cursor: pointer; transition: background var(--transition);
}
.people-item:hover { background: var(--surface-hover); }
.people-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1, #22d3ee);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: white; overflow: hidden;
  position: relative;
}
.people-avatar img { width: 100%; height: 100%; object-fit: cover; }
.online-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--bg); background: var(--muted);
}
.people-avatar.online .online-dot { background: var(--online); }
.people-info { flex: 1; min-width: 0; }
.people-name { font-size: 15px; font-weight: 600; }
.people-meta { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people-chat-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: rgba(99,102,241,0.15); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition); flex-shrink: 0;
}
.people-chat-btn:hover { background: var(--primary); color: white; }

/* === Profile Tab === */
.profile-content { flex: 1; overflow-y: auto; padding: 0 16px 100px; }
.profile-card { text-align: center; padding: 32px 16px 24px; }
.profile-avatar {
  width: 80px; height: 80px; border-radius: 50%; margin: 0 auto 12px;
  background: linear-gradient(135deg, #6366f1, #22d3ee);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 28px; color: white; overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 22px; font-weight: 700; }
.profile-email { font-size: 13px; color: var(--muted); margin-top: 4px; }
.profile-username { display: inline-block; margin-top: 8px; font-size: 13px; color: var(--primary); font-weight: 500; background: rgba(99,102,241,0.1); padding: 4px 12px; border-radius: 20px; }
.profile-section { margin-top: 24px; }
.profile-section h3 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }
.bio-editor textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 14px; resize: none; outline: none; min-height: 72px;
  transition: border-color var(--transition);
}
.bio-editor textarea:focus { border-color: var(--primary); }
.bio-editor textarea::placeholder { color: var(--muted); }
.bio-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.bio-char-count { font-size: 12px; color: var(--muted); }
.profile-menu { display: flex; flex-direction: column; gap: 2px; }
.menu-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 14px; cursor: pointer; transition: all var(--transition);
  text-decoration: none; border: none; width: 100%; text-align: left;
}
.menu-item:hover { background: var(--surface-hover); text-decoration: none; }
.menu-item span:first-of-type { flex: 1; }
.menu-item svg:first-child { color: var(--primary); flex-shrink: 0; }
.menu-toggle { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; }
.menu-toggle.on { color: var(--online); background: rgba(34,197,94,0.1); }
.menu-toggle.off { color: var(--danger); background: rgba(239,68,68,0.1); }
.about-text { font-size: 13px; color: var(--muted); line-height: 1.6; }
.version-text { font-size: 12px; color: var(--muted); margin-top: 8px; }
.logout-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; margin-top: 24px; padding: 14px;
  border-radius: var(--radius); border: 1px solid var(--danger);
  background: transparent; color: var(--danger); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
}
.logout-btn:hover { background: rgba(239,68,68,0.1); }

/* === Bottom Tab Bar === */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--tab-bar-height);
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  border: none; background: none; color: var(--muted);
  font-size: 11px; font-weight: 500; cursor: pointer;
  transition: color var(--transition); padding: 8px 0;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn.active { color: var(--primary); }
.tab-btn:not(.active):hover { color: var(--text); }
.tab-btn svg { transition: transform 0.2s ease; }
.tab-btn.active svg { transform: scale(1.1); }

/* === Chat View (Full-screen overlay) === */
.chat-view {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; flex-direction: column;
  animation: slideInRight 0.2s ease;
}
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
.chat-view-header {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; height: var(--header-height);
  background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.chat-view-info { flex: 1; min-width: 0; }
.chat-view-name { font-size: 16px; font-weight: 600; }
.chat-view-status { font-size: 12px; color: var(--muted); }

/* === Messages === */
.messages-container { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; }
.messages { display: flex; flex-direction: column; gap: 4px; margin-top: auto; }
.message { display: flex; flex-direction: column; max-width: 80%; }
.message.own { align-self: flex-end; }
.message.other { align-self: flex-start; }
.message-bubble { padding: 10px 14px; border-radius: 18px; font-size: 14px; line-height: 1.45; word-wrap: break-word; }
.message.own .message-bubble { background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.message.other .message-bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.message-sender { font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 3px; }
.message.own .message-sender { color: rgba(255,255,255,0.7); }
.message-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 11px; color: var(--muted); justify-content: flex-end; }
.message.own .message-meta { color: rgba(255,255,255,0.5); }
.message-status { font-size: 14px; line-height: 1; }
.message-status.read { color: var(--read); }
.message-status.delivered { color: var(--sent); }
.message-date-divider { text-align: center; padding: 16px 0 8px; font-size: 12px; color: var(--muted); font-weight: 500; position: relative; }
.message-date-divider span { background: var(--bg); padding: 0 12px; position: relative; z-index: 1; }
.message-date-divider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--border); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* === Typing Indicator === */
.typing-indicator { padding: 4px 16px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.typing-dots { display: flex; gap: 3px; }
.typing-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: bounce 1.4s ease-in-out infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* === Message Input === */
.message-input-area { padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0)); }
.input-wrapper { display: flex; align-items: flex-end; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 24px; padding: 6px 6px 6px 16px; transition: border-color var(--transition); }
.input-wrapper:focus-within { border-color: var(--primary); }
#message-input { flex: 1; border: none; background: none; color: var(--text); font-size: 14px; resize: none; outline: none; max-height: 120px; line-height: 1.4; padding: 6px 0; }
#message-input::placeholder { color: var(--muted); }
.send-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: white; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--transition); flex-shrink: 0; }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.send-btn:not(:disabled):hover { background: var(--primary-hover); transform: scale(1.05); }

/* === Empty Tab State === */
.empty-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; text-align: center; }
.empty-tab-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-tab p { font-size: 16px; font-weight: 600; color: var(--text); }
.empty-tab span { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* === Modal === */
.modal-overlay { position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn 0.2s ease; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 500px; max-height: 80vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-close { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--bg); color: var(--muted); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { color: var(--text); }

/* === Admin Panel === */
.admin-tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 16px; }
.admin-tab { padding: 12px 16px; border: none; background: none; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; transition: all var(--transition); }
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.admin-content { padding: 16px; }
.admin-section { margin-bottom: 20px; }
.admin-section h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--accent); }
.admin-input { width: 100%; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 14px; margin-bottom: 8px; outline: none; }
.admin-input:focus { border-color: var(--primary); }
.admin-btn { padding: 10px 20px; border-radius: var(--radius-sm); border: none; background: var(--primary); color: white; font-size: 13px; font-weight: 600; cursor: pointer; transition: all var(--transition); }
.admin-btn:hover { background: var(--primary-hover); }
.admin-btn.danger { background: var(--danger); }
.user-list-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 8px; }
.user-list-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.user-list-info { flex: 1; min-width: 0; }
.user-list-name { font-size: 13px; font-weight: 600; }
.user-list-email { font-size: 11px; color: var(--muted); }

/* === Toast === */
#toast-container { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 10px 20px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards; white-space: nowrap; pointer-events: auto; }
.toast.success { border-color: var(--online); color: var(--online); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.info { border-color: var(--accent); color: var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* === Skeleton Loaders === */
.skeleton { position: relative; overflow: hidden; background: var(--surface); border-radius: var(--radius-sm); }
.skeleton::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent); animation: shimmer 1.5s infinite; }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.skeleton-chat-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); }
.skeleton-avatar { width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; }
.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skeleton-line { height: 12px; border-radius: 6px; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-msg { display: flex; flex-direction: column; gap: 4px; max-width: 60%; }
.skeleton-msg.own { align-self: flex-end; align-items: flex-end; }
.skeleton-msg.other { align-self: flex-start; align-items: flex-start; }
.skeleton-bubble { height: 40px; border-radius: 18px; }
.skeleton-msg:nth-child(1) .skeleton-bubble { width: 55%; }
.skeleton-msg:nth-child(2) .skeleton-bubble { width: 75%; }
.skeleton-msg:nth-child(3) .skeleton-bubble { width: 45%; }
.skeleton-msg:nth-child(4) .skeleton-bubble { width: 65%; }

/* === Update Banner === */
.update-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 9999; padding: 12px 16px; background: var(--primary); color: white; text-align: center; font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 12px; animation: slideDown 0.3s ease; }
.update-banner button { background: white; color: var(--primary); border: none; padding: 6px 16px; border-radius: 20px; font-size: 12px; font-weight: 700; cursor: pointer; transition: transform 0.15s ease; }
.update-banner button:hover { transform: scale(1.05); }

/* === Smooth Transitions (Global) === */
.chat-item { transition: background var(--transition), transform 0.15s ease; }
.chat-item:active { transform: scale(0.98); }
.people-item { transition: background var(--transition), transform 0.15s ease; }
.people-item:active { transform: scale(0.98); }
.menu-item { transition: background var(--transition), transform 0.15s ease; }
.menu-item:active { transform: scale(0.98); }
.icon-btn { transition: background var(--transition), transform 0.15s ease; }
.icon-btn:active { transform: scale(0.9); }
.modal { animation: modalIn 0.25s ease; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.tab-panel { animation: tabFadeIn 0.25s ease; }
@keyframes tabFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* === Message slide-in — only the newest message === */
.message-new { animation: msgSlideIn 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
.message-new.own { animation-name: msgSlideRight; }
.message-new.other { animation-name: msgSlideLeft; }
@keyframes msgSlideRight { from { opacity: 0; transform: translateY(12px) translateX(20px); } to { opacity: 1; transform: translateY(0) translateX(0); } }
@keyframes msgSlideLeft { from { opacity: 0; transform: translateY(12px) translateX(-20px); } to { opacity: 1; transform: translateY(0) translateX(0); } }
@keyframes msgSlideIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* === New message glow highlight === */
.message-new-glow .message-bubble { animation: newMsgGlow 0.8s ease-out; }
@keyframes newMsgGlow { 0% { box-shadow: 0 0 0 0 rgba(99,102,241,0.5); } 40% { box-shadow: 0 0 0 6px rgba(99,102,241,0.15); } 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); } }

/* === Add People button in chat header === */
.add-people-btn { width: 36px; height: 36px; border-radius: 50%; border: none; background: rgba(99,102,241,0.15); color: var(--primary); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--transition); flex-shrink: 0; }
.add-people-btn:hover { background: var(--primary); color: white; transform: scale(1.1); }
.add-people-btn:active { transform: scale(0.95); }

/* === Member list in add-people modal === */
.member-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px; background: rgba(99,102,241,0.1); color: var(--primary); font-size: 13px; font-weight: 500; border: 1px solid var(--border); }
.member-chip .remove-member { cursor: pointer; color: var(--danger); font-weight: 700; margin-left: 4px; transition: transform 0.15s ease; }
.member-chip .remove-member:hover { transform: scale(1.2); }


/* === Chat Placeholder (shown when no chat selected on desktop) === */
.chat-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; }
.chat-placeholder-inner { text-align: center; opacity: 0.6; }
.chat-placeholder-inner h2 { font-size: 24px; font-weight: 700; background: linear-gradient(135deg, #6366f1, #22d3ee); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-top: 16px; }
.chat-placeholder-inner p { color: var(--muted); font-size: 14px; margin-top: 8px; }
.chat-active-content { display: flex; flex-direction: column; height: 100%; }
.hidden-desktop { display: none; }

/* ============================================
   Desktop Layout (>=768px)
   Sidebar tabs + chat list + chat panel side-by-side
   ============================================ */
@media (min-width: 768px) {
  /* Show hidden-desktop elements, hide mobile-only */
  .hidden-desktop { display: flex; }

  /* App container becomes horizontal */
  .app-container {
    flex-direction: row;
    overflow: hidden;
  }

  /* Tab bar becomes vertical sidebar on the LEFT */
  .tab-bar {
    position: relative;
    bottom: auto; left: auto; right: auto;
    order: -1;
    width: 72px;
    height: 100%;
    flex-direction: column;
    border-top: none;
    border-right: 1px solid var(--border);
    padding-bottom: 0;
    justify-content: flex-start;
    padding-top: 16px;
    gap: 4px;
    z-index: 10;
    flex-shrink: 0;
  }
  .tab-btn { width: 100%; padding: 14px 0; }
  .tab-btn-icon-wrap { position: relative; }
  .tab-badge { top: -4px; right: -8px; }

  /* Tab panels get fixed-width left column */
  .tab-panel {
    width: 360px;
    min-width: 360px;
    max-width: 360px;
    border-right: 1px solid var(--border);
  }

  /* Chat list: show active state on hover */
  .chat-item:hover { background: var(--surface-hover); }
  .chat-item.active { background: rgba(99,102,241,0.15); }

  /* Chat view: inline panel, not overlay */
  .chat-view {
    position: relative;
    inset: auto;
    z-index: 1;
    flex: 1;
    animation: none;
    border-left: none;
  }

  /* Profile content bottom padding */
  .profile-content { padding-bottom: 24px; }

  /* Toast position */
  #toast-container { bottom: 24px; }

  /* Messages: wider bubbles for desktop readability */
  .messages {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }
  .message { max-width: 60%; }

  /* Input area */
  .message-input-area { padding-bottom: 12px; }

  /* Hide back button on desktop (no need in sidebar layout) */
  .chat-view-header .icon-btn:first-child { display: none; }

  /* Auth container: larger on desktop */
  .auth-container { padding: 48px 40px; }

  /* Scrollbar: wider on desktop */
  ::-webkit-scrollbar { width: 6px; }

  /* Search bar: more padding */
  .tab-search { padding: 10px 16px; }
}

@media (min-width: 1024px) {
  .tab-panel {
    width: 400px;
    min-width: 400px;
    max-width: 400px;
  }
  .tab-title { font-size: 24px; }
  .chat-placeholder-inner svg { width: 100px; height: 100px; }
  .chat-placeholder-inner h2 { font-size: 28px; }
}
