/* ===== APP LAYOUT ===== */
.app-layout {
  height: 100dvh;
}

.app-row {
  height: 100%;
  flex-wrap: nowrap;
}

/* ===== SIDEBAR ===== */
.sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #020617;
  color: #e5e7eb;
  border-right: 1px solid rgba(148, 163, 184, .18);
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, .18);
  flex-shrink: 0;
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-item-wrap {
  padding: .75rem;
  border-bottom: 1px solid rgba(148, 163, 184, .12);
}

.sidebar-item-link {
  display: block;
  color: #e5e7eb;
  text-decoration: none;
}

.sidebar-item-link:hover {
  color: #ffffff;
}

.sidebar-item-link--simple {
  padding: .75rem;
  border-bottom: 1px solid rgba(148, 163, 184, .12);
}

/* ===== EMPTY PANEL ===== */
.panel-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: #0b1220;
}

/* ===== CHAT ===== */
.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #0b1220;
}

.chat-header {
  padding: 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, .18);
  background: #020617;
  color: #e5e7eb;
  flex-shrink: 0;
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 1rem;
  background: linear-gradient(180deg, rgba(2, 6, 23, .55), rgba(15, 23, 42, .9));
}

.chat-quick-replies {
  padding: .5rem .75rem;
  background: rgba(2, 6, 23, .75);
  border-top: 1px solid rgba(148, 163, 184, .18);
  flex-shrink: 0;
}

.chat-footer {
  padding: .75rem;
  border-top: 1px solid rgba(148, 163, 184, .18);
  background: #020617;
  flex-shrink: 0;
}

.chat-form {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}


/* lados */
.chat-actions-left,
.chat-actions-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* botones redondos */
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #e5e7eb;

  display: grid;
  place-items: center;
  cursor: pointer;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, .08);
}

.msg-text {
  white-space: pre-wrap;
  /* respeta \n y espacios, y hace wrap */
  word-break: break-word;
  padding: 8px 0 0 0;
}

/* ===== INPUT ===== */
.chat-input {
  flex: 1;
  resize: none;
  max-height: 160px;
  background: rgba(15, 23, 42, .75);
  border: 1px solid rgba(148, 163, 184, .25);
  color: #e5e7eb;
}

.chat-input:focus {
  background: rgba(15, 23, 42, .95);
  border-color: rgba(37, 99, 235, .6);
  box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .18);
  color: #e5e7eb;
}

.chat-send {
  height: 38px;
}

/* ===== BUBBLES ===== */
.msg-bubble {
  max-width: 72%;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 14px;
  padding: 10px 12px;
  line-height: 1.25;
  word-break: break-word;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .18);
}

.msg-in {
  background: rgba(30, 41, 59, .8);
  color: #e5e7eb;
  border-top-left-radius: 8px;
}

.msg-out {
  background: rgba(37, 99, 235, .85);
  color: #fff;
  border-top-right-radius: 8px;
}

.msg-meta {
  margin-top: 6px;
  font-size: 11px;
  opacity: .85;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.status-ico {
  font-size: 12px;
}

.qr-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 100%;
  max-height: 240px;
  overflow: auto;
  background: var(--dsm-bubble-in);
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, .10);
  padding: 6px;
  z-index: 50;
}

.qr-item {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}

.qr-item.is-selected {
  background: var(--dsm-bubble-out)
}

.qr-shortcut {
  font-weight: 700;
}

.qr-preview {
  opacity: .75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qr-empty {
  padding: 12px;
  opacity: .7;
}

.composer-wrap {
  position: relative;
  flex: 1;
}

/* ambos deben tener el mismo box model */
.composer-preview,
.composer-input {
  font-family: inherit;
  font-size: inherit;
  line-height: 1.25;
  letter-spacing: normal;
  padding: .375rem .75rem;
}

/* PREVIEW (se ve) */
.composer-preview {
  min-height: 38px;
  max-height: 160px;
  overflow-y: auto;

  white-space: pre-wrap;
  word-break: break-word;

  background: rgba(15, 23, 42, .75);
  border: 1px solid rgba(148, 163, 184, .25);
  border-radius: .375rem;
  color: #e5e7eb;

  pointer-events: none;
}

/* TEXTAREA (solo caret/selección) */
.composer-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: none;

  background: transparent;
  border: 1px solid transparent;
  /* ok */
  outline: none;

  color: transparent;
  -webkit-text-fill-color: transparent;
  /* importante en Chrome */
  caret-color: #e5e7eb;
}

/* cuando focus, aplica el “focus” visual al preview */
.composer-wrap:focus-within .composer-preview {
  background: rgba(15, 23, 42, .95);
  border-color: rgba(37, 99, 235, .6);
  box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .18);
}

.wa-marker {
  opacity: .35;
  font-weight: 600;
}


.msg-media {
  display: grid;
  gap: 8px;
}

.msg-media-img {
  max-width: 260px;
  max-height: 300px;

  width: auto;
  height: auto;

  object-fit: cover; /* 🔥 más visual tipo WhatsApp */

  border-radius: 12px;
}

.msg-media-audio,
.msg-media-video {
  width: 280px;
  max-width: 100%;
}

.msg-placeholder {
  opacity: .75;
  font-style: italic;
}

.status-read {
  color: #34b7f1;
  /* azul tipo WhatsApp */
}



/* ===== PREVIEW DE ARCHIVO EN COMPOSER ===== */
.composer-preview {
  position: relative;
}

/* contenedor del preview de archivo + botón quitar */
.preview-box {
  position: relative;
  padding: 10px;
  border-radius: 12px;
  background: rgba(2, 6, 23, .55);
  border: 1px solid rgba(148, 163, 184, .25);
  margin-bottom: 8px;
  max-width: 320px;
  pointer-events: auto;
  /* 👈 para que el botón ✕ sea clickeable */
  z-index: 500000;
}

/* botón quitar */
.preview-remove {
  position: absolute;
  top: 6px;
  right: 8px;
  border: none;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  border-radius: 999px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

/* media */
.preview-image,
.preview-video {
  width: 100%;
  border-radius: 10px;
  display: block;
}

.preview-audio {
  width: 100%;
}

.preview-filename {
  font-size: 12px;
  opacity: .85;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-document {
  font-size: 13px;
  opacity: .95;
}

/* preview del texto (caption) */
.text-preview {
  pointer-events: none;
  /* mantiene tu comportamiento original */
}


.chat-date-separator {
  text-align: center;
  margin: 16px 0;
}

.chat-date-separator span {
  background: rgba(37, 99, 235, .15);
  color: #93c5fd;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 10px;
  display: inline-block;
  backdrop-filter: blur(4px);
}

.chat-date-floating {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.chat-date-floating span {
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
}

.chat-scroll-bottom {
  position: absolute;
  right: 57px;
  bottom: 204px;
  z-index: 30;

  width: 38px;
  height: 38px;
  border-radius: 50%;

  background: rgba(37, 99, 235, .9);
  color: #fff;
  border: none;

  display: grid;
  place-items: center;

  box-shadow: 0 6px 16px rgba(0, 0, 0, .3);
  cursor: pointer;

  transition: all .2s ease;
}

.chat-scroll-bottom:hover {
  transform: scale(1.1);
  background: #2563eb;
}

.chat-scroll-bottom i {
  font-size: 14px;
}


.sidebar-item-link.active {
  background-color: #2a3942;
  /* fondo oscuro tipo WhatsApp */
  border-left: 3px solid #00a884;
  /* verde WhatsApp */
}

.sidebar-item-link:hover {
  background-color: #202c33;
}

/* ===== SIDEBAR SECTIONS ===== */
.sidebar-section {
  flex-wrap: wrap;
  gap: 6px;
  padding: .75rem;
  border-bottom: 1px solid var(--dsm-border);
}

.sidebar-title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--dsm-muted);
  margin-bottom: .5rem;
  display: block;
}

/* ===== FILTER LINKS ===== */
.sidebar-filter {
  display: inline-flex;
  padding: .4rem .5rem;
  border-radius: 8px;
  color: var(--dsm-text);
  text-decoration: none;
  font-size: 14px;
}

.sidebar-filter:hover {
  background: rgba(148, 163, 184, .1);
}

/* ===== LABELS ===== */
.sidebar-label {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  padding: .4rem .5rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--dsm-text);
  font-size: 14px;
}

.sidebar-label:hover {
  background: rgba(148, 163, 184, .1);
}

/* puntico de color */
.label-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  flex-shrink: 0;
  background: var(--dsm-primary);
}

/* contador */
.label-count {
  font-size: 12px;
  color: var(--dsm-muted);
}



/* ===== CHAT LABELS (tipo WhatsApp tags) ===== */
.chat-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  font-size: 11px;
  font-weight: 500;

  padding: 3px 8px;
  border-radius: 999px;

  line-height: 1;

  background: rgba(148, 163, 184, .15);
  color: var(--dsm-text);

  border: 1px solid rgba(148, 163, 184, .25);

  backdrop-filter: blur(4px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
  transition: all .2s ease;
  white-space: nowrap;

}

/* pequeño efecto hover */
.chat-label:hover {
  transform: scale(1.05);
}

/* versión compacta (sidebar) */
.chat-label.small {
  font-size: 10px;
  padding: 2px 6px;
}

/* ===== CHAT LABELS CONTAINER (scroll horizontal) ===== */
/* mejora real del scroll horizontal */
.chat-labels-wrap {
  display: flex;
  gap: 6px;

  overflow-x: auto;
  overflow-y: hidden;

  padding-bottom: 4px;

  -webkit-overflow-scrolling: touch;
  /* 🔥 scroll suave en móvil */
  scroll-behavior: smooth;

  max-width: 100%;
  /* 🔥 evita que rompa layout */
}

/* evita que los hijos se deformen */
.chat-labels-wrap>* {
  flex: 0 0 auto;
}

/* ocultar scrollbar (opcional estilo limpio) */
.chat-labels-wrap::-webkit-scrollbar {
  height: 4px;
}

.chat-labels-wrap::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, .3);
  border-radius: 10px;
}

.chat-labels-wrap {
  cursor: grab;
}

.chat-labels-wrap:active {
  cursor: grabbing;
}

turbo-frame#chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  /* 🔥 CLAVE */
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  /* 🔥 CLAVE */
}

section.col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.media-modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, .85);
  backdrop-filter: blur(12px);
  /* 🔥 PRO */
  z-index: 9999;

  display: flex;
  flex-direction: column;
}

.media-modal-header {
  padding: 12px;
  display: flex;
  justify-content: flex-end;
}

.media-modal-header .btn-icon {
  background: rgba(255, 255, 255, .08);
  backdrop-filter: blur(6px);
}

.media-modal-header .btn-icon:hover {
  background: rgba(255, 255, 255, .15);
}

.media-modal-body {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.media-preview-big img,
.media-preview-big video {
  max-width: 65vw;
  /* 🔥 más grande */
  max-height: 75vh;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
  transition: transform .2s ease;
}

.media-preview-big img:hover,
.media-preview-big video:hover {
  transform: scale(1.02);
}

.media-modal-footer {
  padding: 12px;
  background: rgba(2, 6, 23, .7);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(148, 163, 184, .15);

  display: flex;
  flex-direction: column;
  gap: 10px;
}

.media-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 10px;
}

.media-thumb {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  opacity: .5;
  transition: all .2s ease;
  border: 2px solid transparent;
}

.media-thumb:hover {
  opacity: .9;
  transform: scale(1.05);
}

.media-thumb.active {
  border: 2px solid #2563eb;
  opacity: 1;
  transform: scale(1.08);
}

.media-thumb img,
.media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-thumb.active {
  border: 2px solid #2563eb;
  opacity: 1;
}

.media-thumb img,
.media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-body.dragging {
  border: 2px dashed #00a884;
  background: rgba(0, 168, 132, 0.05);
}

.media-input-wrap .send-btn {
  flex-shrink: 0;

  width: 44px;
  height: 44px;
  border-radius: 50%;

  background: #2563eb;
  color: #fff;

  display: grid;
  place-items: center;

  border: none;
  cursor: pointer;

  transition: all .2s ease;
}

.media-input {
  overflow-y: auto;
}

.media-input-wrap .send-btn:hover {
  transform: scale(1.1);
  background: #1d4ed8;
}

/* ===== MEDIA MODAL INPUT (NUEVO) ===== */
.media-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.media-input {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 120px;

  padding: 10px 14px;
  border-radius: 12px;

  background: rgba(15, 23, 42, .9);
  border: 1px solid rgba(148, 163, 184, .25);

  color: #e5e7eb;
  font-size: 14px;
  line-height: 1.4;

  outline: none;
}

.media-input:focus {
  border-color: rgba(37, 99, 235, .6);
  box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .18);
}

/* ===== REPLY PREVIEW (composer) ===== */
.reply-preview {
  background: rgba(37, 99, 235, .15);
  border-left: 3px solid #25D366;

  padding: 6px 10px;
  margin-bottom: 6px;
  border-radius: 8px;

  display: flex;
  justify-content: space-between;
  align-items: center;

  font-size: 13px;
  color: #e5e7eb;

  backdrop-filter: blur(4px);
}

.reply-preview button {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.reply-preview button:hover {
  background: rgba(255, 255, 255, .15);
}

.reply-box {
  border-left: 3px solid #25D366;
  background: rgba(255,255,255,.05);
  padding: 6px 8px;
  margin-bottom: 6px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.reply-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.reply-content {
  display: flex;
  align-items: center;
  gap: 6px;
}

.reply-thumb {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 4px;
}

.reply-thumb.file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: rgba(255,255,255,.1);
  border-radius: 4px;
  width: 22px;
  height: 22px;
}

.reply-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.media-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
}

.media-viewer-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-viewer-img {
  max-width: 90%;
  max-height: 90%;
  transition: transform 0.2s ease;
  cursor: zoom-in;
}

.media-close {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 24px;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
}

.media-viewer-img {
  cursor: grab;
  user-select: none;
}

.msg-actions {
  position: relative; /* 🔥 CLAVE */
  margin-left: 6px;
  display: flex;
  align-items: center;
}

.msg-actions i {
  cursor: pointer;
  opacity: .6;
}

.msg-actions i:hover {
  opacity: 1;
}

.reaction-picker {
  position: absolute;

  right: 28;

  background: #111827;
  padding: 6px;
  border-radius: 12px;
  display: flex;
  gap: 6px;
  box-shadow: 0 10px 20px rgba(0,0,0,.4);
}

.reaction-picker span {
  cursor: pointer;
  font-size: 18px;
}

.msg-actions {
  margin: 0 6px;
  opacity: 0;
  transition: opacity .15s ease;
}

/* mostrar en hover */
[id^="message_"]:hover .msg-actions {
  opacity: 1;
}

/* 👉 POSICIÓN */
.msg-actions.left {
  order: 2; /* después del mensaje */
}

.msg-actions.right {
  order: -1; /* antes del mensaje */
}

.msg-reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.msg-reaction {
  background: rgba(255,255,255,.1);
  border-radius: 12px;
  padding: 2px 6px;
  font-size: 12px;
}
.conv-preview {
  flex: 1;
  min-width: 0;
}

.conv-time {
  font-size: 12px;
  white-space: nowrap;
}

.conv-unread-badge {
  flex-shrink: 0;
}

.conv-unread-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 999px;

  background-color: #21c063;
  color: #000;

  font-size: 12px;
  font-weight: 700;
  line-height: 1;

  flex-shrink: 0;
}

.conv-preview-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.conv-status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
}

.conv-preview {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-status .status-read {
  color: #53bdeb;
}

.conversation-context-menu {
  position: fixed;
  z-index: 9999;
  width: 220px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 12px 35px rgba(0,0,0,.16);
  padding: 6px;
}

.context-item {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  text-align: left;
  border-radius: 8px;
  font-size: 14px;
}

.context-item:hover {
  background: #f3f4f6;
}

.context-submenu {
  position: relative;
}

.context-submenu-panel {
  display: none;
  position: absolute;
  top: 0;
  left: 100%;
  width: 220px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 12px 35px rgba(0,0,0,.16);
  padding: 6px;
  z-index: 10000;
}

.context-submenu:hover .context-submenu-panel {
  display: block;
}

.context-label-option {
  display: flex;
  align-items: center;
  gap: 8px;
}

.context-label-check {
  width: 16px;
  flex-shrink: 0;
  color: #16a34a;
}

.context-label-option.active .context-label-check::before {
  content: "✓";
  font-weight: bold;
}
