/* =====================================================================
 * WifiCord — Ações de mensagem (responder / reagir / menu "⋯")
 * Usa as variáveis do tema (escuro, aero…) com fallback.
 * ===================================================================== */

/* Os botões antigos (fixar/editar/apagar) continuam no HTML — o menu "⋯"
   aciona eles por .click() — mas não aparecem mais soltos no cabeçalho. */
#messages-list .message-actions { display: none !important; }

#messages-list .message-item .message-body { position: relative; }
#messages-list .message-item { touch-action: pan-y pinch-zoom; }

/* ------------------------------------------------ barra flutuante (hover) */
/* Fica NO ESPAÇO VAZIO ao lado da bolha (à direita nas mensagens dos outros,
   à esquerda nas minhas), nunca por cima de avatar, nome ou texto. */
.message-toolbar {
  position: absolute;
  top: 2px;
  left: calc(100% + 8px);
  z-index: 6;
  display: none;
  align-items: center;
  gap: 1px;
  padding: 3px;
  border-radius: 11px;
  background: var(--bg-elevated, #171A28);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, .1));
  box-shadow: 0 8px 22px rgba(0, 0, 0, .32);
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity .12s ease, transform .12s var(--ease-smooth, ease);
  white-space: nowrap;
}
.message-item.own .message-toolbar { left: auto; right: calc(100% + 8px); }
/* bolha larga: sem espaço ao lado, a barra sobe para o canto da linha */
.message-item.ma-tb-top .message-toolbar,
.message-item.own.ma-tb-top .message-toolbar { top: -22px; left: auto; right: 8px; }
/* janela estreita sem toque: não há espaço ao lado, então vai pro canto da linha */
@media (max-width: 680px) {
  .message-toolbar, .message-item.own .message-toolbar { top: -16px; left: auto; right: 6px; }
}

@media (hover: hover) and (pointer: fine) {
  .message-toolbar { display: inline-flex; }
  .message-item:hover .message-toolbar,
  .message-item.ma-active .message-toolbar,
  .message-toolbar:focus-within {
    opacity: 1; pointer-events: auto; transform: none;
  }
}

.ma-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary, #AEB4CC);
  cursor: pointer;
  transition: background .12s ease, color .12s ease, transform .12s ease;
}
.ma-btn svg {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.ma-btn:hover, .ma-btn:focus-visible {
  background: var(--bg-hover, rgba(255, 255, 255, .09));
  color: var(--accent-cyan, #22D3EE);
  outline: none;
}
.ma-btn:active { transform: scale(.92); }

/* --------------------------------------------- citação dentro da mensagem */
/* Cartão compacto: [↩ Nome]  trecho…  — clicável, leva até a original. */
.message-reply {
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  min-width: min(260px, 100%);
  max-width: 100%;
  margin: 0 0 5px;
  padding: 6px 12px 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(34, 211, 238, .22);
  border-left: 3px solid var(--accent-cyan, #22D3EE);
  background: rgba(34, 211, 238, .08);
  color: var(--text-secondary, #AEB4CC);
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background .14s ease, border-color .14s ease, transform .12s ease;
}
.message-reply::before {
  content: '';
  flex: none;
  width: 14px; height: 14px;
  background: no-repeat center / contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2322D3EE' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.5 6 4 11.5 9.5 17'/%3E%3Cpath d='M4 11.5h9a7 7 0 0 1 7 7'/%3E%3C/svg%3E");
}
.message-reply:hover { background: rgba(34, 211, 238, .16); border-color: rgba(34, 211, 238, .45); }
.message-reply:active { transform: scale(.985); }
.message-reply:focus-visible { outline: 2px solid var(--accent-cyan, #22D3EE); outline-offset: 2px; }
.message-reply .mr-hook { display: none; }
.message-reply .mr-author { flex: none; max-width: 11em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; color: var(--accent-cyan, #22D3EE); }
.message-reply .mr-snippet { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary, #F5F6FC); opacity: .82; }
.message-reply.is-deleted { cursor: default; font-style: italic; border-color: var(--glass-border, rgba(255, 255, 255, .1)); border-left-color: var(--text-muted, #6E7590); background: rgba(255, 255, 255, .04); }
.message-reply.is-deleted::before { background-image: none; width: 0; }
.message-reply.is-deleted .mr-snippet { color: var(--text-muted, #6E7590); opacity: 1; }
.message-reply.is-deleted:hover { background: rgba(255, 255, 255, .04); border-color: var(--glass-border, rgba(255, 255, 255, .1)); }
/* resposta a uma mensagem MINHA: amarelo, igual menção (a mensagem toda ganha .mentions-me no app.js) */
.message-item.reply-to-me .message-reply { border-color: rgba(251, 191, 36, .35); border-left-color: #FBBF24; background: rgba(251, 191, 36, .09); }
.message-item.reply-to-me .message-reply:hover { background: rgba(251, 191, 36, .17); }
.message-item.reply-to-me .message-reply .mr-author { color: #FBBF24; }

/* ------------------------------------------------- realces (pular / respondendo) */
.message-item.ma-replying { box-shadow: inset 3px 0 0 var(--accent-cyan, #22D3EE); background: rgba(34, 211, 238, .07); }
.message-item.ma-active { background: rgba(255, 255, 255, .045); }
/* piscada forte ao pular para a mensagem original (linha + bolha) */
.message-item.ma-flash { animation: ma-flash 2.4s ease-out; }
.message-item.ma-flash .message-content { animation: ma-ring 2.4s ease-out; }
@keyframes ma-flash {
  0%, 25% { background: rgba(34, 211, 238, .30); box-shadow: inset 4px 0 0 var(--accent-cyan, #22D3EE); }
  100% { background: transparent; box-shadow: inset 4px 0 0 transparent; }
}
@keyframes ma-ring {
  0%, 25% { box-shadow: 0 0 0 3px var(--accent-cyan, #22D3EE), 0 0 22px rgba(34, 211, 238, .55); }
  100% { box-shadow: 0 0 0 0 transparent, 0 0 0 transparent; }
}

/* --------------------------------------------- barra "Respondendo a…" */
.wc-reply-bar {
  position: relative;
  z-index: 6;
  flex: 0 0 auto !important;
  min-height: 46px;
  box-sizing: border-box;
  opacity: 1 !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 12px -1px;
  padding: 7px 8px 7px 12px;
  border: 1px solid var(--glass-border, rgba(255, 255, 255, .1));
  border-bottom: 0;
  border-left: 3px solid var(--accent-cyan, #22D3EE);
  border-radius: 12px 12px 0 0;
  background: var(--bg-elevated, #171A28);
  background-color: var(--bg-elevated, #171A28) !important;
  color: var(--text-secondary, #AEB4CC);
  font-size: 13px;
  cursor: pointer;
  animation: ma-bar-in .16s var(--ease-smooth, ease);
}
@keyframes ma-bar-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.wc-reply-bar .rb-icon { flex: none; display: inline-grid; color: var(--accent-cyan, #22D3EE); }
.wc-reply-bar .rb-icon svg, .wc-reply-bar .rb-close svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.wc-reply-bar .rb-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.wc-reply-bar .rb-title b { color: var(--text-primary, #F5F6FC); font-weight: 700; }
.wc-reply-bar .rb-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--text-muted, #6E7590); }
.wc-reply-bar .rb-close {
  flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary, #AEB4CC); cursor: pointer;
}
.wc-reply-bar .rb-close:hover, .wc-reply-bar .rb-close:focus-visible { background: var(--bg-hover, rgba(255, 255, 255, .1)); color: var(--text-primary, #fff); outline: none; }
.message-form.ma-has-reply { border-top-left-radius: 0; border-top-right-radius: 0; }

/* ------------------------------------------------------------- menu "⋯" */
.ma-layer { position: fixed; inset: 0; z-index: 10050; }
.ma-scrim { position: absolute; inset: 0; background: transparent; }
.ma-layer.is-sheet .ma-scrim { background: rgba(3, 5, 12, .55); opacity: 0; transition: opacity .16s ease; }
.ma-layer.is-sheet.open .ma-scrim { opacity: 1; }

.ma-menu {
  position: absolute;
  width: 262px;
  max-width: calc(100vw - 20px);
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--glass-border, rgba(255, 255, 255, .1));
  background: var(--bg-elevated, #171A28);
  color: var(--text-primary, #F5F6FC);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .55);
  font-size: 14px;
  opacity: 0;
  transform: scale(.97) translateY(-3px);
  transform-origin: top right;
  transition: opacity .12s ease, transform .14s var(--ease-smooth, ease);
}
.ma-layer.open .ma-menu { opacity: 1; transform: none; }

.ma-peek { display: none; }
.ma-quick, .ma-grid { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px 3px 5px; }
.ma-quick { justify-content: space-between; flex-wrap: nowrap; }
.ma-grid { padding-top: 0; border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, .08)); margin-bottom: 4px; max-height: 164px; overflow-y: auto; }
.ma-grid[hidden] { display: none; }
.ma-q {
  flex: none; display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 10px; background: transparent; font-size: 21px; line-height: 1; cursor: pointer;
  transition: transform .12s var(--ease-smooth, ease), background .12s ease;
}
.ma-q:hover, .ma-q:focus-visible { background: var(--bg-hover, rgba(255, 255, 255, .1)); transform: scale(1.14); outline: none; }
.ma-q.on { background: rgba(34, 211, 238, .2); box-shadow: inset 0 0 0 1.5px var(--accent-cyan, #22D3EE); }
.ma-q-more { color: var(--text-secondary, #AEB4CC); }
.ma-q-more svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.ma-items { display: flex; flex-direction: column; }
.ma-sep { height: 1px; margin: 4px 6px; background: var(--glass-border, rgba(255, 255, 255, .08)); }
.ma-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 11px; border: 0; border-radius: 9px;
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
  transition: background .1s ease;
}
.ma-item:hover, .ma-item:focus-visible { background: var(--bg-hover, rgba(255, 255, 255, .09)); outline: none; }
.ma-item .ma-ic { flex: none; display: inline-grid; width: 18px; height: 18px; color: var(--text-secondary, #AEB4CC); }
.ma-item .ma-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ma-item .ma-lb { flex: 1; min-width: 0; }
.ma-item.ma-primary .ma-ic { color: var(--accent-cyan, #22D3EE); }
.ma-item.ma-subhead { font-weight: 700; color: var(--text-secondary, #AEB4CC); }
.ma-item.ma-danger, .ma-item.ma-danger .ma-ic { color: var(--danger, #FF4D6D); }
.ma-item.ma-danger:hover, .ma-item.ma-danger:focus-visible { background: rgba(255, 77, 109, .14); }
.ma-item[data-armed="1"] { background: rgba(255, 77, 109, .2); }

.ma-foot { padding: 7px 11px 5px; font-size: 11.5px; line-height: 1.35; color: var(--text-muted, #6E7590); border-top: 1px solid var(--glass-border, rgba(255, 255, 255, .08)); margin-top: 4px; }

/* ---- celular / tela estreita: bottom sheet ---- */
.ma-layer.is-sheet .ma-menu {
  left: 0 !important; right: 0; top: auto !important; bottom: 0;
  width: auto; max-width: none; max-height: 82vh;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  border-radius: 20px 20px 0 0; border-bottom: 0;
  transform: translateY(100%); opacity: 1;
  transform-origin: bottom center;
  transition: transform .22s var(--ease-smooth, ease);
}
.ma-layer.is-sheet.open .ma-menu { transform: none; }
.ma-layer.is-sheet .ma-menu::before {
  content: ''; display: block; width: 38px; height: 4px; margin: 2px auto 8px; border-radius: 4px;
  background: var(--text-muted, #6E7590); opacity: .55;
}
.ma-layer.is-sheet .ma-peek {
  display: flex; flex-direction: column; gap: 1px; padding: 2px 10px 8px;
  border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, .08)); margin-bottom: 6px;
}
.ma-layer.is-sheet .ma-peek b { font-size: 13px; color: var(--accent-cyan, #22D3EE); }
.ma-layer.is-sheet .ma-peek span { font-size: 13px; color: var(--text-secondary, #AEB4CC); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ma-layer.is-sheet .ma-q { width: 44px; height: 44px; font-size: 25px; }
.ma-layer.is-sheet .ma-item { padding: 13px 12px; font-size: 15.5px; }

/* ---------------------------------------------- arrastar para responder (toque) */
/* Minhas mensagens (direita): puxa para a ESQUERDA. Das outras pessoas (esquerda): para a DIREITA.
   O movimento é feito por transform direto no JS (leve); aqui só o ícone e dicas de composição. */
.message-item.ma-swiping { position: relative; }
.message-item.ma-swiping .message-body,
.message-item.ma-swiping .message-avatar { backface-visibility: hidden; }
.ma-swipe-ic {
  position: absolute; top: 50%; width: 32px; height: 32px; margin-top: -16px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--bg-hover, rgba(255, 255, 255, .14)); color: var(--accent-cyan, #22D3EE);
  pointer-events: none; will-change: transform, opacity;
  transition: background .12s ease, color .12s ease;
}
.ma-swipe-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ma-swipe-ic.at-right { right: 14px; }
.ma-swipe-ic.at-left { left: 14px; }
.ma-swipe-ic.is-ready { background: var(--accent-cyan, #22D3EE); color: #04222a; }

/* ------------------------------------------------------------- lembretes */
.ma-remind-host { position: fixed; right: 16px; bottom: 16px; z-index: 10040; display: flex; flex-direction: column; gap: 10px; max-width: min(360px, calc(100vw - 32px)); }
.ma-remind {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: start;
  padding: 12px 14px; border-radius: 14px;
  background: var(--bg-elevated, #171A28); color: var(--text-primary, #F5F6FC);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, .1)); border-left: 3px solid var(--accent-cyan, #22D3EE);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
  animation: ma-bar-in .22s var(--ease-smooth, ease);
}
.ma-remind-ic { grid-row: 1 / span 2; display: inline-grid; color: var(--accent-cyan, #22D3EE); }
.ma-remind-ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ma-remind-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13.5px; }
.ma-remind-tx span { color: var(--text-secondary, #AEB4CC); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ma-remind-bt { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.ma-remind-bt button {
  padding: 6px 12px; border: 0; border-radius: 9px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
  background: var(--accent-cyan, #22D3EE); color: #04222a;
}
.ma-remind-bt button.ghost { background: transparent; color: var(--text-secondary, #AEB4CC); }
.ma-remind-bt button.ghost:hover { background: var(--bg-hover, rgba(255, 255, 255, .1)); }
@media (max-width: 680px) { .ma-remind-host { right: 12px; left: 12px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); max-width: none; } }

@media (prefers-reduced-motion: reduce) {
  .ma-menu, .ma-layer.is-sheet .ma-menu, .message-toolbar, .wc-reply-bar, .ma-remind { transition: none; animation: none; }
  .message-item.ma-flash { animation: none; background: rgba(34, 211, 238, .2); }
}
