/* =====================================================================
   CONNECTO.v2 — Chat UI  /shared/css/chat.css
   ===================================================================== */

/* ── Variables ────────────────────────────────────────────────────── */
:root {
  --nav-bg: #0E5F56;
  --nav-hover: rgba(255, 255, 255, .12);
  --nav-active: rgba(255, 255, 255, .22);
  --nav-width: 50px;
  --list-width: 370px;
  --filter-width: 48px;
  --panel-width: 400px;

  --primary: #10B981;
  --primary-dark: #059669;
  --primary-light: #D1FAE5;
  --danger: #EF4444;
  --warning: #F59E0B;
  --info: #3B82F6;
  --muted: #6B7280;
  --border: #E5E7EB;
  --bg-page: #F8FAFC;
  --bg-card: #FFFFFF;

  --msg-out-bg: #DCF8C6;
  --msg-in-bg: #FFFFFF;
  --msg-radius: 12px;

  --font: 'Inter', system-ui, sans-serif;
  --text-main: #111827;
  --text-secondary: #6B7280;
  --text-light: #9CA3AF;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .08);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, .12);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, .16);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;

  --z-dropdown: 200;
  --z-modal: 500;
  --z-toast: 900;
}

/* ── Reset / Base ─────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-main);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

/* ── Root layout ──────────────────────────────────────────────────── */
.chat-root {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* =====================================================================
   LEFT NAV SIDEBAR
   ===================================================================== */
.nav-sidebar {
  flex: 0 0 var(--nav-width);
  width: var(--nav-width);
  background: var(--nav-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  z-index: 10;
  overflow: hidden;
}

.nav-logo {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, .18);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  flex-shrink: 0;
  cursor: pointer;
}

.nav-logo i {
  color: #fff;
  font-size: 18px;
}

.nav-items-top,
.nav-items-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
}

.nav-items-top {
  flex: 1;
  padding-top: 4px;
}

.nav-items-bottom {
  padding-bottom: 6px;
}

.nav-item {
  position: relative;
  width: 46px;
  margin-left: 6px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px 0px 0px 10px;
  cursor: pointer;
  color: rgba(255, 255, 255, .7);
  transition: background .15s, color .15s;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--nav-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--nav-active);
  color: #fff;
}

.nav-item i {
  font-size: 17px;
  margin-left: -3px;
}

/* Badge on nav item */
.nav-badge {
  position: absolute;
  top: 5px;
  right: 4px;
  background: #F59E0B;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* User avatar at bottom of nav */
.nav-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #F59E0B;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 4px;
  border: 2px solid rgba(255, 255, 255, .3);
  letter-spacing: .5px;
  position: relative;
}

/* Avatar dropdown menu */
.nav-avatar-menu {
  display: none;
  position: fixed;
  left: 56px;
  bottom: 12px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .15);
  min-width: 180px;
  z-index: 9999;
  overflow: hidden;
}

.nav-avatar-menu.open {
  display: block;
}

.nav-avatar-menu-name {
  padding: 12px 14px 8px;
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  border-bottom: 1px solid #F3F4F6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-avatar-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  font-size: 13px;
  color: #374151;
  text-decoration: none;
  transition: background .12s;
}

.nav-avatar-menu-item:hover {
  background: #F3F4F6;
}

.nav-avatar-menu-item.danger {
  color: #EF4444;
}

/* Tooltip on hover */
.nav-item[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, .8);
  color: #fff;
  font-size: 11px;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 999;
}

/* =====================================================================
   CHAT LIST PANEL
   ===================================================================== */
.chat-list-panel {
  flex: 0 0 var(--list-width);
  width: var(--list-width);
  min-width: 350px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
}

/* Header */
.cls-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cls-header-title {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.cls-header-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.cls-header-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background .15s, color .15s;
}

.cls-header-btn:hover {
  background: var(--bg-page);
  color: var(--text-main);
}

/* Search bar */
.cls-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cls-search input {
  flex: 1;
  border: none;
  background: var(--bg-page);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 15px;
  color: var(--text-main);
  outline: none;
}

.cls-search input::placeholder {
  color: var(--text-light);
}

#convSearch:focus {
  border: 1px solid #aaa;
}

.cls-search-actions {
  display: flex;
  gap: 2px;
}

.cls-search-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: none;
  color: #fff;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.cls-search-btn:hover {
  background: var(--bg-page);
}

.cls-search-dir-btn {
  width: 42px;
  height: 42px;
  border: none;
  background: none;
  color: var(--muted);
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.cls-search-dir-btn:hover {
  background: var(--bg-page);
  color: var(--primary);
}

/* Body = filter sidebar + chat items */
.cls-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Filter sidebar ── */
.cls-filter-bar {
  flex: 0 0 var(--filter-width);
  width: var(--filter-width);
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #F8FAFC;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  scrollbar-width: none;
  padding: 0;
  gap: 2px;
}

.cls-filter-bar::-webkit-scrollbar {
  display: none;
}

.cls-filter-bar::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 2px;
}

.cls-filter-item {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 0;
  cursor: pointer;
  border-radius: 6px;
  border-left: none;
  border-right: 3px solid transparent;
  transition: background .15s, border-color .15s;
  font-size: 9px;
  color: var(--muted);
  text-align: center;
}

.cls-filter-item:hover {
  background: #EFF1F3;
}

.cls-filter-item.active {
  border-left: none;
  border-right-color: #25D366;
  border-radius: 0;
  color: var(--primary);
  background: var(--primary-light);
}

.cls-filter-item i {
  font-size: 14px;
  position: relative;
  left: -3px;
}

.cls-filter-item[data-filter="labels"] i,
.cls-filter-item[data-filter="teams"] i,
.cls-filter-item[data-filter="channels"] i {
  left: 3px;
}

.cls-filter-item .flt-label {
  font-size: 8px;
  font-weight: 500;
  line-height: 1.2;
}

.cls-filter-item .flt-count {
  position: absolute;
  top: 2px;
  right: 2px;
  background: color-mix(in srgb, var(--primary) 70%, transparent);
  color: #fff;
  font-size: 8px;
  font-weight: 100;
  border-radius: 8px;
  min-width: 14px;
  height: 13px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.cls-filter-item.active .flt-count {
  background: var(--primary-dark);
}

.cls-filter-separator {
  width: 28px;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Chat items list ── */
.cls-items {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#mineSection {
  overflow-y: auto;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

#mineSection::-webkit-scrollbar {
  width: 3px;
}

#mineSection::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 3px;
}

#unassignedSection {
  overflow-y: auto;
  min-height: 48px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

#unassignedSection::-webkit-scrollbar {
  width: 3px;
}

#unassignedSection::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 3px;
}

.h-resizer {
  flex-shrink: 0;
  height: 4px;
  background: var(--border, #e5e5e5);
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  user-select: none;
}

.h-resizer:hover {
  background: var(--primary, #25D366);
}

.h-resizer-handle {
  width: 28px;
  height: 3px;
  border-radius: 2px;
  background: #bbb;
  pointer-events: none;
}

.h-resizer:hover .h-resizer-handle {
  background: #fff;
}

.cls-items::-webkit-scrollbar {
  width: 3px;
}

.cls-items::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 3px;
}

.cls-group-header {
  padding: 8px 10px 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 2;
}

.cls-group-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--primary, #25D366);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  vertical-align: middle;
}

.cls-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0, 0, 0, .04);
  transition: background .12s;
  position: relative;
}

.cls-item:hover {
  background: #F3F4F6;
}

.cls-item.active {
  background: #EFF6FF;
}

.cls-item.unread {}

.cls-item-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: #6366F1;
  position: relative;
}

/* Channel badge on avatar */
.cls-item-avatar .ch-badge {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #6B7280;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1;
  color: #fff;
}

.cls-item-avatar .ch-badge[data-channel="whatsapp"] {
  background: #25D366;
}

.cls-item-avatar .ch-badge[data-channel="messenger"] {
  background: #0084FF;
}

.cls-item-avatar .ch-badge[data-channel="instagram"] {
  background: #E1306C;
}

.cls-item-avatar .ch-badge[data-channel="telegram"] {
  background: #229ED9;
}

.cls-empty-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px;
  color: var(--text-secondary);
  user-select: none;
  pointer-events: none;
}

.cls-empty-section i {
  font-size: 2rem;
  opacity: .22;
  color: var(--text-secondary);
}

.cls-empty-section span {
  font-size: 1rem;
  font-weight: 500;
  opacity: .55;
  color: var(--text-main);
  text-align: center;
}

.cls-item-body {
  flex: 1;
  min-width: 0;
}

.cls-item-row1 {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}

.cls-item-name {
  flex: 1;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.cls-item-time {
  font-size: 10px;
  color: var(--text-light);
  flex-shrink: 0;
  white-space: nowrap;
}

.cls-item-row2 {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cls-item-preview {
  flex: 1;
  font-size: 11.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cls-item-badge {
  flex-shrink: 0;
  background: color-mix(in srgb, var(--primary) 70%, transparent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Footer of chat list ── */
.cls-footer {
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cls-footer label {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.cls-footer select {
  flex: 1;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 6px;
  background: var(--bg-card);
  color: var(--text-main);
  outline: none;
}


/* ── Empty state: no conversation open ─────────────────────────────────── */
#noConvState {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-secondary);
  user-select: none;
  pointer-events: none;
}

.chat-main.is-empty #noConvState {
  display: flex;
}

.chat-main.is-empty> :not(#noConvState) {
  display: none !important;
}

#noConvState i {
  font-size: 52px;
  opacity: .25;
}

#noConvState p {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  opacity: .55;
}

#noConvState span {
  font-size: 13px;
  opacity: .45;
}

/* =====================================================================
   MAIN CHAT AREA
   ===================================================================== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-page);
  overflow: hidden;
}

/* ── Chat header ── */
.cm-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.cm-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #0D9488;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.cm-header-avatar .online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 70%, transparent);
  border: 2px solid #fff;
}

.cm-header-info {
  flex: 1;
  min-width: 0;
}

.cm-header-name {
  font-size: 1rem;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.3;
}

.cm-header-sub {
  font-size: 11px;
  color: var(--text-secondary);
}

.cm-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.cm-btn {
  height: 32px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 200;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background .15s;
}

.cm-btn-resolve {
  background: color-mix(in srgb, var(--primary) 70%, transparent);
  color: #fff;
}

.cm-btn-resolve:hover {
  background: var(--primary-dark);
}

/* Split button group */
.cm-btn-split-group {
  display: flex;
  align-items: stretch;
}

.cm-btn-split-group .cm-btn-resolve {
  border-radius: 6px 0 0 6px;
}

.cm-btn-resolve-dd {
  width: 26px;
  height: 32px;
  padding: 0;
  border: none;
  background: color-mix(in srgb, var(--primary) 70%, transparent);
  color: #fff;
  border-left: 1px solid rgba(255, 255, 255, .3);
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.cm-btn-resolve-dd:hover {
  background: var(--primary-dark);
}

.cm-btn-split {
  width: 28px;
  height: 32px;
  padding: 0;
  background: color-mix(in srgb, var(--primary) 70%, transparent);
  color: #fff;
  border-left: 1px solid rgba(255, 255, 255, .3);
  border-radius: 0 6px 6px 0;
  margin-left: 1px;
}

.cm-btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background .15s, color .15s;
}

.cm-btn-icon:hover {
  background: var(--bg-page);
  color: var(--text-main);
}

.cm-btn-reassign {
  background: #F3F4F6;
  color: var(--text-main);
  font-size: 1rem;
  font-weight: 200;
}

.cm-btn-reassign:hover {
  background: #E5E7EB;
}

/* ── Dropdown menus ── */
.cm-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: var(--z-dropdown);
  overflow: hidden;
  display: none;
}

.cm-dropdown.open {
  display: block;
}

.cm-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--text-main);
  cursor: pointer;
  transition: background .12s;
}

.cm-dropdown-item:hover {
  background: var(--bg-page);
}

.cm-dropdown-item i {
  width: 14px;
  color: var(--muted);
  font-size: 13px;
}

.cm-dropdown-item.danger {
  color: var(--danger);
}

.cm-dropdown-item.danger i {
  color: var(--danger);
}

.cm-dropdown-sep {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

/* ── Message thread ── */
.cm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* Fondo del área de conversación: patrón de íconos de mensajería (tenant-app/public/fondo.png).
     El color es el del propio patrón, por si la imagen tarda en cargar. */
  background-color: #FCFBF8;
  /* La imagen se ajusta al ancho, se repite solo en vertical (si hace falta) y se ve con su opacidad original (sin capa encima). */
  background-image: url('/fondo.png?v=fdc7f74');
  background-size: 100% auto;
  background-repeat: repeat-y;
  background-position: top center;
}

.cm-messages::-webkit-scrollbar {
  width: 4px;
}

.cm-messages::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}

.msg-date-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 4px;
}

.msg-date-divider::before,
.msg-date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.msg-date-text {
  font-size: 0.7rem;
  color: var(--text-secondary);
  white-space: nowrap;
  padding: 3px 10px;
  background: rgba(0, 0, 0, .05);
  border-radius: 10px;
}

/* Message row */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  width: fit-content;
  min-width: 150px;
  max-width: 400px;
  animation: msgIn .2s ease-out;
}

.msg-content {
  flex: 1;
  min-width: 0;
}

.msg-row.out {
  flex-direction: row-reverse;
  align-self: flex-end;
}

.msg-row.in {
  align-self: flex-start;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.msg-bubble {
  max-width: 100%;
  padding: 8px 12px;
  border-radius: var(--msg-radius);
  font-size: 13px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

.msg-row.in .msg-bubble {
  background: var(--msg-in-bg);
  box-shadow: var(--shadow-sm);
  border-bottom-left-radius: 3px;
  color: var(--text-main);
}

.msg-row.out .msg-bubble {
  background: var(--msg-out-bg);
  border-bottom-right-radius: 3px;
  color: var(--text-main);
}

.msg-bubble a {
  color: var(--info);
}

.msg-image {
  display: block;
  max-width: 260px;
  max-height: 320px;
  width: 100%;
  border-radius: calc(var(--msg-radius) - 4px);
  cursor: pointer;
  object-fit: cover;
}

.msg-image-caption {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
}

/* Meta: time + status */
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 9px;
}

.msg-time {
  margin-top: -10px;
  font-size: 10px;
  color: var(--text-light);
}

.msg-status {
  font-size: 0.9rem;
  color: var(--info);
}

.msg-status.read {
  color: #34D399;
  margin-left: -20px !important;
}

/* ── Input area ── */
.cm-input-area {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Tabs */
.cm-input-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
}

.cm-input-tab {
  padding: 2px 6px;
  font-size: 0.9rem;
  font-weight: 100;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.cm-input-tab:hover {
  color: var(--text-main);
}

.cm-input-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.cm-input-tab .tab-ai-badge {
  background: linear-gradient(135deg, #8B5CF6, #EC4899);
  color: #fff;
  font-size: 9px;
  border-radius: 3px;
  padding: 1px 4px;
}

.cm-input-tab-spacer {
  flex: 1;
}

.cm-input-settings-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

/* Suggestion panel (canned responses) */
.cm-suggestions {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 80px;
  overflow-y: auto;
}

.cm-suggestion-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 4px;
}

.cm-suggestion-item:hover {
  background: var(--bg-page);
}

.cm-suggestion-shortcut {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}

.cm-suggestion-preview {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.typing-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}

.typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 70%, transparent);
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: .2s;
}

.typing-dot:nth-child(3) {
  animation-delay: .4s;
}

@keyframes typingBounce {

  0%,
  80%,
  100% {
    transform: scale(.7);
    opacity: .5;
  }

  40% {
    transform: scale(1.1);
    opacity: 1;
  }
}

/* Text input row */
.cm-input-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px 8px;
}

.cm-input-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}

.cm-input-btn:hover {
  background: var(--bg-page);
  color: var(--text-main);
}

.cm-textarea-wrap {
  flex: 1;
  min-width: 0;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: visible;
  display: flex;
  align-items: flex-end;
  position: relative;
}

.cm-emoji-btn {
  width: 32px;
  height: 36px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: color .15s;
  border-right: 1px solid var(--border);
  margin-bottom: 0;
  align-self: stretch;
}

.cm-emoji-btn:hover {
  color: var(--primary);
}

.cm-emoji-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 296px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: none;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  z-index: 200;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}

.cm-emoji-picker.open {
  display: grid;
}

.cm-emoji-item {
  font-size: 20px;
  cursor: pointer;
  text-align: center;
  padding: 4px 2px;
  border-radius: 5px;
  line-height: 1.3;
  transition: background .1s;
  user-select: none;
}

.cm-emoji-item:hover {
  background: var(--bg-hover, rgba(0, 0, 0, .06));
}

.cm-textarea {
  flex: 1;
  border: none;
  background: none;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font);
  resize: none;
  outline: none;
  color: var(--text-main);
  min-height: 36px;
  max-height: 120px;
  line-height: 1.5;
}

.cm-textarea::placeholder {
  color: var(--text-light);
}

.cm-send-group {
  display: flex;
  position: relative;
  margin-left: 4px;
  flex-shrink: 0;
}

.cm-send-btn {
  height: 34px;
  padding: 0 12px;
  border: none;
  border-radius: 5px 0 0 5px;
  background: #25D366;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
  transition: background .15s, filter .15s;
  white-space: nowrap;
}

.cm-send-dropdown-btn {
  height: 34px;
  width: 22px;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, .3);
  border-radius: 0 5px 5px 0;
  background: #25D366;
  color: #fff;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, filter .15s;
  padding: 0;
}

.cm-send-btn:hover,
.cm-send-dropdown-btn:hover {
  filter: brightness(1.12);
}

.cm-send-group.mode-audio .cm-send-btn,
.cm-send-group.mode-audio .cm-send-dropdown-btn {
  background: #2563EB;
}

.cm-send-btn:hover {
  background: var(--primary-dark);
}

.cm-send-btn:active {
  transform: scale(.92);
}

/* =====================================================================
   RIGHT INFO PANEL
   ===================================================================== */
.info-panel {
  /* ancho y ancho mínimo del panel completo (barra de secciones + contenido) */
  flex: 0 0 420px;
  width: 420px;
  min-width: 420px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
}

/* Barra de secciones + contenido, debajo de la tarjeta del contacto (que ocupa todo el ancho del panel) */
.ip-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
}

.ip-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

.ip-main::-webkit-scrollbar {
  width: 3px;
}

.ip-main::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 3px;
}

/* Barra de secciones del panel: hereda el aspecto de .cls-filter-bar; va a la izquierda del contenido */
.ip-filter-bar {
  border-right: 1px solid var(--border);
}

/* Íconos y etiquetas centrados en la barra: el indicador de la opción activa se dibuja con una sombra interior
   (en vez de un borde que quitaba 3px de ancho y descentraba el contenido) */
.ip-filter-bar .cls-filter-item {
  border-right: 0;
}

.ip-filter-bar .cls-filter-item.active {
  box-shadow: inset -3px 0 0 #25D366;
}

.ip-filter-bar .cls-filter-item i {
  left: 0;
}

/* Secciones que solo muestran su nombre */
.ip-view-msg {
  align-items: center;
  justify-content: center;
  min-height: 100%;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Contact card */
.ip-contact-card {
  flex: 0 0 auto;
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 2px;
  text-align: left;
}

.ip-avatar {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #0D9488;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  grid-column: 1;
  grid-row: 1 / 4;
  align-self: center;
}

.ip-name {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-main);
  grid-column: 2;
  grid-row: 1;
  line-height: 1.3;
}

.ip-phone {
  font-size: 11.5px;
  color: var(--text-secondary);
  grid-column: 2;
  grid-row: 2;
  line-height: 1.3;
}

.ip-edit-btn {
  padding: 0px !important;
  border: none;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.7rem !important;
  font-weight: 100 !important;
  cursor: pointer;
  transition: background .15s;
  grid-column: 2;
  grid-row: 3;
  align-self: start;
  justify-self: start;
}

.ip-edit-btn:hover {
  background: #A7F3D0;
}

/* Info section */
.ip-section {
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.ip-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px 7px;
  cursor: pointer;
  user-select: none;
}

.ip-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.ip-section-toggle {
  color: var(--text-light);
  font-size: 0.8rem;
  transition: transform .2s;
}

.ip-section.collapsed .ip-section-toggle {
  transform: rotate(-90deg);
}

.ip-section-body {
  padding: 4px 14px 12px;
}

.ip-section.collapsed .ip-section-body {
  display: none;
}

/* Info rows */
.ip-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0px 0px;
  font-size: 0.9rem;
  color: var(--text-main);
}

.ip-row-icon {
  width: 14px;
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: 1rem;
  text-align: center;
}

.ip-row-label {
  color: var(--text-secondary);
  min-width: 0;
  font-size: 0.9rem !important;
}

.ip-row-value {
  color: var(--text-main);
  font-weight: 200;
  flex: 1;
  text-align: right;
  font-size: 0.9rem !important;
}

.ip-row-value a {
  color: var(--info);
  text-decoration: none;
}

.ip-row-value a:hover {
  text-decoration: underline;
}

.ip-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 70%, transparent);
  margin-right: 4px;
}

.ip-divider {
  border: 0;
  border-top: 1px solid var(--border-color, #E5E7EB);
  margin: 8px 0;
}

.ip-row.ip-row-sm,
.ip-row-sm {
  font-size: 0.7rem;
  padding: 2px 0;
}

.ip-row.ip-row-sm .ip-row-icon,
.ip-row-sm .ip-row-icon {
  font-size: 0.7rem;
}

/* Contact grid */
.ip-contact-grid {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 6px 8px;
  font-size: 1rem;
}

.ip-contact-grid .grid-label {
  color: var(--text-secondary);
}

.ip-contact-grid .grid-value {
  color: var(--text-main);
  font-weight: 500;
  word-break: break-word;
}

/* Campaign row */
.ip-campaign-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 15px;
}

.ip-campaign-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}

.ip-campaign-info {
  flex: 1;
  min-width: 0;
}

.ip-campaign-name {
  font-weight: 600;
}

.ip-campaign-time {
  color: var(--text-secondary);
  font-size: 11px;
}

.ip-add-link {
  font-size: 1rem;
  color: var(--info);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  padding: 2px 0;
}

.ip-add-link:hover {
  text-decoration: underline;
}

/* =====================================================================
   MISCELLANEOUS
   ===================================================================== */

/* Empty state */
.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
  padding: 40px;
}

.chat-empty-state i {
  font-size: 48px;
  color: var(--text-light);
}

.chat-empty-state h3 {
  font-size: 16px;
  font-weight: 600;
}

.chat-empty-state p {
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
}

/* System message */
.msg-system {
  align-self: center;
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, .05);
  border-radius: 10px;
  padding: 3px 12px;
  margin: 4px 0;
}

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: var(--z-toast);
}

.toast {
  background: var(--text-main);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease-out;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success {
  background: var(--primary-dark);
}

.toast.error {
  background: var(--danger);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* Modal backdrop */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: var(--z-modal);
  align-items: center;
  justify-content: center;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
}

.modal-close {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--muted);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Buttons (generic) */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg-page);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #E5E7EB;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  opacity: .88;
}

/* Form controls */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-main);
  background: var(--bg-card);
  outline: none;
  transition: border-color .15s;
}

.form-control:focus {
  border-color: var(--primary);
}

.form-control::placeholder {
  color: var(--text-light);
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* Responsive: hide right panel on small screens */
@media (max-width: 1100px) {
  .info-panel {
    display: none;
  }
}

@media (max-width: 780px) {
  .chat-list-panel {
    display: none;
  }
}

@media (max-width: 500px) {
  .nav-sidebar {
    display: none;
  }
}

/* ── Column resizer handles ────────────────────────────────────────── */
.col-resizer {
  flex: 0 0 4px;
  width: 4px;
  cursor: col-resize;
  background: var(--border);
  position: relative;
  z-index: 20;
  transition: background 0.15s;
  user-select: none;
}

.col-resizer:hover,
.col-resizer.is-dragging {
  background: color-mix(in srgb, var(--primary) 70%, transparent);
}

.col-resizer::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -5px;
  right: -5px;
}

.col-resizer.hidden {
  display: none !important;
}

/* ── Flat (single-list) mode when a filter is active ── */
.cls-items.cls-flat-view {
  overflow-y: auto;
}

.cls-items.cls-flat-view #mineSection,
.cls-items.cls-flat-view #unassignedSection {
  overflow-y: visible;
  flex: none;
  height: auto !important;
  min-height: 0;
}

.cls-items.cls-flat-view #sectionResizer,
.cls-items.cls-flat-view #convListMineHeader,
.cls-items.cls-flat-view #convListUnassignedHeader,
.cls-items.cls-flat-view #mineEmptyState,
.cls-items.cls-flat-view #unassignedEmptyState {
  display: none !important;
}


/* Flat-view empty state: align to top, not vertically centered */
#flatEmptyState {
  justify-content: flex-start;
  padding-top: 16px;
}

#flatEmptyState span {
  font-weight: 100;
}

.cls-item-avatar-img,
.cm-header-avatar-img,
.ip-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* Mensajes automáticos como separador — el texto original aparece al pasar el mouse */
.msg-auto-divider {
  position: relative;
}

.msg-auto-divider .msg-date-text {
  cursor: help;
}

.msg-auto-tip {
  display: none;
  position: absolute;
  left: 50%;
  top: calc(100% + 2px);
  transform: translateX(-50%);
  width: max-content;
  max-width: min(360px, 90%);
  padding: 8px 12px;
  background: #1F2937;
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  z-index: 20;
  pointer-events: none;
}

.msg-auto-divider .msg-date-text:hover+.msg-auto-tip {
  display: block;
}

/* ═══ Menú de mensaje (responder / fijar / copiar) ═══ */
.msg-row {
  position: relative;
}

/* Botón flotante de 3 puntos: fuera de la burbuja (20px), absoluto, no mueve el mensaje.
   Saliente = esquina superior derecha; entrante = esquina superior izquierda. */
.msg-menu-btn {
  position: absolute;
  top: 2px;
  z-index: 2;
  width: 16px;
  height: 22px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 2px;
  background: var(--bg-card);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s;
}

.msg-row.out .msg-menu-btn {
  right: -16px;
  margin-top: 2px;
}

.msg-row.in .msg-menu-btn {
  left: -16px;
  margin-top: 2px;
}

.msg-row:hover .msg-menu-btn,
.msg-menu-btn:focus-visible,
.msg-menu-btn.open {
  opacity: 1;
}

.msg-menu-btn:hover {
  color: var(--text-main);
}

@media (hover: none) {
  .msg-menu-btn {
    opacity: .75;
  }
}

.msg-menu {
  position: fixed;
  z-index: 10000;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  padding: 4px;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}

.msg-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 5px;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
}

.msg-menu-item i {
  width: 14px;
  text-align: center;
  color: var(--text-secondary);
}

.msg-menu-item:hover:not(:disabled) {
  background: #F3F4F6;
}

.msg-menu-item:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.msg-menu-sep {
  height: 1px;
  margin: 4px 2px;
  background: var(--border);
}

/* Cita dentro del globo (mensaje que responde a otro) */
.msg-quote {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: -8px -12px 6px -12px;
  padding: 6px 12px;
  border-left: 3px solid #10B981;
  border-top-left-radius: var(--msg-radius);
  border-top-right-radius: var(--msg-radius);
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  background: rgba(0, 0, 0, .05);
  font-size: 12px;
}

.msg-quote-author {
  font-size: 11px;
  font-weight: 700;
  color: #059669;
}

.msg-quote-text {
  color: var(--text-secondary);
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* "Respondiendo a…" sobre el input */
.cm-reply-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: #F8FAFC;
  border-top: 1px solid var(--border);
  border-left: 3px solid #10B981;
}

.cm-reply-preview[hidden] {
  display: none;
}

.cm-reply-icon {
  color: #10B981;
}

.cm-reply-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.cm-reply-author {
  font-size: 12px;
  font-weight: 700;
  color: #059669;
}

.cm-reply-text {
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cm-reply-cancel {
  padding: 4px 7px;
  border: none;
  border-radius: 4px;
  background: none;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

.cm-reply-cancel:hover {
  background: rgba(0, 0, 0, .06);
  color: var(--text-main);
}

/* Mensajes fijados: pegados al header, 30px por mensaje, una sola línea */
.cm-pinned-bar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.cm-pinned-bar[hidden] {
  display: none;
}

.cm-pinned-item {
  height: 30px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-top: 1px solid var(--border);
  cursor: pointer;
}

.cm-pinned-item:first-child {
  border-top: 0;
}

.cm-pinned-item:hover {
  background: rgba(0, 0, 0, .04);
}

.cm-pinned-item:focus-visible {
  outline: 2px solid #10B981;
  outline-offset: -2px;
}

.cm-pinned-icon {
  flex-shrink: 0;
  font-size: 11px;
  color: #10B981;
}

.cm-pinned-text {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cm-pinned-unpin {
  flex-shrink: 0;
  padding: 2px 6px;
  border: none;
  border-radius: 4px;
  background: none;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: .7;
}

.cm-pinned-item:hover .cm-pinned-unpin,
.cm-pinned-unpin:focus-visible {
  opacity: 1;
}

.cm-pinned-unpin:hover {
  background: rgba(0, 0, 0, .08);
  color: var(--text-main);
}

/* Parpadeo de 1 s al saltar a un mensaje fijado */
@keyframes msgBlink {

  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 transparent;
  }

  15%,
  45%,
  75% {
    opacity: .25;
  }

  30%,
  60%,
  90% {
    opacity: 1;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, .7);
  }
}

.msg-bubble.msg-blink {
  animation: msgBlink 1s ease-in-out 1;
}

/* Ícono de desfijar = chincheta tachada (FA Free no trae thumbtack-slash) */
.cm-unpin-stack {
  width: 1.2em;
  height: 1.2em;
  line-height: 1.2em;
  font-size: 12px;
}

.cm-unpin-stack .fa-slash {
  font-size: 13px;
}

/* ═══ Reacciones ═══ */
/* Barra sobre el borde superior del globo, visible solo al pasar el mouse.
   Es descendiente de la fila y solapa 6px con ella, así el hover no se pierde al subir. */
.msg-react-bar {
  position: absolute;
  bottom: calc(100% - 6px);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 2px 4px;
  border-radius: 18px;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
  opacity: 0;
  visibility: hidden;
  transition: opacity .12s;
  white-space: nowrap;
}

.msg-row.in .msg-react-bar {
  left: 0;
}

.msg-row.out .msg-react-bar {
  right: 0;
}

.msg-row:hover .msg-react-bar,
.msg-row.react-open .msg-react-bar {
  opacity: 1;
  visibility: visible;
}

@media (hover: none) {
  .msg-row .msg-react-bar {
    opacity: .95;
    visibility: visible;
  }
}

.msg-react-emoji,
.msg-react-more {
  width: 26px;
  height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: none;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: transform .1s, background .1s;
}

.msg-react-more {
  font-size: 12px;
  color: var(--text-secondary);
}

.msg-react-emoji:hover {
  transform: scale(1.25);
}

.msg-react-more:hover {
  background: rgba(0, 0, 0, .07);
  color: var(--text-main);
}

.msg-react-emoji.active {
  background: rgba(16, 185, 129, .18);
}

.msg-react-pop {
  position: fixed;
  z-index: 1000;
  width: 296px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md, 0 6px 20px rgba(0, 0, 0, .15));
}

.msg-react-pop .msg-react-emoji {
  width: 100%;
  height: 32px;
  border-radius: 6px;
  font-size: 19px;
}

/* Chip con la reacción del agente, montado sobre la esquina inferior del globo. */
.msg-content {
  position: relative;
}

.msg-react-chip {
  position: absolute;
  bottom: -12px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  line-height: 20px;
  cursor: pointer;
  z-index: 1;
}

.msg-react-chip[hidden] {
  display: none;
}

.msg-row.out .msg-react-chip {
  right: 8px;
}

.msg-row.in .msg-react-chip {
  left: 8px;
}

.msg-row.has-react {
  margin-bottom: 14px;
}

/* Tooltip "Eliminar reacción" al pasar el mouse sobre la reacción del mensaje */
.msg-react-chip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 8px;
  border-radius: 5px;
  background: #1F2937;
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .12s;
}

.msg-react-chip:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Anclado al borde de la reacción (no centrado) para que no lo recorte el área de mensajes */
.msg-row.in .msg-react-chip::after {
  left: 0;
  right: auto;
  transform: none;
}

.msg-row.out .msg-react-chip::after {
  right: 0;
  left: auto;
  transform: none;
}

/* Reacción recibida del contacto: informativa, sin acción ni tooltip (solo se eliminan las enviadas) */
.msg-react-recv {
  position: absolute;
  bottom: -12px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  line-height: 20px;
  cursor: default;
  z-index: 1;
}

.msg-react-recv[hidden] {
  display: none;
}

.msg-row.out .msg-react-recv {
  left: 8px;
}

.msg-row.in .msg-react-recv {
  right: 8px;
}

/* Reacciones enviada y recibida: una junto a la otra, en la esquina inferior del globo */
.msg-react-stack {
  position: absolute;
  bottom: -12px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 4px;
}

.msg-row.out .msg-react-stack {
  right: 8px;
}

.msg-row.in .msg-react-stack {
  left: 8px;
}

.msg-row .msg-react-stack .msg-react-chip,
.msg-row .msg-react-stack .msg-react-recv {
  position: relative;
  bottom: auto;
  left: auto;
  right: auto;
}

/* Badge de la red social también sobre el avatar del encabezado y del panel de información */
.cm-header-avatar .ch-badge,
.ip-avatar .ch-badge {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #6B7280;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 400;
  line-height: 1;
  color: #fff;
}

.ip-avatar {
  position: relative;
}

.ip-avatar .ch-badge {
  width: 22px;
  height: 22px;
  font-size: 12px;
  bottom: -2px;
  right: -2px;
}

/* el punto de "en línea" pasa a la esquina superior para no chocar con el badge */
.cm-header-avatar .online-dot {
  bottom: auto;
  top: 1px;
}

.ch-badge[data-channel="whatsapp"] {
  background: #25D366;
}

.ch-badge[data-channel="messenger"] {
  background: #0084FF;
}

.ch-badge[data-channel="instagram"] {
  background: #E1306C;
}

.ch-badge[data-channel="telegram"] {
  background: #229ED9;
}

.ch-badge[data-channel="tiktok"] {
  background: #000;
}

.ch-badge[data-channel="helplive"] {
  background: #10B981;
}

/* ═══ Notas internas (panel sobre las pestañas de entrada, redimensionable) ═══ */
.cm-note-panel {
  position: relative;
  flex: 0 0 auto;
  height: 200px;
  display: flex;
  flex-direction: column;
  background: #FFFBEB;
  border-top: 1px solid #FCD34D;
  min-height: 0;
}

.cm-note-panel[hidden] {
  display: none;
}

.cm-note-resizer {
  position: absolute;
  top: -4px;
  left: 0;
  right: 0;
  height: 9px;
  cursor: ns-resize;
  z-index: 5;
  touch-action: none;
}

.cm-note-resizer::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 50%;
  width: 36px;
  height: 3px;
  margin-left: -18px;
  border-radius: 2px;
  background: #F59E0B;
  opacity: .55;
}

.cm-note-resizer:hover::after,
.cm-note-panel.resizing .cm-note-resizer::after {
  opacity: 1;
}

body.cm-note-resizing {
  cursor: ns-resize;
  user-select: none;
}

.cm-note-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: #92400E;
}

.cm-note-title {
  font-weight: 700;
}

.cm-note-hint {
  flex: 1;
  font-size: 11px;
  opacity: .75;
}

.cm-note-close {
  border: none;
  background: none;
  color: #92400E;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.cm-note-close:hover {
  background: rgba(0, 0, 0, .07);
}

.cm-note-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cm-note-empty {
  font-size: 12px;
  color: #92400E;
  opacity: .7;
  padding: 6px 0;
}

.cm-note-item {
  position: relative;
  padding: 6px 28px 6px 10px;
  background: #FEF3C7;
  border-left: 3px solid #F59E0B;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-main);
}

.cm-note-meta {
  font-size: 11px;
  color: #92400E;
  margin-bottom: 2px;
}

.cm-note-meta b {
  font-weight: 700;
}

.cm-note-text {
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: -4px;
  font-size: 0.8rem;
}

.cm-note-del {
  position: absolute;
  top: 4px;
  right: 4px;
  border: none;
  background: none;
  color: #92400E;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 4px;
  opacity: 0;
}

.cm-note-item:hover .cm-note-del {
  opacity: .8;
}

.cm-note-del:hover {
  background: rgba(0, 0, 0, .08);
  opacity: 1;
}

.cm-note-compose {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 6px 12px 10px;
  align-items: stretch;
}

.cm-note-compose textarea {
  flex: 1;
  resize: none;
  border: 1px solid #FCD34D;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  outline: none;
}

.cm-note-compose textarea:focus {
  border-color: #F59E0B;
}

.cm-note-save {
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  background: #F59E0B;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.cm-note-save:hover {
  background: #D97706;
}

.cm-note-save:disabled {
  opacity: .5;
  cursor: default;
}

/* Estado de entrega / lectura de los mensajes enviados */
.msg-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  color: #9CA3AF;
  line-height: 1;
}

.msg-status i+i {
  margin-left: -5px;
}

.msg-status.st-read {
  color: #3B82F6;
}

.msg-status.st-failed {
  color: #9CA3AF;
}

/* Estado de entrega en la misma línea que la hora (mismo alto y mismo desplazamiento) y 10px a la derecha */
.msg-status {
  margin-top: -10px;
  height: 15px;
  line-height: 15px;
  position: relative;
  left: 10px;
}

/* Hora y estado 2px más abajo; la hora se acerca 10px a los checks */
.msg-time {
  margin-top: -8px;
  position: relative;
  left: 10px;
}

.msg-status {
  margin-top: -8px;
}

/* el acercamiento a los checks solo aplica a mensajes enviados (los recibidos no tienen checks) */
.msg-time {
  position: static;
  left: auto;
}

.msg-row.out .msg-time {
  position: relative;
  left: 10px;
}

/* Hora y estado de los mensajes enviados: 4px más a la izquierda */
.msg-row.out .msg-time {
  left: 6px;
}

.msg-status {
  left: 6px;
}

/* ═══ Adjuntos (menú "+", ventanas y burbujas) ═══ */
.cm-dropdown-item.disabled {
  opacity: .4;
  cursor: not-allowed;
}

.cm-dropdown-item.disabled:hover {
  background: transparent;
}

.att-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.att-modal {
  width: 100%;
  max-width: 460px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-card, #fff);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
  overflow: hidden;
}

.att-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.att-head i {
  color: var(--primary);
}

.att-head span {
  flex: 1;
}

.att-x {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 6px;
  border-radius: 4px;
}

.att-x:hover {
  background: rgba(0, 0, 0, .07);
}

.att-body {
  padding: 14px 16px;
  overflow-y: auto;
}

.att-error {
  margin: 0 16px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #FEE2E2;
  color: #B91C1C;
  font-size: 12.5px;
}

.att-error[hidden],
.att-progress[hidden] {
  display: none;
}

.att-progress {
  margin: 8px 16px 0;
  height: 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, .08);
  overflow: hidden;
}

.att-progress-bar {
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width .15s;
}

.att-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}

.att-btn {
  border: 1px solid var(--border);
  background: var(--bg-card, #fff);
  color: var(--text-main);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.att-btn:hover {
  background: var(--bg-page);
}

.att-ok {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.att-ok:hover {
  background: var(--primary);
  filter: brightness(.95);
}

.att-ok:disabled {
  opacity: .7;
  cursor: default;
}

.att-geo {
  width: 100%;
  margin-bottom: 4px;
}

.att-label {
  display: block;
  margin: 10px 0 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.att-input,
.att-caption {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-card, #fff);
  color: var(--text-main);
  outline: none;
}

.att-input:focus,
.att-caption:focus {
  border-color: var(--primary);
}

.att-caption {
  margin-top: 10px;
  resize: none;
}

.att-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.att-maps-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--primary);
}

.att-maps-link[hidden] {
  display: none;
}

.att-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .05);
  border-radius: 8px;
  overflow: hidden;
}

.att-preview img,
.att-preview video {
  display: block;
  max-width: 100%;
  max-height: 300px;
}

.att-preview-file {
  justify-content: flex-start;
  gap: 12px;
  padding: 14px;
}

.att-preview-file>i {
  font-size: 30px;
  color: var(--primary);
}

.att-file-name {
  font-weight: 600;
  font-size: 13px;
  word-break: break-all;
}

.att-file-size {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.att-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.att-result {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  text-align: left;
  border: none;
  background: rgba(0, 0, 0, .04);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-main);
}

.att-result:hover {
  background: rgba(0, 0, 0, .09);
}

.att-result span,
.att-noresult {
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* Burbujas */
.msg-video {
  display: block;
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  background: #000;
}

.msg-file,
.msg-loc,
.msg-contact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .06);
  color: inherit;
  text-decoration: none;
  min-width: 200px;
}

.msg-file-icon,
.msg-loc-icon,
.msg-contact-icon {
  font-size: 22px;
  color: var(--primary);
  flex-shrink: 0;
}

.msg-loc-icon {
  color: #EF4444;
}

.msg-file-info,
.msg-loc-info,
.msg-contact-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.msg-file-name,
.msg-loc-title,
.msg-contact-name {
  font-weight: 600;
  font-size: 13px;
  word-break: break-word;
}

.msg-file-size,
.msg-loc-sub,
.msg-contact-line {
  font-size: 11.5px;
  color: var(--text-secondary);
  word-break: break-word;
}

.msg-contact-line i {
  width: 12px;
  margin-right: 2px;
}

.msg-file-dl {
  color: var(--text-secondary);
}

.msg-file:hover,
.msg-loc:hover {
  background: rgba(0, 0, 0, .1);
}

.msg-bubble .msg-loc,
.msg-bubble .msg-file {
  color: inherit;
  text-decoration: none;
}

.att-note {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: #FEF3C7;
  color: #92400E;
  font-size: 12px;
}

/* Toast de error anclado al top de .cm-input-tabs (posición y ancho los fija showToast) */
.toast.toast-anchored {
  position: fixed;
  z-index: var(--z-toast, 10000);
  padding: 4px 12px;
  font-size: 12.5px;
  border-radius: 6px;
  box-sizing: border-box;
  animation: toastAnchoredIn .2s ease-out;
}

@keyframes toastAnchoredIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* Video: miniatura del primer frame, clic para reproducir en la burbuja, botón de pantalla completa */
.msg-video-wrap {
  position: relative;
  display: block;
  min-width: 200px;
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  cursor: pointer;
  line-height: 0;
}

.msg-video-wrap .msg-video {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 0;
}

.msg-video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: 16px;
  padding-left: 3px;
  cursor: pointer;
  transition: background .15s, transform .15s;
}

.msg-video-wrap:hover .msg-video-play {
  background: rgba(0, 0, 0, .8);
  transform: scale(1.06);
}

.msg-video-wrap.playing .msg-video-play {
  display: none;
}

.msg-video-fs {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  z-index: 2;
}

.msg-video-wrap:hover .msg-video-fs,
.msg-video-fs:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .msg-video-fs {
    opacity: .85;
  }
}

.msg-video-wrap.msg-video-broken {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px;
  background: rgba(0, 0, 0, .06);
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.4;
  cursor: default;
}

/* Audio (notas de voz y archivos de audio) y adjuntos que ya no se pueden descargar */
.msg-audio {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
}

.msg-audio-icon {
  font-size: 18px;
  color: var(--primary);
  flex-shrink: 0;
}

.msg-audio-el {
  flex: 1;
  min-width: 0;
  height: 34px;
  max-width: 100%;
}

.msg-media-gone {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .06);
  color: var(--text-secondary);
  font-size: 12.5px;
}

/* Lista de formatos permitidos (programa + extensión) */
.att-fmt-intro {
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 10px;
}

.att-fmt-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 300px;
  overflow-y: auto;
}

.att-fmt-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .04);
  font-size: 12.5px;
}

.att-fmt-name {
  font-weight: 600;
}

.att-fmt-exts {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Tarjeta de contacto clicable + formulario para agregarlo a Contactos */
.msg-contact {
  cursor: pointer;
  transition: background .15s;
}

.msg-contact:hover {
  background: rgba(0, 0, 0, .1);
}

.msg-contact:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.msg-contact-cta {
  margin-top: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
}

.msg-contact-cta .cta-saved {
  display: none;
}

.msg-contact.saved .msg-contact-cta .cta-add {
  display: none;
}

.msg-contact.saved .msg-contact-cta .cta-saved {
  display: inline;
}

.msg-contact.saved .msg-contact-cta i {
  display: none;
}

.att-dup {
  margin-bottom: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  background: #FEF3C7;
  color: #92400E;
  font-size: 12px;
}

.att-dup[hidden] {
  display: none;
}

.cc-multi {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cc-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.cc-row .att-input {
  flex: 1;
}

.cc-del {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 4px;
}

.cc-del:hover {
  background: rgba(0, 0, 0, .08);
}

.att-add {
  margin-top: 6px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 0;
}

.att-add:hover {
  text-decoration: underline;
}

/* ═══ Grabadora de mensajes de voz (reemplaza el campo de texto en modo "Mensaje de audio") ═══ */
.cm-input-row.audio-mode .cm-textarea,
.cm-input-row.audio-mode .cm-emoji-btn {
  display: none;
}

.cm-recorder {
  flex: 1;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  color: var(--text-secondary);
  font-size: 12.5px;
}

.cm-recorder[hidden] {
  display: none;
}

.cm-rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9CA3AF;
  flex-shrink: 0;
}

.cm-rec-time {
  min-width: 34px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-main);
}

.cm-rec-level {
  flex: 0 0 90px;
  height: 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, .08);
  overflow: hidden;
  display: none;
}

.cm-rec-level i {
  display: block;
  height: 100%;
  width: 0;
  background: #EF4444;
  transition: width .08s linear;
}

.cm-rec-hint {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cm-recorder[data-state="recording"] .cm-rec-dot {
  background: #EF4444;
  animation: recPulse 1s infinite ease-in-out;
}

.cm-recorder[data-state="recording"] .cm-rec-level {
  display: block;
}

.cm-recorder[data-state="recording"] .cm-rec-hint {
  color: #B91C1C;
}

.cm-recorder[data-state="cancel"] .cm-rec-hint {
  color: #6B7280;
  text-decoration: line-through;
}

.cm-recorder[data-state="cancel"] .cm-rec-dot {
  background: #9CA3AF;
}

.cm-recorder[data-state="sending"] .cm-rec-dot {
  background: var(--primary);
  animation: recPulse .6s infinite ease-in-out;
}

.cm-recorder[data-state="idle"] .cm-rec-time,
.cm-recorder[data-state="starting"] .cm-rec-time {
  color: var(--text-secondary);
  font-weight: 400;
}

@keyframes recPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .3;
  }
}

.cm-send-group.mode-audio .cm-send-btn {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.cm-send-group.mode-audio .cm-send-btn:active {
  transform: scale(1.15);
  background: #DC2626;
}

/* Edición inline del panel Información: lápiz a la izquierda del valor, visible solo al pasar sobre la fila */
.ip-row-editable {
  position: relative;
}

.ip-edit-btn {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  align-self: center;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 4px;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s, background .12s, color .12s;
}

.ip-row-editable:hover .ip-edit-btn,
.ip-row-editable:focus-within .ip-edit-btn {
  opacity: 1;
  pointer-events: auto;
}

.ip-row-editable.editing .ip-edit-btn {
  display: none;
}

.ip-edit-btn:hover {
  background: rgba(0, 0, 0, .06);
  color: var(--text-main);
}

.ip-inline-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
  text-align: right;
  padding: 3px 6px;
  border: 1px solid var(--info, #3B82F6);
  border-radius: 4px;
  background: #fff;
  outline: none;
}

select.ip-inline-input {
  text-align: left;
}

/* Panel Información: 4px entre líneas; lápiz pegado a la izquierda del valor; editor al 60% del ancho */
.ip-section-info .ip-row {
  padding: 1px 0;
}

.ip-row-editable .ip-row-value {
  flex: 0 1 auto;
  min-width: 0;
  margin-left: 0;
  overflow-wrap: anywhere;
}

.ip-row-editable .ip-edit-btn {
  margin-left: auto;
}

.ip-row-editable.editing .ip-row-value {
  flex: 0 0 60%;
  margin-left: auto;
}

.ip-row-editable.editing .ip-inline-input {
  width: 100%;
  text-align: left;
}

.ip-row-editable:not(.editing) .ip-row-value {
  cursor: pointer;
}

/* Fila editable: fondo gris claro al pasar el mouse */
.ip-row-editable {
  border-radius: 4px;
  transition: background .12s;
}

.ip-row-editable:hover,
.ip-row-editable.editing {
  background: #F3F4F6;
}

/* Panel Información: 1px entre líneas; el nombre siempre en mayúscula */
.ip-section-info .ip-row {
  padding: 0;
  margin-bottom: 1px;
}

#ipInfoNombre,
#ipInfoNombre .ip-inline-input {
  text-transform: uppercase;
}

/* Metadatos del contacto (panel Información) */
.ip-meta-item {
  padding: 0px 0px;
  border-bottom: 1px solid #F0F1F3;
}

.ip-meta-item:last-of-type {
  border-bottom: none;
}

.ip-meta-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ip-meta-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.ip-meta-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  min-width: 0;
  overflow-wrap: anywhere;
}

.ip-meta-badge {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 10px;
  background: #F3F4F6;
  color: #4B5563;
  white-space: nowrap;
}

.ip-meta-badge-ia {
  background: #EDE9FE;
  color: #6D28D9;
}

.ip-meta-badge-sistema {
  background: #E0F2FE;
  color: #0369A1;
}

.ip-meta-badge-asesor {
  background: #ECFDF5;
  color: #047857;
}

.ip-meta-del {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity .12s;
}

.ip-meta-item:hover .ip-meta-del {
  opacity: 1;
}

.ip-meta-del:hover {
  background: rgba(0, 0, 0, .06);
  color: #B91C1C;
}

.ip-meta-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: -2px 0 0 16px;
}

.ip-meta-desc {
  font-size: 0.8rem;
  line-height: 1.45;
  color: #4B5563;
  margin: 4px 0 0 16px;
}

.ip-meta-picker {
  position: fixed;
  z-index: 1200;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  background: #fff;
  overflow-y: auto;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .16);
}

.ip-meta-add-btn {
  margin: 0 auto 0 8px;
  padding: 1px 9px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: .4px;
  line-height: 1.5;
  color: #fff;
  background: var(--primary, #10B981);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.ip-meta-add-btn:hover {
  filter: brightness(.92);
}

.ip-meta-empty {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 2px 0 6px;
}

.ip-meta-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.ip-meta-option:hover {
  background: #F3F4F6;
}

.ip-meta-option .ip-meta-dot {
  margin-top: 4px;
}

.ip-meta-option-txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ip-meta-option-txt strong {
  font-size: 0.92rem;
  color: var(--text-main);
}

.ip-meta-option-txt small {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.ip-meta-picker-empty {
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Modal de confirmación */
.att-modal-confirm {
  max-width: 420px;
}

.att-confirm-msg {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-main);
}

.att-btn.att-ok.att-danger {
  background: #DC2626;
  border-color: #DC2626;
  color: #fff;
}

.att-btn.att-ok.att-danger:hover {
  background: #B91C1C;
  border-color: #B91C1C;
}

/* Badge del tipo de contacto bajo el nombre del encabezado */
.cm-header-tipo {
  margin: 2px 0 1px;
}

.tipo-badge {
  display: inline-block;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: .3px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

/* Cantidad de notas junto a la pestaña «Nota» */
.cm-input-tab .tab-count {
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-sizing: border-box;
}

/* Botones de la tarjeta del contacto. (Antes usaban .ip-edit-btn, la clase del lápiz de edición inline, y quedaban ocultos.) */
.ip-card-actions {
  grid-column: 2;
  grid-row: 3;
  align-self: start;
  justify-self: start;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.ip-card-btn {
  padding: 3px 9px;
  border: none;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}

.ip-card-btn:hover {
  background: #A7F3D0;
}

.ip-card-btn i {
  font-size: 0.68rem;
  margin-right: 2px;
}

/* Vista «Notas» del panel de contacto */
.ip-notes-head {
  padding: 10px 14px 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .4px;
}

#ipNotesList {
  padding: 0 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ip-note-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.ip-note-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.ip-note-meta b {
  color: var(--text-main);
}

.ip-note-tag {
  margin-left: auto;
  font-size: 0.68rem;
  padding: 1px 7px;
  border-radius: 10px;
  background: #ECFDF5;
  color: #047857;
}

.ip-note-tag.chat {
  background: #EEF2FF;
  color: #4338CA;
}

.ip-note-text {
  margin-top: 4px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-main);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ip-notes-empty {
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding: 8px 0;
}

/* Botón «Fusionar contacto» con la mira a la derecha (misma pieza, funciones independientes) */
.ip-card-split {
  display: inline-flex;
  border-radius: 6px;
  overflow: hidden;
  background: var(--primary-light);
}

.ip-card-split .ip-card-btn {
  border-radius: 0;
}

.ip-card-aim {
  border-left: 1px solid rgba(0, 0, 0, .1) !important;
  cursor: crosshair !important;
  touch-action: none;
  padding: 3px 8px !important;
}

.ip-card-aim i {
  margin-right: 0 !important;
  font-size: 0.8rem !important;
}

/* Durante el arrastre */
body.merge-aiming,
body.merge-aiming * {
  cursor: crosshair !important;
  user-select: none !important;
}

.merge-line-layer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 3100;
}

/* Copia flotante de la conversación bajo el puntero: zoom-in por encima de todos los componentes (no la recorta ningún contenedor) */
.cls-item.merge-clone {
  position: fixed;
  margin: 0;
  z-index: 3000;
  pointer-events: none;
  background: #FEF9C3 !important;
  border-radius: 6px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .28);
  transform-origin: center;
  transition: transform .12s ease-out;
  box-sizing: border-box;
}

/* Modal de comparación al fusionar contactos */
.mg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 3200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.mg-modal {
  background: #fff;
  border-radius: 10px;
  width: 760px;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  overflow: hidden;
}

.mg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
}

.mg-x {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 1rem;
}

.mg-body {
  overflow-y: auto;
  padding: 4px 18px 8px;
}

.mg-grid {
  display: grid;
  grid-template-columns: 170px 1fr 1fr;
}

.mg-grid>div {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-main);
  overflow-wrap: anywhere;
  display: flex;
  align-items: center;
}

.mg-h {
  position: sticky;
  top: 0;
  background: #fff;
  font-size: 0.72rem !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-secondary) !important;
  z-index: 1;
}

.mg-label {
  color: var(--text-secondary) !important;
  font-weight: 600;
}

.mg-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  flex: 0 0 auto;
}

.mg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mg-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* Fusión de contactos: opciones por dato, scroll de 5px y aviso de error */
.mg-body {
  scrollbar-width: thin;
  scrollbar-color: #CBD5E1 transparent;
}

.mg-body::-webkit-scrollbar {
  width: 5px;
}

.mg-body::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 5px;
}

.mg-intro {
  margin: 10px 0 6px;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.mg-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  width: 100%;
  min-width: 0;
}

.mg-opt input {
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.mg-opt>span,
.mg-opt>.mg-avatar {
  min-width: 0;
  overflow-wrap: anywhere;
}

.mg-none {
  color: var(--text-secondary);
}

.mg-error {
  margin: 0 18px 8px;
  padding: 8px 12px;
  border-radius: 6px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #991B1B;
  font-size: 0.85rem;
}

.mg-foot {
  gap: 8px;
}

.mg-foot .att-ok {
  background: var(--primary);
  color: #fff;
}

/* Redes fusionadas (panel de contacto) */
.ip-fus-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #F0F1F3;
}

.ip-fus-item:last-child {
  border-bottom: none;
}

.ip-fus-info {
  flex: 1;
  min-width: 0;
}

.ip-fus-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-main);
}

.ip-fus-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.ip-fus-undo {
  flex: 0 0 auto;
  border: 1px solid #FECACA;
  background: #fff;
  color: #B91C1C;
  border-radius: 6px;
  padding: 2px 9px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.ip-fus-undo:hover {
  background: #FEF2F2;
}

.ip-fus-keep {
  display: block;
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--text-main);
  cursor: pointer;
}

/* Íconos de las redes del contacto, junto al teléfono de la tarjeta */
.ip-phone {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.ip-nets {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ip-net {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  border: none;
  background: none;
}

.ip-net.fused {
  cursor: pointer;
  border-radius: 4px;
}

.ip-net.fused:hover {
  background: rgba(0, 0, 0, .07);
}

/* Inicio de conversación en el historial unificado de un contacto con redes fusionadas */
.conv-start-divider .msg-date-text {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Divisores seguidos (fecha + inicio de conversación): 2px de separación vertical entre ellos.
   Hoy hay 4px de margen inferior + 4px de gap del hilo, así que el segundo sube 6px. */
.msg-date-divider+.msg-date-divider {
  margin-top: -6px;
}

/* Globo de aviso: el contacto quiere iniciar conversación por otra red (una línea, del tamaño del texto) */
.switch-bubble {
  position: fixed;
  z-index: 3000;
  width: max-content;
  max-width: none;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 8px;
  background: #1F2937;
  color: #fff;
  font-size: 0.8rem;
  line-height: 1.3;
  font-weight: 500;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  pointer-events: none;
}

.switch-bubble::before {
  /* punta del globo, hacia la conversación */
  content: '';
  position: absolute;
  left: -5px;
  top: 50%;
  width: 10px;
  height: 10px;
  background: #1F2937;
  transform: translateY(-50%) rotate(45deg);
  border-radius: 2px;
}

/* Buscador de contactos por red (Fusionar contacto) */
.mg-search-modal {
  width: 720px;
}

.mg-search-bar {
  display: flex;
  gap: 8px;
  margin: 6px 0 10px;
}

.mg-search-net {
  flex: 0 0 170px;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 0.9rem;
  background: #fff;
}

.mg-search-q {
  flex: 1;
  min-width: 0;
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 0.9rem;
  outline: none;
}

.mg-search-q:focus,
.mg-search-net:focus {
  border-color: var(--primary);
}

.mg-search-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.mg-search-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-secondary);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
}

.mg-search-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.mg-search-table tr.blocked td {
  opacity: .55;
}

.mg-search-who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.mg-search-who .mg-avatar {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.mg-search-act {
  text-align: right;
  white-space: nowrap;
}

.mg-search-pick {
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.mg-search-pick:disabled {
  background: #D1D5DB;
  cursor: not-allowed;
}

.mg-search-empty,
.mg-search-more {
  padding: 14px 8px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  text-align: center;
}

/* Buscador de «Fusionar contacto»: alto fijo del 80% de la pantalla; la tabla se desplaza y la paginación queda al fondo */
.mg-search-modal {
  height: 80vh;
  max-height: 80vh;
}

.mg-search-modal .mg-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mg-search-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.mg-search-scroll::-webkit-scrollbar {
  width: 5px;
}

.mg-search-scroll::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 5px;
}

.mg-search-pager {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 4px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.mg-pg-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mg-pg-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-main);
  cursor: pointer;
}

.mg-pg-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.mg-pg-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.mg-search-who>span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mg-search-member {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--text-secondary);
}