/* =========================================================
   WIRTZ HUB · MENSAJERÍA
   CSS COMPLETO

   Diseño:
   - Premium
   - Minimalista
   - Blanco en modo claro
   - Negro real en modo oscuro
   - Sin violeta
   - Sin azul oscuro
   - Sin glow
   - Iconos compactos
   - Panel de iconos moderno
   - Conversaciones tipo aplicación profesional
   ========================================================= */

/* =========================================================
   RESET LOCAL
   ========================================================= */

.mensajes-page,
.mensajes-page *,
.mensajes-modal,
.mensajes-modal *,
.mensajes-action,
.mensajes-icon-btn,
.mensajes-filter,
.mensajes-send,
.mensajes-composer__tool {
  box-sizing: border-box;
}

.mensajes-page button,
.mensajes-modal button,
.mensajes-page input,
.mensajes-modal input,
.mensajes-page select,
.mensajes-modal select,
.mensajes-page textarea,
.mensajes-modal textarea {
  font: inherit;
}

.mensajes-page button,
.mensajes-modal button,
.mensajes-page label {
  -webkit-tap-highlight-color: transparent;
}

.mensajes-page img,
.mensajes-modal img {
  display: block;
  max-width: 100%;
}

/* =========================================================
   VARIABLES · MODO CLARO
   ========================================================= */

.mensajes-page {
  --msg-page: #f7f7f7;

  --msg-surface: #ffffff;
  --msg-surface-soft: #fafafa;
  --msg-surface-muted: #f3f3f3;
  --msg-surface-strong: #ececec;
  --msg-surface-hover: #f5f5f5;

  --msg-text: #171717;
  --msg-text-strong: #0d0d0d;
  --msg-text-soft: #565656;
  --msg-muted: #858585;
  --msg-muted-soft: #a6a6a6;

  --msg-border: rgba(0, 0, 0, 0.08);
  --msg-border-strong: rgba(0, 0, 0, 0.15);

  --msg-primary: #111111;
  --msg-primary-hover: #252525;
  --msg-primary-text: #ffffff;

  --msg-success: #177245;
  --msg-success-soft: rgba(23, 114, 69, 0.09);
  --msg-success-line: rgba(23, 114, 69, 0.2);

  --msg-warning: #946500;
  --msg-warning-soft: rgba(148, 101, 0, 0.09);
  --msg-warning-line: rgba(148, 101, 0, 0.2);

  --msg-danger: #b42318;
  --msg-danger-soft: rgba(180, 35, 24, 0.08);
  --msg-danger-line: rgba(180, 35, 24, 0.2);

  --msg-radius-xs: 6px;
  --msg-radius-sm: 8px;
  --msg-radius-md: 11px;
  --msg-radius-lg: 14px;

  --msg-shadow:
    0 12px 32px rgba(0, 0, 0, 0.06);

  --msg-shadow-modal:
    0 28px 80px rgba(0, 0, 0, 0.24);

  --msg-transition:
    150ms ease;

  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;

  width: 100%;
  min-width: 0;
  height: calc(
    100vh -
    var(--topbar-height, 54px) -
    54px
  );
  min-height: 0;

  color: var(--msg-text);
  background: var(--msg-page);

  overflow: hidden;
}

/* =========================================================
   VARIABLES · MODO OSCURO NEGRO REAL
   ========================================================= */

html[data-theme="dark"] .mensajes-page,
body.dark .mensajes-page,
.dark .mensajes-page {
  --msg-page: #000000;

  --msg-surface: #070707;
  --msg-surface-soft: #0c0c0c;
  --msg-surface-muted: #121212;
  --msg-surface-strong: #181818;
  --msg-surface-hover: #101010;

  --msg-text: #f4f4f4;
  --msg-text-strong: #ffffff;
  --msg-text-soft: #bdbdbd;
  --msg-muted: #7f7f7f;
  --msg-muted-soft: #5f5f5f;

  --msg-border: rgba(255, 255, 255, 0.08);
  --msg-border-strong: rgba(255, 255, 255, 0.15);

  --msg-primary: #f5f5f5;
  --msg-primary-hover: #ffffff;
  --msg-primary-text: #000000;

  --msg-success: #72d6a5;
  --msg-success-soft: rgba(114, 214, 165, 0.09);
  --msg-success-line: rgba(114, 214, 165, 0.2);

  --msg-warning: #e5c36a;
  --msg-warning-soft: rgba(229, 195, 106, 0.09);
  --msg-warning-line: rgba(229, 195, 106, 0.2);

  --msg-danger: #ff8a80;
  --msg-danger-soft: rgba(255, 138, 128, 0.08);
  --msg-danger-line: rgba(255, 138, 128, 0.2);

  --msg-shadow:
    0 18px 42px rgba(0, 0, 0, 0.72);

  --msg-shadow-modal:
    0 32px 90px rgba(0, 0, 0, 0.85);

  background: #000000;
}

/* =========================================================
   ICONOS GLOBALES
   ========================================================= */

.mensajes-page .icon,
.mensajes-modal .icon {
  width: 15px;
  height: 15px;

  flex: 0 0 auto;

  stroke-width: 1.8;
}

/* =========================================================
   CONTENEDORES PRINCIPALES
   ========================================================= */

.mensajes-hero,
.mensajes-layout,
.mensajes-card {
  width: 100%;
  min-width: 0;

  color: var(--msg-text);
  background: var(--msg-surface);
  border: 1px solid var(--msg-border);
  border-radius: var(--msg-radius-lg);

  overflow: hidden;
}

/* =========================================================
   CABECERA SUPERIOR
   ========================================================= */

.mensajes-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;

  min-height: 68px;
  padding: 12px 14px;
}

.mensajes-hero__top {
  display: contents;
}

.mensajes-hero__main {
  display: flex;
  align-items: center;
  gap: 11px;

  min-width: 0;
}

.mensajes-hero__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 38px;
  height: 38px;
  flex: 0 0 38px;

  color: var(--msg-text);
  background: var(--msg-surface-soft);
  border: 1px solid var(--msg-border);
  border-radius: 10px;
}

.mensajes-hero__icon .icon {
  width: 18px;
  height: 18px;
}

.mensajes-hero__copy {
  min-width: 0;
}

.mensajes-hero__copy > span,
.mensajes-card__head span,
.mensajes-thread__identity > div > span,
.mensajes-modal__head > div > span,
.mensajes-field > span {
  display: block;

  color: var(--msg-muted);

  font-size: 9px;
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mensajes-hero__copy h1 {
  margin: 3px 0 0;

  overflow: hidden;

  color: var(--msg-text-strong);

  font-size: 20px;
  font-weight: 760;
  line-height: 1.1;
  letter-spacing: -0.025em;

  text-overflow: ellipsis;
  white-space: nowrap;
}

.mensajes-hero__copy p {
  margin: 4px 0 0;

  overflow: hidden;

  color: var(--msg-text-soft);

  font-size: 11.5px;
  line-height: 1.35;

  text-overflow: ellipsis;
  white-space: nowrap;
}

.mensajes-hero__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;

  flex-wrap: wrap;
}

/* =========================================================
   OCULTAR ESTADÍSTICAS DEL HERO
   Layout más limpio
   ========================================================= */

.mensajes-hero__stats,
.mensajes-hero-stat,
.mensajes-kpis,
.mensajes-kpi {
  display: none !important;
}

/* =========================================================
   BOTONES
   ========================================================= */

.mensajes-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  min-height: 36px;
  padding: 0 12px;

  color: var(--msg-text);
  background: var(--msg-surface);
  border: 1px solid var(--msg-border-strong);
  border-radius: 8px;

  font-size: 11.5px;
  font-weight: 680;
  line-height: 1;
  white-space: nowrap;

  cursor: pointer;

  transition:
    color var(--msg-transition),
    background-color var(--msg-transition),
    border-color var(--msg-transition),
    transform var(--msg-transition);
}

.mensajes-action:hover {
  background: var(--msg-surface-muted);
}

.mensajes-action:active {
  transform: translateY(1px);
}

.mensajes-action--primary {
  color: var(--msg-primary-text);
  background: var(--msg-primary);
  border-color: var(--msg-primary);
}

.mensajes-action--primary:hover {
  color: var(--msg-primary-text);
  background: var(--msg-primary-hover);
  border-color: var(--msg-primary-hover);
}

.mensajes-action .icon {
  width: 14px;
  height: 14px;
}

.mensajes-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  padding: 0;

  color: var(--msg-text-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;

  cursor: pointer;

  transition:
    color var(--msg-transition),
    background-color var(--msg-transition),
    border-color var(--msg-transition);
}

.mensajes-icon-btn:hover,
.mensajes-icon-btn.is-active {
  color: var(--msg-text);
  background: var(--msg-surface-strong);
  border-color: var(--msg-border);
}

.mensajes-icon-btn--danger:hover {
  color: var(--msg-danger);
  background: var(--msg-danger-soft);
  border-color: var(--msg-danger-line);
}

/* =========================================================
   LAYOUT PRINCIPAL
   ========================================================= */

.mensajes-layout {
  display: grid;
  grid-template-columns:
    minmax(280px, 340px)
    minmax(0, 1fr);

  min-width: 0;
  min-height: 0;
}

.mensajes-sidebar-panel {
  display: grid;
  grid-template-rows:
    auto
    auto
    minmax(0, 1fr);

  min-width: 0;
  min-height: 0;

  background: var(--msg-surface);
  border-right: 1px solid var(--msg-border);
}

.mensajes-thread {
  display: grid;
  grid-template-rows:
    auto
    minmax(0, 1fr)
    auto;

  min-width: 0;
  min-height: 0;

  background: var(--msg-surface);
}

/* =========================================================
   BÚSQUEDA E INBOX
   ========================================================= */

.mensajes-toolbar {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    auto;
  gap: 7px;

  padding: 10px;

  background: var(--msg-surface);
  border-bottom: 1px solid var(--msg-border);
}

.mensajes-search {
  display: flex;
  align-items: center;
  gap: 8px;

  height: 36px;
  min-width: 0;
  padding: 0 10px;

  color: var(--msg-muted);
  background: var(--msg-surface-soft);
  border: 1px solid var(--msg-border);
  border-radius: 8px;
}

.mensajes-search:focus-within {
  background: var(--msg-surface);
  border-color: var(--msg-border-strong);
}

.mensajes-search .icon {
  width: 14px;
  height: 14px;
}

.mensajes-search input {
  width: 100%;
  min-width: 0;

  color: var(--msg-text);
  background: transparent;
  border: 0;
  outline: 0;

  font-size: 11.5px;
}

.mensajes-search input::placeholder {
  color: var(--msg-muted);
}

.mensajes-filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  height: 36px;
  padding: 0 10px;

  color: var(--msg-text-soft);
  background: var(--msg-surface);
  border: 1px solid var(--msg-border);
  border-radius: 8px;

  font-size: 10.5px;
  font-weight: 680;

  cursor: pointer;
}

.mensajes-filter:hover,
.mensajes-filter.is-active {
  color: var(--msg-text);
  background: var(--msg-surface-strong);
  border-color: var(--msg-border-strong);
}

.mensajes-alert {
  display: flex;
  align-items: center;
  gap: 7px;

  margin: 8px 10px 0;
  padding: 9px 10px;

  color: var(--msg-danger);
  background: var(--msg-danger-soft);
  border: 1px solid var(--msg-danger-line);
  border-radius: 8px;

  font-size: 10.5px;
  line-height: 1.4;
}

.mensajes-inbox {
  min-height: 0;
  padding: 6px;

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

.mensajes-inbox__item {
  display: grid;
  grid-template-columns:
    38px
    minmax(0, 1fr);
  gap: 9px;

  width: 100%;
  min-height: 62px;
  padding: 8px;

  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;

  text-align: left;

  cursor: pointer;

  transition:
    background-color var(--msg-transition),
    border-color var(--msg-transition);
}

.mensajes-inbox__item:hover {
  background: var(--msg-surface-hover);
}

.mensajes-inbox__item.is-active {
  background: var(--msg-surface-strong);
  border-color: var(--msg-border);
}

.mensajes-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 38px;
  height: 38px;
  flex: 0 0 38px;

  color: var(--msg-text);
  background: var(--msg-surface-muted);
  border: 1px solid var(--msg-border);
  border-radius: 50%;

  font-size: 10px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.mensajes-avatar--large {
  width: 40px;
  height: 40px;
  flex-basis: 40px;

  font-size: 10.5px;
}

.mensajes-avatar .icon {
  width: 16px;
  height: 16px;
}

.mensajes-inbox__content {
  display: grid;
  align-content: center;
  gap: 6px;

  min-width: 0;
}

.mensajes-inbox__top,
.mensajes-inbox__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;

  min-width: 0;
}

.mensajes-inbox__top strong {
  min-width: 0;

  overflow: hidden;

  color: var(--msg-text-strong);

  font-size: 11.5px;
  font-weight: 720;
  line-height: 1.2;

  text-overflow: ellipsis;
  white-space: nowrap;
}

.mensajes-inbox__top small {
  flex: 0 0 auto;

  color: var(--msg-muted);

  font-size: 9px;
  line-height: 1;
}

.mensajes-inbox__bottom > span:first-child {
  min-width: 0;

  overflow: hidden;

  color: var(--msg-text-soft);

  font-size: 10px;
  line-height: 1.3;

  text-overflow: ellipsis;
  white-space: nowrap;
}

.mensajes-inbox__flags {
  display: inline-flex;
  align-items: center;
  gap: 4px;

  flex: 0 0 auto;
}

.mensajes-inbox__flags .icon {
  width: 11px;
  height: 11px;

  color: var(--msg-muted);
}

.mensajes-inbox__flags em {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 18px;
  height: 18px;
  padding: 0 5px;

  color: var(--msg-primary-text);
  background: var(--msg-primary);
  border-radius: 999px;

  font-size: 8px;
  font-style: normal;
  font-weight: 750;
}

.mensajes-list-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;

  min-height: 190px;
  padding: 22px;

  color: var(--msg-muted);

  font-size: 11px;
  text-align: center;
}

.mensajes-list-state .icon {
  width: 22px;
  height: 22px;
}

/* =========================================================
   CABECERA DE CONVERSACIÓN
   ========================================================= */

.mensajes-thread__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;

  min-height: 64px;
  padding: 10px 14px;

  background: var(--msg-surface);
  border-bottom: 1px solid var(--msg-border);
}

.mensajes-thread__identity {
  display: flex;
  align-items: center;
  gap: 10px;

  min-width: 0;
}

.mensajes-thread__identity > div {
  min-width: 0;
}

.mensajes-thread__identity > div > span {
  font-size: 8px;
}

.mensajes-thread__identity h2 {
  margin: 3px 0 0;

  overflow: hidden;

  color: var(--msg-text-strong);

  font-size: 14px;
  font-weight: 730;
  line-height: 1.2;
  letter-spacing: -0.015em;

  text-overflow: ellipsis;
  white-space: nowrap;
}

.mensajes-thread__identity p {
  margin: 3px 0 0;

  overflow: hidden;

  color: var(--msg-text-soft);

  font-size: 10px;
  line-height: 1.3;

  text-overflow: ellipsis;
  white-space: nowrap;
}

.mensajes-thread__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;

  flex: 0 0 auto;
}

/* =========================================================
   CUERPO DE CONVERSACIÓN
   ========================================================= */

.mensajes-thread__body {
  display: flex;
  flex-direction: column;
  gap: 7px;

  min-height: 0;
  padding: 16px;

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

  background: var(--msg-surface-soft);
}

html[data-theme="dark"] .mensajes-thread__body,
body.dark .mensajes-thread__body,
.dark .mensajes-thread__body {
  background: #030303;
}

.mensajes-date-separator {
  display: flex;
  justify-content: center;

  margin: 5px 0;
}

.mensajes-date-separator span {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: 22px;
  padding: 0 9px;

  color: var(--msg-muted);
  background: var(--msg-surface);
  border: 1px solid var(--msg-border);
  border-radius: 999px;

  font-size: 8.5px;
  font-weight: 680;
  text-transform: uppercase;
}

.mensajes-thread__placeholder,
.mensajes-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;

  min-height: 100%;
  padding: 28px;

  color: var(--msg-muted);

  text-align: center;
}

.mensajes-thread__placeholder > .icon,
.mensajes-empty__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 44px;
  height: 44px;
  margin-bottom: 11px;

  color: var(--msg-muted);
  background: var(--msg-surface);
  border: 1px solid var(--msg-border);
  border-radius: 12px;
}

.mensajes-thread__placeholder > .icon {
  padding: 12px;
}

.mensajes-empty__icon .icon {
  width: 19px;
  height: 19px;
}

.mensajes-thread__placeholder h3,
.mensajes-empty h3 {
  margin: 0;

  color: var(--msg-text-strong);

  font-size: 15px;
  font-weight: 720;
}

.mensajes-thread__placeholder p,
.mensajes-empty p {
  max-width: 380px;
  margin: 6px 0 0;

  color: var(--msg-text-soft);

  font-size: 11px;
  line-height: 1.5;
}

/* =========================================================
   BURBUJAS
   ========================================================= */

.mensajes-bubble {
  width: fit-content;
  max-width: min(620px, 76%);
  padding: 9px 11px;

  color: var(--msg-text);
  background: var(--msg-surface);
  border: 1px solid var(--msg-border);
  border-radius:
    5px
    13px
    13px
    13px;
}

.mensajes-bubble.is-own {
  align-self: flex-end;

  color: var(--msg-primary-text);
  background: var(--msg-primary);
  border-color: var(--msg-primary);
  border-radius:
    13px
    5px
    13px
    13px;
}

.mensajes-bubble.is-other {
  align-self: flex-start;
}

.mensajes-bubble.is-deleted {
  opacity: 0.55;
}

.mensajes-bubble__meta {
  display: flex;
  align-items: center;
  gap: 6px;

  margin-bottom: 5px;
}

.mensajes-bubble__meta strong {
  font-size: 9px;
  font-weight: 720;
}

.mensajes-bubble__meta span,
.mensajes-bubble__meta em {
  opacity: 0.65;

  font-size: 8.5px;
  font-style: normal;
}

.mensajes-bubble p {
  margin: 0;

  font-size: 11.5px;
  line-height: 1.45;

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

.mensajes-bubble__actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;

  margin-top: 7px;
}

.mensajes-bubble__actions button {
  padding: 0;

  color: currentColor;
  background: transparent;
  border: 0;

  opacity: 0.65;

  font-size: 8.5px;
  font-weight: 680;

  cursor: pointer;
}

.mensajes-bubble__actions button:hover {
  opacity: 1;
  text-decoration: underline;
}

/* =========================================================
   MENSAJE CON ICONO LUCIDE
   ========================================================= */

.mensajes-lucide-message {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mensajes-lucide-message > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 27px;
  height: 27px;
  flex: 0 0 27px;

  color: currentColor;
  background: rgba(127, 127, 127, 0.1);
  border: 1px solid rgba(127, 127, 127, 0.16);
  border-radius: 7px;
}

.mensajes-lucide-message > span .icon {
  width: 13px;
  height: 13px;
}

.mensajes-lucide-message p {
  font-size: 11px;
  font-weight: 680;
}

/* =========================================================
   ADJUNTOS
   ========================================================= */

.mensajes-attachments {
  display: grid;
  gap: 7px;

  margin-top: 8px;
}

.mensajes-attachments__title {
  display: flex;
  align-items: center;
  gap: 5px;

  color: currentColor;

  opacity: 0.75;

  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
}

.mensajes-attachments__title .icon {
  width: 11px;
  height: 11px;
}

.mensajes-attachments__title em {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 17px;
  height: 17px;
  padding: 0 4px;

  color: currentColor;
  background: rgba(127, 127, 127, 0.12);
  border-radius: 999px;

  font-size: 8px;
  font-style: normal;
}

.mensajes-attachments__list {
  display: grid;
  gap: 5px;
}

.mensajes-attachment {
  display: grid;
  grid-template-columns:
    30px
    minmax(0, 1fr)
    auto;
  align-items: center;
  gap: 8px;

  width: 100%;
  min-width: 220px;
  max-width: 440px;
  padding: 6px;

  color: currentColor;
  background: rgba(127, 127, 127, 0.08);
  border: 1px solid rgba(127, 127, 127, 0.15);
  border-radius: 8px;

  text-align: left;

  cursor: pointer;
}

.mensajes-attachment:hover {
  background: rgba(127, 127, 127, 0.13);
}

.mensajes-attachment__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 30px;
  height: 30px;

  background: rgba(127, 127, 127, 0.12);
  border-radius: 7px;
}

.mensajes-attachment__icon .icon {
  width: 14px;
  height: 14px;
}

.mensajes-attachment__copy {
  display: grid;
  gap: 3px;

  min-width: 0;
}

.mensajes-attachment__copy strong {
  overflow: hidden;

  font-size: 10px;
  font-weight: 700;

  text-overflow: ellipsis;
  white-space: nowrap;
}

.mensajes-attachment__copy small {
  overflow: hidden;

  opacity: 0.65;

  font-size: 8.5px;

  text-overflow: ellipsis;
  white-space: nowrap;
}

.mensajes-attachment__download {
  width: 13px;
  height: 13px;

  opacity: 0.7;
}

/* =========================================================
   COMPOSITOR
   ========================================================= */

.mensajes-composer-wrap {
  position: relative;

  display: grid;

  background: var(--msg-surface);
  border-top: 1px solid var(--msg-border);
}

.mensajes-composer {
  display: grid;
  grid-template-columns:
    auto
    auto
    auto
    minmax(0, 1fr)
    auto;
  align-items: center;
  gap: 5px;

  padding: 10px 12px;
}

.mensajes-composer__tool,
.mensajes-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 32px;
  height: 32px;
  padding: 0;

  border-radius: 8px;

  cursor: pointer;

  transition:
    color var(--msg-transition),
    background-color var(--msg-transition),
    border-color var(--msg-transition);
}

.mensajes-composer__tool {
  color: var(--msg-text-soft);
  background: transparent;
  border: 1px solid transparent;
}

.mensajes-composer__tool:hover,
.mensajes-composer__tool.is-active {
  color: var(--msg-text);
  background: var(--msg-surface-strong);
  border-color: var(--msg-border);
}

.mensajes-composer__tool .icon,
.mensajes-send .icon {
  width: 14px;
  height: 14px;
}

.mensajes-composer input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 12px;

  color: var(--msg-text);
  background: var(--msg-surface-soft);
  border: 1px solid var(--msg-border);
  border-radius: 9px;

  font-size: 11.5px;

  outline: none;
}

.mensajes-composer input:focus {
  background: var(--msg-surface);
  border-color: var(--msg-border-strong);
}

.mensajes-composer input::placeholder {
  color: var(--msg-muted);
}

.mensajes-send {
  color: var(--msg-primary-text);
  background: var(--msg-primary);
  border: 1px solid var(--msg-primary);
}

.mensajes-send:hover {
  background: var(--msg-primary-hover);
}

.mensajes-send:disabled,
.mensajes-composer input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mensajes-composer--disabled {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  min-height: 58px;
  padding: 12px;

  color: var(--msg-muted);
  background: var(--msg-surface);

  font-size: 10.5px;
}

/* =========================================================
   PANEL DE ICONOS Y EMOJIS
   ========================================================= */

.mensajes-quick-panel {
  position: absolute;
  right: 12px;
  bottom: calc(100% + 8px);
  z-index: 20;

  display: grid;
  grid-template-rows:
    auto
    minmax(0, 1fr);

  width: min(540px, calc(100vw - 390px));
  max-height: 340px;

  color: var(--msg-text);
  background: var(--msg-surface);
  border: 1px solid var(--msg-border-strong);
  border-radius: 12px;
  box-shadow: var(--msg-shadow);

  overflow: hidden;
}

.mensajes-quick-tabs {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 4px;

  padding: 7px;

  background: var(--msg-surface-soft);
  border-bottom: 1px solid var(--msg-border);
}

.mensajes-quick-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  height: 30px;
  padding: 0 10px;

  color: var(--msg-text-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;

  font-size: 10px;
  font-weight: 680;

  cursor: pointer;
}

.mensajes-quick-tabs button:hover,
.mensajes-quick-tabs button.is-active {
  color: var(--msg-text);
  background: var(--msg-surface);
  border-color: var(--msg-border);
}

.mensajes-quick-tabs .icon {
  width: 13px;
  height: 13px;
}

.mensajes-quick-body {
  display: grid;
  align-content: start;
  gap: 12px;

  min-height: 0;
  padding: 10px;

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

  background: var(--msg-surface);
}

.mensajes-quick-group {
  display: grid;
  gap: 7px;

  min-width: 0;
}

.mensajes-quick-group > strong {
  color: var(--msg-muted);

  font-size: 8.5px;
  font-weight: 720;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.mensajes-quick-grid,
.mensajes-emoji-grid {
  display: grid;
  grid-template-columns:
    repeat(12, minmax(0, 1fr));
  gap: 4px;
}

.mensajes-quick-grid button,
.mensajes-emoji-grid button {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 0;
  height: 31px;
  padding: 0;

  color: var(--msg-text-soft);
  background: var(--msg-surface-soft);
  border: 1px solid var(--msg-border);
  border-radius: 7px;

  cursor: pointer;

  transition:
    color var(--msg-transition),
    background-color var(--msg-transition),
    border-color var(--msg-transition);
}

.mensajes-quick-grid button:hover,
.mensajes-emoji-grid button:hover {
  color: var(--msg-text);
  background: var(--msg-surface-strong);
  border-color: var(--msg-border-strong);
}

.mensajes-quick-grid button .icon {
  width: 13px !important;
  height: 13px !important;

  stroke-width: 1.8;
}

.mensajes-emoji-grid button {
  font-size: 15px;
  line-height: 1;
}

/* =========================================================
   MODALES
   ========================================================= */

.mensajes-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;

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

  padding: 18px;

  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(2px);
}

.mensajes-modal__card {
  display: grid;
  grid-template-rows:
    auto
    minmax(0, 1fr);

  width: min(560px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);

  color: var(--msg-text);
  background: var(--msg-surface);
  border: 1px solid var(--msg-border-strong);
  border-radius: 14px;
  box-shadow: var(--msg-shadow-modal);

  overflow: hidden;
}

.mensajes-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;

  padding: 15px 16px;

  background: var(--msg-surface);
  border-bottom: 1px solid var(--msg-border);
}

.mensajes-modal__head h3 {
  margin: 4px 0 0;

  color: var(--msg-text-strong);

  font-size: 17px;
  font-weight: 740;
  letter-spacing: -0.02em;
}

.mensajes-modal__head p {
  margin: 5px 0 0;

  color: var(--msg-text-soft);

  font-size: 10.5px;
  line-height: 1.4;
}

.mensajes-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 33px;
  height: 33px;
  flex: 0 0 33px;
  padding: 0;

  color: var(--msg-text-soft);
  background: transparent;
  border: 1px solid var(--msg-border);
  border-radius: 8px;

  cursor: pointer;
}

.mensajes-modal__close:hover {
  color: var(--msg-text);
  background: var(--msg-surface-strong);
}

.mensajes-modal__body {
  display: grid;
  align-content: start;
  gap: 12px;

  min-height: 0;
  padding: 14px;

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

  background: var(--msg-surface-soft);
}

.mensajes-field {
  display: grid;
  gap: 6px;
}

.mensajes-field input,
.mensajes-field select,
.mensajes-field textarea {
  width: 100%;
  min-width: 0;

  color: var(--msg-text);
  background: var(--msg-surface);
  border: 1px solid var(--msg-border);
  border-radius: 8px;

  font-size: 11.5px;

  outline: none;
}

.mensajes-field input,
.mensajes-field select {
  height: 38px;
  padding: 0 10px;
}

.mensajes-field textarea {
  min-height: 94px;
  padding: 10px;

  line-height: 1.45;

  resize: vertical;
}

.mensajes-field input:focus,
.mensajes-field select:focus,
.mensajes-field textarea:focus {
  border-color: var(--msg-border-strong);
}

.mensajes-users-box {
  display: grid;
  gap: 4px;

  max-height: 190px;
  padding: 6px;

  background: var(--msg-surface);
  border: 1px solid var(--msg-border);
  border-radius: 8px;

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

.mensajes-users-box > p {
  margin: 0;
  padding: 18px;

  color: var(--msg-muted);

  font-size: 10.5px;
  text-align: center;
}

.mensajes-user-check {
  display: grid;
  grid-template-columns:
    auto
    minmax(0, 1fr);
  align-items: center;
  gap: 9px;

  padding: 8px;

  border-radius: 7px;

  cursor: pointer;
}

.mensajes-user-check:hover {
  background: var(--msg-surface-hover);
}

.mensajes-user-check input {
  width: 14px;
  height: 14px;

  accent-color: var(--msg-primary);
}

.mensajes-user-check > span {
  display: grid;
  gap: 3px;

  min-width: 0;
}

.mensajes-user-check strong {
  overflow: hidden;

  color: var(--msg-text-strong);

  font-size: 10.5px;
  font-weight: 700;

  text-overflow: ellipsis;
  white-space: nowrap;
}

.mensajes-user-check small {
  overflow: hidden;

  color: var(--msg-text-soft);

  font-size: 9px;

  text-overflow: ellipsis;
  white-space: nowrap;
}

.mensajes-modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;

  padding-top: 3px;
}

/* =========================================================
   LOADING
   ========================================================= */

.mensajes-card {
  padding: 14px;
}

.mensajes-card--loading {
  min-height: 120px;
}

.mensajes-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mensajes-card__head h3 {
  margin: 4px 0 0;

  color: var(--msg-text-strong);

  font-size: 14px;
  font-weight: 720;
}

/* =========================================================
   SELECTS · MODO OSCURO
   ========================================================= */

html[data-theme="dark"] .mensajes-page select,
body.dark .mensajes-page select,
.dark .mensajes-page select,
html[data-theme="dark"] .mensajes-modal select,
body.dark .mensajes-modal select,
.dark .mensajes-modal select {
  color-scheme: dark;
}

html[data-theme="dark"] .mensajes-page option,
body.dark .mensajes-page option,
.dark .mensajes-page option,
html[data-theme="dark"] .mensajes-modal option,
body.dark .mensajes-modal option,
.dark .mensajes-modal option {
  color: #f5f5f5;
  background: #080808;
}

/* =========================================================
   SCROLLBARS
   ========================================================= */

.mensajes-inbox,
.mensajes-thread__body,
.mensajes-quick-body,
.mensajes-modal__body,
.mensajes-users-box {
  scrollbar-width: thin;
  scrollbar-color:
    var(--msg-border-strong)
    transparent;
}

.mensajes-inbox::-webkit-scrollbar,
.mensajes-thread__body::-webkit-scrollbar,
.mensajes-quick-body::-webkit-scrollbar,
.mensajes-modal__body::-webkit-scrollbar,
.mensajes-users-box::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.mensajes-inbox::-webkit-scrollbar-thumb,
.mensajes-thread__body::-webkit-scrollbar-thumb,
.mensajes-quick-body::-webkit-scrollbar-thumb,
.mensajes-modal__body::-webkit-scrollbar-thumb,
.mensajes-users-box::-webkit-scrollbar-thumb {
  background: var(--msg-border-strong);
  border-radius: 999px;
}

/* =========================================================
   MODO OSCURO · FORZAR NEGRO REAL
   ========================================================= */

html[data-theme="dark"] .mensajes-page,
body.dark .mensajes-page,
.dark .mensajes-page {
  background-color: #000000;
  background-image: none;
}

html[data-theme="dark"] .mensajes-hero,
body.dark .mensajes-hero,
.dark .mensajes-hero,
html[data-theme="dark"] .mensajes-layout,
body.dark .mensajes-layout,
.dark .mensajes-layout,
html[data-theme="dark"] .mensajes-sidebar-panel,
body.dark .mensajes-sidebar-panel,
.dark .mensajes-sidebar-panel,
html[data-theme="dark"] .mensajes-thread,
body.dark .mensajes-thread,
.dark .mensajes-thread,
html[data-theme="dark"] .mensajes-thread__header,
body.dark .mensajes-thread__header,
.dark .mensajes-thread__header,
html[data-theme="dark"] .mensajes-composer-wrap,
body.dark .mensajes-composer-wrap,
.dark .mensajes-composer-wrap,
html[data-theme="dark"] .mensajes-modal__card,
body.dark .mensajes-modal__card,
.dark .mensajes-modal__card,
html[data-theme="dark"] .mensajes-modal__head,
body.dark .mensajes-modal__head,
.dark .mensajes-modal__head {
  background-color: #070707;
  background-image: none;
}

html[data-theme="dark"] .mensajes-toolbar,
body.dark .mensajes-toolbar,
.dark .mensajes-toolbar {
  background-color: #070707;
}

html[data-theme="dark"] .mensajes-thread__body,
body.dark .mensajes-thread__body,
.dark .mensajes-thread__body {
  background-color: #030303;
  background-image: none;
}

html[data-theme="dark"] .mensajes-quick-panel,
body.dark .mensajes-quick-panel,
.dark .mensajes-quick-panel,
html[data-theme="dark"] .mensajes-quick-body,
body.dark .mensajes-quick-body,
.dark .mensajes-quick-body {
  background-color: #070707;
  background-image: none;
}

html[data-theme="dark"] .mensajes-quick-tabs,
body.dark .mensajes-quick-tabs,
.dark .mensajes-quick-tabs {
  background-color: #0c0c0c;
}

html[data-theme="dark"] .mensajes-modal,
body.dark .mensajes-modal,
.dark .mensajes-modal {
  background: rgba(0, 0, 0, 0.84);
}

html[data-theme="dark"] .mensajes-modal__body,
body.dark .mensajes-modal__body,
.dark .mensajes-modal__body {
  background-color: #0c0c0c;
}

/* =========================================================
   ANIMACIÓN DE CARGA
   ========================================================= */

.mensajes-spin {
  animation:
    mensajesSpin
    0.85s
    linear
    infinite;
}

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

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1180px) {
  .mensajes-quick-grid,
  .mensajes-emoji-grid {
    grid-template-columns:
      repeat(10, minmax(0, 1fr));
  }
}

@media (max-width: 1020px) {
  .mensajes-layout {
    grid-template-columns:
      minmax(260px, 310px)
      minmax(0, 1fr);
  }

  .mensajes-quick-panel {
    width: min(
      500px,
      calc(100vw - 350px)
    );
  }

  .mensajes-quick-grid,
  .mensajes-emoji-grid {
    grid-template-columns:
      repeat(8, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .mensajes-page {
    height: auto;
    min-height: calc(
      100vh -
      var(--topbar-height, 54px) -
      54px
    );

    overflow: visible;
  }

  .mensajes-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .mensajes-hero__actions {
    width: 100%;
    justify-content: flex-start;
  }

  .mensajes-layout {
    grid-template-columns: 1fr;
  }

  .mensajes-sidebar-panel {
    min-height: 310px;
    max-height: 370px;

    border-right: 0;
    border-bottom: 1px solid var(--msg-border);
  }

  .mensajes-thread {
    min-height: 540px;
  }

  .mensajes-quick-panel {
    right: 8px;
    left: 8px;

    width: auto;
  }
}

@media (max-width: 620px) {
  .mensajes-page {
    gap: 8px;
  }

  .mensajes-hero,
  .mensajes-layout {
    border-radius: 11px;
  }

  .mensajes-hero {
    padding: 11px;
  }

  .mensajes-hero__copy p {
    white-space: normal;
  }

  .mensajes-hero__actions {
    display: grid;
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .mensajes-hero__actions .mensajes-action {
    width: 100%;
  }

  .mensajes-toolbar {
    grid-template-columns: 1fr;
  }

  .mensajes-filter {
    width: 100%;
  }

  .mensajes-thread__header {
    align-items: flex-start;
  }

  .mensajes-thread__body {
    padding: 11px;
  }

  .mensajes-bubble {
    max-width: 92%;
  }

  .mensajes-composer {
    grid-template-columns:
      auto
      auto
      auto
      minmax(0, 1fr)
      auto;

    gap: 3px;
    padding: 8px;
  }

  .mensajes-composer__tool,
  .mensajes-send {
    width: 30px;
    height: 30px;
  }

  .mensajes-composer input {
    height: 36px;
    padding: 0 9px;
  }

  .mensajes-quick-grid {
    grid-template-columns:
      repeat(6, minmax(0, 1fr));
  }

  .mensajes-emoji-grid {
    grid-template-columns:
      repeat(7, minmax(0, 1fr));
  }

  .mensajes-modal {
    padding: 8px;
  }

  .mensajes-modal__card {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);

    border-radius: 11px;
  }

  .mensajes-modal__head {
    padding: 13px;
  }

  .mensajes-modal__head p {
    display: none;
  }

  .mensajes-modal__body {
    padding: 10px;
  }

  .mensajes-modal__footer {
    display: grid;
    grid-template-columns: 1fr;
  }

  .mensajes-modal__footer .mensajes-action {
    width: 100%;
  }

  .mensajes-attachment {
    min-width: 0;
    max-width: 100%;
  }
}

@media (max-width: 430px) {
  .mensajes-hero__actions {
    grid-template-columns: 1fr;
  }

  .mensajes-sidebar-panel {
    max-height: 320px;
  }

  .mensajes-thread {
    min-height: 500px;
  }

  .mensajes-thread__header {
    flex-direction: column;
  }

  .mensajes-thread__actions {
    width: 100%;
  }

  .mensajes-quick-grid {
    grid-template-columns:
      repeat(5, minmax(0, 1fr));
  }

  .mensajes-emoji-grid {
    grid-template-columns:
      repeat(6, minmax(0, 1fr));
  }

  .mensajes-composer {
    grid-template-columns:
      auto
      auto
      auto
      minmax(0, 1fr)
      auto;
  }

  .mensajes-composer__tool,
  .mensajes-send {
    width: 28px;
    height: 28px;
  }

  .mensajes-composer__tool .icon,
  .mensajes-send .icon {
    width: 12px;
    height: 12px;
  }
}

/* =========================================================
   ALTURAS REDUCIDAS
   ========================================================= */

@media (max-height: 760px) and (min-width: 821px) {
  .mensajes-page {
    height: calc(
      100vh -
      var(--topbar-height, 54px) -
      44px
    );
  }

  .mensajes-hero {
    min-height: 60px;
    padding: 9px 12px;
  }

  .mensajes-thread__header {
    min-height: 56px;
  }
}

/* =========================================================
   ACCESIBILIDAD
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .mensajes-page,
  .mensajes-page *,
  .mensajes-page *::before,
  .mensajes-page *::after,
  .mensajes-modal,
  .mensajes-modal *,
  .mensajes-modal *::before,
  .mensajes-modal *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}/* =========================================================
   BORDES · MÁS VISIBLES
   ========================================================= */

.app-sidebar {
  border-right-color: rgba(0, 0, 0, 0.34) !important;
}

.app-topbar,
.topbar {
  border-bottom-color: rgba(0, 0, 0, 0.30) !important;
}

html[data-theme="dark"] .app-sidebar {
  border-right-color: rgba(255, 255, 255, 0.26) !important;
}

html[data-theme="dark"] .app-topbar,
html[data-theme="dark"] .topbar {
  border-bottom-color: rgba(255, 255, 255, 0.23) !important;
}/* =========================================================
   MENSAJERÍA · BORDES MÁS VISIBLES
   ========================================================= */

.mensajes-page {
  --msg-border: rgba(0, 0, 0, 0.19);
  --msg-border-strong: rgba(0, 0, 0, 0.30);
}

html[data-theme="dark"] .mensajes-page,
body.dark .mensajes-page,
.dark .mensajes-page {
  --msg-border: rgba(255, 255, 255, 0.20);
  --msg-border-strong: rgba(255, 255, 255, 0.31);
}