/* ═══════════════════════════════════════════════════════
   NEXUS MESSENGER — CSS
   Telegram-inspired dark/light design
═══════════════════════════════════════════════════════ */

:root {
  --bg-primary: #212121;
  --bg-secondary: #2b2b2b;
  --bg-tertiary: #363636;
  --bg-input: #2b2b2b;
  --surface: #1e1e1e;
  --surface-2: #282828;
  --border: rgba(255,255,255,0.08);
  --text-primary: #f0f0f0;
  --text-secondary: #8b8b8b;
  --text-muted: #5c5c5c;
  --accent: #2AABEE;
  --accent-hover: #1e96d8;
  --accent-light: rgba(42,171,238,0.15);
  --msg-out: #2b5278;
  --msg-out-hover: #345e8a;
  --msg-in: #2b2b2b;
  --msg-in-hover: #323232;
  --danger: #e53935;
  --success: #43a047;
  --warning: #fb8c00;
  --online: #4caf50;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-msg: 18px;
  --sidebar-width: 360px;
  --header-h: 60px;
  --input-h: 64px;
  --transition: 0.2s ease;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Auth Screen ─────────────────────────────────────────── */
.auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  z-index: 1000;
}

.auth-bg {
  position: absolute; inset: 0;
  overflow: hidden; pointer-events: none;
}

.auth-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
  animation: blobFloat 8s ease-in-out infinite;
}

.blob1 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #2AABEE, transparent 70%);
  top: -100px; left: -100px;
  animation-delay: 0s;
}

.blob2 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, #229ED9, transparent 70%);
  bottom: -80px; right: -80px;
  animation-delay: -3s;
}

.blob3 {
  width: 250px; height: 250px;
  background: radial-gradient(circle, #5B9CF6, transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -6s;
}

@keyframes blobFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(20px, -20px) scale(1.05); }
  66% { transform: translate(-15px, 15px) scale(0.95); }
}

.auth-card {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  width: 420px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.4s ease;
}

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

.auth-logo {
  display: flex; align-items: center; gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
  font-size: 28px; font-weight: 700;
  color: var(--text-primary);
}

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

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

.auth-tab.active {
  background: var(--accent);
  color: white;
}

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

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

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

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition);
  resize: vertical;
}

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

.input-wrap {
  position: relative;
}

.input-wrap input { padding-right: 44px; }

.eye-btn {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-secondary);
  padding: 4px;
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 8px;
}

.auth-btn, .save-btn {
  width: 100%;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
  transition: background var(--transition), transform 0.1s;
}

.auth-btn:hover, .save-btn:hover { background: var(--accent-hover); }
.auth-btn:active, .save-btn:active { transform: scale(0.98); }

/* ── App Layout ────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 10;
}

.sidebar-header {
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-wrap {
  flex: 1;
  position: relative;
  display: flex; align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-secondary);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid transparent;
  border-radius: 20px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 36px 8px 34px;
  outline: none;
  transition: border-color var(--transition);
}

.search-wrap input:focus {
  border-color: var(--accent);
}

.search-clear {
  position: absolute;
  right: 8px;
  background: none; border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
}

/* Sidebar menu */
.sidebar-menu {
  position: absolute;
  top: calc(var(--header-h) + 4px);
  left: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  z-index: 100;
  min-width: 200px;
  box-shadow: var(--shadow-lg);
  animation: menuSlide 0.15s ease;
}

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

.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: background var(--transition);
}

.menu-item:hover { background: var(--bg-primary); }
.menu-item.danger { color: var(--danger); }
.menu-separator { height: 1px; background: var(--border); margin: 4px 0; }

/* Chat list */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.chat-list-loading {
  display: flex; justify-content: center;
  padding: 40px;
}

.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}

.chat-item:hover { background: var(--bg-tertiary); }
.chat-item.active { background: var(--accent-light); }
.chat-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.chat-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600;
  color: var(--text-primary);
  background-image: linear-gradient(135deg, #2AABEE22, #229ED922);
  overflow: hidden;
  position: relative;
}

.chat-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.online-dot {
  position: absolute;
  bottom: 1px; right: 1px;
  width: 12px; height: 12px;
  background: var(--online);
  border: 2px solid var(--bg-secondary);
  border-radius: 50%;
}

.chat-item-body { flex: 1; min-width: 0; }

.chat-item-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 3px;
}

.chat-item-name {
  font-size: 15px; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}

.chat-item-time {
  font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-left: 8px;
}

.chat-item-bottom {
  display: flex; align-items: center; justify-content: space-between;
}

.chat-item-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}

.unread-badge {
  background: var(--accent);
  color: white;
  font-size: 11px; font-weight: 600;
  min-width: 20px; height: 20px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
  margin-left: 8px;
}

/* Search results */
.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.search-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 16px 4px;
}

/* ── Main Panel ─────────────────────────────────────────── */
.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* Chat wallpaper pattern */
.main-panel::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.03) 1px, transparent 0);
  background-size: 32px 32px;
  pointer-events: none;
}

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-secondary);
}

.empty-icon { animation: pulse 3s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.empty-state h2 { font-size: 22px; color: var(--text-primary); }
.empty-state p { font-size: 14px; text-align: center; max-width: 280px; }

/* Chat area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

/* Chat header */
.chat-header {
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px 0 12px;
  flex-shrink: 0;
  z-index: 5;
}

.back-btn { display: none; }

.chat-header-info {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  min-width: 0;
}

.chat-header-info .chat-avatar {
  width: 40px; height: 40px;
  font-size: 15px;
}

.chat-header-name {
  font-size: 15px; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.chat-header-status {
  font-size: 12px;
  color: var(--text-secondary);
}

.chat-header-status.online { color: var(--accent); }

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

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

.messages-loader {
  display: flex; justify-content: center;
  padding: 20px;
}

/* Message bubble */
.message-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin: 1px 0;
  animation: msgIn 0.15s ease;
}

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

.message-wrapper.out { flex-direction: row-reverse; }

.msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  align-self: flex-end;
}

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

.message-bubble {
  max-width: 68%;
  background: var(--msg-in);
  border-radius: var(--radius-msg);
  padding: 8px 12px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
}

.message-bubble:hover { background: var(--msg-in-hover); }

.message-wrapper.out .message-bubble {
  background: var(--msg-out);
  border-bottom-right-radius: 6px;
}

.message-wrapper.out .message-bubble:hover { background: var(--msg-out-hover); }
.message-wrapper:not(.out) .message-bubble { border-bottom-left-radius: 6px; }

.msg-sender-name {
  font-size: 12px; font-weight: 600;
  color: var(--accent);
  margin-bottom: 3px;
}

.msg-reply {
  background: rgba(255,255,255,0.07);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.msg-reply-name { color: var(--accent); font-weight: 600; font-size: 11px; }

.msg-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-image {
  max-width: 300px; max-height: 300px;
  border-radius: 10px;
  cursor: pointer;
  display: block;
  object-fit: cover;
}

.msg-file {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text-primary);
}

.msg-file-icon { font-size: 24px; }
.msg-file-info { flex: 1; min-width: 0; }
.msg-file-name {
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.msg-audio {
  width: 220px;
}

.msg-audio audio { width: 100%; }

.msg-video {
  max-width: 300px;
  border-radius: 10px;
  overflow: hidden;
}

.msg-video video { width: 100%; border-radius: 10px; }

.msg-meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  margin-top: 4px;
}

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

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

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

.msg-status.read { color: var(--accent); }

/* Date separator */
.date-separator {
  text-align: center;
  margin: 12px 0;
}

.date-separator span {
  background: rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Typing indicator */
.typing-indicator {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 12px;
  max-width: 60px;
  background: var(--msg-in);
  border-radius: var(--radius-msg);
  border-bottom-left-radius: 6px;
  align-self: flex-start;
  margin-left: 34px;
}

.typing-indicator span {
  width: 6px; height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typingDot 1.2s ease-in-out infinite;
}

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

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Reply preview */
.reply-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.reply-bar { width: 3px; height: 36px; background: var(--accent); border-radius: 2px; flex-shrink: 0; }

.reply-content { flex: 1; min-width: 0; }
.reply-name { font-size: 12px; font-weight: 600; color: var(--accent); }
.reply-text { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Input area */
.input-area {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  display: flex; align-items: flex-end; gap: 8px;
  flex-shrink: 0;
}

.message-input-wrap {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 8px 14px;
  transition: border-color var(--transition);
}

.message-input-wrap:focus-within { border-color: var(--accent); }

.message-input-wrap textarea {
  width: 100%;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
}

.message-input-wrap textarea::placeholder { color: var(--text-secondary); }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

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

.send-btn {
  width: 44px; height: 44px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), transform 0.1s;
  flex-shrink: 0;
}

.send-btn:hover { background: var(--accent-hover); }
.send-btn:active { transform: scale(0.92); }

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
  backdrop-filter: blur(4px);
}

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

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.25s ease;
  box-shadow: var(--shadow-lg);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  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);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 18px; font-weight: 700;
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

/* Settings modal */
.settings-modal { width: 520px; }

.settings-content {
  overflow-y: auto;
  flex: 1;
  padding: 0 24px 24px;
}

.settings-avatar-section {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 0;
  gap: 8px;
}

.settings-avatar {
  width: 90px; height: 90px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700;
  transition: opacity var(--transition);
}

.settings-avatar:hover .avatar-overlay { opacity: 1; }

.avatar-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
}

.settings-avatar img {
  width: 100%; height: 100%; object-fit: cover;
  position: absolute; inset: 0;
}

.settings-name { font-size: 18px; font-weight: 600; }
.settings-username { font-size: 14px; color: var(--text-secondary); }

.settings-section {
  margin-bottom: 24px;
}

.settings-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

/* Chat info modal */
.chat-info-modal { width: 400px; }

.chat-info-content {
  overflow-y: auto;
  flex: 1;
  padding: 20px 24px;
}

.chat-info-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  margin: 0 auto 16px;
  font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-tertiary);
  overflow: hidden;
}

.chat-info-avatar img { width: 100%; height: 100%; object-fit: cover; }

.chat-info-name {
  text-align: center;
  font-size: 20px; font-weight: 700;
  margin-bottom: 4px;
}

.chat-info-sub {
  text-align: center;
  font-size: 13px; color: var(--text-secondary);
  margin-bottom: 20px;
}

.info-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.info-row:last-child { border-bottom: none; }

.info-row-icon { color: var(--accent); flex-shrink: 0; }
.info-row-label { font-size: 11px; color: var(--text-secondary); }
.info-row-value { font-size: 14px; }

.member-list { margin-top: 16px; }
.member-list-title {
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.member-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  cursor: pointer;
}

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

.member-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

.member-avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-name { font-size: 14px; font-weight: 500; }
.member-role { font-size: 11px; color: var(--text-secondary); }

/* Group/contacts modal */
.new-group-modal, .contacts-modal { width: 480px; }

.group-search-results, .contacts-results {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 240px;
  overflow-y: auto;
}

.user-result-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.user-result-item:hover { background: var(--bg-tertiary); }

.user-result-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

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

.user-result-name { font-size: 14px; font-weight: 500; }
.user-result-username { font-size: 12px; color: var(--text-secondary); }

.user-result-action {
  margin-left: auto;
  background: var(--accent-light);
  color: var(--accent);
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.user-result-action:hover { background: var(--accent); color: white; }

.group-selected {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 12px;
}

.selected-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 13px;
}

.selected-chip button {
  background: none; border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
}

/* ── Call Overlay ────────────────────────────────────────── */
.call-overlay {
  position: fixed; inset: 0;
  z-index: 900;
  display: flex; align-items: center; justify-content: center;
}

.call-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  animation: callBgShift 4s ease-in-out infinite;
}

@keyframes callBgShift {
  0%, 100% { filter: hue-rotate(0deg); }
  50% { filter: hue-rotate(20deg); }
}

.call-content {
  position: relative;
  z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
  width: 100%;
  height: 100%;
  padding: 40px 20px 60px;
}

.call-avatar {
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  font-size: 44px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,0.2);
  box-shadow: 0 0 60px rgba(42,171,238,0.4);
  animation: callAvatarPulse 2s ease-in-out infinite;
}

@keyframes callAvatarPulse {
  0%, 100% { box-shadow: 0 0 40px rgba(42,171,238,0.3); }
  50% { box-shadow: 0 0 80px rgba(42,171,238,0.6); }
}

.call-avatar img { width: 100%; height: 100%; object-fit: cover; }

.call-name {
  font-size: 28px; font-weight: 700;
  color: white;
}

.call-status {
  font-size: 15px;
  color: rgba(255,255,255,0.6);
}

/* Video call */
.call-videos {
  flex: 1;
  position: relative;
  width: 100%;
  display: flex; align-items: center; justify-content: center;
}

#remote-video {
  width: 100%; height: 100%;
  max-height: 60vh;
  object-fit: cover;
  border-radius: var(--radius);
  background: #000;
}

#local-video {
  position: absolute;
  bottom: 12px; right: 12px;
  width: 120px; height: 90px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #111;
  border: 2px solid rgba(255,255,255,0.2);
}

.call-controls {
  display: flex; align-items: center; gap: 20px;
  margin-top: auto;
  padding-top: 20px;
}

.call-btn {
  width: 60px; height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  background: rgba(255,255,255,0.15);
  color: white;
  backdrop-filter: blur(10px);
}

.call-btn:hover { background: rgba(255,255,255,0.25); transform: scale(1.05); }
.call-btn.active { background: var(--accent); }
.call-btn.muted { background: var(--danger); }

.end-btn {
  background: var(--danger) !important;
  width: 70px; height: 70px;
}

.end-btn:hover { background: #c62828 !important; }

/* Incoming call */
.incoming-call {
  position: fixed;
  bottom: 20px; right: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px 20px;
  z-index: 800;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-lg);
  animation: incomingSlide 0.3s ease;
  min-width: 300px;
}

@keyframes incomingSlide {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

.incoming-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--accent-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}

.incoming-avatar img { width: 100%; height: 100%; object-fit: cover; }

.incoming-info { flex: 1; }
.incoming-name { font-size: 15px; font-weight: 600; }
.incoming-type { font-size: 12px; color: var(--text-secondary); }

.incoming-actions { display: flex; gap: 10px; }

.call-accept, .call-decline {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s;
  color: white;
}

.call-accept { background: var(--success); }
.call-decline { background: var(--danger); }
.call-accept:hover, .call-decline:hover { transform: scale(1.1); }

/* ── Context Menu ────────────────────────────────────────── */
.context-menu {
  position: fixed;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  z-index: 700;
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  animation: menuSlide 0.15s ease;
}

.ctx-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: background var(--transition);
}

.ctx-item:hover { background: var(--bg-primary); }
.ctx-item.danger { color: var(--danger); }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 14px;
  z-index: 1000;
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease;
  white-space: nowrap;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Image Viewer ─────────────────────────────────────────── */
.image-viewer {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  animation: fadeIn 0.2s ease;
}

.image-viewer img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 8px;
}

.image-viewer-close {
  position: absolute;
  top: 20px; right: 20px;
  background: rgba(255,255,255,0.15);
  border: none; border-radius: 50%;
  color: white; font-size: 20px;
  width: 44px; height: 44px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}

.image-viewer-close:hover { background: rgba(255,255,255,0.25); }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

  .sidebar {
    position: fixed; inset: 0;
    z-index: 50;
    transform: translateX(0);
    transition: transform var(--transition);
  }

  .sidebar.hidden-mobile {
    transform: translateX(-100%);
  }

  .main-panel {
    position: fixed; inset: 0;
  }

  .back-btn { display: flex; }

  .chat-area.active { z-index: 60; }
}

/* ── Utility ─────────────────────────────────────────────── */
.accent { color: var(--accent); }
.text-secondary { color: var(--text-secondary); }
