/* ==========================================================================
   Base Design Tokens & Resets
   ========================================================================== */
:root {
  --font-family: 'Outfit', sans-serif;
  
  /* Color Palette */
  --bg-dark: #0b0f19;
  --bg-sidebar: #0f1524;
  --bg-panel: rgba(19, 26, 45, 0.4);
  --bg-card: rgba(30, 41, 70, 0.35);
  
  --border-color: rgba(255, 255, 255, 0.05);
  --border-active: rgba(16, 185, 129, 0.4);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-color: #10b981; /* WhatsApp Emerald */
  --accent-hover: #059669;
  --accent-glow: rgba(16, 185, 129, 0.15);
  
  --bubble-user: rgba(16, 185, 129, 0.15);
  --bubble-contact: rgba(30, 41, 70, 0.5);
  
  /* Shadows & Radius */
  --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
  
  --transition-speed: 0.3s;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--accent-color);
}

/* ==========================================================================
   Layout Structures
   ========================================================================== */
#app-container {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Mobile Header */
#mobile-header {
  display: none;
  background-color: var(--bg-sidebar);
  height: 60px;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

#mobile-header button {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 8px;
}

.mobile-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.5px;
}

.mobile-logo .logo-icon {
  color: var(--accent-color);
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */
#sidebar {
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 90;
  transition: transform var(--transition-speed) ease;
}

.sidebar-logo {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo .logo-icon {
  color: var(--accent-color);
  font-size: 1.8rem;
  filter: drop-shadow(0 0 12px var(--accent-glow));
}

.sidebar-logo h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #fff 30%, #a7f3d0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-nav {
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  transition: all 0.2s ease;
}

.nav-item i {
  font-size: 1.15rem;
}

.nav-item:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
  color: var(--text-primary);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.02) 100%);
  border-left: 3px solid var(--accent-color);
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
}

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

.user-profile .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--accent-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
}

.profile-info h4 {
  font-size: 0.9rem;
  font-weight: 600;
}

.profile-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Main Content Area & Tabs
   ========================================================================== */
#main-content {
  overflow: hidden;
  height: 100%;
}

.tab-pane {
  display: none;
  height: 100%;
  width: 100%;
}

.tab-pane.active {
  display: block;
}

/* ==========================================================================
   Inbox Tab Layout
   ========================================================================== */
.inbox-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: 1fr;
  height: 100%;
  overflow: hidden;
  transition: grid-template-columns 0.3s ease;
}

.inbox-layout.details-active {
  grid-template-columns: 320px 1fr 300px;
}

/* Contacts Panel */
#contacts-panel {
  border-right: 1px solid var(--border-color);
  background-color: rgba(15, 21, 36, 0.2);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.panel-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box i {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.search-box input {
  width: 100%;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 10px 14px 10px 38px;
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s ease;
}

.search-box input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-glow);
}

#contacts-list {
  flex: 1;
  overflow-y: auto;
}

.contact-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

.contact-card:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.contact-card.active {
  background-color: rgba(16, 185, 129, 0.06);
  border-left: 3px solid var(--accent-color);
}

.contact-card .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 1.1rem;
}

.contact-info {
  flex: 1;
  overflow: hidden;
}

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

.contact-info-top h4 {
  font-size: 0.95rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-info-top span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.contact-last-msg {
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Chat Window Area
   ========================================================================== */
#chat-window {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  background-image: radial-gradient(circle at 10% 20%, rgba(19, 26, 45, 0.15) 0%, transparent 100%);
  min-height: 0;
  overflow: hidden;
}

#chat-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  width: 80%;
  max-width: 400px;
}

#chat-placeholder i {
  font-size: 4rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  opacity: 0.4;
}

#chat-placeholder h3 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 8px;
}

#chat-placeholder p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Active Chat UI */
#chat-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  min-height: 0;
  /* No overflow:hidden here — it would clip the chat footer input row */
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(11, 15, 25, 0.6);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  flex-shrink: 0;
}

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

.contact-meta .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--accent-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
}

.contact-meta h3 {
  font-size: 1rem;
  font-weight: 600;
}

.contact-meta p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

.ai-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 6px 12px;
  border-radius: var(--border-radius-lg);
  font-size: 0.75rem;
  font-weight: 500;
}

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

.status-dot.green {
  background-color: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-color);
}

.status-dot.red {
  background-color: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

.action-btn {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-family);
  padding: 8px 14px;
  border-radius: var(--border-radius-sm);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background-color: rgba(255, 255, 255, 0.03);
  border-color: var(--accent-color);
}

/* Messages History Panel */
#messages-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background-color: rgba(11, 15, 25, 0.2);
  min-height: 0;
}

.message-row {
  display: flex;
  width: 100%;
}

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

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

.message-bubble {
  max-width: 65%;
  padding: 12px 16px;
  border-radius: var(--border-radius-md);
  position: relative;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  word-wrap: break-word;
}

.incoming .message-bubble {
  background-color: var(--bubble-contact);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

.outgoing .message-bubble {
  background-color: var(--bubble-user);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-bottom-right-radius: 4px;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.message-meta .sender-tag {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Rich Media Message Rendering */
.message-image {
  max-width: 100%;
  max-height: 250px;
  border-radius: var(--border-radius-sm);
  display: block;
  margin-bottom: 6px;
  border: 1px solid var(--border-color);
}

.audio-player-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.audio-player-wrapper i {
  font-size: 1.5rem;
  color: var(--accent-color);
}

.audio-player-wrapper audio {
  height: 32px;
  outline: none;
}

.video-player-wrapper {
  width: 100%;
}

.video-player-wrapper video {
  display: block;
  max-width: 100%;
  max-height: 280px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
}

/* Document download card */
.document-bubble {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.2s ease;
  min-width: 200px;
}

.document-bubble:hover {
  background: rgba(255, 255, 255, 0.1);
}

.document-bubble > i:first-child {
  font-size: 1.8rem;
  color: var(--accent-color);
  flex-shrink: 0;
}

.document-bubble-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.document-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.document-ext {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.document-bubble > i:last-child {
  font-size: 1rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Input Bar Footer */
.chat-footer {
  padding: 16px 24px;
  background-color: rgba(11, 15, 25, 0.6);
  border-top: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.input-actions {
  display: flex;
  gap: 10px;
}

.attach-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attach-btn:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.05);
}

/* Mic button turns red and pulses while recording */
.attach-btn.recording-active {
  color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.15) !important;
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50%       { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ── Voice Recording Bar ───────────────────────────────────────────────────── */
#voice-recording-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--border-radius-sm);
  padding: 6px 12px;
  animation: slide-in-bar 0.2s ease;
}

@keyframes slide-in-bar {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.record-cancel-btn,
.record-send-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.record-cancel-btn {
  color: #ef4444;
}
.record-cancel-btn:hover {
  background: rgba(239, 68, 68, 0.15);
}

.record-send-btn {
  color: var(--accent-color);
}
.record-send-btn:hover {
  background: rgba(var(--accent-rgb, 79, 209, 197), 0.15);
}

/* Animated waveform bars */
.record-waveform {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 28px;
}

.record-waveform span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: #ef4444;
  animation: waveform-bounce 0.8s ease-in-out infinite;
}

/* Stagger each bar's animation delay */
.record-waveform span:nth-child(1) { animation-delay: 0.0s;  height: 8px;  }
.record-waveform span:nth-child(2) { animation-delay: 0.1s;  height: 16px; }
.record-waveform span:nth-child(3) { animation-delay: 0.2s;  height: 22px; }
.record-waveform span:nth-child(4) { animation-delay: 0.3s;  height: 12px; }
.record-waveform span:nth-child(5) { animation-delay: 0.4s;  height: 20px; }
.record-waveform span:nth-child(6) { animation-delay: 0.25s; height: 14px; }
.record-waveform span:nth-child(7) { animation-delay: 0.15s; height: 18px; }
.record-waveform span:nth-child(8) { animation-delay: 0.05s; height: 10px; }

@keyframes waveform-bounce {
  0%, 100% { transform: scaleY(0.4); opacity: 0.6; }
  50%       { transform: scaleY(1.0); opacity: 1.0; }
}

.record-timer {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ef4444;
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
}

#chat-input-form {
  flex: 1;
  display: flex;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 4px 8px 4px 16px;
  transition: all 0.2s ease;
}

#chat-input-form:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-glow);
}

#chat-input-field {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.9rem;
  outline: none;
  padding: 8px 0;
}

#btn-send-message {
  background-color: var(--accent-color);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

#btn-send-message:hover {
  background-color: var(--accent-hover);
  transform: scale(1.05);
}

/* ==========================================================================
   Settings & Configuration Tab
   ========================================================================== */
.settings-layout {
  height: 100%;
  padding: 40px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.settings-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.settings-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
}

.settings-card {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(16px);
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: rgba(255, 255, 255, 0.01);
}

.card-header i {
  color: var(--accent-color);
  font-size: 1.25rem;
}

.card-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.form-group label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-control {
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-control:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-glow);
}

textarea.form-control {
  resize: vertical;
}

.helper-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Webhook URL Helper Badge */
.config-webhook-help {
  background-color: rgba(0, 0, 0, 0.25);
  border: 1px dashed var(--border-color);
  padding: 16px;
  border-radius: var(--border-radius-sm);
}

.config-webhook-help h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.config-webhook-help code {
  color: var(--accent-color);
  font-size: 0.85rem;
  font-weight: 600;
  word-break: break-all;
}

/* Save Actions Panel */
.settings-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

.primary-btn {
  background-color: var(--accent-color);
  border: none;
  color: #fff;
  font-family: var(--font-family);
  font-weight: 600;
  padding: 14px 28px;
  border-radius: var(--border-radius-sm);
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
}

.primary-btn:hover {
  background-color: var(--accent-hover);
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: translateY(-1px);
}

.status-msg {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent-color);
  transition: opacity var(--transition-speed) ease;
}

/* Switch Slider styling */
.toggle-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.02);
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  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: var(--text-muted);
  transition: .4s;
}

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

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

input:checked + .slider:before {
  transform: translateX(22px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* ==========================================================================
   Utilities & Media Breakpoints (Responsive design)
   ========================================================================== */
.hidden {
  display: none !important;
}

.mobile-only {
  display: none !important;
}

/* ── Large desktops (1400px+) — default, full layout ── */

/* ── Medium-large desktops (1200px – 1399px) ── */
@media (max-width: 1399px) {
  #app-container {
    grid-template-columns: 200px 1fr;
  }
  .sidebar-logo h1 {
    font-size: 1.1rem;
  }
  .inbox-layout {
    grid-template-columns: 280px 1fr;
  }
  .inbox-layout.details-active {
    grid-template-columns: 280px 1fr 260px;
  }
}

/* ── Standard desktops (1024px – 1199px) ── */
@media (max-width: 1199px) {
  #app-container {
    grid-template-columns: 180px 1fr;
  }
  .nav-item {
    padding: 12px 14px;
    font-size: 0.85rem;
  }
  .inbox-layout {
    grid-template-columns: 240px 1fr;
  }
  .inbox-layout.details-active {
    grid-template-columns: 240px 1fr 240px;
  }
  .chat-header {
    padding: 12px 16px;
  }
  #messages-container {
    padding: 16px;
  }
  .chat-footer {
    padding: 12px 16px;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Small desktops / large tablets (900px – 1023px) ── */
@media (max-width: 1023px) {
  #app-container {
    grid-template-columns: 60px 1fr;
  }
  .sidebar-logo h1,
  .nav-item span,
  .sidebar-footer .profile-info {
    display: none;
  }
  .sidebar-logo {
    justify-content: center;
    padding: 16px;
  }
  .sidebar-logo .logo-icon {
    font-size: 1.6rem;
  }
  .nav-item {
    justify-content: center;
    padding: 14px;
  }
  .nav-item i {
    font-size: 1.2rem;
  }
  .sidebar-footer {
    padding: 12px;
  }
  .user-profile .avatar {
    margin: 0 auto;
  }
  .inbox-layout {
    grid-template-columns: 220px 1fr;
  }
  /* Details panel becomes a slide-over at this breakpoint */
  .inbox-layout.details-active {
    grid-template-columns: 220px 1fr;
  }
  /* Slide-over details panel */
  #details-panel {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    width: 300px;
    height: 100dvh;
    z-index: 300;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    transform: translateX(110%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.4);
  }
  #details-panel.panel-visible {
    transform: translateX(0);
  }
  .details-toggle-btn {
    display: flex;
  }
  .close-details-btn {
    display: flex;
  }
  .message-bubble {
    max-width: 75%;
  }
}

/* ── Tablets (768px – 899px) ── */
@media (max-width: 899px) {
  .inbox-layout {
    grid-template-columns: 220px 1fr;
  }
  .contact-card {
    padding: 12px;
    gap: 8px;
  }
  .contact-card .avatar {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
  }
  .contact-card-footer {
    display: none;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
  /* Action button labels hidden to save space */
  .action-btn-label {
    display: none;
  }
  .chat-actions {
    gap: 8px;
  }
  .action-btn {
    padding: 8px 10px;
  }
  .assignee-box {
    display: none;
  }
}

/* ── Mobile (≤768px) — full single-column layout ── */
@media (max-width: 768px) {
  #app-container {
    grid-template-columns: 1fr;
    grid-template-rows: 60px 1fr;
  }

  #mobile-header {
    display: flex;
  }

  #sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    width: 240px;
    height: calc(100dvh - 60px);
    transform: translateX(-100%);
    z-index: 200;
  }

  #sidebar.sidebar-visible {
    transform: translateX(0);
    box-shadow: var(--card-shadow);
  }

  /* Show sidebar nav labels again on mobile drawer */
  .sidebar-logo h1,
  .nav-item span,
  .sidebar-footer .profile-info {
    display: block;
  }
  .nav-item {
    justify-content: flex-start;
    padding: 14px 18px;
  }

  /* ── Mobile inbox: smooth slide animation ── */
  .inbox-layout {
    grid-template-columns: 1fr;
    position: relative;
    overflow: hidden;
  }
  .inbox-layout.details-active {
    grid-template-columns: 1fr;
  }

  /* Both panels always rendered, slid off-screen when inactive */
  .inbox-layout #contacts-panel {
    display: flex;
    position: absolute;
    inset: 0;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1;
  }
  .inbox-layout #chat-window {
    display: flex;
    flex-direction: column;
    position: absolute;
    inset: 0;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1;
  }
  .inbox-layout.chat-view-active #contacts-panel {
    transform: translateX(-100%);
  }
  .inbox-layout.chat-view-active #chat-window {
    transform: translateX(0);
  }

  /* Slide-over details panel (same as tablet) */
  #details-panel {
    width: 85vw;
    max-width: 320px;
  }

  #main-content {
    height: calc(100dvh - 60px);
  }

  /* ── Chat header: wrap to 2 rows on mobile ── */
  .chat-header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .contact-meta {
    flex: 1;
    min-width: 0;
  }
  .contact-meta h3 {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
  }
  .assignee-box {
    display: none;
  }
  .chat-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 6px;
  }
  .ai-status-badge {
    padding: 5px 8px;
    font-size: 0.7rem;
  }
  .action-btn {
    padding: 7px 9px;
    font-size: 0.78rem;
    gap: 5px;
  }

  /* ── Contact cards ── */
  .contact-card {
    padding: 10px 12px;
    gap: 8px;
  }
  .contact-card .avatar {
    width: 34px;
    height: 34px;
    font-size: 0.78rem;
    flex-shrink: 0;
  }
  .contact-info-top h4 {
    font-size: 0.85rem;
  }
  .contact-time {
    white-space: nowrap;
    flex-shrink: 0;
  }
  .contact-card-footer {
    display: none;
  }

  /* ── Status tabs: horizontally scrollable ── */
  .status-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    margin-top: 10px;
  }
  .status-tabs::-webkit-scrollbar {
    display: none;
  }
  .status-tab {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 0.7rem;
    padding: 5px 10px;
  }

  /* ── Messages ── */
  #messages-container {
    padding: 12px;
  }
  .message-bubble {
    max-width: 88%;
  }

  /* ── Chat footer ── */
  .chat-footer {
    padding: 10px 12px;
  }
  .input-actions {
    gap: 2px;
  }
  .attach-btn {
    padding: 6px 7px;
    min-width: 36px;
    min-height: 36px;
  }
  #chat-input-field {
    font-size: 16px; /* Prevent iOS auto-zoom */
  }

  /* ── Touch-friendly minimum tap targets ── */
  .mode-tab {
    min-height: 40px;
    padding: 8px 12px;
  }
  #btn-send-message {
    min-width: 40px;
    min-height: 40px;
  }

  .mobile-only {
    display: flex !important;
  }

  .settings-layout {
    padding: 16px;
  }
}

/* ── Very small phones (≤ 480px) ── */
@media (max-width: 480px) {
  .message-bubble {
    max-width: 92%;
  }
  .chat-header {
    padding: 8px 10px;
  }
  .contact-meta h3 {
    max-width: 120px;
  }
}

/* ==========================================================================
   Respond.io Team Collaboration & Assignment Styles
   ========================================================================== */
.assignee-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 16px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 6px 12px;
}

.assignee-box i {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.assignee-select {
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.8rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.assignee-select option {
  background-color: var(--bg-sidebar);
  color: var(--text-primary);
}

.chat-footer {
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 12px !important;
  flex-shrink: 0 !important;
}

.chat-footer-modes {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.mode-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-tab:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.03);
}

.mode-tab.active#mode-reply {
  color: #fff;
  background-color: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.mode-tab.active#mode-note {
  color: #fff;
  background-color: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.chat-footer-inputs {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.chat-footer-inputs form {
  flex: 1;
}

/* Yellow Internal Note Message Bubble Styling */
.message-bubble.internal-note {
  background-color: rgba(245, 158, 11, 0.12) !important;
  border: 1px dashed rgba(245, 158, 11, 0.35) !important;
  color: #fef08a !important; /* soft yellow */
}

.message-bubble.internal-note .sender-tag {
  color: #fbbf24 !important;
}

/* Team & Agent Management Table & Layout Styles */
.team-layout-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 24px;
}

.agents-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.agents-table th, .agents-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}

.agents-table th {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  background-color: rgba(255, 255, 255, 0.01);
}

.agents-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.role-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--border-radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.role-badge.owner {
  background-color: rgba(139, 92, 246, 0.15);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.role-badge.admin {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.role-badge.manager {
  background-color: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.role-badge.agent {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.delete-agent-btn {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--border-radius-sm);
  transition: all 0.2s;
}

.delete-agent-btn:hover {
  background-color: rgba(239, 68, 68, 0.15);
}

/* --- Login Screen Styling --- */
#login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at top right, rgba(16, 185, 129, 0.15), transparent 60%),
              radial-gradient(circle at bottom left, rgba(79, 70, 229, 0.1), transparent 50%),
              #0B0F17;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
}

#login-container.hidden {
  display: none !important;
}

.auth-box {
  width: 100%;
  max-width: 440px;
  padding: 0;
  background: rgba(18, 24, 38, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
  overflow: hidden;
}

/* Auth Tabs (Sign In / Create Account) */
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 18px 0;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.auth-tab.active {
  color: #fff;
  background: rgba(16, 185, 129, 0.05);
}

.auth-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent-color);
}

.auth-tab:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

#login-panel,
#register-panel {
  padding: 32px 40px 40px;
}

/* ── Login page responsive ── */
@media (max-width: 768px) {
  #login-container {
    padding: 16px;
    align-items: center;
  }
  .auth-box {
    max-width: 100%;
    border-radius: var(--border-radius-md);
  }
  #login-panel,
  #register-panel {
    padding: 24px 24px 32px;
  }
  .login-header h1 {
    font-size: 1.5rem;
  }
  .login-logo-icon {
    font-size: 2.5rem;
  }
  .auth-box input {
    font-size: 16px; /* Prevent iOS auto-zoom */
  }
}

@media (max-width: 480px) {
  #login-container {
    padding: 12px;
  }
  #login-panel,
  #register-panel {
    padding: 20px 18px 28px;
  }
  .login-header h1 {
    font-size: 1.3rem;
  }
  .auth-tab {
    font-size: 0.8rem;
    padding: 14px 0;
  }
}

.login-header h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  margin-top: 15px;
  margin-bottom: 8px;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 30px;
}

.login-logo-icon {
  font-size: 3rem;
  color: var(--success-color);
  filter: drop-shadow(0 0 12px rgba(16, 185, 129, 0.4));
}

.auth-box .input-group {
  margin-bottom: 18px;
  text-align: left;
}

.auth-box .input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.auth-box .input-wrapper {
  position: relative;
}

.auth-box .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.95rem;
}

.auth-box input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  background-color: rgba(11, 15, 23, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-md);
  color: #fff;
  font-size: 0.9rem;
  font-family: var(--font-family);
  transition: all 0.3s;
}

.auth-box input:focus {
  outline: none;
  border-color: var(--success-color);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.login-btn {
  width: 100%;
  padding: 12px;
  margin-top: 10px;
  justify-content: center;
  font-size: 0.95rem;
}

.error-msg {
  background-color: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #f87171;
  padding: 10px;
  border-radius: var(--border-radius-md);
  font-size: 0.8rem;
  margin-bottom: 16px;
  text-align: left;
}

.success-msg {
  background-color: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
  padding: 10px;
  border-radius: var(--border-radius-md);
  font-size: 0.8rem;
  margin-bottom: 16px;
  text-align: left;
}

.login-footer {
  margin-top: 25px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.login-footer code {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.08);
  padding: 2px 5px;
  border-radius: var(--border-radius-sm);
}

/* Logout button in header */
.logout-btn-header {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
}

.logout-btn-header:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #fff;
}

/* Details panel backdrop overlay */
#details-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 299;
  animation: backdropFadeIn 0.25s ease;
}

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

#details-backdrop.visible {
  display: block;
}

/* The toggle button — hidden on full desktop, shown on tablet/mobile */
.details-toggle-btn {
  display: none;
}

/* Close button — hidden on full desktop */
.close-details-btn {
  display: none;
}

/* On desktop, the details panel is an inline grid column — action-btn-labels always visible */
.action-btn-label {
  display: inline;
}

/* --- Contact Details Panel (Right Sidebar) --- */
#details-panel {
  width: 300px;
  background-color: var(--card-bg);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
}

#details-panel.hidden {
  display: none !important;
}

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

.details-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
}

.details-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.details-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 20px;
}

.details-avatar-section .avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--primary-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.details-avatar-section h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.details-avatar-section p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.details-section {
  margin-bottom: 24px;
}

.details-section .section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.details-section .section-title i {
  font-size: 0.85rem;
}

/* Tags styles */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.contact-tag {
  background-color: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #34d399;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.contact-tag .btn-remove-tag {
  background: none;
  border: none;
  color: #f87171;
  cursor: pointer;
  padding: 0;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
}

.contact-tag .btn-remove-tag:hover {
  color: #ef4444;
}

.add-tag-box {
  display: flex;
  gap: 6px;
}

.small-input {
  flex: 1;
  background-color: rgba(11, 15, 23, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-sm);
  padding: 6px 10px;
  color: #fff;
  font-size: 0.8rem;
}

.small-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.btn-icon {
  background-color: var(--primary-color);
  border: none;
  color: #fff;
  border-radius: var(--border-radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

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

/* Custom fields inputs */
.custom-fields-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.field-input, .field-select {
  background-color: rgba(11, 15, 23, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-sm);
  padding: 8px 12px;
  color: #fff;
  font-size: 0.85rem;
  width: 100%;
}

.field-input:focus, .field-select:focus {
  outline: none;
  border-color: var(--primary-color);
}

.field-select option {
  background-color: #0b0f17;
  color: #fff;
}

/* ==========================================================================
   Conversation Status System Styling
   ========================================================================== */

/* Status Filter Tabs */
.status-tabs {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  padding: 2px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.status-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 0;
  border-radius: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.status-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.status-tab.active {
  color: #fff;
  background: var(--accent-color);
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* Unread Badge */
.unread-badge {
  background-color: var(--accent-color);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 6px var(--accent-glow);
}

/* Contact status tag in sidebar card */
.contact-status-tag {
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.contact-status-tag.status-open {
  background-color: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.contact-status-tag.status-pending {
  background-color: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.contact-status-tag.status-resolved {
  background-color: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Chat Status Badge in header */
.chat-status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 6px 12px;
  border-radius: var(--border-radius-lg);
  text-transform: uppercase;
}

.chat-status-badge.status-open {
  background-color: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.chat-status-badge.status-pending {
  background-color: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.chat-status-badge.status-resolved {
  background-color: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* ==========================================================================
   Canned Responses UI CSS
   ========================================================================== */
.chat-footer {
  position: relative;
}

.canned-dropdown {
  position: absolute;
  bottom: calc(100% - 10px);
  left: 24px;
  right: 24px;
  background-color: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  box-shadow: var(--card-shadow);
  z-index: 200;
  max-height: 200px;
  overflow-y: auto;
}

.canned-item {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s;
}

.canned-item:last-child {
  border-bottom: none;
}

.canned-item:hover, .canned-item.selected {
  background-color: rgba(16, 185, 129, 0.15);
}

.canned-item .shortcut {
  font-weight: 600;
  color: var(--accent-color);
}

.canned-item .content {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
  font-size: 0.85rem;
}

/* Custom Confirm Modal Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(11, 15, 25, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.modal-overlay.hidden {
  display: none !important;
  opacity: 0;
}

.modal-container {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px var(--accent-glow);
  width: 90%;
  max-width: 440px;
  overflow: hidden;
  animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
  from {
    transform: scale(0.95) translateY(10px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: rgba(255, 255, 255, 0.01);
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
}

.modal-header .warn-icon {
  color: #ef4444;
  font-size: 1.35rem;
}

.modal-body {
  padding: 24px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal-actions {
  padding: 16px 24px;
  background-color: rgba(0, 0, 0, 0.15);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.danger-btn {
  background-color: #ef4444 !important;
  border-color: #ef4444 !important;
}

.danger-btn:hover {
  background-color: #dc2626 !important;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4) !important;
}

/* ==========================================================================
   Premium Inbox & Real-time Visual Enhancements
   ========================================================================== */

/* Online pulsator dot on avatar */
.avatar-online-dot {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 11px;
  height: 11px;
  background-color: #10b981;
  border: 2px solid #0f1524;
  border-radius: 50%;
  box-shadow: 0 0 6px #10b981;
  animation: pulse-green-dot 2s infinite;
  z-index: 5;
}

@keyframes pulse-green-dot {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Highlight unread cards in the contacts panel */
.contact-card.unread-card {
  background-color: rgba(16, 185, 129, 0.03);
}

.contact-card.unread-card:hover {
  background-color: rgba(16, 185, 129, 0.06);
}

.contact-card.unread-card .contact-info-top h4 {
  font-weight: 700;
  color: #ffffff;
}

.contact-card.unread-card .contact-last-msg {
  font-weight: 600;
  color: var(--text-primary);
}

/* Unread Badge Glow and Soft Pulsing */
.unread-badge {
  animation: pulse-badge-glow 2s infinite;
}

@keyframes pulse-badge-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Unread Message Separator & Bubble Highlight */
.unread-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 18px 0;
  width: 100%;
  animation: separatorFadeIn 0.3s ease;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

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

.unread-separator::before,
.unread-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.35), transparent);
}

.unread-separator span {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 14px;
  border-radius: 14px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin: 0 12px;
}

.unread-separator.fade-out {
  opacity: 0;
  transform: translateY(-6px);
}

.message-bubble.unread-highlight {
  border: 1px solid rgba(16, 185, 129, 0.45) !important;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2), 0 2px 12px 0 rgba(0, 0, 0, 0.1) !important;
  transition: border-color 1.2s ease, box-shadow 1.2s ease;
}


