:root {
  --bg-primary: #07121f;
  --bg-secondary: #0d1c2c;
  --bg-card: #102234;
  --bg-hover: #162c44;
  --accent-cyan: #00f5d4;
  --accent-purple: #5b4bc4;
  --accent-blue: #3a86ff;
  --accent-green: #00c896;
  --accent-orange: #ff9e00;
  --accent-red: #ff4d6d;
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: rgba(255, 255, 255, 0.08);
  --bubble-me: linear-gradient(135deg, #093734 0%, #0d4a44 100%);
  --bubble-peer: #132437;
  --rail-bg: #050d17;
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body.light-theme {
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: rgba(0, 0, 0, 0.08);
  --bubble-me: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  --bubble-peer: #ffffff;
  --rail-bg: #e2e8f0;
}

body.light-theme .message-bubble.me .msg-text {
  color: #064e3b;
}

body.light-theme .message-bubble.me .msg-footer {
  color: #047857;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  position: relative;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Ambient glow orbs */
.glow-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.16;
}

.orb-1 {
  width: 480px;
  height: 480px;
  background: var(--accent-cyan);
  top: -100px;
  left: -100px;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: var(--accent-purple);
  bottom: -150px;
  right: -150px;
}

/* View containers */
.view-container {
  display: none;
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100vh;
}

.view-container.active {
  display: flex;
  flex-direction: column;
}

/* ======================================================== */
/* 1. QR PAIRING VIEW (Logged Out State)                     */
/* ======================================================== */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 48px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(13, 28, 44, 0.4);
  backdrop-filter: blur(12px);
}

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

.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 11px;
  font-weight: 800;
  background: rgba(0, 245, 212, 0.15);
  color: var(--accent-cyan);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(0, 245, 212, 0.3);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

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

.live-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-cyan);
}

.admin-portal-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(108, 92, 231, 0.12);
  color: #a29bfe;
  border: 1px solid rgba(108, 92, 231, 0.35);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
}

.admin-portal-btn:hover {
  background: rgba(108, 92, 231, 0.25);
  border-color: rgba(108, 92, 231, 0.6);
  color: #fff;
  transform: translateY(-1px);
}

.pairing-card {
  margin: auto;
  max-width: 900px;
  width: 90%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 48px;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 48px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.section-tag {
  color: var(--accent-cyan);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.main-heading {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 24px;
  line-height: 1.2;
}

.steps-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.steps-list li {
  display: flex;
  align-items: center;
  gap: 16px;
}

.step-num {
  width: 28px;
  height: 28px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--accent-cyan);
}

.step-text {
  font-size: 15px;
  color: var(--text-secondary);
}

.step-text strong {
  color: var(--text-primary);
}

.security-badge {
  margin-top: 32px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(0, 245, 212, 0.05);
  border: 1px solid rgba(0, 245, 212, 0.15);
  border-radius: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.qr-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.qr-wrapper {
  position: relative;
  padding: 16px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 256px;
  height: 256px;
}

.laser-beam {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
  box-shadow: 0 0 12px var(--accent-cyan);
  animation: laserScan 2.5s ease-in-out infinite alternate;
}

@keyframes laserScan {
  0% { top: 12px; }
  100% { top: 244px; }
}

.stay-signed-in {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.app-footer {
  text-align: center;
  padding: 24px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ======================================================== */
/* 2. AUTHENTICATED DASHBOARD LAYOUT                        */
/* ======================================================== */

.dashboard-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* 2.1 Navigation Rail (Leftmost bar) */
.nav-rail {
  width: 64px;
  min-width: 64px;
  height: 100%;
  background: var(--rail-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  z-index: 10;
}

.rail-top, .rail-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.rail-brand {
  margin-bottom: 8px;
}

.rail-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

.rail-btn.active {
  background: rgba(0, 245, 212, 0.12);
  color: var(--accent-cyan);
}

.rail-btn.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--accent-cyan);
}

.rail-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--accent-cyan);
  color: #07121f;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 10px;
}

.rail-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
}

.rail-profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  background-size: cover;
  background-position: center;
}

/* 2.2 Sidebar Panel (Sub-tabs) */
.sidebar-panel {
  width: 380px;
  min-width: 340px;
  height: 100%;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.tab-content {
  display: none;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.tab-content.active {
  display: flex;
}

.panel-header {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title-row h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.count-tag {
  font-size: 12px;
  background: var(--bg-hover);
  padding: 3px 8px;
  border-radius: 12px;
  color: var(--accent-cyan);
}

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

.icon-action-btn:hover {
  background: var(--accent-cyan);
  color: #07121f;
  border-color: var(--accent-cyan);
}

/* Search Box */
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 9px 14px;
}

.search-box svg {
  color: var(--text-muted);
}

.search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  width: 100%;
  outline: none;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

/* Filter Chips */
.filter-chips {
  display: flex;
  gap: 8px;
}

.filter-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 5px 14px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-chip:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.filter-chip.active {
  background: rgba(0, 245, 212, 0.15);
  border-color: rgba(0, 245, 212, 0.4);
  color: var(--accent-cyan);
}

/* Panel Scrollable Area */
.panel-scroll {
  flex: 1;
  overflow-y: auto;
}

/* 2.3 Chats List Items */
.chat-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}

.chat-item:hover {
  background: var(--bg-hover);
}

.chat-item.active {
  background: rgba(0, 245, 212, 0.08);
}

.chat-item.active::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent-cyan);
}

.chat-avatar-wrap {
  position: relative;
}

.chat-item-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #17283c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  background-size: cover;
  background-position: center;
  color: var(--accent-cyan);
}

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

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

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

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

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

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

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

.chat-unread-badge {
  background: var(--accent-cyan);
  color: #07121f;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 12px;
  margin-left: 8px;
}

/* 2.4 Status / Stories Items */
.status-section-title {
  padding: 12px 18px 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-cyan);
}

.story-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.story-item:hover {
  background: var(--bg-hover);
}

.story-avatar-wrap {
  position: relative;
}

.story-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #17283c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 2.5px solid var(--accent-cyan);
  background-size: cover;
  background-position: center;
}

.story-avatar.viewed {
  border-color: var(--text-muted);
}

.add-story-wrap .story-avatar {
  border: 2px dashed rgba(255, 255, 255, 0.2);
}

.add-story-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-cyan);
  color: #07121f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  border: 2px solid var(--bg-secondary);
}

.story-item-info h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.story-item-info p {
  font-size: 12px;
  color: var(--text-muted);
}

/* 2.5 Calls List Items */
.call-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.call-item:hover {
  background: var(--bg-hover);
}

.call-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #17283c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  background-size: cover;
  background-position: center;
}

.call-item-info {
  flex: 1;
}

.call-item-info h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.call-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.call-dir-icon.incoming { color: var(--accent-green); }
.call-dir-icon.outgoing { color: var(--accent-blue); }
.call-dir-icon.missed { color: var(--accent-red); }

.call-action-btn {
  background: rgba(0, 245, 212, 0.1);
  border: 1px solid rgba(0, 245, 212, 0.3);
  color: var(--accent-cyan);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-action-btn:hover {
  background: var(--accent-cyan);
  color: #07121f;
}

/* 2.6 Contacts List Items */
.contact-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.contact-item:hover {
  background: var(--bg-hover);
}

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

.contact-item-info h4 {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.contact-msg-btn {
  padding: 6px 14px;
  background: rgba(0, 245, 212, 0.15);
  border: 1px solid rgba(0, 245, 212, 0.3);
  color: var(--accent-cyan);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.contact-msg-btn:hover {
  background: var(--accent-cyan);
  color: #07121f;
}

/* 2.7 Settings Panel */
.settings-scroll {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.settings-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #17283c;
  border: 2px solid var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  background-size: cover;
  background-position: center;
}

.settings-user-info h3 {
  font-size: 18px;
  font-weight: 700;
}

.settings-user-info span {
  font-size: 13px;
  color: var(--accent-cyan);
}

.settings-bio {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.settings-group {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-group-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-cyan);
  letter-spacing: 0.5px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row-label {
  font-size: 14px;
  font-weight: 600;
}

.row-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #2a3a4d;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-cyan);
}

input:checked + .slider:before {
  transform: translateX(20px);
  background-color: #07121f;
}

.btn-text-action {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.btn-secondary {
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn-primary {
  background: var(--accent-cyan);
  border: none;
  color: #07121f;
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-danger-outline {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 77, 109, 0.1);
  border: 1px solid rgba(255, 77, 109, 0.3);
  color: var(--accent-red);
  padding: 12px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger-outline:hover {
  background: var(--accent-red);
  color: white;
}

.active-badge {
  font-size: 11px;
  background: rgba(0, 245, 212, 0.15);
  color: var(--accent-cyan);
  padding: 3px 8px;
  border-radius: 8px;
  font-weight: 700;
}

/* ======================================================== */
/* 3. MAIN CHAT WINDOW                                      */
/* ======================================================== */

.chat-main {
  flex: 1;
  height: 100%;
  display: flex;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.empty-chat-state {
  margin: auto;
  text-align: center;
  max-width: 440px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.empty-icon-wrap {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(0, 245, 212, 0.1);
  border: 1px solid rgba(0, 245, 212, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-chat-state h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
}

.empty-chat-state p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.e2ee-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Active Chat Container */
.active-chat-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

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

.peer-info-clickable {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 12px;
  transition: background 0.15s ease;
}

.peer-info-clickable:hover {
  background: var(--bg-hover);
}

.peer-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #17283c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  background-size: cover;
  background-position: center;
  color: var(--accent-cyan);
}

.peer-info h3 {
  font-size: 16px;
  font-weight: 600;
}

.online-indicator {
  font-size: 12px;
  color: var(--accent-cyan);
}

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

.header-action-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.header-action-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-cyan);
}

/* In-Chat Search Bar */
.in-chat-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 24px;
}

.in-chat-search-bar input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 14px;
  color: var(--text-primary);
  outline: none;
}

.icon-btn-sm {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Messages Scroll Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.date-divider {
  align-self: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 12px;
  margin: 12px 0;
}

.message-bubble {
  max-width: 65%;
  padding: 10px 14px;
  border-radius: 16px;
  position: relative;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  animation: fadeIn 0.15s ease-out;
}

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

.message-bubble.me {
  align-self: flex-end;
  background: var(--bubble-me);
  border-bottom-right-radius: 4px;
  color: #fff;
  border: 1px solid rgba(0, 245, 212, 0.15);
}

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

.msg-text {
  margin-bottom: 4px;
}

.msg-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
}

/* Media in Bubbles */
.msg-image-wrap {
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 6px;
  cursor: pointer;
  max-width: 320px;
}

.msg-image-wrap img {
  width: 100%;
  display: block;
  transition: transform 0.2s ease;
}

.msg-image-wrap:hover img {
  transform: scale(1.02);
}

.msg-file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 6px;
  text-decoration: none;
  color: var(--text-primary);
}

.msg-file-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent-cyan);
  color: #07121f;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-file-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

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

/* Audio Player Bubble */
.msg-audio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
}

.msg-audio-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-cyan);
  border: none;
  color: #07121f;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Typing Indicator Banner */
.typing-indicator-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 32px;
  font-size: 12px;
  color: var(--accent-cyan);
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  animation: typingPulse 1.4s infinite ease-in-out;
}

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

@keyframes typingPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* Voice Recording Bar Overlay */
.voice-recording-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.recording-pulsing-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-red);
  box-shadow: 0 0 10px var(--accent-red);
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.5; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1.1); }
}

.recording-time {
  font-weight: 700;
  font-size: 15px;
  color: var(--accent-red);
}

.recording-label {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
}

.voice-cancel-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.voice-send-btn {
  background: var(--accent-cyan);
  border: none;
  color: #07121f;
  padding: 6px 16px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

/* Emoji Picker Popup */
.emoji-picker-popup {
  position: absolute;
  bottom: 74px;
  left: 24px;
  width: 320px;
  height: 260px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 20;
}

.emoji-tabs {
  display: flex;
  justify-content: space-around;
  padding: 8px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.emoji-tab {
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}

.emoji-tab.active {
  background: rgba(0, 245, 212, 0.15);
}

.emoji-grid {
  flex: 1;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  overflow-y: auto;
  font-size: 20px;
}

.emoji-item {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  transition: transform 0.1s ease;
}

.emoji-item:hover {
  background: var(--bg-hover);
  transform: scale(1.2);
}

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

.input-tool-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.input-tool-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-cyan);
}

.message-input-bar input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 11px 18px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
}

.message-input-bar input:focus {
  border-color: rgba(0, 245, 212, 0.4);
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-cyan);
  border: none;
  color: #07121f;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 14px var(--accent-cyan);
}

/* ======================================================== */
/* 4. RIGHT CONTACT INFO DRAWER PANEL                       */
/* ======================================================== */

.contact-info-panel {
  width: 320px;
  min-width: 320px;
  height: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideInRight 0.25s ease-out;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 16px;
}

.drawer-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.drawer-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.drawer-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #17283c;
  border: 2px solid var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  background-size: cover;
  background-position: center;
}

.drawer-hero h2 {
  font-size: 18px;
  font-weight: 700;
}

.drawer-hero span {
  font-size: 13px;
  color: var(--accent-cyan);
}

.drawer-bio-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-cyan);
}

.drawer-media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.drawer-media-item {
  aspect-ratio: 1;
  border-radius: 8px;
  background: #17283c;
  background-size: cover;
  background-position: center;
  cursor: pointer;
}

.no-media-text {
  grid-column: span 3;
  font-size: 12px;
  color: var(--text-muted);
}

.drawer-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.drawer-btn:hover {
  background: var(--bg-hover);
}

.drawer-btn.text-warning {
  color: var(--accent-orange);
}

.drawer-btn.text-danger {
  color: var(--accent-red);
}

/* ======================================================== */
/* 5. MODALS & OVERLAYS                                     */
/* ======================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 90%;
  max-width: 440px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: popIn 0.2s ease-out;
}

@keyframes popIn {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

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

.close-modal-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.new-chat-users-list {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text-primary);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-cyan);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

/* Story Viewer Modal */
.story-viewer-modal {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-viewer-content {
  width: 100%;
  max-width: 480px;
  height: 90vh;
  position: relative;
  display: flex;
  flex-direction: column;
  background: #111;
  border-radius: 16px;
  overflow: hidden;
}

.story-progress-bar-container {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  height: 3px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  z-index: 10;
  overflow: hidden;
}

.story-progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  transition: width 0.05s linear;
}

.story-header-bar {
  position: absolute;
  top: 24px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.story-author-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.story-author-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  background-size: cover;
  background-position: center;
}

.story-author-info h4 {
  font-size: 14px;
  font-weight: 600;
}

.story-author-info span {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
}

.story-close-btn {
  background: none;
  border: none;
  font-size: 28px;
  color: #fff;
  cursor: pointer;
}

.story-media-display {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-media-display img, .story-media-display video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.story-caption {
  position: absolute;
  bottom: 24px;
  left: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.6);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  text-align: center;
}

/* Call Overlay Modal */
.call-overlay-modal {
  position: fixed;
  inset: 0;
  background: rgba(7, 18, 31, 0.95);
  backdrop-filter: blur(16px);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
}

.call-avatar-pulse {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-avatar-pulse::after {
  content: '';
  position: absolute;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 2px solid var(--accent-cyan);
  animation: ripple 1.5s infinite ease-out;
}

@keyframes ripple {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

.call-peer-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #17283c;
  border: 3px solid var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 800;
  background-size: cover;
  background-position: center;
}

.call-overlay-card h2 {
  font-size: 26px;
  font-weight: 700;
}

.call-status-label {
  font-size: 14px;
  color: var(--accent-cyan);
}

.call-end-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-red);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(255, 77, 109, 0.5);
  transition: transform 0.2s ease;
}

.call-end-btn:hover {
  transform: scale(1.1);
}

/* Lightbox Modal */
.lightbox-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.lightbox-modal img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  background: none;
  border: none;
  color: #fff;
  font-size: 36px;
  cursor: pointer;
}

/* Utilities */
.loading-state, .no-chats-state {
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}
