/* PATH: /public/css/dm.css */

/* Chat Screen (Quizio-like) */
.vx-dm{
  /* ocupa a area util do app (seu app ja tem padding top/bottom na vitrix-main) */
  height: calc(100vh - 84px - 92px);
  display:flex;
  flex-direction: column;
  position: relative;
  min-height: 0; /* IMPORTANTISSIMO pra permitir scroll interno */
}

body:not(.vx-show-topbar) .vx-dm{
  height: calc(100vh - 92px);
}


/* ✅ header sempre visível */
.vx-dm-header{
  flex: 0 0 auto;
  position: sticky; /* garante que, se algum ancestral scrollar, ele não some */
  top: 0;
  z-index: 20;

  display:flex;
  align-items:center;
  gap: 10px;
  padding: 12px 10px;
  margin: 0 -12px;
  background: linear-gradient(180deg, var(--vx-brand), var(--vx-brand-2));
  color: #fff;
  border-bottom-left-radius: var(--vx-r-lg);
  border-bottom-right-radius: var(--vx-r-lg);
}

/* buttons */
.vx-dm-iconBtn{
  border:0;
  width:42px;
  height:42px;
  border-radius: 999px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(255,255,255,.16);
  color:#fff;
  font-size: 18px;
  transition: transform .12s ease, background .12s ease;
}
.vx-dm-iconBtn:hover{ background: rgba(255,255,255,.22); }
.vx-dm-iconBtn:active{ transform: scale(.98); }
.vx-dm-iconBtn:disabled{
  opacity:.45;
  cursor:not-allowed;
}

.vx-dm-peer{
  border:0;
  background: transparent;
  color:#fff;
  display:flex;
  align-items:center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 0;
  text-align:left;
  cursor:pointer;
}

.vx-dm-avatarRing{
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: var(--vx-r-md);
  padding: 2px;
  background: conic-gradient(from 180deg, #ff7a18, #af002d, #319197, #ff7a18);
  flex: 0 0 auto;
}
.vx-dm-avatar{
  width: 100%;
  height: 100%;
  border-radius: calc(var(--vx-r-md) - 2px);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 950;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.18);
  color:#fff;
}

.vx-dm-onlineDot{
  position:absolute;
  right: 2px;
  bottom: 2px;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(255,255,255,.25);
}
.vx-dm-onlineDot--off{ background: rgba(255,255,255,.35); }

.vx-dm-peerMeta{
  display:flex;
  flex-direction: column;
  min-width:0;
}
.vx-dm-peerName{
  font-weight: 950;
  letter-spacing: var(--vx-ls-tight);
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vx-dm-peerSub{
  font-size: 12px;
  opacity: .88;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ✅ scroll SOMENTE aqui */
.vx-dm-body{
  flex: 1 1 auto;
  min-height: 0;            /* IMPORTANTÍSSIMO */
  overflow: auto;
  padding: 14px 2px 138px;
  -webkit-overflow-scrolling: touch;

  background:
    radial-gradient(1200px 600px at 50% -20%, color-mix(in srgb, var(--vx-brand) 10%, transparent), transparent 55%),
    linear-gradient(180deg, transparent, transparent);
}

.vx-dm-empty{
  padding: 14px;
  border-radius: var(--vx-r-md);
  border: 1px dashed var(--vx-border-2);
  color: var(--vx-muted);
  background: color-mix(in srgb, var(--vx-surface) 86%, transparent);
}

.vx-dm-msg{
  display:flex;
  margin: 8px 0;
}
.vx-dm-msg--mine{ justify-content: flex-end; }
.vx-dm-msg--theirs{ justify-content: flex-start; }

.vx-dm-bubble{
  max-width: 78%;
  padding: 10px 12px;
  border-radius: var(--vx-r-md);
  border: 1px solid var(--vx-border-2);
  background: var(--vx-surface);
  box-shadow: var(--vx-shadow-xs);
}

.vx-dm-msg--mine .vx-dm-bubble{
  background: color-mix(in srgb, var(--vx-brand) 18%, transparent);
  border-color: color-mix(in srgb, var(--vx-brand) 16%, var(--vx-border-2));
}

.vx-dm-text{
  font-size: 14px;
  color: var(--vx-text);
}

.vx-dm-time{
  margin-top: 4px;
  font-size: 11px;
  color: var(--vx-muted);
  text-align: right;
}

/* composer fixo no fundo da área útil */
.vx-dm-composer{
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;

  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px 10px calc(env(safe-area-inset-bottom, 0px) + 10px);
  background: color-mix(in srgb, var(--vx-bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--vx-border-2);
}

.vx-dm-actionBtn{
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--vx-border-2);
  background: var(--vx-surface);
  display:flex;
  align-items:center;
  justify-content:center;
  color: var(--vx-brand);
  font-size: 16px;
  transition: transform .12s ease;
}
.vx-dm-actionBtn:active{ transform: scale(.98); }

.vx-dm-inputWrap{
  flex: 1;
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--vx-border-2);
  background: var(--vx-surface);
}

.vx-dm-input{
  flex:1;
  border:0;
  outline:0;
  background: transparent;
  color: var(--vx-text);
  font-weight: 700;
}
.vx-dm-input::placeholder{ color: var(--vx-muted); font-weight: 600; }

.vx-dm-emojiBtn{
  border:0;
  background: transparent;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: transform .12s ease, background .12s ease;
  cursor:pointer;
}
.vx-dm-emojiBtn:hover{ background: color-mix(in srgb, var(--vx-brand) 8%, transparent); }
.vx-dm-emojiBtn:active{ transform: scale(.98); }

.vx-dm-sendBtn{
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 0;
  background: var(--vx-brand);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow: 0 12px 22px color-mix(in srgb, var(--vx-brand) 22%, transparent);
  transition: transform .12s ease, filter .12s ease;
}
.vx-dm-sendBtn:active{ transform: scale(.98); }
.vx-dm-sendBtn:hover{ filter: brightness(.98); }

/* Emoji bar (fica entre body e composer) */
.vx-dm-emojiBar{
  position: absolute;
  left: 0;
  right: 0;
  bottom: 74px;
  z-index: 16;

  margin: 0;
  padding: 10px 12px 14px;
  background: color-mix(in srgb, var(--vx-surface) 92%, transparent);
  border-top: 1px solid var(--vx-border-2);
  backdrop-filter: blur(10px);
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 170px;
  overflow: auto;
}

.vx-dm-emojiPick{
  border: 1px solid var(--vx-border-2);
  background: var(--vx-surface);
  border-radius: var(--vx-r-sm);
  padding: 8px 10px;
  font-weight: 900;
  cursor: pointer;
}
