/* =========================
   Chat Widget (ccw2-*)
   Option A: Lead card in-body
   ========================= */
:root {
  --ccw-bg: #fff;
  --ccw-text: #0f172a;
  --ccw-muted: #6b7280;
  --ccw-soft: #f3f4f6;
  --ccw-line: #e5e7eb;
  --ccw-primary: #2563eb;
  --ccw-primary-press: #1e40af;
  --ccw-success: #16a34a;
  --ccw-danger: #dc2626;
  --ccw-radius: 14px;
}

/* bubble launcher */
.ccw-bubble {
  position: fixed; right: 16px; bottom: 16px; z-index: 1000;
  transform: translateY(40px); transition: transform .3s ease;
  background: var(--ccw-primary); color: #fff; border: 0; border-radius: 999px;
  padding: 10px 14px; font: 600 14px/1.1 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell;
  display: flex; gap: 8px; align-items: center; box-shadow: 0 6px 20px rgba(37, 99, 235, .35);
}
.ccw-badge { background: rgba(255,255,255,.2); padding: 4px 8px; border-radius: 999px; font-weight:700; }

/* portal/drawer */
.ccw2-portal { position: fixed; inset: 0; z-index: 1000; opacity: 0; transition: opacity .18s ease; }
.ccw2-portal.is-on { opacity: 1; }
.ccw2-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .35); }
.ccw2-drawer {
  position: absolute; right: 0; top: 0; bottom: 0; width: 380px; max-width: 100%;
  background: var(--ccw-bg); display: flex; flex-direction: column; box-shadow: -6px 0 24px rgba(0,0,0,.18);
}
@media (max-width: 640px){
  .ccw2-drawer { width: 100%; }
}
.ccw2-header { display:flex; align-items:center; justify-content:space-between; padding: 12px 14px; border-bottom:1px solid var(--ccw-line); }
.ccw2-title h3 { margin:0; font: 700 16px/1.2 system-ui,-apple-system,Segoe UI,Roboto; color: var(--ccw-text); }
.ccw2-title small { display:block; color: var(--ccw-muted); font-size:12px; margin-top:2px; }
#ccw2-close { background:transparent; border:0; font-size:18px; line-height:1; cursor:pointer; color: var(--ccw-muted); }

.ccw2-chiprow { padding:8px 12px; display:flex; gap:8px; overflow:auto; border-bottom: 1px solid var(--ccw-line); }
.ccw2-chip { background: var(--ccw-soft); border:1px solid var(--ccw-line); border-radius: 999px; padding:6px 10px; font-size:12px; color:var(--ccw-text); white-space:nowrap; }

.ccw2-body {
  position: relative; flex: 1 1 auto; overflow: auto; padding: 12px; background: #fafafa;
}

/* messages */
.ccw2-msg {
  max-width: 86%; background: #eef2ff; color: #111827; border-radius: var(--ccw-radius);
  padding: 10px 12px; margin: 10px 8px; box-shadow: 0 1px 1px rgba(0,0,0,.04);
}
.ccw2-msg.you { margin-left: auto; background: #e5e7eb; }

/* lead-card bubble (in-body) */
.ccw2-leadcard {
  max-width: 92%;
  background: #fff;
  border: 1px dashed var(--ccw-line);
  border-radius: var(--ccw-radius);
  padding: 12px;
  margin: 10px 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.ccw2-lead-head { font: 700 13px/1.3 system-ui,-apple-system,Segoe UI,Roboto; margin-bottom: 6px; }
.ccw2-lead-hint { color: var(--ccw-muted); font-size: 12px; margin: 0 0 10px; }
.ccw2-row { display:flex; gap:8px; align-items:center; margin-bottom: 8px; }
.ccw2-row .ccw2-input {
  position: relative; flex: 1 1 auto; display:flex; align-items:center; gap:8px;
  background: var(--ccw-soft); border:1px solid var(--ccw-line); border-radius: 12px; padding: 8px 10px;
}
.ccw2-row input {
  border:0; background:transparent; outline:none; width:100%; font-size:16px; /* anti-zoom iOS */
}
.ccw2-ico { width:18px; height:18px; color:#64748b; display:inline-flex; }
.ccw2-btn {
  background: var(--ccw-primary); color:#fff; border:0; border-radius: 12px; padding: 10px 12px;
  font-weight:700; cursor:pointer;
}
.ccw2-btn:disabled { opacity:.45; cursor:not-allowed; }
.ccw2-link { background: transparent; border:0; padding: 0; color: var(--ccw-primary); font-weight:600; cursor:pointer; }
.ccw2-error { color: var(--ccw-danger); font-size:12px; margin-top:4px; }

/* composer (chat) */
.ccw2-form { position: sticky; bottom: 0; background: var(--ccw-bg); padding: 10px 12px; border-top:1px solid var(--ccw-line); }
#ccw2-chat-wrap { display:flex; gap:8px; }
#ccw2-chat-input {
  flex:1 1 auto; border:1px solid var(--ccw-line); background: var(--ccw-soft); border-radius: 12px;
  padding: 12px; font-size:16px; outline:none;
}
#ccw2-chat-send { white-space: nowrap; }
.ccw2-foot { display:flex; justify-content:space-between; align-items:center; padding-top:6px; color: var(--ccw-muted); font-size:12px; }
#ccw2-error { color: var(--ccw-danger); }

/* RTL quick support (when Arabic locale) */
html:has(.ccw2-portal) [dir="rtl"] .ccw2-drawer,
.ccw2-portal[dir="rtl"] .ccw2-drawer { direction: rtl; }
