:root {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-card: rgba(18, 26, 45, 0.75);
  --bg-card-hover: rgba(28, 38, 64, 0.85);
  --bg-glass: rgba(15, 23, 42, 0.65);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.35);

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.4);

  --secondary: #10b981;
  --secondary-glow: rgba(16, 185, 129, 0.4);

  --accent-gold: #f59e0b;
  --danger: #ef4444;

  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.07) 0%, transparent 40%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Auth Overlay / Modal */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  position: relative;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.logo-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid var(--border-glow);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  margin-bottom: 16px;
}

.logo-badge svg {
  color: var(--primary);
}

.logo-badge span {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.auth-header h1 {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.auth-header p {
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.8);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

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

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

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 14px;
  transition: all 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, #4338ca 100%);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.auth-alert {
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.auth-alert.error {
  display: block;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* Main Dashboard Layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.app-header {
  height: 64px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.header-brand h2 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.header-brand h2 span {
  color: var(--secondary);
}

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

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--accent-gold);
  cursor: pointer;
  transition: all 0.2s;
}

.status-chip:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.status-chip.connected {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--secondary);
}

.status-chip-tg {
  background: rgba(34, 158, 217, 0.12);
  border-color: rgba(34, 158, 217, 0.3);
  color: #229ed9;
}

.status-chip-tg.connected {
  background: rgba(34, 158, 217, 0.2);
  border-color: rgba(34, 158, 217, 0.5);
  color: #38bdf8;
}

.badge-telegram {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(34, 158, 217, 0.15);
  color: #229ed9;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-dot.pulse {
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 currentColor; }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.btn-header {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-header:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-vip {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(217, 119, 6, 0.2) 100%);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}

.btn-vip:hover {
  background: rgba(245, 158, 11, 0.3);
}

/* App Main Workspace */
.app-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left Sidebar: Contacts */
.contacts-sidebar {
  width: 340px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.contacts-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.contacts-header h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.account-pills-container {
  padding: 8px 14px 4px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.account-pills-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.account-pills-scroll::-webkit-scrollbar {
  display: none;
}

.account-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.account-filter-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.account-filter-pill.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: #38bdf8;
  color: #38bdf8;
  font-weight: 600;
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.contact-account-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.03em;
  margin-left: 4px;
  display: inline-flex;
  align-items: center;
}

.account-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.account-card-item:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
}

.search-box {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
}

.search-input-wrapper {
  position: relative;
}

.search-input-wrapper svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input-wrapper input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.search-input-wrapper input:focus {
  border-color: var(--primary);
}

.contacts-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: all 0.15s ease;
}

.contact-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.contact-item.active {
  background: rgba(99, 102, 241, 0.12);
  border-left: 3px solid var(--primary);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-main);
  flex-shrink: 0;
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.contact-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.contact-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chat Main View */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.chat-header {
  height: 64px;
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-glass);
}

.chat-partner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-partner-info h4 {
  font-size: 15px;
  font-weight: 600;
}

.chat-partner-info span {
  font-size: 12px;
  color: var(--text-muted);
}

.chat-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-select-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.select-custom {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

/* Message Stream */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message-bubble {
  max-width: 65%;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  position: relative;
  line-height: 1.45;
}

.message-bubble.incoming {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

.message-bubble.outgoing {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(79, 70, 229, 0.3) 100%);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-bottom-right-radius: 4px;
}

.bubble-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.bubble-tag.trans {
  color: var(--secondary);
}

.bubble-tag.orig {
  color: var(--text-muted);
}

.msg-text-primary {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 6px;
}

.msg-text-translated {
  font-size: 13px;
  color: #cbd5e1;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.msg-audio-player {
  margin-top: 8px;
  width: 100%;
}

.msg-time {
  align-self: flex-end;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Chat Input Bar */
.chat-input-area {
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-message {
  flex: 1;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 12px 16px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.input-message:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-send {
  background: var(--primary);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-send:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-record {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-record:hover {
  border-color: var(--secondary);
  color: var(--secondary);
}

.btn-record.recording {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--danger);
  color: var(--danger);
  animation: pulse-dot 1.2s infinite;
}

/* Modals (WhatsApp Linking, Add Contact, VIP) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.8);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  position: relative;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.btn-close:hover {
  color: var(--text-main);
}

/* QR Code Section */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
}

.qr-box {
  width: 240px;
  height: 240px;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.25);
  margin-bottom: 16px;
}

.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pairing-code-display {
  font-family: monospace;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--secondary);
  background: rgba(16, 185, 129, 0.1);
  border: 1px dashed var(--secondary);
  padding: 16px 28px;
  border-radius: var(--radius-md);
  margin: 16px 0;
}

/* Empty State */
.empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 12px;
}

.empty-chat svg {
  color: var(--primary);
  opacity: 0.6;
}

/* VIP Subscription Cards */
.vip-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.vip-plan-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: all 0.2s;
}

.vip-plan-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.vip-plan-card.featured {
  border-color: var(--accent-gold);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08) 0%, rgba(15, 23, 42, 0.7) 100%);
}

.vip-plan-card h4 {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
}

.vip-price {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  margin: 10px 0;
}

.vip-price span {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.vip-features {
  list-style: none;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  flex: 1;
}

.vip-features li {
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-tone-btn.active {
  background: rgba(0, 168, 132, 0.25) !important;
  color: #00A884 !important;
  border-color: #00A884 !important;
  font-weight: 700;
}

/* ─── Refresh Chat Button Animation ─────────────────────────────────────────── */
.btn-header.refreshing svg {
  animation: spin 0.8s linear infinite;
  color: var(--secondary) !important;
}

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

/* ─── Message Row & Swipe to Reply ─────────────────────────────────────────── */
.message-row {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
  margin-bottom: 4px;
}

.message-row.incoming {
  justify-content: flex-start;
}

.message-row.outgoing {
  justify-content: flex-end;
}

.swipe-reply-indicator {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%) scale(0.6);
  opacity: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 168, 132, 0.2);
  border: 1px solid rgba(0, 168, 132, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #00A884;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
  z-index: 1;
}

.swipe-reply-indicator.ready {
  opacity: 1;
  transform: translateY(-50%) scale(1.1);
  background: #00A884;
  color: white;
  box-shadow: 0 0 12px rgba(0, 168, 132, 0.6);
}

.message-bubble {
  touch-action: pan-y;
  user-select: text;
  transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  z-index: 2;
}

.message-bubble.swiping {
  transition: none;
}

/* ─── Hover Action Bar (Desktop Quick Actions) ─────────────────────────────── */
.bubble-action-bar {
  position: absolute;
  top: -14px;
  opacity: 0;
  pointer-events: none;
  display: flex;
  gap: 4px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 2px 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: opacity 0.15s ease, transform 0.15s ease;
  transform: translateY(4px);
  z-index: 20;
}

.message-row.incoming .bubble-action-bar {
  right: -8px;
}

.message-row.outgoing .bubble-action-bar {
  left: -8px;
}

.message-row:hover .bubble-action-bar {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.bubble-action-btn {
  background: none;
  border: none;
  color: #cbd5e1;
  padding: 4px 6px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background 0.15s, transform 0.15s, color 0.15s;
}

.bubble-action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  transform: scale(1.15);
}

/* ─── Quoted Message Header in Message Bubble ──────────────────────────────── */
.quoted-message-header {
  display: flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 8px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border-left: 3.5px solid #00A884;
  transition: background 0.15s ease;
}

.quoted-message-header.outgoing-quoted {
  border-left-color: #53BDEB;
}

.quoted-message-header:hover {
  background: rgba(0, 0, 0, 0.38);
}

.quoted-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.quoted-author {
  font-size: 11px;
  font-weight: 700;
  color: #00A884;
  margin-bottom: 2px;
}

.quoted-message-header.outgoing-quoted .quoted-author {
  color: #53BDEB;
}

.quoted-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

/* Flash animation for scrolled target message */
@keyframes highlight-flash {
  0% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.03); filter: brightness(1.6); box-shadow: 0 0 18px rgba(0, 168, 132, 0.6); }
  100% { transform: scale(1); filter: brightness(1); }
}

.highlight-target {
  animation: highlight-flash 1s ease;
}

/* ─── Quoted Reply Preview Bar (above Chat Input) ──────────────────────────── */
.quoted-reply-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #182229;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 18px;
  animation: slideDown 0.2s ease;
  z-index: 10;
}

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

.quoted-reply-accent {
  width: 4px;
  height: 38px;
  border-radius: 2px;
  background: #00A884;
  flex-shrink: 0;
}

.quoted-reply-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.quoted-reply-author {
  font-size: 12px;
  font-weight: 700;
  color: #00A884;
  margin-bottom: 2px;
}

.quoted-reply-snippet {
  font-size: 13px;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-cancel-reply {
  background: none;
  border: none;
  color: #8696A0;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.btn-cancel-reply:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

/* ─── Emoji Reactions on Message Bubble ────────────────────────────────────── */
.bubble-reactions {
  position: absolute;
  bottom: -11px;
  display: flex;
  gap: 3px;
  z-index: 5;
}

.message-bubble.outgoing .bubble-reactions {
  right: 8px;
}

.message-bubble.incoming .bubble-reactions {
  left: 8px;
}

.reaction-pill {
  background: #1F2C34;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 2px 6px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

.reaction-pill:hover {
  transform: scale(1.15);
  border-color: #00A884;
}

.reaction-pill.me {
  background: rgba(0, 168, 132, 0.25);
  border-color: #00A884;
}

/* Floating Quick Reaction Picker */
.quick-reaction-picker {
  position: absolute;
  top: -46px;
  background: #1F2C34;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 28px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  z-index: 100;
  animation: popScale 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popScale {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}

.message-bubble.outgoing .quick-reaction-picker {
  right: 0;
}

.message-bubble.incoming .quick-reaction-picker {
  left: 0;
}

.reaction-btn {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.15s ease, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reaction-btn:hover {
  transform: scale(1.3);
  background: rgba(255, 255, 255, 0.1);
}

.reaction-btn.more-btn {
  font-size: 18px;
  color: #8696A0;
  width: 28px;
  height: 28px;
}

.reaction-btn.more-btn:hover {
  color: white;
}

/* Full Emoji Reaction Picker Grid Modal */
.reaction-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 8px 4px;
}

.reaction-grid-emoji {
  font-size: 26px;
  text-align: center;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: transform 0.12s, background 0.12s;
  user-select: none;
}

.reaction-grid-emoji:hover {
  transform: scale(1.25);
  background: rgba(255, 255, 255, 0.1);
}

/* ─── Media Presentation in Chat ───────────────────────────────────────────── */
.msg-image-wrap {
  margin-bottom: 6px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  border-radius: 8px;
  max-width: 320px;
}

.msg-image-wrap img {
  display: block;
  max-width: 100%;
  max-height: 280px;
  border-radius: 8px;
  object-fit: cover;
  transition: filter 0.2s ease, transform 0.2s ease;
}

.msg-image-wrap:hover img {
  filter: brightness(1.05);
}

.msg-image-hover-icon {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  color: white;
  border-radius: 50%;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.msg-image-wrap:hover .msg-image-hover-icon {
  opacity: 1;
}

.msg-video-wrap {
  margin-bottom: 6px;
  max-width: 340px;
  border-radius: 8px;
  overflow: hidden;
}

.msg-video-wrap video {
  width: 100%;
  max-height: 280px;
  border-radius: 8px;
  display: block;
  background: black;
}

.msg-doc-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 6px;
  text-decoration: none;
  color: white;
  transition: background 0.15s ease;
}

.msg-doc-card:hover {
  background: rgba(0, 0, 0, 0.35);
}

.msg-doc-icon {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.msg-doc-info {
  flex: 1;
  min-width: 0;
}

.msg-doc-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-doc-meta {
  font-size: 11px;
  color: #8696A0;
}

/* ─── Modern Voice Note Player ─────────────────────────────────────────────── */
.voice-note-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  margin-top: 4px;
  margin-bottom: 4px;
  min-width: 220px;
}

.btn-audio-play {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #00A884;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease, background 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 168, 132, 0.3);
}

.btn-audio-play:hover {
  transform: scale(1.08);
  background: #00c49b;
}

.voice-waveform-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.voice-waveform-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

.voice-waveform-progress {
  height: 100%;
  background: #00A884;
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
}

.voice-note-time {
  font-size: 11px;
  color: #8696A0;
}

/* ─── Fullscreen Image Lightbox ────────────────────────────────────────────── */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(10px);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.lightbox-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

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

.lightbox-toolbar {
  position: absolute;
  top: 20px;
  right: 24px;
  display: flex;
  gap: 12px;
  z-index: 10;
}

.lightbox-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
  text-decoration: none;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.08);
}

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 85vh;
}

.lightbox-content img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8);
}

.lightbox-caption {
  margin-top: 14px;
  color: #e2e8f0;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 16px;
  border-radius: 8px;
  max-width: 80vw;
  text-align: center;
}

/* ─── AI Chat Summary Feature ─── */
#btnSummarizeChat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

#btnSummarizeChat:hover {
  background: rgba(168, 85, 247, 0.25) !important;
  border-color: rgba(168, 85, 247, 0.6) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.25);
}

.summary-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-section {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 13px 16px;
  transition: background 0.2s, border-color 0.2s;
}

.summary-section:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(168, 85, 247, 0.3);
}

.summary-section-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #f8fafc;
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.summary-section-body {
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.6;
}

.summary-section-body ul {
  margin: 4px 0 0 0;
  padding-left: 18px;
}

.summary-section-body li {
  margin-bottom: 5px;
}

.summary-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(168, 85, 247, 0.2);
  border-top-color: #a855f7;
  border-radius: 50%;
  animation: summarySpin 0.8s linear infinite;
}

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

.btn-summary-scope {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-summary-scope:hover {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.4);
  color: #c084fc;
}

.btn-summary-scope.active {
  background: rgba(168, 85, 247, 0.25) !important;
  border-color: rgba(168, 85, 247, 0.75) !important;
  color: #f3e8ff !important;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.25);
}

