/* FastFix CRM — chat igual ao celular (menu da mensagem, áudio, ligação, contato, status) */

/* Menu ⌄ em cada mensagem, como no WhatsApp */
body.ffp article.chat-message { position: relative; }
.ffm-more {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 22px; border: 0; border-radius: 6px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  background: inherit; color: var(--ffp-muted); opacity: 0; transition: opacity .12s; box-shadow: -6px 0 8px -2px rgba(255,255,255,.9);
}
article.chat-message:hover > .ffm-more, .ffm-more:focus-visible { opacity: 1; }
article.chat-message.outgoing > .ffm-more { box-shadow: -6px 0 8px -2px rgba(217,253,211,.95); }
#ffm-menu {
  position: fixed; z-index: 10000; min-width: 190px; background: #fff; border-radius: 10px; padding: 6px 0;
  box-shadow: 0 10px 30px rgba(11,20,26,.22), 0 0 0 1px rgba(11,20,26,.06); font: 14px system-ui, -apple-system, "Segoe UI", sans-serif;
}
#ffm-menu button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 9px 16px; text-align: left; cursor: pointer; color: var(--ffp-ink); font: inherit; }
#ffm-menu button span { width: 18px; text-align: center; color: var(--ffp-muted); }
#ffm-menu button:hover, #ffm-menu button:focus-visible { background: var(--ffp-hover); outline: none; }
#ffm-menu button.bad { color: #c92a2a; } #ffm-menu button.bad span { color: #c92a2a; }

/* Marcas no rodapé da mensagem */
.ffm-flags { display: inline-flex; gap: 6px; margin-right: 6px; font-size: 11px; color: var(--ffp-muted); }
.ffm-flags .heard { color: #1c7ed6; font-weight: 600; }
.ffm-flags .del { color: #c92a2a; }
body.ffp article.chat-message.ffm-deleted > p, body.ffp article.chat-message.ffm-deleted > div:not(.ffm-flags) { opacity: .45; text-decoration: line-through; }

/* Ligação: aviso centralizado e destacado */
body.ffp article.chat-message.ffm-call {
  align-self: center !important; margin: 8px auto !important; background: #fff4e6 !important; border: 1px solid #ffd8a8 !important;
  border-radius: 10px !important; max-width: 420px !important; text-align: center; box-shadow: none !important;
}
body.ffp article.chat-message.ffm-call > p { color: #8a4b00; font-weight: 600; }
body.ffp article.chat-message.ffm-call .message-author { display: none !important; }

/* Velocidade do áudio */
.ffm-speed {
  align-self: flex-start; width: auto !important; flex: none;
  margin: 4px 0 0 6px; border: 0; border-radius: 999px; padding: 2px 9px; font: 700 12px system-ui, sans-serif; cursor: pointer;
  background: rgba(11,20,26,.08); color: var(--ffp-ink-2); vertical-align: middle;
}
.ffm-speed:hover { background: rgba(11,20,26,.14); }
body.ffp article.chat-message.ffm-heard audio { filter: hue-rotate(160deg) saturate(1.4); }

/* Número e presença embaixo do nome; nome e foto abrem os dados do contato */
.ffm-info { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font: 12px system-ui, sans-serif; color: var(--ffp-muted); }
.ffm-info .num { border: 0; background: transparent; padding: 0; font: inherit; color: var(--ffp-ink-2); cursor: pointer; }
.ffm-info .num:hover { text-decoration: underline; }
.ffm-info .pres.on { color: #2b8a3e; font-weight: 600; }
.ffm-info .pres.typing { color: var(--ffp-green-dark); font-weight: 600; font-style: italic; }
.ffm-clickable { cursor: pointer; }
body.ffp header.chat-top .chat-title > b.ffm-clickable:hover { text-decoration: underline; }

/* Painel do contato */
#ffm-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); z-index: 9000; background: #fff;
  box-shadow: -10px 0 30px rgba(11,20,26,.18); transform: translateX(105%); transition: transform .2s ease; display: flex; flex-direction: column;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ffp-ink);
}
#ffm-drawer.open { transform: none; }
#ffm-drawer > header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--ffp-header); }
#ffm-drawer > header .x { border: 0; background: transparent; font-size: 24px; line-height: 1; cursor: pointer; color: var(--ffp-muted); }
#ffm-drawer .body { padding: 20px; overflow-y: auto; display: grid; gap: 10px; justify-items: center; text-align: center; }
#ffm-drawer .photo { width: 200px; height: 200px; border-radius: 50%; overflow: hidden; border: 0; padding: 0; background: #dfe5e7; display: flex; align-items: center; justify-content: center; font-size: 56px; color: #fff; cursor: zoom-in; }
#ffm-drawer .photo.empty, #ffm-drawer .photo.loading { cursor: default; }
#ffm-drawer .photo img { width: 100%; height: 100%; object-fit: cover; }
#ffm-drawer h3 { margin: 4px 0 0; font-size: 20px; font-weight: 600; }
#ffm-drawer .phone { border: 1px solid var(--ffp-line); background: #fff; border-radius: 999px; padding: 5px 12px; font: 600 15px system-ui, sans-serif; cursor: pointer; color: var(--ffp-ink); }
#ffm-drawer .phone small { color: var(--ffp-muted); font-weight: 500; margin-left: 4px; }
#ffm-drawer .pres { margin: 0; color: #2b8a3e; font-weight: 600; }
#ffm-drawer .names { list-style: none; margin: 0; padding: 0; color: var(--ffp-ink-2); font-size: 13px; }
#ffm-drawer .sect { width: 100%; text-align: left; border-top: 1px solid var(--ffp-line); padding-top: 12px; margin-top: 4px; }
#ffm-drawer .sect > small { display: block; color: var(--ffp-green-dark); font-weight: 600; margin-bottom: 6px; }
#ffm-drawer .sect p { margin: 0; font-size: 13px; }
#ffm-drawer .muted { color: var(--ffp-muted); margin: 0; } #ffm-drawer .small { font-size: 12px; }
#ffm-drawer .stories { display: flex; flex-wrap: wrap; gap: 8px; }
.story { width: 64px; height: 96px; border-radius: 10px; overflow: hidden; border: 2px solid var(--ffp-green); padding: 0; background: #222; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; }
.story img { width: 100%; height: 100%; object-fit: cover; }
.story.text { background: #5f3dc4; font-size: 10px; padding: 4px; line-height: 1.2; }
#ffm-drawer .stars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#ffm-drawer .stars li { background: var(--ffp-header); border-radius: 8px; padding: 6px 9px; font-size: 13px; display: grid; gap: 2px; }
#ffm-drawer .stars time { font-size: 11px; color: var(--ffp-muted); }

/* Visualizador em tela cheia */
.ffm-viewer { position: fixed; inset: 0; z-index: 10001; background: rgba(10,14,16,.94); display: flex; flex-direction: column; color: #fff; font: 14px system-ui, sans-serif; outline: none; }
.ffm-viewer .top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.ffm-viewer .top small { color: #adb5bd; } .ffm-viewer .sp { flex: 1; }
.ffm-viewer .top .x { border: 0; background: transparent; color: #fff; font-size: 30px; line-height: 1; cursor: pointer; }
.ffm-viewer .top .go { border: 0; background: var(--ffp-green); color: #fff; border-radius: 999px; padding: 6px 14px; font: 600 13px system-ui, sans-serif; cursor: pointer; }
.ffm-viewer .stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 0 12px; }
.ffm-viewer .stage img, .ffm-viewer .stage video { max-width: min(92vw, 900px); max-height: 100%; object-fit: contain; border-radius: 6px; }
.ffm-viewer .stage .txt { max-width: 520px; background: #5f3dc4; border-radius: 12px; padding: 40px 28px; font-size: 22px; text-align: center; white-space: pre-wrap; }
.ffm-viewer .nav { border: 0; background: rgba(255,255,255,.12); color: #fff; width: 44px; height: 44px; border-radius: 50%; font-size: 28px; cursor: pointer; flex: none; }
.ffm-viewer .cap { text-align: center; margin: 8px 16px; }
.ffm-viewer .count { text-align: center; color: #adb5bd; margin: 0 0 12px; font-size: 12px; }

/* Modais (encaminhar, confirmar) */
.ffm-modal { width: min(440px, calc(100vw - 32px)) !important; }
.ffm-modal header p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; }
.ffm-pad { padding: 4px 20px 20px; display: grid; gap: 10px; }
.ffm-pad .actions { display: flex; justify-content: flex-end; gap: 8px; }
.ffm-pad .danger { background: #c92a2a !important; border-color: #c92a2a !important; }
.ffm-search { border: 1px solid var(--ffp-line); border-radius: 8px; padding: 8px 11px; font: inherit; }
.ffm-list { max-height: 50vh; overflow-y: auto; display: grid; gap: 2px; }
.ffm-list button { display: grid; text-align: left; gap: 1px; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; cursor: pointer; font: 14px system-ui, sans-serif; color: var(--ffp-ink); }
.ffm-list button small { color: var(--ffp-muted); font-size: 12px; }
.ffm-list button:hover, .ffm-list button:focus-visible { background: var(--ffp-hover); outline: none; }
.ffm-list button.sending { background: #e7fce3; }
.ffm-list .none { color: var(--ffp-muted); margin: 8px; }

/* Aba Status do WhatsApp */
body.ffm-on main.workspace > .page-heading,
body.ffm-on .main-tabs > [data-slot="tabs-content"],
body.ffm-on #fastfix-agent-flow-container,
body.ffm-on #ffp-dashboard,
body.ffm-on main.workspace > section:not(#ffm) { display: none !important; }
body.ffm-on .modern-workspace .navigation [data-slot="tabs-trigger"][data-state="active"]:not(.ffp-nav-btn) { background: transparent !important; color: var(--ffp-ink-2) !important; font-weight: 500 !important; }
#ffm { display: none; font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ffp-ink); }
body.ffm-on #ffm { display: block; }
.ffm-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.ffm-top h1 { margin: 0; font-size: 22px; } .ffm-top p { margin: 4px 0 0; color: var(--ffp-muted); font-size: 13px; max-width: 720px; }
.ffm-post { background: #fff; border: 1px solid var(--ffp-line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; margin-bottom: 16px; max-width: 640px; }
.ffm-post textarea { border: 1px solid var(--ffp-line); border-radius: 8px; padding: 8px 10px; font: inherit; resize: vertical; }
.ffm-post .row { display: flex; align-items: center; gap: 10px; }
.ffm-post .sp { flex: 1; }
.ffm-post .file { border: 1px dashed #b8c4ca; border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.ffm-post .fname { font-size: 12px; color: var(--ffp-muted); }
.ffm-post .primary { border: 0; background: var(--ffp-green); color: #fff; border-radius: 8px; padding: 8px 16px; font: 700 14px system-ui, sans-serif; cursor: pointer; }
.ffm-post small { color: var(--ffp-muted); font-size: 12px; }
.ffm-post .mode { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }
.ffm-post .mode label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.ffm-post .when label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.ffm-post .when input[type=date], .ffm-post .when input[type=time] { border: 1px solid var(--ffp-line); border-radius: 8px; padding: 5px 8px; font: inherit; }
.ffm-post .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ffm-post .chip input { position: absolute; opacity: 0; pointer-events: none; }
.ffm-post .chip span { display: inline-block; border: 1px solid var(--ffp-line); border-radius: 999px; padding: 4px 11px; font-size: 13px; cursor: pointer; user-select: none; }
.ffm-post .chip input:checked + span { background: var(--ffp-green); border-color: var(--ffp-green); color: #fff; }
.ffm-post .chip input:focus-visible + span { outline: 2px solid var(--ffp-green-dark); outline-offset: 2px; }
.ffm-post .ghost, #ffm .ghost { border: 1px solid var(--ffp-line); background: #fff; border-radius: 8px; padding: 5px 11px; font: 13px system-ui, sans-serif; cursor: pointer; color: var(--ffp-ink); }
#ffm .ghost.bad { color: #c92a2a; }
#ffm h2 { font-size: 15px; margin: 18px 0 8px; }
.ffm-sched, .ffm-log { list-style: none; margin: 0; padding: 0; max-width: 640px; display: grid; gap: 8px; }
.ffm-sched li { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--ffp-line); border-radius: 12px; padding: 8px 10px; }
.ffm-sched li.off { opacity: .6; }
.ffm-sched li.muted, .ffm-log li.muted { display: block; background: transparent; border: 0; padding: 0; color: var(--ffp-muted); }
.ffm-sched .th { flex: none; width: 44px; height: 60px; border-radius: 8px; overflow: hidden; background: #222; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px; }
.ffm-sched .th.txt { background: #5f3dc4; font-weight: 700; font-size: 15px; }
.ffm-sched .th img { width: 100%; height: 100%; object-fit: cover; }
.ffm-sched .tx { flex: 1; min-width: 0; display: grid; gap: 1px; }
.ffm-sched .tx span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ffp-ink-2); font-size: 13px; }
.ffm-sched .tx small { font-size: 12px; color: var(--ffp-muted); }
#ffm small.ok { color: #2b8a3e; } #ffm small.bad { color: #c92a2a; }
.ffm-sched .ac { flex: none; display: flex; gap: 6px; }
.ffm-log li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 13px; border-bottom: 1px solid var(--ffp-line); padding: 5px 0; }
.ffm-log time { color: var(--ffp-muted); font-size: 12px; min-width: 82px; }
.ffm-log .k { color: var(--ffp-muted); font-size: 12px; }
.ffm-log .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) { .ffm-sched li { flex-wrap: wrap; } .ffm-sched .ac { width: 100%; justify-content: flex-end; } }
