/* ============================================
   GOFTEMON - Modern Chat Application Styles
   A beautiful, user-friendly messaging UI
   ============================================ */

/* ============================================
   CSS Variables - Light & Dark Mode
   ============================================ */
:root {
  /* Primary Colors - Vibrant Purple/Cyan Theme */
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-light: rgba(124, 58, 237, 0.15);
  --secondary: #06b6d4;
  --secondary-light: rgba(6, 182, 212, 0.15);
  
  /* Gradient Colors */
  --gradient-start: #7c3aed;
  --gradient-middle: #a855f7;
  --gradient-end: #06b6d4;
  --gradient-primary: linear-gradient(135deg, var(--gradient-start), var(--gradient-middle), var(--gradient-end));
  --gradient-hover: linear-gradient(135deg, #6d28d9, #9333ea, #0891b2);
  
  /* Background Colors - Light Mode */
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-tertiary: #e2e8f0;
  
  /* Glass Effect Colors */
  --glass-bg: rgba(255, 255, 255, 0.75);
  --glass-bg-strong: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(148, 163, 184, 0.25);
  --glass-shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
  --glass-shadow-lg: 0 25px 50px -12px rgba(15, 23, 42, 0.15);
  
  /* Text Colors */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-inverse: #ffffff;
  
  /* Border Colors */
  --border-light: rgba(148, 163, 184, 0.2);
  --border-medium: rgba(148, 163, 184, 0.35);
  --border-focus: var(--primary);
  
  /* Message Bubbles */
  --message-self-bg: var(--gradient-primary);
  --message-self-text: #ffffff;
  --message-other-bg: #ffffff;
  --message-other-text: var(--text-primary);
  --message-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  
  /* Status Colors */
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.15);
  --success-bg: #047857;
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.15);
  --warning-bg: #b45309;
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.15);
  --danger-bg: #b91c1c;
  --info: #3b82f6;
  --info-light: rgba(59, 130, 246, 0.15);
  --info-bg: #1d4ed8;
  
  /* Overlay */
  --overlay: rgba(15, 23, 42, 0.5);
  --overlay-light: rgba(15, 23, 42, 0.3);
  
  /* Animation Timings */
  --transition-fast: 150ms;
  --transition-normal: 250ms;
  --transition-slow: 350ms;

  /* Avatar Color Palette */
  --avatar-1: linear-gradient(135deg, #667eea, #764ba2);
  --avatar-2: linear-gradient(135deg, #f093fb, #f5576c);
  --avatar-3: linear-gradient(135deg, #4facfe, #00f2fe);
  --avatar-4: linear-gradient(135deg, #43e97b, #38f9d7);
  --avatar-5: linear-gradient(135deg, #fa709a, #fee140);
  --avatar-6: linear-gradient(135deg, #a18cd1, #fbc2eb);
  --avatar-7: linear-gradient(135deg, #fccb90, #d57eeb);
  --avatar-8: linear-gradient(135deg, #e0c3fc, #8ec5fc);
  --avatar-9: linear-gradient(135deg, #f5576c, #ff5858);
  --avatar-10: linear-gradient(135deg, #13547a, #80d0c7);
  
  /* Spacing */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;
}

/* Dark Mode */
:root[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  
  --glass-bg: rgba(30, 41, 59, 0.75);
  --glass-bg-strong: rgba(30, 41, 59, 0.9);
  --glass-border: rgba(148, 163, 184, 0.12);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --glass-shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  
  --border-light: rgba(148, 163, 184, 0.1);
  --border-medium: rgba(148, 163, 184, 0.2);
  
  --message-other-bg: #1e293b;
  --message-other-text: #f1f5f9;
  --message-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  
  --overlay: rgba(0, 0, 0, 0.7);
  --overlay-light: rgba(0, 0, 0, 0.5);
}

/* Auto Dark Mode based on system preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    
    --glass-bg: rgba(30, 41, 59, 0.75);
    --glass-bg-strong: rgba(30, 41, 59, 0.9);
    --glass-border: rgba(148, 163, 184, 0.12);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --glass-shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    
    --border-light: rgba(148, 163, 184, 0.1);
    --border-medium: rgba(148, 163, 184, 0.2);
    
    --message-other-bg: #1e293b;
    --message-other-text: #f1f5f9;
    --message-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    
    --overlay: rgba(0, 0, 0, 0.7);
    --overlay-light: rgba(0, 0, 0, 0.5);
  }
}

/* ============================================
   Base Reset & Global Styles
   ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "IRANYekanX", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  min-height: 100dvh;
  min-height: var(--app-height, 100dvh);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.4s ease, color 0.4s ease;
}

* {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ============================================
   Login Page Styles
   ============================================ */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  min-height: var(--app-height, 100dvh);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

/* Animated Background */
.login-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.login-bg-gradient {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(124, 58, 237, 0.3), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(6, 182, 212, 0.2), transparent),
    radial-gradient(ellipse 50% 30% at 0% 100%, rgba(168, 85, 247, 0.2), transparent),
    var(--bg-primary);
}

.login-bg-orbs {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
  animation: float 20s ease-in-out infinite;
}

.orb-1 {
  width: 400px;
  height: 400px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  top: -10%;
  right: -10%;
  animation-delay: 0s;
}

.orb-2 {
  width: 300px;
  height: 300px;
  background: linear-gradient(135deg, #06b6d4, #22d3ee);
  bottom: -5%;
  left: -5%;
  animation-delay: -5s;
}

.orb-3 {
  width: 200px;
  height: 200px;
  background: linear-gradient(135deg, #ec4899, #f472b6);
  top: 50%;
  left: 10%;
  animation-delay: -10s;
}

.orb-4 {
  width: 250px;
  height: 250px;
  background: linear-gradient(135deg, #8b5cf6, #a78bfa);
  bottom: 20%;
  right: 15%;
  animation-delay: -15s;
}

@keyframes float {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  25% {
    transform: translate(20px, -30px) scale(1.05);
  }
  50% {
    transform: translate(-20px, 20px) scale(0.95);
  }
  75% {
    transform: translate(30px, 10px) scale(1.02);
  }
}

.login-bg-grid {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(148, 163, 184, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* Login Container */
.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

/* Login Card */
.login-card {
  width: 100%;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-2xl);
  padding: 2rem;
  box-shadow: var(--glass-shadow-lg);
  animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Login Header */
.login-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.login-logo-wrapper {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(124, 58, 237, 0.3);
  animation: logoGlow 3s ease-in-out infinite alternate;
}

@keyframes logoGlow {
  from {
    box-shadow: 0 8px 30px rgba(124, 58, 237, 0.3);
  }
  to {
    box-shadow: 0 8px 40px rgba(124, 58, 237, 0.5);
  }
}

.login-logo-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.login-logo-fallback {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  color: #fff;
  font-size: 2.5rem;
}

.login-brand {
  text-align: center;
}

.login-title {
  font-size: 1.75rem;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Login Divider */
.login-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-medium), transparent);
}

.login-divider span {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Login Form */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-label i {
  font-size: 0.75rem;
  color: var(--primary);
}

.input-wrapper {
  position: relative;
}

.form-input {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  outline: none;
  transition: all var(--transition-normal) ease;
}

.form-input::placeholder {
  color: var(--text-light);
}

.form-input:hover {
  border-color: var(--border-medium);
}

.form-input:focus {
  border-color: var(--primary);
  background: var(--bg-primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.input-focus-border {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--gradient-primary);
  transform: translateX(-50%);
  transition: width var(--transition-normal) ease;
  border-radius: var(--radius-full);
}

.form-input:focus ~ .input-focus-border {
  width: calc(100% - 2rem);
}

.input-ltr {
  direction: ltr;
  text-align: left;
}

/* Password Toggle */
.password-wrapper {
  position: relative;
}

.password-wrapper .form-input {
  padding-left: 3rem;
}

.password-toggle {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast) ease;
}

.password-toggle:hover {
  color: var(--primary);
  background: var(--primary-light);
}

/* Login Button */
.login-btn {
  position: relative;
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-inverse);
  background: var(--gradient-primary);
  border: none;
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-normal) ease;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.35);
}

.login-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gradient-hover);
  opacity: 0;
  transition: opacity var(--transition-normal) ease;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(124, 58, 237, 0.45);
}

.login-btn:hover::before {
  opacity: 1;
}

.login-btn:active {
  transform: translateY(0);
}

.btn-content,
.btn-loader {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-loader.hidden {
  display: none;
}

/* Login Status */
.login-status {
  min-height: 1.25rem;
  font-size: 0.875rem;
  text-align: center;
  transition: color var(--transition-fast) ease;
}

.login-status.text-danger {
  color: var(--danger);
}

.login-status.text-muted {
  color: var(--text-muted);
}

/* Login Footer */
.login-footer {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
  text-align: center;
}

.login-footer-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.login-footer-text i {
  color: var(--success);
}

/* Version Badge & Footer Actions */
.login-footer-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.version-badge {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  backdrop-filter: blur(10px);
}

.app-version-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.25rem 0;
}

.clear-cache-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-family: inherit;
  color: var(--text-muted);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: all 0.2s ease;
}

.clear-cache-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: rgba(124, 58, 237, 0.1);
}

.clear-cache-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.clear-cache-btn.clear-cache-success {
  color: #10b981;
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}

.clear-cache-btn.clear-cache-error {
  color: #ef4444;
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* ============================================
   Main Application Shell
   ============================================ */
.app-shell {
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: 
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(124, 58, 237, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(6, 182, 212, 0.06), transparent),
    var(--bg-primary);
}

/* App Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header.compact {
  padding: 0.6rem 1rem;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast) ease;
}

.menu-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
  border-color: var(--primary);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-inverse);
  font-size: 1.1rem;
  box-shadow: var(--glass-shadow);
  overflow: hidden;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
}

.brand-logo-fallback {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  color: var(--text-inverse);
}

.brand-title {
  font-size: 1.125rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-datetime {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Mobile datetime: only in conversation list header, opposite "گفتمون‌ها"; hidden on desktop and in chat detail view */
.mobile-datetime-inline {
  display: none;
}

.desktop-menu-items {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-pill {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast) ease;
}

.nav-pill:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.nav-pill.active {
  color: var(--primary);
  background: var(--primary-light);
  border-color: var(--primary);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
}

.user-info-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* App Main Content */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.app-main .md-h-screen {
  height: 100%;
}

/* ============================================
   Layout Grid - Conversations & Chat
   ============================================ */
.layout-grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 1rem;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

@media (min-width: 1024px) {
  .layout-grid {
    flex-direction: row-reverse;
  }
}

/* ============================================
   Conversation Panel (Sidebar)
   ============================================ */
.conversation-panel {
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}

@media (min-width: 1024px) {
  .conversation-panel {
    flex: 0 0 340px;
    max-width: 340px;
  }
}

.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.conversation-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
}

.conversation-header-flag-slot {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.conversation-header-flag {
  height: 1.375rem;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
}

.modal-backdrop-btn {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: default;
}

.flag-modal-content {
  position: relative;
  max-width: 520px;
}

.flag-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding-top: 0.5rem;
}

.flag-modal-image {
  width: min(420px, 100%);
  height: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--glass-shadow);
}

.flag-modal-caption {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
}

.conversation-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.conversation-filters {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
}

.search-wrapper {
  position: relative;
}

.search-wrapper i {
  position: absolute;
  right: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.search-clear-btn {
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
}

.search-clear-btn i {
  position: static;
  transform: none;
  color: inherit;
  font-size: inherit;
}

.chat-header-search .search-input {
  padding-left: 2.5rem;
}

.search-input {
  width: 100%;
  padding: 0.625rem 2.5rem 0.625rem 0.875rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  outline: none;
  transition: all var(--transition-fast) ease;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.filter-row {
  display: flex;
  gap: 0.5rem;
}

.filter-select {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.75rem center;
  padding-left: 2rem;
}

/* Conversation List */
#conversation-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem;
  min-height: 0;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-normal) ease;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.conversation-item::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition-normal) ease;
  border-radius: inherit;
}

.conversation-item:hover {
  background: var(--bg-secondary);
  transform: translateX(-2px);
}

.conversation-item.active {
  background: var(--primary-light);
  border-color: rgba(124, 58, 237, 0.2);
}

.conversation-item.active::before {
  opacity: 0.06;
}

.conversation-item.unread {
  background: var(--primary-light);
}

.conversation-item .avatar {
  flex-shrink: 0;
}

.conversation-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.conversation-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.conversation-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
  flex-wrap: wrap; /* Allow wrapping so "last seen" can be on next line */
}

.conversation-last-seen {
  flex-basis: 100%;
  width: 100%;
  white-space: nowrap; /* Keep it readable on one line */
}

.conversation-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.message-preview {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-preview.unread {
  color: var(--text-primary);
  font-weight: 500;
}

.unread-dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--primary-light);
}

.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-inverse);
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
  animation: badgePop 0.3s ease-out;
}

.mention-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.3rem;
  padding: 0 0.4rem;
  margin-inline-start: 0.35rem;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: var(--warning-bg);
  cursor: pointer;
  vertical-align: middle;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.mention-unread-badge:hover {
  filter: brightness(1.08);
}

.mention-unread-badge:active {
  transform: scale(0.96);
}

.unread-mentions-body {
  max-height: min(70vh, 28rem);
  overflow-y: auto;
}

.unread-mentions-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0;
}

.unread-mentions-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.25rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition: background 0.12s ease;
}

.unread-mentions-item:last-child {
  border-bottom: none;
}

.unread-mentions-item:hover {
  background: var(--surface-hover, rgba(255, 255, 255, 0.06));
}

.unread-mentions-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.unread-mentions-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.unread-mentions-item-preview {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.conversation-mention-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: var(--warning-bg);
}

@keyframes badgePop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Self Conversation (Saved Messages) */
.conversation-item.self-conversation {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.08) 0%, rgba(6, 182, 212, 0.06) 100%);
  border: 1px solid rgba(124, 58, 237, 0.15);
}

.conversation-item.self-conversation:hover {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.12) 0%, rgba(6, 182, 212, 0.08) 100%);
}

.conversation-item.self-conversation.active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.18) 0%, rgba(6, 182, 212, 0.12) 100%);
  border-color: rgba(124, 58, 237, 0.3);
}

.conversation-item .avatar.self {
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.3);
}

/* ============================================
   Chat Panel
   ============================================ */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: var(--glass-bg-strong);
  border-bottom: 1px solid var(--border-light);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap; /* move chat header search to next line */
}

.chat-header-info .avatar {
  flex-shrink: 0;
}

.chat-header-text h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.125rem;
}

.chat-header-text p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Member Bar */
#member-bar {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

/* Chat header conversation search should occupy full row */
#chat-conversation-search {
  flex: 0 0 100%;
  width: 100%;
}

#member-bar.hidden {
  display: none;
}

.member-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.member-bar-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.member-avatars-stack {
  display: flex;
  flex-direction: row;
}

.member-avatars-stack .avatar {
  margin-inline-start: -0.5rem;
  border: 2px solid var(--bg-secondary);
  position: relative;
}

.member-avatars-stack .avatar:first-child {
  margin-inline-start: 0;
}

.avatar-xs {
  width: 28px;
  height: 28px;
  font-size: 0.625rem;
}

.avatar-xs .online-indicator {
  width: 8px;
  height: 8px;
  bottom: -1px;
  right: -1px;
  border-width: 1.5px;
}

.member-avatar-extra {
  background: var(--glass-bg);
  color: var(--text-muted);
  font-size: 0.625rem;
  font-weight: 600;
  border: 2px solid var(--bg-secondary);
}

.member-count-text {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Chat Body / Messages Area */
.chat-body {
  flex: 1;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: 
    linear-gradient(135deg, rgba(124, 58, 237, 0.03) 0%, rgba(6, 182, 212, 0.02) 100%);
  overflow: hidden;
}

/* Pinned messages strip (above message list) */
.pinned-messages-bar {
  flex-shrink: 0;
  padding: 0.5rem 0.75rem;
  background: var(--glass-bg-strong);
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(8px);
}

.pinned-messages-bar-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.pinned-messages-bar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.pinned-chip {
  max-width: 100%;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md, 0.5rem);
  border: 1px solid var(--border-medium);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.75rem;
  cursor: pointer;
  text-align: right;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.pinned-chip:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.pinned-chip-more {
  font-weight: 600;
  color: var(--primary);
}

.pinned-modal-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pinned-modal-row {
  width: 100%;
  text-align: right;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-md, 0.5rem);
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.pinned-modal-row:hover {
  border-color: var(--primary);
}

.chat-bubble.message-pinned {
  box-shadow: 0 0 0 2px var(--warning), var(--message-shadow);
}

.icon-btn.pinned-active {
  color: var(--warning);
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Prevent long text from blowing out message wrappers */
.chat-messages > * {
  min-width: 0;
  max-width: 100%;
}

/* Scroll To Bottom Button */
.scroll-to-bottom-btn {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--glass-bg-strong);
  border: 1px solid var(--border-light);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
  color: var(--text-primary);
  cursor: pointer;
  z-index: 12;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.scroll-to-bottom-btn:hover {
  background: var(--bg-elevated);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.3);
  transform: translateY(-1px);
}

.scroll-to-bottom-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
}

/* Message Styles */
.message-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  max-width: 85%;
  min-width: 0;
  overflow: visible;
}

.message-row.self {
  flex-direction: row-reverse;
  margin-right: auto;
  margin-left: 0;
}

.message-row.other {
  margin-left: auto;
  margin-right: 0;
}

.chat-bubble {
  max-width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-xl);
  background: var(--message-other-bg);
  color: var(--message-other-text);
  box-shadow: var(--message-shadow);
  border: 1px solid var(--border-light);
  overflow: hidden;
  min-width: 0;
}

/* Touch: «واکنش به پیام» — دکمه داخل حباب، گوشهٔ بالا به‌سمت مرکز گفتگو */
.chat-bubble.has-message-sheet-trigger {
  position: relative;
}

.chat-bubble.has-message-sheet-trigger:not(.self) {
  padding-inline-end: 2.25rem;
}

.chat-bubble.has-message-sheet-trigger.self {
  padding-inline-start: 2.25rem;
}

.chat-bubble .message-sheet-trigger--inside.icon-btn {
  position: absolute;
  top: 0.4rem;
  z-index: 2;
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  font-size: 0.72rem;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.chat-bubble:not(.self) .message-sheet-trigger--inside {
  inset-inline-end: 0.45rem;
  color: var(--message-other-text);
  background: color-mix(in srgb, var(--bg-primary) 82%, transparent);
  border: 1px solid var(--border-light);
}

.chat-bubble.self .message-sheet-trigger--inside {
  inset-inline-start: 0.45rem;
  color: var(--message-self-text);
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.chat-bubble.is-new {
  animation: messageSlideIn 0.3s ease-out;
}

.chat-bubble.self {
  background: var(--message-self-bg);
  color: var(--message-self-text);
  border: none;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

/* Message grouping - consecutive messages from same sender */
.message-group-first .chat-bubble { border-radius: var(--radius-xl) var(--radius-xl) var(--radius-xl) var(--radius-sm); }
.message-group-middle .chat-bubble { border-radius: var(--radius-sm) var(--radius-xl) var(--radius-xl) var(--radius-sm); }
.message-group-last .chat-bubble { border-radius: var(--radius-sm) var(--radius-xl) var(--radius-xl) var(--radius-xl); }
.message-group-first.self .chat-bubble { border-radius: var(--radius-xl) var(--radius-xl) var(--radius-sm) var(--radius-xl); }
.message-group-middle.self .chat-bubble { border-radius: var(--radius-xl) var(--radius-sm) var(--radius-sm) var(--radius-xl); }
.message-group-last.self .chat-bubble { border-radius: var(--radius-xl) var(--radius-sm) var(--radius-xl) var(--radius-xl); }

/* Tighter spacing for grouped messages */
.message-group-middle, .message-group-last { margin-top: -0.35rem; }

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message-sender {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.85;
  margin-bottom: 0.25rem;
}

.message-text {
  font-size: 0.9375rem;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  overflow: hidden;
}

.message-mention {
  display: inline;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 0.35rem;
  padding: 0 0.25rem;
}

.chat-bubble.self .message-mention {
  color: var(--text-inverse);
  background: rgba(255, 255, 255, 0.2);
}

.emoji-inline {
  font-size: 1.1em;
  vertical-align: middle;
  margin: 0 0.1em;
}

/* Message Actions */
.message-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity var(--transition-fast) ease;
  pointer-events: none;
}

.message-row:hover .message-actions {
  opacity: 1;
  pointer-events: auto;
}

.message-row.show-actions .message-actions {
  opacity: 1;
  pointer-events: auto;
}

.message-action-buttons {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  backdrop-filter: blur(10px);
  position: relative;
}

.message-action-buttons .icon-btn {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
}

.message-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  font-size: 0.625rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.message-sent-caption {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.625rem;
  line-height: 1.25;
  color: var(--text-muted);
  margin-top: 0.2rem;
  white-space: nowrap;
  user-select: none;
}

.message-sent-caption .message-status-row {
  margin-top: 0;
}

.message-sheet-preview-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.message-sheet-preview-meta .message-sheet-preview-status {
  align-items: center;
}

.message-sheet-preview-meta .message-status-row {
  display: inline-flex;
  align-items: center;
}

/* ============================================
   Message actions bottom sheet (واکنش به پیام)
   Spacing aligned with Material 8dp grid
   ============================================ */
#modal-message-actions .modal-content.bottom-sheet-content {
  padding: 0.5rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

#modal-message-actions .bottom-sheet-handle {
  margin-bottom: 0.75rem;
}

#modal-message-actions #message-sheet-step-actions > .modal-header,
#modal-message-actions #message-sheet-step-forward > .modal-header {
  margin-bottom: 0.5rem;
}

#modal-message-actions #message-sheet-step-actions > .divider,
#modal-message-actions #message-sheet-step-forward > .divider {
  margin: 0 0 1rem;
}

#modal-message-actions .message-actions-sheet-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

#modal-message-actions .message-actions-sheet-preview.forward-message-preview {
  padding: 1rem;
  margin: 0;
  border-radius: var(--radius-md);
}

#modal-message-actions .message-actions-sheet-preview-sender {
  font-size: 0.75rem;
  line-height: 1.25;
  color: var(--text-muted);
  font-weight: 500;
}

#modal-message-actions .message-actions-sheet-preview-text {
  margin-top: 0.25rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-primary);
  font-weight: 400;
}

#modal-message-actions .message-actions-sheet-preview-meta.message-sheet-preview-meta {
  margin-top: 0.75rem;
  gap: 0.5rem;
}

#modal-message-actions .message-actions-sheet-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  row-gap: 0.25rem;
}

#modal-message-actions .message-actions-sheet-status-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

#modal-message-actions .message-actions-sheet-album-tags {
  margin-top: 0.25rem;
}

#modal-message-actions .message-actions-sheet-reactions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#modal-message-actions .message-actions-sheet-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.2;
}

#modal-message-actions .message-actions-sheet-reaction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 2.75rem);
  gap: 0.5rem;
  justify-content: start;
  max-height: min(38vh, 260px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.125rem 0;
  scrollbar-width: thin;
}

#modal-message-actions .message-actions-sheet-reaction-grid .reaction-option {
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  border-radius: 50%;
  font-size: 1.125rem;
  box-sizing: border-box;
}

#modal-message-actions .message-actions-sheet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.625rem;
}

@media (max-width: 360px) {
  #modal-message-actions .message-actions-sheet-grid {
    grid-template-columns: 1fr;
  }
}

#modal-message-actions .message-actions-sheet-grid .btn {
  width: 100%;
  min-height: 3rem;
  padding: 0.625rem 0.875rem;
  justify-content: center;
  text-align: center;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: normal;
}

#modal-message-actions .message-actions-sheet-grid .btn i {
  flex-shrink: 0;
}

/* Reaction Styles */
.reaction-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.375rem;
}

.reaction-details {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.3rem;
}

.reaction-detail-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.reaction-detail-item i {
  color: var(--text-secondary);
  min-width: 0.9rem;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast) ease;
}

.reaction-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.reaction-chip.mine {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-light);
}

.reaction-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
  position: absolute;
  z-index: 10;
  width: 260px;
  bottom: 100%;
  margin-bottom: 0.25rem;
  max-height: 200px;
  overflow-y: auto;
}

.reaction-picker.hidden {
  display: none;
}

.reaction-option {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast) ease;
}

.reaction-option:hover {
  transform: scale(1.15);
  color: var(--primary);
}

.reaction-add {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 50%;
  font-size: 0.75rem;
  cursor: pointer;
}

/* Message Attachments */
.attachment-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Multiple attachments: compact square tiles in a row */
.attachment-grid--multi {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.375rem;
}

.attachment-grid--multi .attachment-item {
  flex: 0 0 auto;
}

.attachment-grid--multi .media-thumb {
  width: 84px;
  height: 84px;
  max-width: 84px;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: block;
  background: var(--bg-tertiary);
}

.attachment-grid--multi .attachment-image {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  border-radius: inherit;
}

.attachment-grid--multi .attachment-video {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  border-radius: inherit;
}

.attachment-grid--multi .media-play {
  width: 36px;
  height: 36px;
  font-size: 0.875rem;
}

/* Single image in chat (not album): modest display (~168px thumb upscaled slightly) */
.attachment-grid:not(.attachment-grid--multi):not(.album-attachment-grid) .attachment-image {
  max-width: min(100%, 200px);
}

/* Album / group: messages stay one per row; only .attachment-grid--multi tiles images within a message. */

.album-attachment-grid {
  margin-top: 0.25rem;
}

.album-attachment-grid .attachment-item {
  margin: 0;
}

.album-attachment-grid .attachment-image,
.album-attachment-grid .attachment-video {
  max-width: 100%;
  border-radius: var(--radius-xl);
}

/* Album + several attachments: same compact square tiles in a row as non-album groups */
.album-attachment-grid.attachment-grid--multi {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.375rem;
}

.album-attachment-grid.attachment-grid--multi .attachment-item {
  flex: 0 0 auto;
  margin: 0;
}

.album-attachment-grid.attachment-grid--multi .media-thumb {
  width: 84px;
  height: 84px;
  max-width: 84px;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: block;
  background: var(--bg-tertiary);
}

.album-attachment-grid.attachment-grid--multi .attachment-image,
.album-attachment-grid.attachment-grid--multi .attachment-video {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  border-radius: inherit;
}

.album-attachment-grid.attachment-grid--multi .media-play {
  width: 36px;
  height: 36px;
  font-size: 0.875rem;
}

.album-message-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
}

.album-tagged-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.album-tag-panel {
  background: var(--bg-primary);
}

.album-viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(17, 24, 39, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  z-index: 2;
}

.album-viewer-prev {
  right: 10px;
}

.album-viewer-next {
  left: 10px;
}

.album-viewer-nav:hover {
  background: rgba(17, 24, 39, 0.7);
}

.album-tagged-name {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.attachment-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.attachment-image {
  width: 100%;
  max-width: min(100%, 280px);
  height: auto;
  display: block;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: transform var(--transition-fast) ease;
}

.attachment-image:hover {
  transform: scale(1.02);
}

.attachment-video {
  width: 100%;
  max-width: min(100%, 320px);
  height: auto;
  display: block;
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
}

.attachment-audio {
  width: 100%;
  max-width: min(100%, 280px);
}

.attachment-pdf {
  width: 100%;
  max-width: min(100%, 360px);
  height: 240px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

/* File download control inside chat bubbles (zip, apk, ovpn, PDF secondary action, etc.) */
.attachment-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  align-self: flex-start;
  max-width: 100%;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.3;
  background: color-mix(in srgb, var(--primary) 14%, var(--bg-secondary));
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 32%, transparent);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition:
    background var(--transition-fast) ease,
    color var(--transition-fast) ease,
    border-color var(--transition-fast) ease,
    box-shadow var(--transition-fast) ease,
    transform var(--transition-fast) ease;
  box-sizing: border-box;
}

.attachment-download-btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.attachment-download-btn .fa-download {
  flex-shrink: 0;
  font-size: 0.875rem;
  opacity: 0.95;
}

.attachment-download-btn__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-bubble:not(.self) .attachment-download-btn {
  background: color-mix(in srgb, var(--primary) 14%, var(--message-other-bg));
}

.chat-bubble:not(.self) .attachment-download-btn:hover {
  background: color-mix(in srgb, var(--primary) 22%, var(--message-other-bg));
  border-color: color-mix(in srgb, var(--primary) 48%, transparent);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.attachment-download-btn:hover {
  text-decoration: none;
  background: color-mix(in srgb, var(--primary) 22%, var(--bg-secondary));
  border-color: color-mix(in srgb, var(--primary) 48%, transparent);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.chat-bubble.self .attachment-download-btn {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.chat-bubble.self .attachment-download-btn:hover {
  background: rgba(255, 255, 255, 0.32);
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chat-bubble.self .attachment-download-btn:active {
  transform: scale(0.98);
}

/* Location Message Card */
.location-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 0.375rem;
  border: 1px solid var(--border-light);
  max-width: min(100%, 280px);
  cursor: pointer;
  transition: all var(--transition-fast) ease;
}

.location-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.location-card-map {
  width: 100%;
  height: 140px;
  background: var(--bg-tertiary);
  position: relative;
  overflow: hidden;
}

.location-card-map img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.location-card-map .location-pin-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -80%);
  font-size: 1.75rem;
  color: var(--danger);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.location-card-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  background: var(--glass-bg);
}

.location-card-info i {
  color: var(--success);
  font-size: 0.875rem;
  flex-shrink: 0;
}

.location-card-info span {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-bubble.self .location-card-info {
  background: rgba(255, 255, 255, 0.15);
}

.chat-bubble.self .location-card-info i {
  color: rgba(255, 255, 255, 0.85);
}

.chat-bubble.self .location-card-info span {
  color: rgba(255, 255, 255, 0.9);
}

.chat-bubble.self .location-card {
  border-color: rgba(255, 255, 255, 0.2);
}

.media-thumb {
  position: relative;
  display: inline-block;
  cursor: pointer;
  width: 100%;
  max-width: 100%;
}

.media-thumb.video::after {
  content: "";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: 50%;
  font-size: 1rem;
  backdrop-filter: blur(4px);
}

/* Audio Player */
.audio-player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  max-width: 100%;
}

.chat-bubble.self .audio-player {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}

.audio-control {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast) ease;
}

.audio-control:hover {
  transform: scale(1.05);
}

.audio-control.playing {
  background: var(--danger);
}

.chat-bubble.self .audio-control {
  background: rgba(255, 255, 255, 0.25);
}

.audio-progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  direction: ltr;
}

.audio-progress {
  width: 100%;
  height: 4px;
  accent-color: var(--primary);
}

.audio-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.625rem;
  color: var(--text-muted);
}

.chat-bubble.self .audio-times {
  color: rgba(255, 255, 255, 0.75);
}

.audio-speed {
  min-width: 36px;
  height: 24px;
  padding: 0 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast) ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.audio-speed:hover {
  background: var(--bg-hover);
}

.audio-speed.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.chat-bubble.self .audio-speed {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.25);
}

.chat-bubble.self .audio-speed:hover {
  background: rgba(255, 255, 255, 0.25);
}

.chat-bubble.self .audio-speed.active {
  background: rgba(255, 255, 255, 0.35);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.audio-element {
  display: none;
}

/* Chat Composer */
.chat-composer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--glass-bg-strong);
  border-top: 1px solid var(--border-light);
  position: relative;
}

/* Composer Menu Backdrop */
.composer-menu-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay-light);
  z-index: 49;
  opacity: 0;
  transition: opacity var(--transition-normal) ease;
}

.composer-menu-backdrop.active {
  opacity: 1;
}

.composer-menu-backdrop.hidden {
  display: none;
}

/* Composer Menu - Bottom Sheet Style */
.composer-menu {
  position: relative;
  z-index: 50;
  padding: 0.5rem 0.75rem 0.75rem;
  margin: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
  transform: translateY(100%);
  opacity: 0;
  transition: transform var(--transition-normal) cubic-bezier(0.4, 0, 0.2, 1),
              opacity var(--transition-fast) ease;
}

.composer-menu.visible {
  transform: translateY(0);
  opacity: 1;
}

.composer-menu.hidden {
  display: none;
}

.composer-menu-handle {
  width: 36px;
  height: 4px;
  margin: 0 auto 0.625rem;
  background: var(--border-medium);
  border-radius: 999px;
}

.composer-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.composer-menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  padding: 0.75rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast) ease;
}

.composer-menu-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.composer-menu-btn:active {
  transform: scale(0.96);
}

.composer-menu-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  color: var(--menu-icon-bg);
  background: var(--menu-icon-bg-light);
  border-radius: 50%;
  transition: all var(--transition-fast) ease;
}

.composer-menu-btn:hover .composer-menu-icon {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.composer-menu-label {
  font-weight: 500;
  white-space: nowrap;
}

/* Plus button rotation when menu open */
#composer-plus.active i {
  transform: rotate(45deg);
}

#composer-plus i {
  transition: transform var(--transition-normal) ease;
}

.chat-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  resize: none;
  outline: none;
  transition: all var(--transition-fast) ease;
}

.chat-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.mention-suggest {
  position: absolute;
  left: 4.25rem;
  right: 4.25rem;
  bottom: calc(100% + 0.4rem);
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  z-index: 35;
  padding: 0.25rem;
}

.mention-suggest.hidden {
  display: none;
}

.mention-suggest-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-align: right;
}

.mention-suggest-item:hover,
.mention-suggest-item.active {
  background: var(--primary-light);
}

.mention-suggest-username {
  font-size: 0.75rem;
  color: var(--text-muted);
  direction: ltr;
}

/* Emoji Panel */
.emoji-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  margin: 0 0.75rem 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}

.emoji-panel.hidden {
  display: none;
}

.emoji-panel .emoji-panel-header {
  margin-bottom: 0.5rem;
}

.emoji-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.emoji-group-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 0.25rem;
}

.emoji-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(38px, 38px));
  justify-content: center;
  gap: 0.375rem;
}

.emoji-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast) ease;
}

.emoji-btn:hover {
  transform: scale(1.1);
  color: var(--primary);
}

/* Edit Banner */
.edit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--info-light);
  border-top: 1px solid rgba(59, 130, 246, 0.2);
  color: var(--info);
  font-size: 0.8125rem;
}

.edit-banner.hidden {
  display: none;
}

/* Reply Banner */
.reply-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--primary-light);
  border-top: 1px solid rgba(124, 58, 237, 0.2);
  border-right: 3px solid var(--primary);
  gap: 0.5rem;
}

.reply-banner.hidden {
  display: none;
}

.reply-banner-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  color: var(--primary);
}

.reply-banner-content i {
  font-size: 0.875rem;
  flex-shrink: 0;
}

.reply-banner-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.reply-banner-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
}

.reply-banner-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Reply Preview in Message */
.reply-preview {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  background: rgba(0, 0, 0, 0.05);
  border-right: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast) ease;
}

.reply-preview:hover {
  background: rgba(0, 0, 0, 0.08);
}

.chat-bubble.self .reply-preview {
  background: rgba(255, 255, 255, 0.15);
  border-right-color: rgba(255, 255, 255, 0.5);
}

.chat-bubble.self .reply-preview:hover {
  background: rgba(255, 255, 255, 0.2);
}

.reply-preview-name {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.125rem;
}

.chat-bubble.self .reply-preview-name {
  color: rgba(255, 255, 255, 0.9);
}

.reply-preview-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.chat-bubble.self .reply-preview-text {
  color: rgba(255, 255, 255, 0.75);
}

/* Forward Info in Message */
.forward-info {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0;
  margin-bottom: 0.25rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}

.forward-info i {
  font-size: 0.625rem;
}

.chat-bubble.self .forward-info {
  color: rgba(255, 255, 255, 0.75);
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

/* Forward Message Preview */
.forward-message-preview {
  padding: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-right: 3px solid var(--secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Message Highlight Animation */
@keyframes highlightMessage {
  0%, 100% {
    background: transparent;
  }
  50% {
    background: var(--primary-light);
  }
}

[data-message-id].highlight .chat-bubble {
  animation: highlightMessage 1s ease-in-out 2;
}

/* Attachment Preview */
.attachment-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.attachment-preview.hidden {
  display: none;
}

.preview-item {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-file {
  font-size: 0.625rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.25rem;
  word-break: break-all;
}

.preview-clear {
  margin-right: auto;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  color: var(--danger);
  background: var(--danger-light);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-full);
  cursor: pointer;
}

/* ============================================
   Avatar Component
   ============================================ */
.avatar {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  color: var(--text-inverse);
  border-radius: var(--radius-lg);
  font-size: 1rem;
  flex-shrink: 0;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 0.75rem;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 1.25rem;
}

.avatar-xl {
  width: 72px;
  height: 72px;
  font-size: 1.5rem;
}

/* Online Status Indicator */
.avatar {
  position: relative;
}

.avatar.online {
  box-shadow: 0 0 0 2px var(--success);
}

.online-indicator {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: var(--success);
  border: 2px solid var(--bg-primary);
  border-radius: 50%;
  z-index: 1;
  animation: onlinePulse 2s ease-in-out infinite;
}

@keyframes onlinePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
}

.avatar-sm .online-indicator {
  width: 10px;
  height: 10px;
  bottom: -1px;
  right: -1px;
  border-width: 1.5px;
}

.avatar-lg .online-indicator {
  width: 14px;
  height: 14px;
  bottom: -2px;
  right: -2px;
}

.avatar-xl .online-indicator {
  width: 16px;
  height: 16px;
  bottom: -3px;
  right: -3px;
}

/* Online text indicator */
.text-success {
  color: var(--success) !important;
}

/* Avatar Picker */
.avatar-picker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.avatar-preview {
  width: 52px;
  height: 52px;
  cursor: pointer;
  border: 2px dashed var(--border-medium);
  background: var(--bg-secondary);
  color: var(--text-muted);
  transition: all var(--transition-fast) ease;
}

.avatar-preview:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 0.5rem;
  max-height: 280px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.avatar-option {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast) ease;
}

.avatar-option:hover {
  transform: scale(1.05);
  color: var(--primary);
  background: var(--primary-light);
}

.avatar-option.selected {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast) ease;
  border: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  color: var(--text-inverse);
  background: var(--gradient-primary);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
}

.btn-secondary {
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
}

.btn-outline {
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-medium);
}

.btn-outline:hover:not(:disabled) {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-light);
}

.btn-danger {
  color: var(--text-inverse);
  background: var(--danger);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  transform: translateY(-1px);
}

/* Icon Button */
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast) ease;
}

.icon-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
  border-color: var(--primary);
}

.icon-btn.send {
  color: var(--text-inverse);
  background: var(--gradient-primary);
  border: none;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
  transition: all var(--transition-fast) ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-btn.send:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
}

.icon-btn.send:active {
  transform: scale(0.92);
}

.icon-btn.send.sending {
  animation: sendPulse 0.6s ease;
}

@keyframes sendPulse {
  0% { transform: scale(1); }
  30% { transform: scale(0.85); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.icon-btn.recording {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }
}

/* ============================================
   Form Inputs
   ============================================ */
.input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  outline: none;
  transition: all var(--transition-fast) ease;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.input::placeholder {
  color: var(--text-muted);
}

select.input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.75rem center;
  padding-left: 2rem;
}

/* Password Field */
.password-field {
  position: relative;
}

.password-field .input {
  padding-left: 3rem;
}

.password-field .icon-btn {
  position: absolute;
  left: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
}

/* ============================================
   Cards
   ============================================ */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--glass-shadow);
}

/* ============================================
   Badges
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
}

.badge.cursor-pointer {
  cursor: pointer;
  transition: all var(--transition-fast) ease;
}

.badge.cursor-pointer:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.badge-success {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

.badge-warning {
  background: var(--warning-light);
  border-color: var(--warning);
  color: var(--warning);
}

.badge-muted {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
  color: var(--text-muted);
}

/* ============================================
   Divider
   ============================================ */
.divider {
  height: 1px;
  background: var(--border-light);
  margin: 0.75rem 0;
}

/* ============================================
   List Items
   ============================================ */
.list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  transition: all var(--transition-fast) ease;
}

.list-item:hover {
  background: var(--bg-secondary);
}

.list-item.active {
  background: var(--primary-light);
  border-color: rgba(124, 58, 237, 0.2);
}

#conversation-list .list-item {
  margin-bottom: 0.75rem;
}

#conversation-list .list-item:last-child {
  margin-bottom: 0;
}

#users-modal-list .list-item,
#member-modal-list .list-item,
#member-modal-list .member-card {
  margin-bottom: 0.75rem;
}

#users-modal-list .list-item:last-child,
#member-modal-list .list-item:last-child,
#member-modal-list .member-card:last-child {
  margin-bottom: 0;
}

/* ============================================
   Member Modal - Group Members Management
   ============================================ */
.modal-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.modal-subtitle {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.member-modal-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.member-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast) ease;
  cursor: pointer;
}

.member-card:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
}

.member-card-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.member-card-details {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.member-card-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.member-card-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.member-card-badges {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.member-role-badge {
  font-size: 0.6875rem;
  padding: 0.125rem 0.5rem;
  cursor: default;
  pointer-events: none;
}

.member-role-badge i {
  margin-inline-start: 0.25rem;
  font-size: 0.6rem;
}

.member-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.member-card-actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

.member-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast) ease;
}

.member-action-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
  border-color: var(--primary);
}

.member-action-btn i {
  font-size: 0.75rem;
}

@media (max-width: 480px) {
  .member-card {
    flex-direction: column;
    align-items: stretch;
  }

  .member-card-actions {
    justify-content: flex-end;
  }

  .member-action-btn span {
    display: none;
  }

  .member-action-btn {
    padding: 0.5rem;
  }
}

/* ============================================
   Modals
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--overlay);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  opacity: 0;
  animation: fadeIn var(--transition-normal) ease forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

.modal.hidden {
  display: none;
}

.modal.bottom-sheet {
  align-items: flex-end;
  padding: 0;
}

.modal-content {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-2xl);
  padding: 1.5rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--glass-shadow-lg);
  animation: modalScaleIn var(--transition-normal) cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.bottom-sheet-content {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  max-height: 85vh;
  animation: slideUpSheet var(--transition-normal) ease;
}

@keyframes slideUpSheet {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Sending Modal */
.sending-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 0;
}

.sending-spinner {
  font-size: 2.5rem;
  color: var(--accent);
}

.sending-modal-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Management Grid */
.management-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

/* Delete Preview */
.delete-preview {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
}

/* Media Viewer */
.media-viewer {
  max-width: 960px;
}

.media-viewer-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.media-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem 0;
  overflow: hidden;
  /* Make viewer use available viewport height (mobile-friendly). */
  height: min(75vh, calc(100dvh - 220px));
}

/* Album / media viewer: loading overlay while next slide loads */
.media-viewer-loading {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  border-radius: var(--radius-lg);
}

.media-viewer-loading.hidden {
  display: none;
}

.media-viewer-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.media-viewer-loading-spinner {
  font-size: 2rem;
  color: rgba(255, 255, 255, 0.92);
}

.media-viewer-loading-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.02em;
}

.media-content {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-lg);
  background: #000;
  object-fit: contain;
}

#media-image {
  transform-origin: center center;
  transition: transform 160ms ease;
  /* We'll implement pinch/pan via pointer events. */
  touch-action: none;
  user-select: none;
}

#media-image.media-pannable {
  cursor: grab;
}

#media-image.media-panning {
  cursor: grabbing;
  transition: none;
}

.media-warning {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.media-warning.hidden {
  display: none;
}

.media-fallback {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Call Modal */
.call-modal {
  max-width: 600px;
}

.call-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  min-height: 320px;
  padding: 1rem;
  background: #111;
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.call-remote {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #000;
}

.call-remote video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.call-placeholder {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
  color: #fff;
}

.call-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}

.call-actions .btn {
  min-width: 140px;
}

.call-local-video {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  width: 100px;
  height: 130px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  background: #000;
}

@media (min-width: 480px) {
  .call-local-video {
    width: 120px;
    height: 160px;
  }
}

.call-remote-audio {
  display: none;
}

/* Recorder Modal */
.recorder-card {
  max-width: 560px;
}

.recorder-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
}

.recorder-video {
  width: 100%;
  max-height: 320px;
  border-radius: var(--radius-lg);
  background: #000;
}

.recorder-audio {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem;
  color: var(--primary);
}

.recorder-audio i {
  font-size: 3rem;
}

.recorder-dot {
  width: 12px;
  height: 12px;
  background: var(--danger);
  border-radius: 50%;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.recorder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.recorder-actions .btn {
  flex: 1;
  min-width: 140px;
}

/* ============================================
   Bottom Navigation (Mobile)
   ============================================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  background: var(--glass-bg-strong);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 100;
}

.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.bottom-nav-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 0.6875rem;
  transition: all var(--transition-fast) ease;
}

.bottom-nav-btn i {
  font-size: 1.25rem;
}

.bottom-nav-btn:hover,
.bottom-nav-btn.active {
  color: var(--primary);
  background: var(--primary-light);
}

.bottom-nav-btn.active i {
  transform: scale(1.15);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bottom-nav-btn i {
  transition: transform 0.2s ease;
}

.nav-avatar {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
  border: 2px solid var(--border-light);
}

.nav-badge {
  position: absolute;
  top: 0.25rem;
  right: 0.75rem;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border-radius: var(--radius-full);
}

/* ============================================
   Scrollbar Styles
   ============================================ */
.scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.scrollbar::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}

.scrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden { display: none !important; }
.block { display: block; }
.inline-flex { display: inline-flex; }
.flex { display: flex; }
.grid { display: grid; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-start { justify-content: flex-start; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.pt-2 { padding-top: 0.5rem; }
.pt-4 { padding-top: 1rem; }
.pb-2 { padding-bottom: 0.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.rounded { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }
.shadow { box-shadow: var(--glass-shadow); }
.shadow-lg { box-shadow: var(--glass-shadow-lg); }
.border { border: 1px solid var(--border-light); }
.w-full { width: 100%; }
.w-72 { width: 18rem; }
.w-80 { width: 20rem; }
.w-96 { width: 24rem; }
.h-full { height: 100%; }
.h-screen { height: 100vh; }
.min-h-screen { min-height: 100vh; }
.max-h-80 { max-height: 20rem; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.cursor-pointer { cursor: pointer; }
.transition { transition: all var(--transition-normal) ease; }
.opacity-70 { opacity: 0.7; }

.text-primary { color: var(--text-primary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--primary); }
.text-white { color: #ffffff; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.bg-accent { background-color: var(--primary); }
.bg-danger { background-color: var(--danger); }
.bg-success { background-color: var(--success); }

/* ============================================
   Responsive Styles
   ============================================ */
@media (min-width: 768px) {
  .md-flex { display: flex; }
  .md-grid { display: grid; }
  .md-block { display: block; }
  .md-hidden { display: none; }
  .md-flex-row { flex-direction: row; }
  .md-flex-col { flex-direction: column; }
  .md-w-80 { width: 20rem; }
  .md-w-96 { width: 24rem; }
  .md-h-screen { height: 100vh; }
  
  .menu-btn {
    display: inline-flex;
  }
  
  .desktop-menu-items {
    display: flex;
  }
}

@media (min-width: 769px) {
  .md-visible {
    display: inline-flex;
  }
}

@media (max-width: 1024px) {
  .message-row {
    max-width: 92%;
  }

  /* Touch / narrow: message actions use bottom sheet instead of inline toolbar */
  .message-actions {
    display: none !important;
    opacity: 1;
  }

  .message-action-buttons {
    flex-wrap: wrap;
    justify-content: center;
  }

  .message-action-buttons .icon-btn {
    width: 32px;
    height: 32px;
  }
}

@media (max-width: 768px) {
  .md-visible {
    display: none;
  }

  .mobile-datetime-inline {
    display: inline;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .app-header {
    display: none;
  }
  
  .app-main {
    padding: 0.5rem;
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
  }
  
  .bottom-nav {
    display: flex;
  }
  
  .desktop-menu-items {
    display: none;
  }
  
  /* Mobile chat view transitions */
  .conversation-panel,
  .chat-panel {
    transition: opacity var(--transition-normal) ease, transform var(--transition-normal) ease;
  }
  
  .conversation-panel {
    flex: 1;
    min-height: 0;
    opacity: 1;
    transform: translateX(0);
  }
  
  .chat-panel {
    opacity: 0;
    transform: translateX(8%);
    pointer-events: none;
    max-height: 0;
    overflow: hidden;
  }
  
  body.show-chat .conversation-panel {
    opacity: 0;
    transform: translateX(-8%);
    pointer-events: none;
    max-height: 0;
    overflow: hidden;
  }
  
  body.show-chat .chat-panel {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    max-height: none;
    flex: 1;
    min-height: 0;
  }
  
  body.show-chat .app-main {
    padding-top: 0;
  }

  body.show-chat .app-main {
    padding-bottom: env(safe-area-inset-bottom);
  }

  body.show-chat .bottom-nav {
    display: none;
  }
  
  .chat-composer {
    padding: 0.625rem;
  }
  
  .icon-btn {
    width: 36px;
    height: 36px;
  }
  
  .chat-input {
    min-height: 44px;
  }
  
  .message-row {
    max-width: 100%;
    min-width: 0;
  }

  .chat-messages {
    padding: 0.75rem;
    overflow-x: hidden;
  }
}

/* Section visibility */
#section-conversations {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

#section-conversations > .layout-grid {
  flex: 1;
  min-height: 0;
}

#section-management,
#section-profile {
  display: none;
}

#section-management.active,
#section-profile.active {
  display: block;
}

/* ============================================
   Error Page Styles
   ============================================ */
.error-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: 
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(239, 68, 68, 0.15), transparent),
    var(--bg-primary);
}

.error-card {
  text-align: center;
  max-width: 400px;
}

.error-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  background: var(--danger-light);
  color: var(--danger);
  border-radius: 50%;
  font-size: 2rem;
}

.error-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.error-message {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* ============================================
   Message Status Indicators
   ============================================ */
.message-status-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.message-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast) ease;
}

.message-status.clickable {
  cursor: pointer;
}

.message-status.clickable:hover {
  transform: scale(1.1);
}

/* Status States */
.message-status.sent {
  color: var(--text-muted);
}

.message-status.sent i {
  opacity: 0.7;
}

.message-status.delivered,
.message-status.partial-delivered {
  color: var(--text-secondary);
}

.message-status.partial-read {
  color: var(--info);
}

.message-status.partial-read i:first-child {
  color: var(--info);
}

.message-status.read {
  color: var(--info);
}

.message-status i {
  font-size: 0.7rem;
}

/* Message Status Modal */
#modal-message-status .modal-content {
  max-width: 360px;
}

#modal-message-status .modal-body {
  padding: 0;
}

.status-section {
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.status-section:last-child {
  border-bottom: none;
}

.status-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border-light);
}

.status-section-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.status-icon {
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.625rem;
}

.status-icon.read {
  background: var(--info-light);
  color: var(--info);
}

.status-icon.delivered {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.status-icon.sent {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.status-user-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.status-user-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast) ease;
}

.status-user-item:hover {
  background: var(--bg-tertiary);
}

.status-user-item .avatar.small {
  width: 1.75rem;
  height: 1.75rem;
  font-size: 0.625rem;
}

.status-user-name {
  flex: 1;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-user-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
  white-space: nowrap;
}

#message-status-content .empty-state {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

#message-status-content .empty-state i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

#message-status-content .empty-state p {
  margin: 0;
  font-size: 0.875rem;
}

/* ============================================
   AMOLED Dark Mode
   ============================================ */
:root[data-theme="amoled"] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #1a1a1a;

  --glass-bg: rgba(10, 10, 10, 0.85);
  --glass-bg-strong: rgba(10, 10, 10, 0.95);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --glass-shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.7);

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-light: #64748b;

  --border-light: rgba(255, 255, 255, 0.05);
  --border-medium: rgba(255, 255, 255, 0.1);

  --message-other-bg: #0a0a0a;
  --message-other-text: #f1f5f9;
  --message-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);

  --overlay: rgba(0, 0, 0, 0.85);
  --overlay-light: rgba(0, 0, 0, 0.6);
}

/* ============================================
   Theme Color Schemes
   ============================================ */
:root[data-accent="blue"] {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: rgba(59, 130, 246, 0.15);
  --gradient-start: #3b82f6;
  --gradient-middle: #60a5fa;
  --gradient-end: #06b6d4;
  --gradient-primary: linear-gradient(135deg, var(--gradient-start), var(--gradient-middle), var(--gradient-end));
  --gradient-hover: linear-gradient(135deg, #2563eb, #3b82f6, #0891b2);
}

:root[data-accent="green"] {
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-light: rgba(16, 185, 129, 0.15);
  --gradient-start: #10b981;
  --gradient-middle: #34d399;
  --gradient-end: #06b6d4;
  --gradient-primary: linear-gradient(135deg, var(--gradient-start), var(--gradient-middle), var(--gradient-end));
  --gradient-hover: linear-gradient(135deg, #059669, #10b981, #0891b2);
}

:root[data-accent="rose"] {
  --primary: #f43f5e;
  --primary-hover: #e11d48;
  --primary-light: rgba(244, 63, 94, 0.15);
  --gradient-start: #f43f5e;
  --gradient-middle: #fb7185;
  --gradient-end: #f97316;
  --gradient-primary: linear-gradient(135deg, var(--gradient-start), var(--gradient-middle), var(--gradient-end));
  --gradient-hover: linear-gradient(135deg, #e11d48, #f43f5e, #ea580c);
}

:root[data-accent="amber"] {
  --primary: #f59e0b;
  --primary-hover: #d97706;
  --primary-light: rgba(245, 158, 11, 0.15);
  --gradient-start: #f59e0b;
  --gradient-middle: #fbbf24;
  --gradient-end: #f97316;
  --gradient-primary: linear-gradient(135deg, var(--gradient-start), var(--gradient-middle), var(--gradient-end));
  --gradient-hover: linear-gradient(135deg, #d97706, #f59e0b, #ea580c);
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
  width: 100%;
  max-width: min(480px, calc(100vw - 2rem));
  padding: 0 1rem;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  pointer-events: auto;
  animation: toastSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
  direction: rtl;
  text-align: right;
}

.toast.toast-exit {
  animation: toastSlideOut 0.3s ease-in forwards;
}

.toast-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  margin-top: 0.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  font-size: 1rem;
  flex-shrink: 0;
}

/* High-contrast toast backgrounds with white text for readability */
.toast-success {
  background: var(--success-bg);
  color: #ffffff;
}
.toast-success .toast-icon { background: rgba(255, 255, 255, 0.25); color: #ffffff; }
.toast-success .toast-title,
.toast-success .toast-message { color: #ffffff; }
.toast-success .toast-close { color: rgba(255, 255, 255, 0.9); }
.toast-success .toast-close:hover { color: #ffffff; background: rgba(255, 255, 255, 0.2); }

.toast-error {
  background: var(--danger-bg);
  color: #ffffff;
}
.toast-error .toast-icon { background: rgba(255, 255, 255, 0.25); color: #ffffff; }
.toast-error .toast-title,
.toast-error .toast-message { color: #ffffff; }
.toast-error .toast-close { color: rgba(255, 255, 255, 0.9); }
.toast-error .toast-close:hover { color: #ffffff; background: rgba(255, 255, 255, 0.2); }

.toast-warning {
  background: var(--warning-bg);
  color: #ffffff;
}
.toast-warning .toast-icon { background: rgba(255, 255, 255, 0.25); color: #ffffff; }
.toast-warning .toast-title,
.toast-warning .toast-message { color: #ffffff; }
.toast-warning .toast-close { color: rgba(255, 255, 255, 0.9); }
.toast-warning .toast-close:hover { color: #ffffff; background: rgba(255, 255, 255, 0.2); }

.toast-info {
  background: var(--info-bg);
  color: #ffffff;
}
.toast-info .toast-icon { background: rgba(255, 255, 255, 0.25); color: #ffffff; }
.toast-info .toast-title,
.toast-info .toast-message { color: #ffffff; }
.toast-info .toast-close { color: rgba(255, 255, 255, 0.9); }
.toast-info .toast-close:hover { color: #ffffff; background: rgba(255, 255, 255, 0.2); }

.toast-body {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

.toast-title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.25rem;
}

.toast-message {
  font-size: 0.875rem;
  line-height: 1.55;
  opacity: 0.95;
}

.toast-close {
  width: 32px;
  height: 32px;
  min-width: 32px;
  margin-top: 0.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast) ease;
  flex-shrink: 0;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  right: 0;
  height: 3px;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  transition: width linear;
}

.toast-success .toast-progress,
.toast-error .toast-progress,
.toast-warning .toast-progress,
.toast-info .toast-progress { background: rgba(255, 255, 255, 0.5); }

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastSlideOut {
  to {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
}

/* ============================================
   Inline Status Messages
   ============================================ */
.status-message {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  font-size: 0.8125rem;
  line-height: 1.5;
  animation: statusFadeIn 0.3s ease-out;
  border: 1px solid;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}

.status-message:empty {
  display: none;
}

.status-message-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.status-message-text {
  flex: 1;
  min-width: 0;
}

/* Status Types - high contrast text on light backgrounds */
.status-message-success {
  background: var(--success-light);
  border-color: var(--success-bg);
  color: var(--success-bg);
}

.status-message-success .status-message-icon {
  color: var(--success-bg);
}

.status-message-error {
  background: var(--danger-light);
  border-color: var(--danger-bg);
  color: var(--danger-bg);
}

.status-message-error .status-message-icon {
  color: var(--danger-bg);
}

.status-message-warning {
  background: var(--warning-light);
  border-color: var(--warning-bg);
  color: var(--warning-bg);
}

.status-message-warning .status-message-icon {
  color: var(--warning-bg);
}

.status-message-info {
  background: var(--info-light);
  border-color: var(--info-bg);
  color: var(--info-bg);
}

.status-message-info .status-message-icon {
  color: var(--info-bg);
}

.status-message-muted {
  background: var(--bg-secondary);
  border-color: var(--border-light);
  color: var(--text-muted);
}

.status-message-muted .status-message-icon {
  color: var(--text-muted);
}

@keyframes statusFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Skeleton Loading
   ============================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-circle {
  border-radius: 50%;
}

.skeleton-conversation {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem;
}

.skeleton-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  flex-shrink: 0;
}

.skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.skeleton-line {
  height: 12px;
  border-radius: var(--radius-sm);
}

.skeleton-line-short { width: 60%; }
.skeleton-line-medium { width: 80%; }
.skeleton-line-full { width: 100%; }

.skeleton-message {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.skeleton-bubble {
  padding: 1rem;
  border-radius: var(--radius-xl);
  max-width: 65%;
}

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   Typing Indicator
   ============================================ */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  animation: fadeIn 0.3s ease;
}

.typing-indicator.active {
  display: flex;
}

.typing-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
  animation: typingBounce 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; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ============================================
   Date Separator
   ============================================ */
.date-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0;
  position: relative;
}

.date-separator::before,
.date-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-medium), transparent);
}

.date-separator-text {
  padding: 0.25rem 1rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
}

.unread-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0;
  position: relative;
}

.unread-separator::before,
.unread-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--primary);
  opacity: 0.5;
}

.unread-separator-text {
  padding: 0.25rem 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--glass-bg);
  border: 1px solid var(--primary);
  border-radius: var(--radius-full);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
  opacity: 0.85;
}

/* ============================================
   Empty States
   ============================================ */
.empty-state-chat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2rem;
  text-align: center;
  animation: fadeIn 0.5s ease;
}

.empty-state-icon {
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  animation: emptyIconFloat 3s ease-in-out infinite;
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.empty-state-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.6;
}

@keyframes emptyIconFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ============================================
   Connection Status Banner
   ============================================ */
.connection-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #fff;
  background: var(--danger);
  animation: slideDown 0.3s ease;
  position: sticky;
  top: 0;
  z-index: 200;
}

.connection-banner.active {
  display: flex;
}

.connection-banner.reconnecting {
  background: var(--warning);
  color: #000;
}

.connection-banner.connected {
  background: var(--success);
  animation: slideDown 0.3s ease, fadeOut 0.5s ease 2s forwards;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

@keyframes fadeOut {
  to { opacity: 0; height: 0; padding: 0; overflow: hidden; }
}

/* ============================================
   Drag & Drop File Overlay
   ============================================ */
.drag-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(124, 58, 237, 0.1);
  border: 3px dashed var(--primary);
  border-radius: var(--radius-xl);
  z-index: 50;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
}

.drag-overlay.active {
  display: flex;
}

.drag-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: var(--primary);
}

.drag-overlay-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 50%;
  font-size: 1.5rem;
  animation: dragBounce 1s ease-in-out infinite;
}

.drag-overlay-text {
  font-size: 0.9375rem;
  font-weight: 600;
}

@keyframes dragBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ============================================
   Colorful Avatars
   ============================================ */
.avatar[data-color="1"] { background: var(--avatar-1); }
.avatar[data-color="2"] { background: var(--avatar-2); }
.avatar[data-color="3"] { background: var(--avatar-3); }
.avatar[data-color="4"] { background: var(--avatar-4); }
.avatar[data-color="5"] { background: var(--avatar-5); }
.avatar[data-color="6"] { background: var(--avatar-6); }
.avatar[data-color="7"] { background: var(--avatar-7); }
.avatar[data-color="8"] { background: var(--avatar-8); }
.avatar[data-color="9"] { background: var(--avatar-9); }
.avatar[data-color="10"] { background: var(--avatar-10); }

/* ============================================
   Login Page Staggered Animations
   ============================================ */
.login-stagger-1 { animation: loginFadeUp 0.6s ease-out 0.1s both; }
.login-stagger-2 { animation: loginFadeUp 0.6s ease-out 0.2s both; }
.login-stagger-3 { animation: loginFadeUp 0.6s ease-out 0.3s both; }
.login-stagger-4 { animation: loginFadeUp 0.6s ease-out 0.4s both; }
.login-stagger-5 { animation: loginFadeUp 0.6s ease-out 0.5s both; }

@keyframes loginFadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Login Success Animation */
.login-success-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--overlay);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 9999;
}

.login-success-overlay.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.login-success-check {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  font-size: 2rem;
  animation: successPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes successPop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

/* Login Parallax */
.login-bg-orbs.parallax .orb {
  transition: transform 0.15s ease-out;
}

/* ============================================
   Improved Bottom Sheet Handle
   ============================================ */
.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border-medium);
  border-radius: var(--radius-full);
  margin: 0 auto 1rem;
}

/* ============================================
   Context Menu (Better Message Actions)
   ============================================ */
.context-menu {
  position: fixed;
  z-index: 1100;
  min-width: 180px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--glass-shadow-lg);
  padding: 0.375rem;
  animation: contextMenuIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.context-menu.hidden {
  display: none;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast) ease;
  width: 100%;
}

.context-menu-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.context-menu-item.danger {
  color: var(--danger);
}

.context-menu-item.danger:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.context-menu-item i {
  width: 18px;
  text-align: center;
  font-size: 0.8125rem;
}

.context-menu-divider {
  height: 1px;
  background: var(--border-light);
  margin: 0.25rem 0.5rem;
}

@keyframes contextMenuIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ============================================
   Theme Picker Dots
   ============================================ */
.theme-accent-picker {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.accent-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all var(--transition-fast) ease;
  position: relative;
}

.accent-dot:hover {
  transform: scale(1.15);
}

.accent-dot.active {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-primary);
}

.accent-dot.active::after {
  content: "";
  position: absolute;
  inset: 4px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E") center/60% no-repeat;
}

.accent-purple { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.accent-blue { background: linear-gradient(135deg, #3b82f6, #60a5fa); }
.accent-green { background: linear-gradient(135deg, #10b981, #34d399); }
.accent-rose { background: linear-gradient(135deg, #f43f5e, #fb7185); }
.accent-amber { background: linear-gradient(135deg, #f59e0b, #fbbf24); }

/* ============================================
   Delete Confirmation Shake
   ============================================ */
.modal-shake {
  animation: modalShake 0.5s ease;
}

@keyframes modalShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ============================================
   Smooth Theme Transitions
   ============================================ */
html.theme-transitioning,
html.theme-transitioning * {
  transition: background-color 0.4s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* ============================================
   Conversation List Improvements
   ============================================ */
.conversation-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  color: var(--text-light);
  padding: 0.1875rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
}

.conversation-type-badge i {
  font-size: 0.5rem;
}

/* Message preview with type icon */
.message-preview-icon {
  display: inline-flex;
  margin-left: 0.25rem;
  color: var(--text-light);
  font-size: 0.6875rem;
}

/* ============================================
   Enhanced Scrollbar
   ============================================ */
.scrollbar::-webkit-scrollbar {
  width: 5px;
}

.scrollbar::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}

.scrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

/* Firefox scrollbar */
.scrollbar {
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

/* ============================================
   Profile Section Inline Styles
   ============================================ */
.profile-section {
  padding: 1.5rem;
}

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.profile-avatar-large {
  width: 80px;
  height: 80px;
  font-size: 2rem;
  border-radius: var(--radius-xl);
  box-shadow: var(--glass-shadow);
}

/* Profile Form Layout */
.profile-form-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0.5rem 0;
}

.profile-form-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
}

.avatar-preview-hero {
  cursor: pointer;
  border: 3px solid var(--primary);
  background: var(--gradient-primary);
  color: var(--text-inverse);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.25);
  transition: all var(--transition-fast) ease;
}

.avatar-preview-hero:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.35);
}

.profile-form-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 1rem;
  border: 1px solid var(--border-light);
}

.profile-form-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.profile-form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.permission-denied-guide {
  margin-top: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--warning-light);
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.permission-denied-guide.hidden {
  display: none;
}

/* ============================================
   Improved Composer
   ============================================ */
.chat-input {
  transition: all var(--transition-fast) ease, height 0.15s ease;
}

.composer-divider {
  height: 1px;
  background: var(--border-light);
  margin: 0;
}

/* File drop zone active state on chat body */
.chat-body.drag-active {
  position: relative;
}

/* ============================================
   Focus within improvements
   ============================================ */
.chat-composer:focus-within {
  border-color: var(--primary);
  background: var(--glass-bg-strong);
}

.chat-composer:focus-within .icon-btn.send {
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
}

/* ============================================
   Improved Button Interactions
   ============================================ */
.btn {
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(255,255,255,0.2) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn:active::after {
  opacity: 1;
}

/* ============================================
   New Message Notification Pill
   ============================================ */
.new-messages-pill {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-inverse);
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
  cursor: pointer;
  z-index: 10;
  animation: pillBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.new-messages-pill.active {
  display: flex;
}

@keyframes pillBounce {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

/* ============================================
   Location Picker Modal
   ============================================ */
.location-picker-card {
  max-width: 500px;
  width: 100%;
}

.location-picker-body {
  position: relative;
  width: 100%;
  height: 350px;
  overflow: hidden;
}

.location-picker-map {
  width: 100%;
  height: 100%;
}

.location-picker-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -90%);
  font-size: 2rem;
  color: var(--danger);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
  pointer-events: none;
  z-index: 10;
}

.location-picker-coords {
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  color: var(--text-secondary);
  z-index: 10;
  direction: ltr;
  font-family: monospace;
}

.location-picker-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  gap: 0.5rem;
}

@media (max-width: 640px) {
  .location-picker-body {
    height: 300px;
  }
}

/* ============================================
   Location Action Sheet
   ============================================ */
.action-sheet {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.action-sheet.hidden {
  display: none;
}

.action-sheet-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease;
}

.action-sheet-content {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--bg-primary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 0.5rem;
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.action-sheet-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.action-sheet-header i {
  color: var(--success);
}

.action-sheet-items {
  display: flex;
  flex-direction: column;
}

.action-sheet-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: none;
  background: none;
  width: 100%;
  text-align: right;
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast) ease;
  font-family: inherit;
}

.action-sheet-item:hover {
  background: var(--bg-secondary);
}

.action-sheet-item i {
  width: 1.25rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 1rem;
}

.action-sheet-cancel {
  display: block;
  width: 100%;
  padding: 0.75rem;
  margin-top: 0.25rem;
  border: none;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: background var(--transition-fast) ease;
}

.action-sheet-cancel:hover {
  background: var(--bg-tertiary);
}

@media (min-width: 641px) {
  .action-sheet {
    align-items: center;
  }

  .action-sheet-content {
    border-radius: var(--radius-xl);
    margin: 0 1rem;
  }
}
