/* ─── Empty State ──────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  z-index: 1;
  animation: emptyStateFade 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes emptyStateFade {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.empty-state-icon {
  width: 100px; height: 100px;
  margin-bottom: 24px;
  opacity: 0.6;
  animation: floatIcon 4s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-12px) rotate(3deg); }
}

.empty-state-icon svg { width: 100%; height: 100%; }

.empty-state-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state-text { color: var(--text-tertiary); font-size: 0.9rem; }

/* ─── Chat Header ──────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  height: var(--header-height);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  z-index: 2;
  flex-shrink: 0;
  position: relative;
}

.chat-search-bar {
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 5;
  display: flex;
  align-items: center;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-search-inner {
  display: flex;
  align-items: center;
  background: var(--bg-main);
  border-radius: 10px;
  padding: 0 12px;
  width: 100%;
}

/* Toggle Switch Styling */
.menu-item-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toggle-switch {
  width: 36px;
  height: 20px;
  background: var(--bg-active);
  border-radius: 20px;
  position: relative;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.menu-item-toggle.active .toggle-switch {
  background: var(--primary);
}

.menu-item-toggle.active .toggle-switch::after {
  left: 18px;
}

.chat-search-inner .search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
}

.chat-search-inner input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 0.95rem;
  min-width: 0;
}

.chat-search-inner input:focus {
  outline: none;
}

.chat-search-counter {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  padding: 0 6px;
  min-width: 50px;
  text-align: center;
}

.chat-search-nav {
  width: 32px !important;
  height: 32px !important;
  padding: 4px !important;
  flex-shrink: 0;
}

.chat-search-nav svg {
  width: 16px;
  height: 16px;
}

.chat-search-nav:disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* Saved Messages avatar in chat list */
.chat-item-avatar .saved-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.chat-item-avatar .saved-icon svg {
  width: 24px;
  height: 24px;
}

/* Group / Channel avatar */
.group-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.group-avatar svg {
  stroke: rgba(255,255,255,0.9);
  fill: none;
}

/* Profile avatar group styling */
.profile-avatar-large .group-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  font-size: 2rem;
}

.profile-header .group-avatar {
  border: 4px solid rgba(255,255,255,0.3);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.profile-header .group-avatar svg {
  width: 40px;
  height: 40px;
}

/* Profile list member items */
.profile-list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}

.profile-list-item:hover {
  background: var(--bg-hover);
}

.profile-list-item:active {
  background: var(--bg-active);
}

.profile-list-info {
  flex: 1;
  min-width: 0;
}

.profile-list-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-list-status {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.profile-list-status.online {
  color: #2ecc71;
  font-weight: 500;
}

@keyframes headerSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-header-avatar {
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-header-avatar:hover { transform: scale(1.1); }
.chat-header-avatar:active { transform: scale(0.95); }

.back-btn { display: none; }

.chat-header-avatar .avatar {
  width: 42px; height: 42px;
  font-size: 1rem;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.chat-header-name {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-status {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  transition: all 0.3s ease;
}

.chat-header-status.chat-type-info {
  color: var(--primary);
  font-weight: 500;
}

.chat-header-status.online { color: #2ecc71; }

.chat-header-status.typing {
  color: var(--primary);
}

/* Actual typing dots animation */
.typing-anim::after {
  content: '';
  animation: typingDotsAnim 1.5s ease-in-out infinite;
}

@keyframes typingDotsAnim {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

.chat-header-actions { display: flex; gap: 4px; }

/* ─── Messages ─────────────────────────────────────── */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  z-index: 1;
  scroll-behavior: smooth;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 40px 30px;
  min-height: 100%;
  justify-content: flex-end;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  position: relative;
}

@media (max-width: 768px) {
  .messages-list { padding: 0 16px; max-width: 100%; }
}

/* Date separator */
.date-separator {
  display: flex;
  justify-content: center;
  padding: 12px 0;
  animation: dateSepFade 0.5s ease backwards;
}

@keyframes dateSepFade {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.date-separator-label {
  background: rgba(0, 0, 0, 0.12);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 500;
  backdrop-filter: blur(12px);
}

[data-theme="dark"] .date-separator-label {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

/* Messages */
.message {
  max-width: 65%;
  margin-bottom: 2px;
  display: flex;
  flex-direction: column;
  position: relative;
  animation: msgSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.message.outgoing { align-self: flex-end; }
.message.incoming { align-self: flex-start; }

/* Different entry direction based on sender */
.message.incoming {
  animation-name: msgSlideInLeft;
}

.message.outgoing {
  animation-name: msgSlideInRight;
}

@keyframes msgSlideInLeft {
  from { opacity: 0; transform: translateX(-20px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes msgSlideInRight {
  from { opacity: 0; transform: translateX(20px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

.message-bubble {
  padding: 8px 14px 10px;
  border-radius: 20px;
  position: relative;
  word-wrap: break-word;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04), 0 0 1px rgba(0,0,0,0.08);
  line-height: 1.48;
  max-width: 100%;
  transition: box-shadow 0.25s ease, filter 0.25s ease, transform 0.25s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.message-bubble:hover {
  filter: brightness(0.96);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Outgoing */
.message.outgoing .message-bubble {
  background: linear-gradient(135deg, rgba(220, 248, 198, 0.95), rgba(204, 242, 175, 0.95));
  color: #111;
  border: 1px solid rgba(0,0,0,0.04);
}

[data-theme="dark"] .message.outgoing .message-bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

/* Incoming */
.message.incoming .message-bubble {
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-primary);
  border: 1px solid rgba(0,0,0,0.05);
}

[data-theme="dark"] .message.incoming .message-bubble {
  background: rgba(30, 41, 59, 0.85);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Group border radius — Modern rounded grouping */
.message.outgoing.group-single .message-bubble { border-radius: 20px 20px 6px 20px; }
.message.outgoing.group-first .message-bubble  { border-radius: 20px 20px 6px 20px; }
.message.outgoing.group-middle .message-bubble { border-radius: 20px 6px 6px 20px; }
.message.outgoing.group-last .message-bubble   { border-radius: 20px 6px 20px 20px; }

.message.incoming.group-single .message-bubble { border-radius: 20px 20px 20px 6px; }
.message.incoming.group-first .message-bubble  { border-radius: 20px 20px 20px 6px; }
.message.incoming.group-middle .message-bubble { border-radius: 6px 20px 20px 6px; }
.message.incoming.group-last .message-bubble   { border-radius: 6px 20px 20px 20px; }

.message-sender {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 3px;
  color: var(--primary);
}

.message-reply {
  display: flex;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  background: rgba(108, 92, 231, 0.08);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

[data-theme="dark"] .message.outgoing .message-reply {
  background: rgba(255, 255, 255, 0.15);
  border-left-color: #fff;
}
[data-theme="dark"] .message.outgoing .message-reply-name {
  color: #fff;
}
[data-theme="dark"] .message.outgoing .message-reply-text {
  color: rgba(255, 255, 255, 0.8);
}

.message-reply:hover { 
  background: rgba(108, 92, 231, 0.12); 
  transform: scale(0.99);
}
[data-theme="dark"] .message.outgoing .message-reply:hover {
  background: rgba(255, 255, 255, 0.2);
}

.message-reply-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.message-reply-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
}

.message-reply-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Message content wrap — Telegram-style inline time */
.message-content-wrap {
  position: relative;
  display: inline;
}

.message-text {
  font-size: 0.93rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.message-text a { color: var(--text-link); text-decoration: underline; }
.message-text code {
  background: rgba(0,0,0,0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}
[data-theme="dark"] .message-text code { background: rgba(255,255,255,0.08); }

/* Inline meta — sits at the end of the last line of text */
.message-meta-inline {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  float: right;
  margin-top: 4px;
  margin-left: 12px;
  position: relative;
  padding-left: 4px;
}

/* Old message-meta kept for fallback */
.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
}

.message-time {
  font-size: 0.68rem;
  opacity: 0.55;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.message-edited {
  font-size: 0.62rem;
  opacity: 0.5;
  font-style: italic;
}

.message-status {
  display: inline-flex;
  align-items: center;
  width: 20px; height: 14px;
  flex-shrink: 0;
  position: relative;
}

.message-status svg { width: 100%; height: 100%; }

/* Telegram-style sent (single check) */
.message-status.sent {
  color: rgba(255, 255, 255, 0.45);
}

/* Light theme sent check */
.message.outgoing .message-status.sent {
  color: rgba(0, 100, 0, 0.35);
}

[data-theme="dark"] .message.outgoing .message-status.sent {
  color: rgba(255, 255, 255, 0.45);
}

/* Telegram-style read (double check, green) */
.message-status.read {
  color: #4ac959;
  animation: checkAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light theme read check */
.message.outgoing .message-status.read {
  color: #4ac959;
}

[data-theme="dark"] .message.outgoing .message-status.read {
  color: #69d97c;
}

/* Check SVG path transitions */
.message-status .check-1,
.message-status .check-2 {
  transition: opacity 0.2s ease;
}

/* Outgoing message meta — use lighter color */
.message.outgoing .message-time { opacity: 0.65; }

@keyframes checkAppear {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* Highlight for search */
.message-highlight .message-bubble {
  box-shadow: 0 0 0 3px var(--primary), 0 0 20px var(--primary-glow);
  animation: highlightPulse 1s ease 2;
}

@keyframes highlightPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--primary), 0 0 20px var(--primary-glow); }
  50% { box-shadow: 0 0 0 6px var(--primary), 0 0 30px var(--primary-glow); }
}

/* ─── Scroll Bottom Button ────────────────────────── */
.scroll-bottom-btn {
  position: absolute;
  bottom: 80px;
  right: 20px;
  width: 44px; height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-sidebar);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  animation: scrollBtnBounce 0.4s var(--transition-bounce);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scrollBtnBounce {
  from { opacity: 0; transform: scale(0) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.scroll-bottom-btn:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: var(--shadow-xl);
}

.scroll-bottom-btn:active { transform: scale(0.9); }

.scroll-bottom-btn svg { width: 20px; height: 20px; }

.scroll-bottom-btn .unread-badge {
  position: absolute;
  top: -8px;
  left: -8px;
  background: var(--text-danger);
}

/* ─── Reply Preview ────────────────────────────────── */
.reply-preview {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  z-index: 2;
  animation: replySlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes replySlideUp {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}

.reply-preview-content { flex: 1; min-width: 0; }

.reply-preview-name {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
}

.reply-preview-text {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reply-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: rotate(90deg);
}

.reply-close-btn svg { width: 16px; height: 16px; }

/* ─── Message Input ────────────────────────────────── */
.message-input-area {
  padding: 6px 8px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  width: 100%;
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: center;
  animation: inputAreaSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes inputAreaSlide {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  max-width: 900px;
  padding: 2px 0;
  box-sizing: border-box;
}

.input-inner {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 0px;
  min-width: 0;
  background: var(--bg-input);
  padding: 6px 12px 6px 6px;
  border-radius: 24px;
  border: 1px solid var(--border-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-inner:focus-within {
  border-color: var(--primary-light);
  box-shadow: 0 4px 12px var(--primary-bg);
  background: var(--bg-sidebar);
}

#message-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  padding: 5px 0px;
  margin: 0 8px;
  max-height: 180px;
  outline: none;
  resize: none;
  line-height: 1.4;
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
  flex-shrink: 0;
}

.send-btn, .voice-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff !important;
  box-shadow: 0 4px 10px var(--primary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
  border: none;
  cursor: pointer;
}

.input-inner .icon-btn {
  width: 32px; height: 32px;
  color: var(--text-tertiary);
  margin-bottom: 0px;
  transition: all 0.2s ease;
}

.input-inner .icon-btn:hover {
  color: var(--primary);
  background: var(--bg-hover);
  transform: scale(1.1);
}

.send-btn:hover, .voice-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 6px 15px var(--primary-glow);
}

.send-btn:active, .voice-btn:active {
  transform: scale(0.92);
}

.send-btn svg, .voice-btn svg { width: 20px; height: 20px; }

.voice-btn {
  background: var(--bg-input);
  color: var(--text-secondary) !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  border: 1px solid var(--border-light);
}

.voice-btn:hover {
  background: var(--bg-hover);
  color: var(--primary) !important;
}

/* When recording is active */
.voice-btn.recording {
  background: var(--text-danger);
  color: #fff !important;
  animation: pulse 1.5s infinite;
}

/* ─── Emoji Picker ─────────────────────────────────── */
.emoji-picker {
  position: absolute;
  bottom: var(--input-height);
  left: 16px;
  width: 340px;
  height: 360px;
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: emojiPickerIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom left;
}

@keyframes emojiPickerIn {
  from { opacity: 0; transform: scale(0.9) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.emoji-tabs {
  display: flex;
  gap: 2px;
  padding: 6px;
  border-bottom: 1px solid var(--border);
}

.emoji-tab {
  flex: 1;
  padding: 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.emoji-tab:hover { background: var(--bg-hover); transform: scale(1.1); }
.emoji-tab.active { background: var(--primary-bg); transform: scale(1.05); }

.emoji-grid {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  align-content: start;
}

.emoji-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.emoji-item:hover {
  background: var(--bg-hover);
  transform: scale(1.3);
}

/* ─── Attach Menu ──────────────────────────────────── */
.attach-menu {
  position: absolute;
  bottom: calc(var(--input-height) + 10px);
  left: 60px;
  width: 280px;
  background: var(--bg-modal);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  animation: emojiPickerIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom left;
}

.attach-menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.attach-menu-item:hover {
  background: var(--bg-hover);
}

.attach-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.attach-icon.bg-photo { background: #3498db; }
.attach-icon.bg-file { background: #e67e22; }
.attach-icon.bg-poll { background: #2ecc71; }

.attach-icon svg {
  width: 20px; height: 20px;
}

.emoji-item:active { transform: scale(0.9); }

/* ═══════════════════════════════════════════════════════
   USER PROFILE MODAL - REDESIGN
   ═══════════════════════════════════════════════════════ */

.profile-modal-content {
  background: var(--bg-modal);
  width: 100%;
  max-width: 420px;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  animation: profileModalIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  border: 1px solid var(--border-light);
}

@keyframes profileModalIn {
  from { opacity: 0; transform: scale(0.9) translateY(30px); filter: blur(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

.profile-modal-header {
  position: relative;
  height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 24px;
  color: #fff;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.profile-modal-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.7) 100%);
  z-index: 1;
}

.profile-header-main {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 20px;
  animation: profileFadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s backwards;
}

@keyframes profileFadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

#profile-view-avatar {
  border: 4px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#profile-view-avatar:hover {
  transform: scale(1.05) rotate(3deg);
  border-color: #fff;
}

.profile-name-container h2 {
  font-size: 1.6rem;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  margin-bottom: 4px;
}

.profile-modal-header .profile-status {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.8);
}

.profile-header-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  display: flex;
  gap: 8px;
}

.profile-header-actions .icon-btn {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.profile-header-actions .icon-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px) scale(1.1);
}

#profile-modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 3;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.profile-modal-body {
  padding: 24px;
  background: var(--bg-modal);
  border-radius: 32px 32px 0 0;
  margin-top: -32px;
  position: relative;
  z-index: 2;
  box-shadow: 0 -12px 24px rgba(0,0,0,0.1);
}

.profile-info-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.profile-info-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border-radius: 16px;
  transition: all 0.3s ease;
  background: var(--bg-hover);
  border: 1px solid transparent;
}

.profile-info-item:hover {
  background: var(--bg-sidebar);
  border-color: var(--border-light);
  transform: translateX(4px);
  box-shadow: var(--shadow-sm);
}

.info-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.profile-info-item:hover .info-icon {
  transform: scale(1.1) rotate(-5deg);
  background: var(--primary);
  color: #fff;
}

.info-icon svg { width: 22px; height: 22px; }

.info-content {
  flex: 1;
  min-width: 0;
}

.info-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.profile-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-hover);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 20px;
}

.profile-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.profile-tab.active {
  background: var(--bg-modal);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.profile-tab:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(0,0,0,0.02);
}

.profile-actions .btn {
  height: 52px;
  border-radius: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.bio-variations-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.bio-var-group {
  margin-bottom: 0 !important;
  position: relative;
}

.bio-var-group::before {
  content: counter(bio-counter);
  counter-increment: bio-counter;
  position: absolute;
  left: 12px;
  top: 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-tertiary);
  pointer-events: none;
  z-index: 1;
}

.bio-variations-list {
  counter-reset: bio-counter;
}

.bio-variation-input {
  font-size: 0.95rem !important;
  padding: 14px 14px 14px 34px !important;
  border-radius: 12px !important;
  background: var(--bg-hover) !important;
  border: 1px solid transparent !important;
  color: var(--text-primary) !important;
  transition: all 0.3s ease !important;
}

.bio-variation-input:focus {
  background: var(--bg-input) !important;
  border-color: var(--primary) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05), 0 0 0 3px var(--primary-bg) !important;
  transform: translateY(-1px);
}

.avatar-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.avatar-color-option {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

.avatar-color-option:hover { transform: scale(1.15); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }

.avatar-color-option.selected {
  border-color: var(--bg-modal);
  box-shadow: 0 0 0 2px var(--primary), 0 4px 12px var(--primary-glow);
  transform: scale(1.1);
}

/* ═══════════════════════════════════════════════════════
   USER PROFILE MODAL - REDESIGN END
   ═══════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  padding: 20px;
  animation: overlayFadeIn 0.25s ease;
}

@keyframes overlayFadeIn {
  from { opacity: 0; backdrop-filter: blur(0); }
  to { opacity: 1; backdrop-filter: blur(4px); }
}

[data-theme="dark"] .modal-overlay { background: rgba(0, 0, 0, 0.8); }

.modal {
  width: 100%;
  max-width: 440px;
  max-height: 80vh;
  background: var(--bg-modal);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSpring 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSpring {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 1.15rem; font-weight: 600; }

.modal-close {
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-close:hover { transform: rotate(90deg) scale(1.1); }
.modal-close svg { width: 18px; height: 18px; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Typing Dots Inline ───────────────────────────── */
.typing-dots-inline {
  display: inline-flex;
  margin-left: 1px;
}

.typing-dots-inline span {
  animation: typingBounce 1.4s ease-in-out infinite;
  font-weight: 700;
}

.typing-dots-inline span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots-inline span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* ─── Muted Icon ──────────────────────────────────── */
.muted-icon {
  display: inline-block;
  vertical-align: middle;
  opacity: 0.5;
  margin-left: 4px;
}

/* ═══════════════════════════════════════════════════════
   ENHANCED INTERACTION ANIMATIONS
   ═══════════════════════════════════════════════════════ */

/* Send button pop on message send */
@keyframes sendPop {
  0% { transform: scale(1); }
  30% { transform: scale(0.8) rotate(-8deg); }
  60% { transform: scale(1.2) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}

/* Voice button pulse effect */
@keyframes voicePulse {
  0% { transform: scale(1); box-shadow: 0 2px 8px var(--primary-glow); }
  25% { transform: scale(1.15); box-shadow: 0 0 0 8px rgba(108, 92, 231, 0.2), 0 2px 8px var(--primary-glow); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.1), 0 2px 8px var(--primary-glow); }
  75% { transform: scale(1.12); box-shadow: 0 0 0 6px rgba(108, 92, 231, 0.15), 0 2px 8px var(--primary-glow); }
  100% { transform: scale(1); box-shadow: 0 2px 8px var(--primary-glow); }
}

/* Button swap crossfade */
@keyframes btnSwapIn {
  0% { opacity: 0; transform: scale(0.5) rotate(-30deg); }
  60% { opacity: 1; transform: scale(1.1) rotate(5deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

/* FAB spin when opening new chat */
@keyframes fabSpin {
  0% { transform: scale(1) rotate(0); }
  50% { transform: scale(0.9) rotate(180deg); }
  100% { transform: scale(1) rotate(360deg); }
}

/* Chat area slide out on back button (mobile) */
@keyframes chatSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(30px); }
}

/* Auth form cross-fade transitions */
@keyframes authFormOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-12px) scale(0.96); }
}

@keyframes authFormIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Scroll-to-bottom button click feedback */
@keyframes scrollBtnClick {
  0% { transform: scale(1); }
  40% { transform: scale(0.85) translateY(3px); }
  70% { transform: scale(1.08) translateY(-2px); }
  100% { transform: scale(1) translateY(0); }
}

/* Search focus pulse (Ctrl+K) */
@keyframes searchFocusPulse {
  0% { box-shadow: none; }
  40% { box-shadow: 0 0 0 4px var(--primary-bg), 0 0 16px var(--primary-glow); }
  100% { box-shadow: none; }
}

/* Scroll-to-bottom pulse for unread messages */
.scroll-bottom-btn:not(.hidden) .unread-badge:not(.hidden) ~ * {
  animation: none;
}

.scroll-bottom-btn.has-unread {
  animation: scrollUnreadPulse 2s ease-in-out infinite;
}

@keyframes scrollUnreadPulse {
  0%, 100% { box-shadow: var(--shadow-lg); }
  50% { box-shadow: var(--shadow-lg), 0 0 0 4px rgba(229, 57, 53, 0.2); }
}

/* Profile header gradient animation (combined with modal open) */
.profile-modal-header {
  background-size: 200% 200%;
  animation: profileModalIn 0.45s cubic-bezier(0.16, 1, 0.3, 1), profileGradientShift 8s ease 0.5s infinite;
}

@keyframes profileGradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Enhanced context menu glass effect for dark theme */
[data-theme="dark"] .context-menu {
  background: rgba(23, 33, 43, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Enhanced emoji item hover wave */
.emoji-item:hover {
  background: var(--bg-hover);
  transform: scale(1.3);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

/* Context menu items cascade animation */
.context-menu .context-item {
  animation: menuItemCascade 0.2s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.context-menu .context-item:nth-child(1) { animation-delay: 0.02s; }
.context-menu .context-item:nth-child(2) { animation-delay: 0.04s; }
.context-menu .context-item:nth-child(3) { animation-delay: 0.06s; }
.context-menu .context-item:nth-child(4) { animation-delay: 0.08s; }
.context-menu .context-item:nth-child(5) { animation-delay: 0.10s; }
.context-menu .context-item:nth-child(6) { animation-delay: 0.12s; }
.context-menu .context-item:nth-child(7) { animation-delay: 0.14s; }

/* Dropdown menu — no cascade animation delay (prevented items from showing on re-open) */

/* Three-dots button active state (morph to X) */
.chat-menu-btn-active svg {
  transform: rotate(90deg);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#chat-menu-btn svg {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dropdown menu item hover improvement */
.dropdown-menu .menu-item:hover {
  background: var(--bg-active);
  padding-left: 18px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Enhanced input wrapper focus glow */
.input-inner:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg), 0 0 16px var(--primary-glow);
  transform: translateY(-1px);
}

/* Improved message hover effects */
.message-bubble:active {
  filter: brightness(0.94);
  transform: scale(0.99);
}

/* Settings save button success animation */
.save-btn.loading svg {
  animation: spin 0.6s linear infinite;
}

.save-btn:not(.loading):active svg {
  animation: checkBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes checkBounce {
  0% { transform: scale(1); }
  40% { transform: scale(0.8); }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* User result hover enhancement */
.user-result:hover .avatar {
  transform: scale(1.1);
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Toast notification icon enhancement */
.toast-notification::before {
  display: inline-block;
  margin-right: 8px;
  font-size: 1.1em;
}

.toast-success::before { content: '✓'; }
.toast-error::before { content: '✕'; }
.toast-info::before { content: 'ℹ'; }

/* --- Selection Mode ---------------------------- */
.selection-bar {
  background: var(--bg-header);
  z-index: 25;
}

.message-select-indicator {
  position: absolute;
  left: -40px;
  top: 50%;
  transform: translateY(-50%) scale(0.5);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--text-secondary);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  z-index: 2;
}

.message-select-indicator svg {
  width: 14px;
  height: 14px;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s ease;
}

.messenger.selection-mode .message {
  transform: translateX(40px);
  cursor: pointer;
}

.messenger.selection-mode .message-select-indicator {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.messenger.selection-mode .message-bubble {
  pointer-events: none; /* Let clicks pass to message wrapper */
}

.messenger.selection-mode .message.selected .message-select-indicator {
  background: var(--primary);
  border-color: var(--primary);
}

.messenger.selection-mode .message.selected .message-select-indicator svg {
  opacity: 1;
  transform: scale(1);
}

.messenger.selection-mode .message.selected .message-bubble {
  background: var(--bg-hover) !important;
  box-shadow: 0 0 0 2px var(--primary) !important;
}


.messenger.selection-mode .message.incoming { transform: translateX(30px); }
.messenger.selection-mode .message.outgoing { transform: translateX(-10px); }

