/* ============================================================
   SOChat - chat.css
   Main app layout, sidebar, chat panel, composer
   ============================================================ */

:root {
  /* ---- Colors: Light (Default) ---- */
  --bg: #f3f4f6;
  --sidebar-bg: #ffffff;
  --chat-bg: #ebe8df;
  --chat-bg-pattern: #ebe8df;
  --card: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --border-light: rgba(0, 0, 0, 0.04);
  
  --text-main: #1f2937;
  --text-sub: #4b5563;
  --text-muted: #9ca3af;
  
  --primary: #286e34;
  --primary-rgb: 40, 110, 52;
  --primary-light: rgba(40, 110, 52, 0.08);
  --primary-glow: rgba(40, 110, 52, 0.15);
  --accent: #34d399;
  
  --input-bg: #f3f4f6;
  --bubble-in: #ffffff;
  --bubble-in-text: #1f2937;
  --bubble-out: #286e34;
  --bubble-out-text: #ffffff;
  
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  
  /* ---- Dimensions & Tokens ---- */
  --sidebar-width: 320px;
  --header-h: 64px;
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  
  --t-fast: 0.15s;
  --t-base: 0.25s;
  --t-slow: 0.35s;
}

/* ---- Dark Theme Overrides ---- */
[data-theme="dark"] {
  --bg: #0f172a;
  --sidebar-bg: #1e293b;
  --chat-bg: #0f172a;
  --chat-bg-pattern: #0f172a;
  --card: #1e293b;
  --border: rgba(255, 255, 255, 0.12);
  --border-light: rgba(255, 255, 255, 0.08);
  
  --text-main: #f8fafc;
  --text-sub: #cbd5e1;
  --text-muted: #64748b;
  
  --input-bg: #0f172a;
  --bubble-in: #334155;
  --bubble-in-text: #f8fafc;
  
  /* Primary and status colors stay similar but can be fine-tuned */
  --primary-light: rgba(40, 110, 52, 0.2);
  --primary-glow: rgba(40, 110, 52, 0.3);
}

/* ---- App Shell ---- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-main);
}

#main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  height: 100%;
  overflow: hidden;
  z-index: 100;
  transition: transform var(--t-slow);
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px 12px;
  height: auto;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.sidebar-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: contain;
  display: block;
}

.brand-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}


/* Profile button */
.btn-icon {
  background: none; border: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-sub);
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.btn-icon:hover {
  background: var(--primary);
  color: #fff;
}

.btn-icon-alt {
  background: var(--input-bg);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-sub);
  transition: all var(--t-fast);
  flex-shrink: 0;
}

.btn-icon-alt:hover {
  background: var(--primary);
  color: #fff;
  transform: scale(1.05);
}


/* ---- Search ---- */
.sidebar-search {
  padding: 12px 16px;
  flex-shrink: 0;
}
.search-wrap {
  position: relative;
}
.search-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .9rem;
  pointer-events: none;
}
#searchInput {
  width: 100%;
  padding: 9px 36px 9px 36px;
  background: var(--input-bg);
  border: 1.5px solid transparent;
  border-radius: 20px;
  font-size: .875rem;
  font-family: 'Inter', sans-serif;
  color: var(--text-main);
  outline: none;
  transition: border-color var(--t-base), background var(--t-base);
}
#searchInput:focus {
  border-color: var(--primary);
  background: var(--sidebar-bg);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.search-clear {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer; color: var(--text-muted);
  font-size: 1rem; display: none;
  padding: 2px;
  border-radius: var(--radius-xs);
  transition: color var(--t-fast);
}
.search-clear:hover { color: var(--text-main); }
.search-clear.visible { display: block; }

/* ---- Search Results ---- */
#searchResults {
  display: none;
  flex-direction: column;
  gap: 2px;
}
#searchResults.visible { display: flex; }
#searchResults .section-label {
  padding: 8px 16px 4px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

/* ---- Chat List ---- */
.conversations-section {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.section-label {
  padding: 8px 16px 4px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  flex-shrink: 0;
}
#chatList {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px 8px;
}

/* ---- Chat Item ---- */
.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--t-fast);
  position: relative;
  text-decoration: none;
  color: inherit;
}
.chat-item:hover {
  background: var(--primary);
}
.chat-item:hover .chat-item-name,
.chat-item:hover .chat-item-time,
.chat-item:hover .chat-item-preview,
.chat-item:hover .pinned-icon {
  color: #fff !important;
}
.chat-item.active {
  background: var(--primary);
  color: #fff;
  border-left: 3px solid var(--primary-dark);
  padding-left: 7px;
}
.chat-item.active .chat-item-name,
.chat-item.active .chat-item-time,
.chat-item.active .chat-item-preview,
.chat-item.active .pinned-icon {
  color: #fff !important;
}
.chat-item-info {
  flex: 1;
  min-width: 0;
}
.chat-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.chat-item-name {
  font-size: .9rem; font-weight: 600;
  color: var(--text-main);
}
.chat-item-time {
  font-size: .7rem; color: var(--text-muted);
  flex-shrink: 0; margin-left: 4px;
}
.chat-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.chat-item-preview {
  font-size: .8rem; color: var(--text-sub);
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1;
}
.chat-item-preview.typing-active {
  color: var(--success);
  font-style: italic;
  font-weight: 500;
}
.chat-item-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.pinned-icon {
  font-size: 0.75rem;
  color: var(--primary);
  opacity: 0.8;
}

.btn-pin-toggle {
  display: none;
  background: var(--primary-light);
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 0.85rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  color: var(--primary);
  padding: 0;
  margin: 0;
  line-height: 1;
}

.chat-item:hover .btn-pin-toggle,
.chat-item.active .btn-pin-toggle {
  display: flex;
}

.btn-pin-toggle:hover {
  background: var(--primary);
  color: #fff;
  transform: scale(1.1);
}

/* ---- Sidebar Footer ---- */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-user-info {
  flex: 1; min-width: 0;
  cursor: pointer;
}
.sidebar-user-name {
  font-size: .875rem; font-weight: 600;
  color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-status {
  font-size: .73rem; color: var(--success);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-footer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}


/* ============================================================ 
   PHASE 2.5: GROUP CHAT STYLES                                
   ============================================================ */

/* Modal size variant */
.modal.modal-md {
  max-width: 440px;
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.form-control {
  width: 100%;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
  transition: all var(--t-fast);
}
.form-control:focus {
  border-color: var(--primary);
  background: var(--card);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

/* Member Search results */
.group-member-results {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  display: flex;
  flex-direction: column;
}
.group-member-results:empty {
  display: none;
}
.member-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--t-fast);
}
.member-result-item:hover {
  background: var(--primary-light);
}
.member-result-info {
  display: flex;
  flex-direction: column;
}
.member-result-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}
.member-result-user {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Selected Members (Chips) */
.group-selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}
.selected-member-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--secondary);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  animation: chipIn 0.2s ease-out;
}
@keyframes chipIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.selected-member-chip button {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity var(--t-fast);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.selected-member-chip button:hover {
  opacity: 1;
}

/* Modal Specific Buttons */
.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}
.btn-primary, .btn-secondary {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  border: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--border-light);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: var(--border);
}
.btn-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-sub);
  transition: all var(--t-fast);
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.btn-close:hover {
  color: var(--danger);
  background: #fee2e2;
}



/* Sender name inside message bubbles (for groups) */
.msg-sender-name {
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--primary);
  display: block;
}
.outgoing .msg-sender-name { display: none; } /* Hide own name in groups */

/* Group Modal & Member Selection */
.group-selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
  min-height: 32px;
}
.selected-member-chip {
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.selected-member-chip button {
  background: none; border: none; font-size: 1rem; cursor: pointer; color: var(--primary);
  line-height: 1; padding: 0;
}

.group-member-results {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 8px;
  background: var(--card-bg);
}
.member-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background var(--t-fast);
}
.member-result-item:hover {
  background: var(--primary-light);
}
.member-result-item .avatar-sm { width: 30px; height: 30px; }
.member-result-info { flex: 1; min-width: 0; }
.member-result-name { font-size: 0.85rem; font-weight: 600; display: block; }
.member-result-user { font-size: 0.75rem; color: var(--text-muted); }

/* Group Chat Header */
.chat-header-group-info {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Sidebar Actions */
.sidebar-actions {
  display: flex;
  gap: 4px;
}
.btn-icon-alt {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  transition: all var(--t-fast);
}
.btn-icon-alt:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* Settings button — explicit affordance in sidebar footer */
.btn-settings {
  font-size: 1rem;
  flex-shrink: 0;
  animation: settingsPulse 1.8s ease 1.2s 2 both;
}
.btn-settings:hover {
  background: var(--primary-light);
  color: var(--primary);
  transform: rotate(30deg);
  transition: background var(--t-fast), color var(--t-fast), transform 0.3s ease;
}
@keyframes settingsPulse {
  0%, 100% { box-shadow: none; }
  50%       { box-shadow: 0 0 0 4px var(--primary-glow); border-radius: 50%; }
}

/* ---- Empty States ---- */
.empty-list {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px;
  text-align: center;
  flex: 1;
  gap: 12px;
}
.empty-list-icon { font-size: 2.5rem; opacity: .4; }
.empty-list-text { font-size: .875rem; color: var(--text-muted); }

/* ============================================================
   Chat Panel
   ============================================================ */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--chat-bg);
  position: relative;
}

/* ---- Welcome / Empty State ---- */
.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 40px;
}
.welcome-icon {
  font-size: 4rem;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}
.welcome-title {
  font-size: 1.4rem; font-weight: 700;
  color: var(--text-main);
}
.welcome-sub {
  font-size: .9rem; color: var(--text-sub);
  max-width: 280px;
}

/* ---- Chat Header ---- */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: var(--header-h);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}
.chat-header-info {
  flex: 1; min-width: 0;
}
.chat-header-name {
  font-size: .95rem; font-weight: 700;
  color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-header-status {
  font-size: .75rem; color: var(--text-muted);
  white-space: nowrap;
}
.chat-header-status.online { color: var(--success); }
.chat-header-typing {
  display: none;
  align-items: center;
  gap: 8px;
}
.chat-header-typing.visible { display: flex; }
.chat-header-typing .typing-text {
  font-size: 0.75rem;
  color: var(--success);
  font-weight: 500;
  font-style: italic;
}
.chat-header-typing .typing-dots { padding: 0; gap: 3px; display: flex; align-items: center; }
.chat-header-typing .typing-dots span {
  width: 4px; height: 4px;
  background: var(--success);
}

/* Back button (mobile) */
.btn-back {
  display: none;
  background: none; border: none;
  cursor: pointer;
  font-size: 1.3rem; color: var(--text-sub);
  min-width: 44px; min-height: 44px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color var(--t-fast), background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.btn-back:hover { 
  background: var(--primary); 
  color: #fff; 
}

/* ---- Messages Area Wrapper (for scroll FAB positioning) ---- */
.messages-area-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---- Scroll-to-bottom FAB ---- */
.btn-scroll-bottom {
  position: absolute;
  bottom: 16px;
  right: 20px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  color: var(--primary);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  opacity: 0;
  transform: translateY(12px) scale(0.85);
  pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-base);
}
.btn-scroll-bottom.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.btn-scroll-bottom:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-1px) scale(1.07);
}

/* ---- Messages Area ---- */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
  background-color: var(--chat-bg-pattern);
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='1.5' cy='1.5' r='1.5' fill='%23c8cccf' fill-opacity='0.35'/%3E%3C/svg%3E");
  background-size: 20px 20px;
}

/* ---- Empty Message State ---- */
.messages-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 40px 24px;
  user-select: none;
}
.messages-empty-icon {
  font-size: 3.2rem;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.12));
}
.messages-empty-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}
.messages-empty-sub {
  font-size: .82rem;
  color: var(--text-muted);
  max-width: 260px;
  line-height: 1.6;
}

/* Date separator */
.date-separator {
  display: flex; align-items: center;
  gap: 12px; margin: 12px 0 8px;
  flex-shrink: 0;
}
.date-separator::before,
.date-separator::after {
  content: ''; flex: 1;
  height: 1px; background: var(--border);
}
.date-separator-label {
  font-size: .72rem; color: var(--text-muted);
  font-weight: 600; white-space: nowrap;
  padding: 2px 10px;
  background: var(--border-light);
  border-radius: 10px;
}

/* ---- Message ---- */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 70%;
  animation: msgSlideIn .25s ease;
}
@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* New incoming message highlight — flash once, then fade out */
@keyframes msgHighlight {
  0%   { background: rgba(var(--primary-rgb, 108, 99, 255), 0.18); }
  60%  { background: rgba(var(--primary-rgb, 108, 99, 255), 0.08); }
  100% { background: transparent; }
}
.msg-row.incoming.msg-new .bubble {
  animation: msgSlideIn .25s ease, msgHighlight .75s ease .15s forwards;
}
.msg-row.outgoing {
  margin-left: auto;
  flex-direction: row-reverse;
}
.msg-row.incoming { margin-right: auto; }

.msg-avatar { margin-bottom: 2px; }
.msg-row.outgoing .msg-avatar { display: none; }

.msg-content {
  display: flex; flex-direction: column;
  gap: 2px;
  max-width: 100%;
}

.bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: .9rem;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
  max-width: 100%;
}
.msg-row.outgoing .bubble {
  background: var(--bubble-out);
  color: var(--bubble-out-text);
  border-bottom-right-radius: 4px;
}
.msg-row.incoming .bubble {
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}

/* Hover actions */
.msg-row { position: relative; margin-bottom: 4px; }
.msg-bubble-wrap { display: flex; align-items: flex-end; gap: 8px; position: relative; }
.msg-row.outgoing .msg-bubble-wrap { flex-direction: row-reverse; }

.msg-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--t-fast);
  padding-bottom: 4px;
}
.msg-row:hover .msg-actions { opacity: 1; }
.btn-action {
  background: var(--card);
  border: 1px solid var(--border);
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--t-fast);
  color: var(--text-sub);
}
.btn-action:hover {
  background: var(--border);
  color: var(--text-main);
  transform: scale(1.1);
}

/* Timestamp + status row */
.msg-meta {
  display: flex; align-items: center; gap: 4px;
  font-size: .68rem;
  padding: 0 4px;
}
.msg-row.outgoing .msg-meta { justify-content: flex-end; }
.msg-row.incoming .msg-meta { justify-content: flex-start; }

.msg-time {
  color: var(--text-muted);
  cursor: default;
  text-decoration: underline dotted var(--border);
  text-underline-offset: 2px;
}
.msg-time:hover { color: var(--text-sub); }
.msg-status { color: var(--text-muted); font-size: .75rem; }
.msg-status.seen { color: var(--primary); }

/* Image attachment */
.bubble-image {
  max-width: 280px;
  border-radius: var(--radius-md);
  overflow: hidden;
  padding: 4px !important;
  box-shadow: var(--shadow-sm);
}
.bubble-img-wrap {
  width: 100%;
  border-radius: calc(var(--radius-md) - 2px);
  overflow: hidden;
  line-height: 0;
  cursor: pointer;
  background: var(--primary-light);
  min-height: 120px;
  display: flex; align-items: center; justify-content: center;
}
.chat-img {
  width: 100%; height: auto;
  display: block;
  transition: transform 0.4s ease, opacity 0.3s ease;
}
.chat-img:hover {
  transform: scale(1.03);
}

.bubble-caption {
  padding: 8px 10px 4px;
  font-size: 0.92rem;
  line-height: 1.4;
  word-wrap: break-word;
}

/* Updated State indicators */
.edited-tag {
  font-size: 0.65rem;
  opacity: 0.7;
  margin-left: 4px;
  font-style: italic;
}
.msg-deleted {
  font-style: italic;
  opacity: 0.6;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
}

/* Reply Snippet in Bubble */
.reply-snippet {
  background: rgba(0,0,0,0.05);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  padding: 6px 10px;
  margin: 4px 4px 8px 4px;
  font-size: 0.8rem;
  cursor: pointer;
  max-width: 100%;
}
.msg-row.outgoing .reply-snippet {
  background: rgba(255,255,255,0.15);
  border-left-color: rgba(255,255,255,0.5);
}
.reply-sender {
  font-weight: 700;
  font-size: 0.75rem;
  margin-bottom: 2px;
  color: var(--primary);
}
.msg-row.outgoing .reply-sender { color: #fff; opacity: 0.9; }
.reply-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.8;
}

/* Composer Reply Preview */
.composer-reply-preview {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  border-radius: 14px;
  margin-bottom: 8px;
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.reply-preview-info { flex: 1; min-width: 0; border-left: 3px solid var(--primary); padding-left: 10px; }
.reply-preview-name { font-weight: 700; font-size: 0.8rem; color: var(--primary); }
.reply-preview-text { font-size: 0.85rem; color: var(--text-sub); }
.btn-close-reply { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); }
.btn-close-reply:hover { color: var(--danger); }

/* File attachment */
.bubble-file {
  min-width: 220px;
  max-width: 280px;
  padding: 6px !important;
  box-shadow: var(--shadow-sm);
}

.bubble-file-card {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--primary-light);
  border-radius: calc(var(--radius-md) - 2px);
  transition: background var(--t-fast);
}
.bubble-file-card:hover {
  background: rgba(var(--primary-rgb), 0.12);
}

.bubble-file-icon { font-size: 1.8rem; flex-shrink: 0; }
.bubble-file-info { flex: 1; min-width: 0; }
.bubble-file-name {
  font-size: 0.85rem; font-weight: 600;
  color: var(--primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bubble-file-size { 
  font-size: 0.72rem; color: var(--text-muted); 
  margin-top: 1px;
}
.bubble-file-dl {
  background: var(--primary);
  color: #fff;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  font-size: 0.9rem;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.bubble-file-dl:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(var(--primary-rgb), 0.3);
}

/* Sender name (group / first message) */
.msg-sender-name {
  font-size: .72rem; font-weight: 700;
  color: var(--primary);
  padding: 0 4px;
  display: block;
}

/* ---- Load more ---- */
.load-more-wrap {
  display: flex; justify-content: center;
  padding: 8px 0 4px;
}
.btn-load-more {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--primary);
  padding: 6px 18px;
  border-radius: 20px;
  font-size: .8rem; font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
}
.btn-load-more:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* ---- Composer ---- */
.composer {
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
  min-height: var(--composer-h);
}

.composer-actions {
  display: flex; align-items: center; gap: 2px;
  flex-shrink: 0;
  padding-bottom: 6px;
}

.composer-input-wrap {
  flex: 1;
  min-width: 0;
  background: var(--input-bg);
  border: 1.5px solid transparent;
  border-radius: 22px;
  padding: 10px 16px;
  display: flex; align-items: flex-end; gap: 8px;
  transition: border-color var(--t-base), box-shadow var(--t-base);
  min-height: 46px;
}
.composer-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--card);
}

#messageInput {
  flex: 1;
  background: none;
  border: none; outline: none;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  color: var(--text-main);
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  min-height: 24px;
  overflow-y: auto;
}
#messageInput::placeholder { color: var(--text-muted); }

/* Attachment preview strip */
.attachment-preview {
  display: none; align-items: center;
  gap: 8px; padding: 8px 0 0;
}
.attachment-preview.visible { display: flex; }
.att-preview-item {
  position: relative;
  display: flex; align-items: center;
  gap: 8px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: .75rem; color: var(--primary);
  font-weight: 600;
  max-width: 220px;
}
.att-preview-remove {
  background: var(--danger);
  border: none; cursor: pointer;
  color: #fff; font-size: 0.7rem;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.att-preview-img {
  width: 32px !important;
  height: 32px !important;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

/* Send button */
.btn-send {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; border: none;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--t-fast);
  box-shadow: 0 2px 8px rgba(108,99,255,.35);
}
.btn-send:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(108,99,255,.45);
}
.btn-send:active { transform: scale(.96); }

/* Hidden file input */
#attachmentInput { display: none; }

/* ---- Typing indicator ---- */
.typing-dots {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 12px;
}
.typing-dots span {
  width: 7px; height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  display: block;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ============================================================
   Profile Modal
   ============================================================ */
.profile-form { display: flex; flex-direction: column; gap: 16px; }
.profile-avatar-section {
  display: flex; align-items: center; gap: 16px;
  padding: 16px;
  background: var(--input-bg);
  border-radius: var(--radius-md);
}
.group-avatar-section {
  margin-bottom: 20px;
  border: 1px dashed var(--border);
  background: var(--bg);
}
.group-avatar-section .avatar {
  background: var(--primary);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-avatar-actions {
  display: flex; flex-direction: column; gap: 6px;
}
.btn-change-avatar {
  background: var(--primary-light);
  color: var(--primary);
  border: none; cursor: pointer;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: .8rem; font-weight: 600;
  font-family: 'Inter', sans-serif;
  transition: all var(--t-fast);
}
.btn-change-avatar:hover { background: var(--primary); color: #fff; }

.profile-field { display: flex; flex-direction: column; gap: 6px; }
.profile-field label {
  font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted);
}
.profile-field input,
.profile-field textarea {
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: .9rem; font-family: 'Inter', sans-serif;
  color: var(--text-main);
  outline: none;
  transition: border-color var(--t-base);
  resize: none;
}
.profile-field input:focus,
.profile-field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--card);
}
.btn-save {
  background: var(--primary);
  color: #fff; border: none;
  padding: 12px; border-radius: var(--radius-md);
  font-size: .95rem; font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all var(--t-fast);
}
.btn-save:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* Image Lightbox */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 2000;
  display: none; align-items: center; justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 90vw; max-height: 90vh;
  border-radius: var(--radius-md);
  object-fit: contain;
  box-shadow: var(--shadow-lg);
}
.lightbox-close {
  position: absolute; top: 20px; right: 24px;
  background: rgba(255,255,255,.15);
  border: none; cursor: pointer;
  color: #fff; font-size: 1.5rem;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast);
}
.lightbox-close:hover { background: rgba(255,255,255,.25); }

/* ---- Skeleton Loaders ---- */
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, #e8eaed 25%, #d2d5da 50%, #e8eaed 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 4px;
}
.skeleton-item {
  padding: 12px 16px;
  display: flex; gap: 12px; align-items: center;
}
.skeleton-avatar { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; }
.skeleton-info { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skeleton-line { height: 10px; width: 100%; border-radius: 2px; }
.skeleton-line.short { width: 45%; }
.skeleton-msg-row {
  display: flex; flex-direction: column;
  padding: 6px 16px; width: 100%;
}
.skeleton-bubble {
  height: 38px; border-radius: 12px; margin-bottom: 4px;
}
.skeleton-bubble.left { align-self: flex-start; width: 55%; }
.skeleton-bubble.right { align-self: flex-end; width: 40%; }

/* ============================================================
   User Profile Preview Modal (read-only card)
   ============================================================ */
.user-preview-modal {
  padding: 0;
  overflow: hidden;
  max-width: 360px;
  border-radius: var(--radius-xl);
  position: relative;
  transform: scale(.93) translateY(20px);
}
.modal-overlay.open .user-preview-modal {
  transform: scale(1) translateY(0);
}

/* Hero gradient banner */
.upv-banner {
  height: 96px;
  background: linear-gradient(135deg, var(--primary) 0%, #43AA8B 50%, var(--accent) 100%);
  position: relative;
  flex-shrink: 0;
}
.upv-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='2' cy='2' r='2' fill='%23ffffff' fill-opacity='0.08'/%3E%3C/svg%3E") repeat;
  background-size: 20px 20px;
}

/* Close button positioned over banner */
.user-preview-modal .modal-close {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 10;
  background: rgba(0,0,0,.25);
  color: #fff;
  border-radius: 50%;
  width: 30px; height: 30px;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast);
}
.user-preview-modal .modal-close:hover {
  background: rgba(0,0,0,.45);
  color: #fff;
}

/* Avatar floating over the banner */
.upv-avatar-wrap {
  position: relative;
  display: inline-block;
  margin: -44px 0 0 24px;
  z-index: 2;
}
.upv-avatar-wrap .avatar-xl {
  width: 88px; height: 88px;
  font-size: 1.6rem;
  border: 4px solid #fff;
  box-shadow: var(--shadow-md);
}
.upv-avatar-wrap .online-dot {
  bottom: 4px; right: 4px;
  width: 16px; height: 16px;
  border-width: 3px;
  border-color: #fff;
}

/* Body content */
.upv-body {
  padding: 10px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.upv-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
  margin-top: 4px;
}
.upv-username {
  font-size: .82rem;
  color: var(--text-muted);
  font-weight: 500;
}
.upv-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--success);
  margin-top: 2px;
  min-height: 18px;
}
.upv-status-badge.offline {
  color: var(--text-muted);
}
.upv-status-badge::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.upv-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 10px 0 4px;
}

/* Meta rows (bio, status msg, last seen) */
.upv-meta {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  animation: upvFadeIn .3s ease both;
}
.upv-meta-icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
  line-height: 1;
}
.upv-meta-text {
  font-size: .875rem;
  color: var(--text-sub);
  line-height: 1.5;
  word-break: break-word;
}

/* Chat header becomes clickable */
.chat-header-clickable {
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast);
  padding: 4px 6px;
  margin: -4px -6px;
}
.chat-header-clickable:hover {
  background: var(--primary-light);
}

@keyframes upvFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Settings Modal
   ============================================================ */
.settings-modal {
  max-width: 520px;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
  flex-shrink: 0;
}

/* ---- Tab Nav ---- */
.settings-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 24px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.settings-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 8px 12px 12px;
  cursor: pointer;
  font-size: .83rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: var(--text-muted);
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
  transition: color var(--t-fast), border-color var(--t-fast);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  white-space: nowrap;
}
.settings-tab:hover  { color: var(--primary); background: var(--primary-light); }
.settings-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ---- Tab Panels ---- */
.settings-panel {
  display: none;
  flex-direction: column;
  gap: 0;
  padding: 20px 24px 24px;
  overflow-y: auto;
  flex: 1;
  animation: settingsPanelIn .2s ease;
}
.settings-panel.active { display: flex; }

@keyframes settingsPanelIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Account Summary Card ---- */
.account-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--input-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  flex-shrink: 0;
}

.btn-preview-sound {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1.5px solid transparent;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t-fast);
  width: fit-content;
  margin-top: 4px;
}
.btn-preview-sound:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-1px);
}
.btn-preview-sound:active {
  transform: translateY(0);
}
.btn-preview-sound::before {
  content: '🔔';
  font-size: 0.9rem;
}
.account-summary-info {
  min-width: 0;
  flex: 1;
}
.account-summary-name {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-summary-username {
  font-size: .78rem;
  color: var(--primary);
  font-weight: 600;
  margin-top: 1px;
}
.account-summary-meta {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Section blocks ---- */
.settings-section {
  margin-bottom: 28px;
}
.settings-section:last-child { margin-bottom: 0; }

.settings-section-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ---- Toggle row ---- */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.settings-row:last-child { border-bottom: none; }

.settings-row-info { flex: 1; min-width: 0; }
.settings-row-label {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-main);
}
.settings-row-desc {
  font-size: .76rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Toggle Switch ---- */
.toggle-switch {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.toggle-track {
  display: block;
  width: 44px; height: 24px;
  background: var(--border);
  border-radius: 12px;
  transition: background var(--t-base);
  position: relative;
}
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  transition: transform var(--t-base);
}
.toggle-switch input:checked + .toggle-track { background: var(--primary); }
.toggle-switch input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }

/* ---- Theme Buttons ---- */
.theme-toggle-group {
  display: flex;
  gap: 8px;
}
.theme-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: var(--text-sub);
  transition: all var(--t-fast);
}
.theme-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
.theme-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.theme-btn-icon { font-size: 1.3rem; }

/* ---- Accent Palette ---- */
.accent-palette {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.accent-swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  background: var(--sw);
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
  outline: none;
}
.accent-swatch:hover {
  transform: scale(1.15);
  box-shadow: 0 3px 10px rgba(0,0,0,.22);
}
.accent-swatch.active {
  border-color: var(--sw);
  box-shadow: 0 0 0 3px rgba(0,0,0,.08), 0 0 0 6px color-mix(in srgb, var(--sw) 25%, transparent);
  transform: scale(1.1);
}

/* ---- Font Size Buttons ---- */
.font-size-group {
  display: flex;
  gap: 8px;
}
.font-size-btn {
  flex: 1;
  padding: 8px 12px;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  color: var(--text-sub);
  transition: all var(--t-fast);
}
.font-size-btn:nth-child(1) { font-size: .75rem; }
.font-size-btn:nth-child(2) { font-size: .875rem; }
.font-size-btn:nth-child(3) { font-size: 1rem; }
.font-size-btn:hover { border-color: var(--primary); color: var(--primary); }
.font-size-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* ---- Danger Button ---- */
.btn-danger-outline {
  background: none;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  padding: 9px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  transition: all var(--t-fast);
}
.btn-danger-outline:hover {
  background: #fee2e2;
  border-color: var(--danger);
}

/* ============================================================
   Emoji Picker
   ============================================================ */
.emoji-picker {
  width: 280px;
  height: 320px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2000;
  animation: fadeInDown .2s ease;
}

.emoji-picker-header {
  display: flex;
  padding: 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  gap: 4px;
}

.emoji-category-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 6px;
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast);
}
.emoji-category-btn:hover,
.emoji-category-btn.active {
  background: var(--primary-light);
}

.emoji-picker-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.emoji-picker-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 12px 0 6px 4px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.btn-emoji-item {
  aspect-ratio: 1;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--t-fast), background var(--t-fast);
}
.btn-emoji-item:hover {
  background: var(--primary-light);
  transform: scale(1.15);
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Forwarded label */
.forwarded-label {
  font-size: 0.65rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.8;
}

/* Forward Modal specific */
.forward-chat-list {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}
.forward-chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--t-fast);
  border: 1.5px solid transparent;
  background: var(--input-bg);
}
.forward-chat-item:hover {
  background: var(--primary-light);
  border-color: var(--primary-glow);
}
.forward-chat-item.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.forward-chat-item .avatar {
  width: 40px; height: 40px;
  flex-shrink: 0;
}
.forward-chat-info {
  flex: 1; min-width: 0;
}
.forward-chat-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}
.forward-chat-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Forward Modal Search */
.modal-body .search-wrap {
  margin-bottom: 20px;
}
#forwardSearchInput {
  width: 100%;
  padding: 11px 40px 11px 40px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: .9rem;
  font-family: inherit;
  color: var(--text-main);
  outline: none;
  transition: all var(--t-base);
}
#forwardSearchInput:focus {
  border-color: var(--primary);
  background: var(--card);
  box-shadow: 0 0 0 4px var(--primary-glow);
}
.modal-body .search-icon {
  left: 14px;
  font-size: 1rem;
  opacity: 0.7;
}

/* ---- Swipe-to-Reply Styles ---- */
.msg-bubble-wrap {
  position: relative;
  overflow: visible;
  touch-action: pan-y; /* Prevent default horizontal touch while allows vertical scrolling */
}

/* The hidden icon that appears behind the bubble */
.swipe-reply-icon {
  position: absolute;
  left: -40px; top: 50%;
  transform: translateY(-50%) scale(0.6);
  opacity: 0;
  font-size: 1.25rem;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1;
  pointer-events: none;
  background: var(--primary-light);
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.swipe-reply-icon.active {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.bubble {
  position: relative;
  z-index: 2;
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28); /* Spring-back effect */
  will-change: transform;
}

/* User feedback: subtle glow on long press/touch */
.bubble.touch-active {
  filter: brightness(0.95);
  transform: scale(0.98);
}
[data-theme="dark"] .bubble.touch-active { filter: brightness(1.15); }

/* ============================================================
   Announcement Banner Styles
   ============================================================ */
#announcementBanner {
  z-index: 1000;
  width: 100%;
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top);
  background: var(--primary); /* Fallback to match type-normal */
}

.announcement-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  gap: 12px;
  animation: slideDown 0.3s ease-out;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.announcement-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.announcement-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.announcement-text {
  font-size: 0.85rem;
  line-height: 1.4;
  color: #fff;
}

.announcement-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  opacity: 0.7;
  padding: 4px;
  border-radius: 4px;
  transition: opacity 0.2s;
}

.announcement-close:hover {
  opacity: 1;
  background: rgba(255,255,255,0.1);
}

/* Announcement Types */
.type-normal {
  background: var(--primary);
}

.type-maintenance {
  background: #ef4444; /* Danger Red */
}

.type-update {
  background: #f59e0b; /* Warning Orange */
}

[data-theme="dark"] .announcement-item {
  border-bottom-color: rgba(255,255,255,0.1);
}

/* ============================================================
   Notification Dropdown Styles
   ============================================================ */
.notif-dropdown {
  position: absolute;
  top: 60px;
  left: 10px;
  width: 320px;
  max-height: 480px;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.notif-dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notif-dropdown-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.notif-list {
  flex: 1;
  overflow-y: auto;
}

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.notif-item:hover {
  background: var(--primary-light);
}

.notif-item.unread {
  border-left: 3px solid var(--primary);
  background: rgba(var(--primary-rgb), 0.03);
}

.notif-item-title {
  font-size: 0.85rem;
  font-weight: 700;
}

.notif-item-msg {
  font-size: 0.8rem;
  color: var(--text-sub);
  line-height: 1.4;
}

.notif-item-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.notif-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}