/* Dominada ERP — Chat flutuante (widget) */

/* escondido na tela de login */
#app[hidden] ~ #cw-root{display:none!important}

/* botão flutuante */
.cw-fab{
  position:fixed;right:22px;bottom:22px;z-index:1200;
  width:60px;height:60px;border-radius:50%;border:none;cursor:pointer;
  background:linear-gradient(135deg,#7C93F5,#2A3F8F);
  color:#ffffff;display:flex;align-items:center;justify-content:center;
  box-shadow:0 10px 30px rgba(27,42,94,.35),0 2px 8px rgba(0,0,0,.4);
  transition:transform .18s ease,box-shadow .18s ease;
}
.cw-fab svg{width:26px;height:26px}
.cw-fab:hover{transform:scale(1.07);box-shadow:0 14px 36px rgba(27,42,94,.45),0 2px 8px rgba(0,0,0,.4)}
.cw-fab:active{transform:scale(.96)}
.cw-fab.active{background:linear-gradient(135deg,#3a3a44,#23232b);color:var(--brand-hi,#7C93F5)}
.cw-fab .notif-badge{position:absolute;top:-2px;right:-2px}
@keyframes cw-pulse{0%{box-shadow:0 0 0 0 rgba(27,42,94,.55)}70%{box-shadow:0 0 0 12px rgba(27,42,94,0)}100%{box-shadow:0 0 0 0 rgba(27,42,94,0)}}
.cw-fab.has-unread{animation:cw-pulse 2s infinite}

/* painel */
.cw-panel{
  position:fixed;right:22px;bottom:94px;z-index:1200;
  width:384px;max-width:calc(100vw - 32px);height:560px;max-height:calc(100vh - 140px);
  background:#141419;border:1px solid var(--border,#2a2a32);border-radius:20px;
  box-shadow:0 24px 70px rgba(0,0,0,.75),0 0 0 1px rgba(27,42,94,.08);
  display:flex;flex-direction:column;overflow:hidden;
  opacity:0;transform:translateY(16px) scale(.98);pointer-events:none;
  transition:opacity .2s ease,transform .22s cubic-bezier(.2,.9,.3,1.2);
}
.cw-panel.open{opacity:1;transform:none;pointer-events:auto}
.cw-panel[hidden]{display:none}

/* cabeçalho */
.cw-head{border-bottom:1px solid var(--border-soft,#22222a);background:linear-gradient(180deg,rgba(27,42,94,.07),transparent);flex:none}
.cw-head-row{display:flex;align-items:center;gap:10px;padding:13px 14px}
.cw-head-row[hidden]{display:none}
.cw-avatar-sm{width:38px;height:38px;border-radius:50%;flex:none;display:flex;align-items:center;justify-content:center;background:linear-gradient(135deg,#7C93F5,#2A3F8F);color:#ffffff}
.cw-avatar-sm svg{width:19px;height:19px}
.cw-title{font-weight:700;font-size:15px}
.cw-sub{font-size:12px;color:var(--text-faint,#8b8578)}
.cw-head .grow{flex:1;min-width:0}
.cw-iconbtn{width:32px;height:32px;border-radius:10px;border:none;background:rgba(255,255,255,.05);color:var(--text-dim,#c9c2b4);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;flex:none}
.cw-iconbtn:hover{background:rgba(255,255,255,.1);color:var(--text,#f2f2f5)}
.cw-iconbtn svg{width:16px;height:16px}
#cw-thread-avatar .chat-avatar{width:36px!important;height:36px!important}

/* corpo */
.cw-body{flex:1;display:flex;flex-direction:column;min-height:0;position:relative}
.cw-list{flex:1;display:flex;flex-direction:column;min-height:0;overflow:hidden}
.cw-list[hidden]{display:none}
.cw-search{padding:10px 12px 6px;flex:none}
.cw-search input{width:100%;background:rgba(255,255,255,.04);border:1px solid var(--border,#2a2a32);border-radius:12px;color:var(--text,#f2f2f5);padding:9px 12px;font-size:13px;font-family:inherit}
.cw-search input:focus{outline:none;border-color:var(--brand,#1B2A5E);box-shadow:0 0 0 3px rgba(27,42,94,.12)}
.cw-conv-list{flex:1;overflow-y:auto;padding:4px 8px 10px}
.cw-conv{display:flex;gap:11px;align-items:center;width:100%;text-align:left;background:none;border:none;border-radius:14px;padding:10px;cursor:pointer;color:var(--text,#f2f2f5);transition:background .12s}
.cw-conv:hover{background:rgba(255,255,255,.045)}
.cw-conv.active{background:rgba(27,42,94,.1)}
.cw-conv-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}
.cw-conv-top{display:flex;align-items:baseline;justify-content:space-between;gap:8px}
.cw-conv-title{font-weight:600;font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cw-conv.unread .cw-conv-title{color:var(--brand-hi,#7C93F5)}
.cw-conv-time{font-size:11px;color:var(--text-faint,#8b8578);flex:none}
.cw-conv-prev{font-size:12.5px;color:var(--text-faint,#8b8578);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:flex;align-items:center;gap:6px}
.cw-faint{color:var(--text-faint,#8b8578);font-style:italic}

/* vazio */
.cw-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:28px 24px;gap:6px;color:var(--text-faint,#8b8578)}
.cw-empty-icon{width:56px;height:56px;border-radius:18px;background:rgba(27,42,94,.1);display:flex;align-items:center;justify-content:center;color:var(--brand-hi,#7C93F5);margin-bottom:8px}
.cw-empty-icon svg{width:26px;height:26px}
.cw-empty-big{font-size:15px;font-weight:700;color:var(--text-dim,#c9c2b4)}
.cw-empty p{font-size:13px;margin:0 0 8px}

/* thread */
.cw-thread{flex:1;display:flex;flex-direction:column;min-height:0}
.cw-thread[hidden]{display:none}
.cw-msgs{flex:1;overflow-y:auto;padding:16px 14px;display:flex;flex-direction:column;gap:8px;background:radial-gradient(ellipse at 50% 0%,rgba(27,42,94,.05),transparent 60%)}
.cw-msg{display:flex;flex-direction:column;max-width:78%;align-self:flex-start;animation:cw-msg-in .18s ease}
.cw-msg.mine{align-self:flex-end;align-items:flex-end}
@keyframes cw-msg-in{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.cw-bubble{background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.07);border-radius:16px 16px 16px 6px;padding:9px 13px;font-size:13.5px;line-height:1.45;word-break:break-word;box-shadow:0 2px 6px rgba(0,0,0,.25)}
.cw-msg.mine .cw-bubble{background:linear-gradient(135deg,#6B85E8,#2A3F8F);border:none;color:#ffffff;font-weight:500;border-radius:16px 16px 6px 16px;box-shadow:0 3px 10px rgba(27,42,94,.25)}
.cw-time{font-size:10px;color:var(--text-faint,#8b8578);margin-top:3px;padding:0 4px}

/* input */
.cw-input-row{display:flex;gap:8px;padding:10px 12px;border-top:1px solid var(--border-soft,#22222a);align-items:flex-end;flex:none;background:rgba(0,0,0,.15)}
.cw-input-row textarea{flex:1;resize:none;min-height:40px;max-height:110px;background:rgba(255,255,255,.04);border:1px solid var(--border,#2a2a32);border-radius:14px;color:var(--text,#f2f2f5);padding:10px 13px;font-size:13.5px;font-family:inherit;line-height:1.4}
.cw-input-row textarea:focus{outline:none;border-color:var(--brand,#1B2A5E);box-shadow:0 0 0 3px rgba(27,42,94,.12)}
.cw-send{width:42px;height:42px;border-radius:50%;border:none;flex:none;cursor:pointer;background:linear-gradient(135deg,#7C93F5,#2A3F8F);color:#ffffff;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 12px rgba(27,42,94,.3);transition:transform .12s}
.cw-send:hover{transform:scale(1.06)}
.cw-send svg{width:17px;height:17px}

/* mobile */
@media(max-width:560px){
  .cw-fab{right:16px;bottom:16px;width:56px;height:56px}
  .cw-panel{right:12px;left:12px;bottom:84px;width:auto;height:calc(100vh - 120px);max-height:none}
  .cw-msg{max-width:86%}
}

/* ---------- caixas (conversas por cliente) ---------- */
.cw-caixa,.chat-caixa{display:flex;align-items:center;gap:8px;padding:8px 12px 0}
.cw-caixa label,.chat-caixa label{font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--brand-hi,#7C93F5)}
.cw-caixa select,.chat-caixa select{flex:1;background:rgba(255,255,255,.05);border:1px solid var(--border,#2a2a32);border-radius:10px;color:var(--text,#f2f2f5);padding:7px 10px;font-size:12.5px;font-family:inherit;cursor:pointer}
.cw-caixa select:focus,.chat-caixa select:focus{outline:none;border-color:var(--brand,#1B2A5E)}
.cw-client-pill,.chat-client-pill{display:inline-block;margin-top:4px;font-size:10.5px;font-weight:700;letter-spacing:.04em;color:#ffffff;background:linear-gradient(135deg,#7C93F5,#2A3F8F);border-radius:20px;padding:2px 8px}
.cw-clientline,.chat-clientline{margin-top:2px;font-size:11.5px;color:var(--text-dim,#c9c2b4)}
.cw-caixa-tag,.chat-caixa-tag{display:inline-flex;align-items:center;gap:5px;font-size:11.5px;color:var(--brand-hi,#7C93F5);font-weight:600}
.cw-linkbtn{background:none;border:none;color:var(--text-faint,#8a867e);cursor:pointer;padding:2px;vertical-align:middle;border-radius:6px}
.cw-linkbtn:hover{color:var(--brand-hi,#7C93F5)}
.cw-faint{color:var(--text-faint,#8a867e)}

/* ---------- exportar conversa (ADM) ---------- */
.cw-exp-meta{font-size:13px;line-height:1.7;margin-bottom:12px;color:var(--text-dim,#c9c2b4)}
.cw-exp-meta strong{color:var(--text,#f2f2f5)}
.cw-exp-preview{max-height:280px;overflow:auto;border:1px solid var(--border,#2a2a32);border-radius:12px;padding:10px 12px;margin-bottom:10px;background:rgba(255,255,255,.02)}
.cw-exp-row{padding:7px 0;border-bottom:1px solid rgba(255,255,255,.05)}
.cw-exp-row:last-child{border-bottom:none}
.cw-exp-who{font-weight:700;font-size:12.5px;color:var(--brand-hi,#7C93F5)}
.cw-exp-time{font-size:11px;color:var(--text-faint,#8a867e);margin-left:8px}
.cw-exp-body{font-size:13px;color:var(--text,#f2f2f5);margin-top:2px;white-space:pre-wrap;word-break:break-word}
.cw-exp-actions{display:flex;gap:10px;margin-top:12px}
.btn-ghost{background:rgba(255,255,255,.06);border:1px solid var(--border,#2a2a32);color:var(--text,#f2f2f5);border-radius:12px;padding:10px 16px;font-size:13px;font-weight:600;cursor:pointer}
.btn-ghost:hover{background:rgba(255,255,255,.1)}

/* ---------- impressão do relatório ---------- */
#print-area{display:none}
@media print{
  body>*{display:none!important}
  #print-area{display:block!important;position:static!important}
  .pr-doc{font-family:Arial,Helvetica,sans-serif;color:#111;max-width:760px;margin:0 auto;padding:8px}
  .pr-doc h1{font-size:20px;margin:0 0 4px;color:#111}
  .pr-sub{font-size:12px;color:#555;margin:0 0 14px}
  .pr-info{width:100%;border-collapse:collapse;margin-bottom:16px;font-size:13px}
  .pr-info td{border:1px solid #ccc;padding:6px 10px}
  .pr-info td:first-child{font-weight:bold;background:#f5f5f5;width:150px}
  .pr-msg{margin-bottom:10px;page-break-inside:avoid}
  .pr-meta{font-size:12px;color:#333;margin-bottom:2px}
  .pr-meta strong{margin-right:8px}
  .pr-body{font-size:13.5px;line-height:1.5;white-space:pre-wrap;word-break:break-word}
}

/* ---------- arquivar conversas ---------- */
.cw-conv-wrap{position:relative;display:flex;align-items:stretch}
.cw-conv-wrap .cw-conv{flex:1}
.cw-arch{flex:none;width:34px;border:none;background:transparent;color:rgba(255,255,255,.28);cursor:pointer;border-radius:0 14px 14px 0;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s ease,color .15s ease}
.cw-conv-wrap:hover .cw-arch{opacity:1}
.cw-arch:hover{color:#1B2A5E;background:rgba(27,42,94,.08)}
.cw-arch-toggle{width:100%;margin-top:8px;padding:9px;border:none;background:rgba(27,42,94,.07);border:1px dashed rgba(27,42,94,.3);border-radius:12px;color:#1B2A5E;font-size:12.5px;font-weight:600;cursor:pointer;font-family:inherit}
.cw-arch-toggle:hover{background:rgba(27,42,94,.12)}
