/* ═══════════════════════════════════════════════════════════
   INBOX  —  WhatsApp-style layout
   ═══════════════════════════════════════════════════════════ */

/* ── Layout ─────────────────────────────────────────────── */
.inbox-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
  background: var(--wa-chat-bg);
}

/* ══════════════════════════════════════════════════════════
   CONVERSATION LIST PANEL
══════════════════════════════════════════════════════════ */
.conv-list-panel {
  width: 340px;
  min-width: 340px;
  max-width: 340px;
  border-right: 1px solid #e9edef;
  display: flex;
  flex-direction: column;
  background: #fff;
  flex-shrink: 0;
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}

/* Header */
.conv-list-header {
  padding: 10px 14px 0;
  border-bottom: 1px solid #e9edef;
  flex-shrink: 0;
  background: #f0f2f5;
}

.conv-list-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.conv-list-title {
  font-size: 19px;
  font-weight: 600;
  color: #111b21;
}

.compose-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #54656f;
  transition: background .12s;
}
.compose-btn:hover { background: #e9edef; color: #111b21; }

/* Search */
.conv-list-search {
  position: relative;
  margin-bottom: 8px;
}
.conv-list-search input {
  padding-left: 38px;
  background: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  color: #111b21;
  height: 36px;
}
.conv-list-search input:focus { border-color: transparent; box-shadow: none; }
.conv-list-search input::placeholder { color: #8696a0; }
.conv-list-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #8696a0;
}

/* Stage chips (pipeline filter in inbox header) */
.stage-chips {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.stage-chips::-webkit-scrollbar { display: none; }

.stage-chip {
  padding: 3px 12px;
  border-radius: 999px;
  border: 1.5px solid #e9edef;
  background: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  color: #54656f;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.stage-chip:hover { border-color: var(--chip-color, #25D366); color: var(--chip-color, #25D366); }
.stage-chip.active {
  background: var(--chip-color, #25D366);
  border-color: var(--chip-color, #25D366);
  color: #fff;
  font-weight: 600;
}
.stage-chip[data-stage=""].active { background: #25D366; border-color: #25D366; }

/* Stage dropdown in contact detail panel */
.stage-select-detail {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--stage-color, #3b82f6);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--stage-color, #3b82f6);
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
}
.stage-select-detail:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--stage-color, #3b82f6) 20%, transparent); }

/* Tabs — pill style matching reference */
.conv-tabs {
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 14px;
  flex-shrink: 0;
}
.conv-tabs::-webkit-scrollbar { display: none; }

.conv-tab {
  padding: 5px 14px;
  border: 1.5px solid #e9edef;
  border-radius: 999px;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  color: #54656f;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
  line-height: 1.4;
}
.conv-tab.active {
  background: #25D366;
  color: #fff;
  border-color: #25D366;
}
.conv-tab:hover:not(.active) { border-color: #25D366; color: #25D366; }
.conv-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 5px;
  background: rgba(0,0,0,.12);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}
.conv-tab.active .conv-tab-count { background: rgba(255,255,255,.3); }

.conv-filter-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: #54656f;
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.conv-filter-btn:hover { background: #e9edef; }

/* Conversation list */
.conv-list { flex: 1; overflow-y: auto; }
.conv-list::-webkit-scrollbar { width: 4px; }
.conv-list::-webkit-scrollbar-thumb { background: #ccd0d5; border-radius: 2px; }

.conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
  transition: background .1s;
  -webkit-tap-highlight-color: transparent;
  min-height: 72px;
}
.conv-item:hover  { background: #f5f6f6; }
.conv-item.active { background: #e9edef; }

.conv-avatar {
  width: 49px; height: 49px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.conv-info { flex: 1; overflow: hidden; min-width: 0; }

.conv-name {
  font-size: 16px;
  font-weight: 400;
  color: #111b21;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-preview {
  font-size: 13px;
  color: #8696a0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

.conv-time { font-size: 12px; color: #8696a0; }

.conv-unread {
  background: var(--wa-green);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

/* ══════════════════════════════════════════════════════════
   CHAT PANEL
══════════════════════════════════════════════════════════ */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #f0f2f5;
  border-bottom: 1px solid #e9edef;
  flex-shrink: 0;
  min-height: 60px;
}

.chat-back-btn {
  display: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: #54656f;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.chat-back-btn:hover { background: #e9edef; }

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

.chat-header-name {
  font-size: 16px;
  font-weight: 500;
  color: #111b21;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-status {
  font-size: 13px;
  color: #8696a0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-header-actions { display: flex; gap: 4px; }

/* ── Chat messages area ───────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8% 8px;
  display: flex;
  flex-direction: column;
  background-color: var(--wa-chat-bg);
  /* subtle dot pattern like WhatsApp */
  background-image:
    radial-gradient(circle, #c8bfb0 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: #b2bec3; border-radius: 3px; }

/* No conversation / empty */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--wa-chat-bg);
  background-image: radial-gradient(circle, #c8bfb0 1px, transparent 1px);
  background-size: 24px 24px;
  color: #54656f;
  gap: 14px;
}
.chat-empty svg { opacity: .3; }
.chat-empty p { font-size: 14px; }

/* Date separator */
.date-sep {
  display: flex;
  justify-content: center;
  margin: 10px 0 6px;
}
.date-sep span {
  background: rgba(255,255,255,.92);
  color: #54656f;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  letter-spacing: .2px;
}

/* ── Message rows ────────────────────────────────────── */
.msg-row {
  display: flex;
  margin-bottom: 2px;
  position: relative;
}
.msg-row.inbound  { justify-content: flex-start; padding-left: 4px; }
.msg-row.outbound { justify-content: flex-end; padding-right: 4px; }
.msg-row.grouped  { margin-bottom: 1px; }

/* ── Bubbles ────────────────────────────────────────── */
.bubble {
  max-width: 65%;
  padding: 7px 10px 6px 10px;
  border-radius: 7.5px;
  font-size: 14.2px;
  line-height: 1.45;
  position: relative;
  word-wrap: break-word;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,.10);
}

/* Sent (outbound) — light green, tail top-right */
.bubble.sent {
  background: var(--bubble-sent);   /* #d9fdd3 */
  color: #111b21;
  border-top-right-radius: 0;
}
.bubble.sent.with-tail::after {
  content: '';
  position: absolute;
  top: 0;
  right: -8px;
  width: 0; height: 0;
  border-left: 8px solid var(--bubble-sent);
  border-bottom: 8px solid transparent;
}

/* Received (inbound) — white, tail top-left */
.bubble.received {
  background: #ffffff;
  color: #111b21;
  border-top-left-radius: 0;
}
.bubble.received.with-tail::after {
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  width: 0; height: 0;
  border-right: 8px solid #ffffff;
  border-bottom: 8px solid transparent;
}

/* Bubble footer: timestamp + ticks float right */
.bubble-footer {
  display: flex;
  align-items: center;
  gap: 3px;
  justify-content: flex-end;
  float: right;
  margin-top: 2px;
  margin-left: 10px;
  margin-bottom: -2px;
  position: relative;
  bottom: 0;
}

.bubble-ts {
  font-size: 11px;
  color: #8696a0;
  line-height: 1;
}

/* Tick SVGs */
.tick-svg {
  display: block;
  flex-shrink: 0;
}

/* Window 24h banner */
.window-banner {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 16px;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}
.window-banner.open {
  background: #f0fdf4;
  color: #166534;
  border-bottom: 1px solid #bbf7d0;
}
.window-banner.closed {
  background: #fffbeb;
  color: #92400e;
  border-bottom: 1px solid #fcd34d;
}
.window-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--wa-green);
  flex-shrink: 0;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: .35; }
}
.window-tip {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  opacity: .7;
}

/* ── Input area ────────────────────────────────────── */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #f0f2f5;
  border-top: none;
  flex-shrink: 0;
}

.chat-input-wrap {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #fff;
  border-radius: 24px;
  padding: 4px 8px 4px 16px;
  min-height: 44px;
}

#chat-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 0;
  resize: none;
  min-height: 32px;
  max-height: 130px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.4;
  outline: none;
  font-family: var(--font);
  color: #111b21;
  width: 100%;
  scrollbar-width: none;
}
#chat-input::-webkit-scrollbar { display: none; }
#chat-input::placeholder { color: #8696a0; }

.chat-input-emoji-btn {
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-bottom: 2px;
  line-height: 1;
}
.chat-input-emoji-btn:hover { background: #f0f2f5; }

.chat-send-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--wa-green);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
  box-shadow: 0 2px 8px rgba(37,211,102,.35);
}
.chat-send-btn:hover   { background: var(--wa-green-dark); }
.chat-send-btn:active  { transform: scale(.93); }

/* Attach button (outside wrap) */
.chat-attach-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #54656f;
  flex-shrink: 0;
  transition: background .12s;
}
.chat-attach-btn:hover { background: #e9edef; }

/* Template button */
.chat-template-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #54656f;
  flex-shrink: 0;
  transition: background .12s, color .12s;
}
.chat-template-btn:hover { background: #e9edef; color: #111b21; }

/* Emoji picker popup */
.emoji-picker-popup {
  position: absolute;
  bottom: 64px;
  left: 56px;
  width: 296px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  z-index: 200;
  border: 1px solid #e9edef;
}
.emoji-item {
  width: 34px; height: 34px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s;
  line-height: 1;
}
.emoji-item:hover { background: #f0f2f5; }

/* ── Canned-reply picker ─────────────────────────────────── */
.cr-picker {
  position: absolute;
  bottom: 64px;
  left: 0; right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border, #e9edef);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14);
  z-index: 220;
  padding: 4px 0;
}
.cr-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background .1s;
}
.cr-item:hover, .cr-item.cr-active {
  background: var(--bg-hover, #f0f2f5);
}
.cr-shortcut {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent, #00a884);
  white-space: nowrap;
  min-width: 70px;
}
.cr-title {
  font-size: 13px;
  color: var(--text-secondary, #667781);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Attach menu popup */
.attach-menu-popup {
  position: absolute;
  bottom: 64px;
  left: 8px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  padding: 6px;
  z-index: 200;
  border: 1px solid #e9edef;
  min-width: 160px;
}
.attach-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #111b21;
  text-align: left;
  transition: background .1s;
}
.attach-menu-item:hover { background: #f0f2f5; }

/* ══════════════════════════════════════════════════════════
   CONTACT DETAIL PANEL
══════════════════════════════════════════════════════════ */
.contact-detail-panel {
  width: 280px;
  min-width: 280px;
  border-left: 1px solid #e9edef;
  background: #fff;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.contact-detail-panel::-webkit-scrollbar { width: 4px; }
.contact-detail-panel::-webkit-scrollbar-thumb { background: #ccd0d5; border-radius: 2px; }

.contact-detail-header {
  text-align: center;
  padding: 24px 16px 16px;
  border-bottom: 1px solid #f0f2f5;
  background: #f0f2f5;
}
.contact-detail-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  margin: 0 auto 12px;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.contact-detail-name { font-size: 17px; font-weight: 600; color: #111b21; }
.contact-detail-phone { font-size: 13px; color: #8696a0; margin-top: 3px; }

.contact-detail-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}
.contact-action-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: #e8fdf5;
  color: var(--wa-green);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.contact-action-btn:hover { background: var(--wa-green); color: #fff; }

.contact-detail-section {
  padding: 14px 16px;
  border-bottom: 1px solid #f0f2f5;
}
.contact-detail-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--wa-green);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 10px;
}
.contact-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
}
.contact-detail-row svg { color: #8696a0; flex-shrink: 0; margin-top: 2px; }
.contact-detail-row-label { color: #8696a0; font-size: 11px; margin-bottom: 1px; }
.contact-detail-row-val { color: #111b21; font-weight: 400; }
.internal-id-badge {
  display: inline-block;
  padding: 2px 8px;
  background: #f0f2f5;
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
  color: #54656f;
}

.shared-media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.shared-media-thumb {
  aspect-ratio: 1;
  border-radius: 4px;
  background: #f0f2f5;
  overflow: hidden;
}
.shared-media-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── Contact Tasks ──────────────────────────────────────── */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border, #e9edef);
}
.task-item:last-child { border-bottom: none; }
.task-check { margin-top: 2px; accent-color: var(--accent, #00a884); cursor: pointer; }
.task-title { font-size: 13px; color: var(--text-primary); line-height: 1.4; word-break: break-word; }
.task-due { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.task-done .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-del { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 12px; padding: 0 2px; flex-shrink: 0; }
.task-del:hover { color: var(--danger, #ef4444); }

/* ── Internal Notes ─────────────────────────────────────── */
.note-item {
  background: var(--bg-secondary, #f0f2f5);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}
.note-author {
  font-weight: 600;
  color: var(--accent, #00a884);
  margin-bottom: 3px;
  font-size: 11px;
}
.note-body {
  color: var(--text-primary, #111b21);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.note-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
  color: var(--text-muted, #8696a0);
  font-size: 11px;
}
.note-del {
  background: none;
  border: none;
  color: var(--danger, #ef4444);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
}
.note-del:hover { text-decoration: underline; }

.contact-danger-section {
  padding: 14px 16px;
  margin-top: auto;
}
.contact-danger-link {
  display: block;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  margin-bottom: 10px;
  background: none;
  border: none;
  text-align: left;
  padding: 0;
  width: 100%;
}
.contact-danger-link.red { color: #ea0038; }
.contact-danger-link.green { color: var(--wa-green); }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — TABLET  (769px – 1024px)
══════════════════════════════════════════════════════════ */
@media (min-width: 769px) and (max-width: 1150px) {
  .contact-detail-panel { display: none; }
  .conv-list-panel { width: 300px; min-width: 300px; max-width: 300px; }
  .chat-messages { padding: 12px 5% 8px; }
  .bubble { max-width: 72%; }
}

/* ══════════════════════════════════════════════════════════
   DARK MODE
══════════════════════════════════════════════════════════ */
[data-theme="dark"] .conv-list-panel {
  background: var(--card);
  border-color: var(--border);
}
[data-theme="dark"] .conv-list-header {
  background: var(--bg-secondary);
  border-color: var(--border);
}
[data-theme="dark"] .conv-list-title { color: var(--text-primary); }
[data-theme="dark"] .conv-list-search input {
  background: var(--surface-container);
  color: var(--text-primary);
  border: none;
}
[data-theme="dark"] .conv-list-search input::placeholder { color: var(--text-muted); }
[data-theme="dark"] .conv-list-search svg { color: var(--text-muted); }
[data-theme="dark"] .compose-btn { color: var(--text-muted); }
[data-theme="dark"] .compose-btn:hover { background: var(--surface-container); color: var(--text-primary); }

[data-theme="dark"] .stage-chip {
  border-color: var(--border);
  background: var(--surface-container);
  color: var(--text-secondary);
}
[data-theme="dark"] .conv-tab { color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .conv-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
[data-theme="dark"] .conv-tab:hover:not(.active) { border-color: var(--accent); color: var(--accent); }
[data-theme="dark"] .conv-filter-btn { color: var(--text-muted); }
[data-theme="dark"] .conv-filter-btn:hover { background: var(--surface-container); }

[data-theme="dark"] .conv-item {
  border-bottom-color: var(--border-light);
}
[data-theme="dark"] .conv-item:hover  { background: var(--surface-container); }
[data-theme="dark"] .conv-item.active { background: var(--surface-container-high); }
[data-theme="dark"] .conv-name  { color: var(--text-primary); }
[data-theme="dark"] .conv-preview { color: var(--text-muted); }
[data-theme="dark"] .conv-time   { color: var(--text-muted); }

[data-theme="dark"] .chat-header {
  background: var(--bg-secondary);
  border-color: var(--border);
}
[data-theme="dark"] .chat-header-name   { color: var(--text-primary); }
[data-theme="dark"] .chat-header-status { color: var(--text-muted); }
[data-theme="dark"] .chat-back-btn { color: var(--text-muted); }
[data-theme="dark"] .chat-back-btn:hover { background: var(--surface-container); }

[data-theme="dark"] .date-sep span {
  background: var(--surface-container);
  color: var(--text-muted);
}

[data-theme="dark"] .bubble.received {
  background: var(--bubble-recv);
  color: #e9edef;
}
[data-theme="dark"] .bubble.received.with-tail::after {
  border-right-color: var(--bubble-recv);
}
[data-theme="dark"] .bubble.sent {
  background: var(--bubble-sent);
  color: #e9edef;
}
[data-theme="dark"] .bubble.sent.with-tail::after {
  border-left-color: var(--bubble-sent);
}

[data-theme="dark"] .chat-input-area  { background: var(--bg-secondary); }
[data-theme="dark"] .chat-input-wrap  { background: var(--surface-container); }
[data-theme="dark"] #chat-input       { color: var(--text-primary); }
[data-theme="dark"] #chat-input::placeholder { color: var(--text-muted); }
[data-theme="dark"] .chat-input-emoji-btn:hover { background: var(--surface-container-high); }
[data-theme="dark"] .chat-attach-btn  { color: var(--text-muted); }
[data-theme="dark"] .chat-attach-btn:hover { background: var(--surface-container); }
[data-theme="dark"] .chat-template-btn { color: var(--text-muted); }
[data-theme="dark"] .chat-template-btn:hover { background: var(--surface-container); }

[data-theme="dark"] .emoji-picker-popup {
  background: var(--card);
  border-color: var(--border);
}
[data-theme="dark"] .emoji-item:hover { background: var(--surface-container); }
[data-theme="dark"] .attach-menu-popup {
  background: var(--card);
  border-color: var(--border);
}
[data-theme="dark"] .attach-menu-item { color: var(--text-primary); }
[data-theme="dark"] .attach-menu-item:hover { background: var(--surface-container); }

[data-theme="dark"] .contact-detail-panel {
  background: var(--card);
  border-color: var(--border);
}
[data-theme="dark"] .contact-detail-header {
  background: var(--bg-secondary);
  border-color: var(--border);
}
[data-theme="dark"] .contact-detail-name  { color: var(--text-primary); }
[data-theme="dark"] .contact-detail-phone { color: var(--text-muted); }
[data-theme="dark"] .contact-detail-section { border-color: var(--border); }
[data-theme="dark"] .contact-detail-row svg { color: var(--text-muted); }
[data-theme="dark"] .contact-detail-row-val { color: var(--text-primary); }
[data-theme="dark"] .contact-detail-row-label { color: var(--text-muted); }
[data-theme="dark"] .internal-id-badge { background: var(--surface-container); color: var(--text-muted); }
[data-theme="dark"] .contact-action-btn { background: rgba(37,211,102,.12); }
[data-theme="dark"] .shared-media-thumb { background: var(--surface-container); }

[data-theme="dark"] .task-item { border-color: var(--border); }
[data-theme="dark"] .note-item { background: var(--surface-container); }
[data-theme="dark"] .note-body { color: var(--text-primary); }

[data-theme="dark"] .window-banner.open {
  background: rgba(37,211,102,.10);
  color: #4ade80;
  border-color: rgba(37,211,102,.20);
}
[data-theme="dark"] .window-banner.closed {
  background: rgba(245,158,11,.10);
  color: #fbbf24;
  border-color: rgba(245,158,11,.20);
}

[data-theme="dark"] .cr-picker {
  background: var(--card);
  border-color: var(--border);
}
[data-theme="dark"] .cr-item:hover,
[data-theme="dark"] .cr-item.cr-active { background: var(--surface-container); }

[data-theme="dark"] .chat-empty { color: var(--text-muted); }
[data-theme="dark"] .stage-select-detail { background: var(--surface-container); color: var(--text-primary); }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE  (≤768px)
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .inbox-layout {
    position: relative;
    overflow: hidden;
    /* fills #main-content which already accounts for topbar + bottom nav */
    height: 100%;
  }

  /* List panel: full width, slide out to left */
  .conv-list-panel {
    position: absolute;
    inset: 0;
    width: 100%;
    min-width: unset;
    max-width: unset;
    z-index: 10;
    border-right: none;
  }
  .conv-list-panel.mobile-hidden {
    transform: translateX(-100%);
    pointer-events: none;
  }

  /* Conversation list: extra breathing room at bottom */
  .conv-list { padding-bottom: 8px; }

  /* Chat panel: full width, slide in from right */
  .chat-panel {
    position: absolute;
    inset: 0;
    z-index: 11;
    transform: translateX(100%);
  }
  .chat-panel.mobile-active {
    transform: translateX(0);
  }

  /* Show back button on mobile */
  .chat-back-btn { display: flex; }

  /* Hide contact panel on mobile */
  .contact-detail-panel { display: none; }

  /* Wider bubbles on mobile */
  .bubble { max-width: 82%; font-size: 14px; }

  /* Less side padding in chat area */
  .chat-messages { padding: 10px 3% 12px; }

  /* Larger tap areas */
  .conv-item { padding: 14px 16px; min-height: 76px; }
  .chat-send-btn { width: 48px; height: 48px; }
}

/* ══════════════════════════════════════════════════════════
   INBOX REDESIGN — Visual polish layer
══════════════════════════════════════════════════════════ */

/* Header: subtle gradient instead of flat grey */
.conv-list-header {
  background: linear-gradient(160deg, #f5f6f8 0%, #edf0f2 100%);
  padding-bottom: 0;
}

/* Active conversation: green left-border accent */
.conv-item.active {
  background: #eef7f2;
  border-left: 3px solid #25D366;
  padding-left: 13px;
}
.conv-item:hover:not(.active) {
  background: #f7f8f9;
  border-left: 3px solid transparent;
  padding-left: 13px;
}

/* Avatar: subtle shadow for depth */
.conv-avatar {
  box-shadow: 0 2px 8px rgba(0,0,0,.13);
}

/* Unread badge: pulse ring */
.conv-unread {
  box-shadow: 0 0 0 2px rgba(37,211,102,.2);
}

/* Unread conv name bold */
.conv-item.unread .conv-name {
  font-weight: 600;
  color: #111b21;
}
.conv-item.unread .conv-time {
  color: #25D366;
  font-weight: 600;
}

/* Chat header: gradient for depth */
.chat-header {
  background: linear-gradient(160deg, #f5f6f8 0%, #edf0f2 100%);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  border-bottom: none;
}

/* Chat messages: lighter, more subtle dot pattern */
.chat-messages {
  background-image: radial-gradient(circle, rgba(0,0,0,.06) 1px, transparent 1px);
}
.chat-empty {
  background-image: radial-gradient(circle, rgba(0,0,0,.05) 1px, transparent 1px);
}

/* Message bubbles: slightly more rounded, richer shadows */
.bubble {
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.09), 0 1px 1px rgba(0,0,0,.06);
}
.bubble.sent { border-top-right-radius: 2px; }
.bubble.received { border-top-left-radius: 2px; }

/* Chat input: softer shadow */
.chat-input-wrap {
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* Input area: matching header gradient */
.chat-input-area {
  background: linear-gradient(160deg, #f5f6f8 0%, #edf0f2 100%);
  padding: 10px 12px 12px;
}

/* Contact detail avatar: ring styling */
.contact-detail-avatar {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px rgba(37,211,102,.25), 0 4px 14px rgba(0,0,0,.14);
}
.contact-detail-header {
  background: linear-gradient(160deg, #f5f6f8 0%, #edf0f2 100%);
}

/* Contact action buttons: more polished */
.contact-action-btn {
  box-shadow: 0 2px 8px rgba(37,211,102,.12);
  transition: all .18s cubic-bezier(.4,0,.2,1);
}
.contact-action-btn:hover {
  background: var(--wa-green);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,211,102,.28);
}

/* Section titles: cleaner look */
.contact-detail-section-title {
  font-size: 10.5px;
  letter-spacing: 1px;
}

/* Stage chips: smoother transitions */
.stage-chip {
  transition: all .18s cubic-bezier(.4,0,.2,1);
}
.stage-chip.active {
  box-shadow: 0 2px 8px rgba(37,211,102,.2);
}

/* Compose button: better hover */
.compose-btn {
  transition: all .18s cubic-bezier(.4,0,.2,1);
}
.compose-btn:hover {
  background: rgba(37,211,102,.1);
  color: #25D366;
}

/* ── Dark mode overrides for new styles ── */
[data-theme="dark"] .conv-list-header {
  background: linear-gradient(160deg, var(--bg-secondary) 0%, var(--surface-container) 100%);
}
[data-theme="dark"] .conv-item.active {
  background: rgba(37,211,102,.08);
  border-left-color: #25D366;
}
[data-theme="dark"] .conv-item:hover:not(.active) {
  background: var(--surface-container);
  border-left-color: transparent;
}
[data-theme="dark"] .chat-header {
  background: linear-gradient(160deg, var(--bg-secondary) 0%, var(--surface-container) 100%);
  border-bottom: none;
}
[data-theme="dark"] .chat-input-area {
  background: linear-gradient(160deg, var(--bg-secondary) 0%, var(--surface-container) 100%);
}
[data-theme="dark"] .contact-detail-header {
  background: linear-gradient(160deg, var(--bg-secondary) 0%, var(--surface-container) 100%);
}
[data-theme="dark"] .contact-detail-avatar {
  box-shadow: 0 0 0 3px var(--card), 0 0 0 5px rgba(37,211,102,.2), 0 4px 14px rgba(0,0,0,.3);
}
[data-theme="dark"] .compose-btn:hover {
  background: rgba(37,211,102,.12);
  color: #25D366;
}
