/* =====================================================================
   OUTREACH (2026-10-17): composer drawer, campaign window, selection bar,
   My channels, Outreach + campaign pages. Monochrome, same motion curves
   as motion.css (--ease-out / --ease-spring).
   ===================================================================== */

/* ---------- small shared bits ---------- */
.icon-btn.icon-wa, .icon-btn.icon-mail { color: #222; }
.icon-btn.icon-wa svg, .icon-btn.icon-mail svg { display: block; }
.row-actions { white-space: nowrap; }
button svg, .btn-link svg { vertical-align: -3px; }
.mini-spin { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1.6px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; vertical-align: -2px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.pre { white-space: pre-line; }
.ghost-danger:hover { color: #b42318 !important; border-color: #f0c7c2 !important; }
.var-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.var-chip {
  border: 1px dashed #cfcfcf !important; background: #fff !important; color: #555 !important; border-radius: 999px !important;
  font-size: 11.5px !important; padding: 3px 9px !important; font-weight: 500 !important; min-height: 0 !important; box-shadow: none !important;
}
.var-chip:hover { border-style: solid !important; color: #111 !important; }
.ch-badge { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #f1f1f1; color: #111; margin-right: 10px; vertical-align: middle; flex: none; }
.ch-badge svg { width: 14px; height: 14px; }
.ch-badge.big { width: 36px; height: 36px; margin-right: 12px; }
.ch-badge.big svg { width: 18px; height: 18px; }
.ch-badge.ch-whatsapp { background: #111; color: #fff; }

/* pills for message / campaign state */
.pill-msg-sent, .pill-camp-done { background: #111; color: #fff; }
.pill-msg-queued, .pill-msg-sending, .pill-camp-paused { background: #ececec; color: #444; }
.pill-msg-failed, .pill-camp-cancelled { background: #fbe9e7; color: #b42318; }
.pill-camp-running { background: #111; color: #fff; position: relative; padding-left: 20px; }
.pill-camp-running::before { content: ""; position: absolute; left: 9px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: #fff; animation: breathe-w 1.6s var(--ease-inout) infinite; }
@keyframes breathe-w { 50% { opacity: .35; } }

.progress { height: 8px; border-radius: 999px; background: #eee; overflow: hidden; position: relative; }
.progress i { display: block; height: 100%; width: var(--p, 0%); background: #111; border-radius: inherit; transition: width 900ms var(--ease-out); }
.progress.big { height: 12px; margin: 18px 0 20px; }
.motion-boot .progress i { animation: grow-x 1100ms var(--ease-out) both; animation-delay: 300ms; }
@keyframes grow-x { from { width: 0; } }

/* ---------- composer drawer ---------- */
.composer-scrim { position: fixed; inset: 0; background: rgba(17,17,17,.18); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); opacity: 0; transition: opacity 320ms var(--ease-out); z-index: 140; }
.composer-scrim.on { opacity: 1; }
body.composer-lock { overflow: hidden; }
.composer {
  position: fixed; top: 12px; right: 12px; bottom: 12px; width: min(480px, calc(100vw - 24px));
  background: #fff; border-radius: 28px; box-shadow: 0 40px 80px -30px rgba(0,0,0,.45), 0 0 0 1px rgba(0,0,0,.04);
  display: flex; flex-direction: column; z-index: 150; overflow: hidden;
  transform: translateX(calc(100% + 40px)) scale(.98); opacity: .6; visibility: hidden;
  transition: transform 560ms var(--ease-spring), opacity 300ms var(--ease-out), visibility 0s linear 560ms;
}
.composer.open { transform: none; opacity: 1; visibility: visible; transition: transform 620ms var(--ease-spring), opacity 260ms var(--ease-out), visibility 0s; }
.composer-head { display: flex; align-items: center; gap: 12px; padding: 20px 20px 14px; }
.composer-avatar { width: 44px; height: 44px; font-size: 15px; background: #111; color: #fff; flex: none; }
.composer-who { min-width: 0; flex: 1; }
.composer-who h3 { margin: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-who p { margin: 2px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-close { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #f3f3f3 !important; color: #111; border: none; }
.composer-close:hover { background: #e9e9e9 !important; transform: rotate(90deg); }
.composer-close { transition: transform 420ms var(--ease-spring), background-color 200ms; }
.composer-seg { margin: 0 20px 6px; align-self: flex-start; background: #f3f3f3; }
.composer-seg .seg-btn { display: inline-flex; align-items: center; gap: 6px; }
.composer-thread { flex: 1; overflow-y: auto; padding: 14px 20px 10px; display: flex; flex-direction: column; gap: 10px; background:
  radial-gradient(circle at 1px 1px, #ececec 1px, transparent 0) 0 0 / 18px 18px; scroll-behavior: smooth; }
.thread-loading, .thread-empty { margin: auto; text-align: center; color: #777; font-size: 13.5px; display: grid; gap: 4px; max-width: 280px; }
.thread-empty strong { color: #111; font-size: 15px; }
.thread-note { background: #fff; border: 1px solid #ececec; border-radius: 14px; padding: 9px 12px; font-size: 12.5px; color: #555; }
.thread-note.warn { background: #fff7ed; border-color: #fde3c4; color: #8a4b0f; }
.thread-connect { margin: auto; text-align: center; display: grid; gap: 8px; justify-items: center; max-width: 300px; background: #fff; border-radius: 22px; padding: 26px 22px; box-shadow: 0 18px 40px -26px rgba(0,0,0,.35); animation: pop 520ms var(--ease-spring) both; }
.thread-connect span { color: #666; font-size: 13px; }
.tc-icon { width: 52px; height: 52px; border-radius: 50%; background: #111; color: #fff; display: grid; place-items: center; margin-bottom: 4px; }

.bubble { max-width: 84%; padding: 10px 13px 7px; border-radius: 18px; font-size: 13.8px; line-height: 1.45; position: relative; animation: bubble-in 460ms var(--ease-spring) both; transform-origin: bottom right; box-shadow: 0 1px 0 rgba(0,0,0,.03); }
.composer-thread.instant .bubble { animation: none; }
.bubble.out { align-self: flex-end; background: #111; color: #fff; border-bottom-right-radius: 6px; }
.bubble.in { align-self: flex-start; background: #fff; color: #111; border: 1px solid #ececec; border-bottom-left-radius: 6px; transform-origin: bottom left; }
.bubble.ch-email.out { background: #fff; color: #111; border: 1px solid #e4e4e4; border-radius: 16px; max-width: 92%; }
.bubble-subject { font-weight: 600; margin-bottom: 4px; }
.bubble-body { white-space: pre-wrap; word-break: break-word; }
.bubble-meta { display: flex; gap: 8px; justify-content: flex-end; align-items: center; font-size: 11px; opacity: .65; margin-top: 4px; }
.bubble-camp { margin-right: auto; font-style: italic; }
.bubble-st { display: inline-flex; }
.bubble.st-failed { background: #fff; color: #111; border: 1px solid #f0c7c2; }
.bubble.st-failed .bubble-st { color: #b42318; opacity: 1; }
.bubble-err { font-size: 12px; color: #b42318; margin-top: 4px; }
.bubble.st-sending, .bubble.st-queued { opacity: .82; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(10px) scale(.92); } to { opacity: 1; transform: none; } }

.composer-form { padding: 12px 16px 14px; border-top: 1px solid #f0f0f0; background: #fff; display: grid; gap: 8px; }
.composer-tools { display: flex; align-items: center; gap: 8px; min-width: 0; }
.composer-tools select { width: auto; max-width: 150px; padding: 6px 10px; font-size: 12.5px; border-radius: 999px; flex: none; }
.composer-tools .var-chips { margin: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.composer-tools .var-chips::-webkit-scrollbar { display: none; }
.composer-form input[type="text"] { border-radius: 14px; }
.composer-box { display: flex; align-items: flex-end; gap: 8px; background: #f4f4f4; border-radius: 22px; padding: 6px 6px 6px 14px; transition: box-shadow 240ms var(--ease-out), background-color 240ms; }
.composer-box:focus-within { background: #fff; box-shadow: 0 0 0 1.5px #111, 0 10px 24px -16px rgba(0,0,0,.5); }
.composer-box textarea { flex: 1; border: none !important; background: transparent !important; box-shadow: none !important; resize: none; padding: 8px 0; min-height: 38px; max-height: 220px; font-size: 14px; line-height: 1.45; outline: none; }
.composer-send { border-radius: 999px !important; height: 40px; padding: 0 16px !important; display: inline-flex; align-items: center; gap: 6px; flex: none; }
.composer-send:hover:not(:disabled) svg { transform: translate(2px, -2px); }
.composer-send svg { transition: transform 420ms var(--ease-spring); }
.composer-foot { margin: 0; font-size: 11.5px; padding-left: 6px; min-height: 14px; }
.composer[data-channel="whatsapp"] .composer-tools select { }

/* ---------- campaign window ---------- */
.campaign-box { max-width: 920px !important; padding: 26px 28px !important; }
.campaign-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 14px; }
.campaign-head h3 { margin: 0 0 4px; font-size: 22px; }
.campaign-head .icon-only { width: 36px; height: 36px; border-radius: 50%; background: #f3f3f3; border: none; display: grid; place-items: center; flex: none; }
.campaign-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; }
.campaign-seg { margin-bottom: 14px; }
.campaign-seg .seg-btn { display: inline-flex; align-items: center; gap: 6px; }
.campaign-audience { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.campaign-side { display: flex; flex-direction: column; gap: 12px; }
.reach-card { background: #111; color: #fff; border-radius: 22px; padding: 18px 20px; }
.reach-num { font-size: 44px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.reach-num.bump { animation: bump 520ms var(--ease-spring); }
@keyframes bump { 0% { transform: scale(.88); opacity: .4; } 100% { transform: none; opacity: 1; } }
.reach-label { margin-top: 6px; font-size: 14px; }
.reach-card .reach-sub { color: #aaa; margin-top: 4px; font-size: 12px; }
.preview-card { background: #f6f6f6; border-radius: 20px; padding: 14px 16px; flex: 1; min-height: 140px; }
.preview-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #888; margin-bottom: 8px; }
.preview-subject { font-weight: 600; margin-bottom: 6px; }
.preview-body { white-space: pre-wrap; font-size: 13.5px; line-height: 1.5; max-height: 220px; overflow: auto; }
.pacing-note { margin: 0; font-size: 12.5px; }

/* ---------- floating selection bar ---------- */
.selection-bar {
  position: fixed; left: 50%; bottom: 24px; z-index: 120; display: flex; align-items: center; gap: 6px;
  background: #111; color: #fff; padding: 7px 7px 7px 18px; border-radius: 999px; box-shadow: 0 24px 50px -20px rgba(0,0,0,.6);
  transform: translate(-50%, 140%); opacity: 0; transition: transform 560ms var(--ease-spring), opacity 260ms var(--ease-out);
}
.selection-bar.on { transform: translate(-50%, 0); opacity: 1; }
.sel-count { font-size: 13.5px; margin-right: 8px; white-space: nowrap; }
.sel-count strong { font-variant-numeric: tabular-nums; }
.sel-btn { background: #fff !important; color: #111 !important; border: none !important; border-radius: 999px !important; padding: 8px 14px !important; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.sel-btn.ghost { background: transparent !important; color: #bbb !important; }
.sel-btn.ghost:hover { color: #fff !important; }

/* ---------- My channels ---------- */
.channel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.channel-card { padding: 26px; }
.channel-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; }
.channel-head h3 { margin: 0; font-size: 19px; }
.channel-head p { margin: 2px 0 0; }
.channel-head > div { flex: 1; }
.channel-icon { width: 46px; height: 46px; border-radius: 50%; background: #111; color: #fff; display: grid; place-items: center; flex: none; }
.channel-icon svg { width: 20px; height: 20px; }
.state-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; background: #f1f1f1; color: #666; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.state-pill i { width: 7px; height: 7px; border-radius: 50%; background: #bbb; }
.state-pill.on { background: #111; color: #fff; }
.state-pill.on i { background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
.state-pill.wait i { background: #111; animation: breathe-w 1.2s var(--ease-inout) infinite; }
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.note-box { background: #f6f6f6; border-radius: 14px; padding: 10px 12px; }
.advanced { border: 1px solid #ececec; border-radius: 16px; padding: 4px 14px; margin: 2px 0 6px; }
.advanced summary { cursor: pointer; padding: 8px 0; font-weight: 600; font-size: 13.5px; list-style: none; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::after { content: "+"; float: right; color: #888; transition: transform 300ms var(--ease-spring); }
.advanced[open] summary::after { transform: rotate(45deg); }
.advanced[open] > div { animation: rise-sm 360ms var(--ease-out) both; }
.channel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.channel-summary { display: grid; gap: 12px; }
.summary-big { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; word-break: break-all; }
.summary-rows { display: grid; gap: 8px; background: #f7f7f7; border-radius: 18px; padding: 14px 16px; }
.summary-rows > div { display: flex; justify-content: space-between; gap: 16px; font-size: 13.5px; }
.summary-rows span { color: #777; }
.summary-rows strong { font-weight: 500; text-align: right; }
.steps { margin: 0 0 18px; padding-left: 20px; display: grid; gap: 8px; color: #333; font-size: 14px; }
.steps.small { font-size: 13px; gap: 4px; margin-bottom: 10px; }
.wa-view { animation: rise-sm 420ms var(--ease-out) both; }
.wa-wait { text-align: center; padding: 18px 0 6px; }
.wa-wait p { margin: 4px 0; }
.wa-spinner { display: flex; justify-content: center; gap: 7px; margin-bottom: 14px; }
.wa-spinner span { width: 10px; height: 10px; border-radius: 50%; background: #111; animation: dots 1.1s var(--ease-inout) infinite; }
.wa-spinner span:nth-child(2) { animation-delay: .15s; } .wa-spinner span:nth-child(3) { animation-delay: .3s; }
@keyframes dots { 0%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-7px); opacity: 1; } }
.wa-qr { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; }
.qr-frame { width: 220px; height: 220px; border-radius: 22px; background: #fff; box-shadow: 0 0 0 1px #ececec, 0 20px 40px -26px rgba(0,0,0,.45); display: grid; place-items: center; padding: 10px; }
.qr-frame img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.qr-frame img.fresh { animation: pop 520ms var(--ease-spring); }
.msg.warn { background: #fff7ed; color: #8a4b0f; border-radius: 14px; padding: 10px 12px; margin-top: 14px; font-size: 13px; }
#channelsPage .msg.error:not(:empty), #waError:not([hidden]) { margin-top: 12px; }

/* ---------- Outreach page ---------- */
.channel-chip-link { display: inline-flex !important; align-items: center; gap: 6px; }
.channel-chip-link .dot { width: 7px; height: 7px; border-radius: 50%; background: #ccc; margin-left: 4px; }
.channel-chip-link .dot.on { background: #111; }
.channel-chip-link .sep { color: #bbb; margin: 0 2px; }
.setup-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #111; color: #fff; border-radius: 22px; padding: 16px 18px 16px 22px; margin-bottom: 20px; }
.setup-banner div { display: grid; gap: 2px; }
.setup-banner span { color: #bbb; font-size: 13.5px; }
.setup-banner .primary { background: #fff !important; color: #111 !important; }
.out-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.out-stats .qs-card { background: #fff; border-radius: 24px; }
.out-stats .qs-icon svg { width: 18px; height: 18px; }
.out-grid { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }
.out-side { display: grid; gap: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.camp-table td { vertical-align: middle; }
.camp-table .progress { width: 100%; max-width: 220px; margin-bottom: 6px; }
.camp-name { display: inline-flex; align-items: center; font-weight: 600; color: #111; }
.row-link { cursor: pointer; }
.mini-item { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; padding: 8px; margin: 0 -8px; border-radius: 14px; transition: background-color 200ms; }
.mini-item:hover { background: #f5f5f5; }
.mini-main { min-width: 0; flex: 1; display: grid; }
.mini-when { white-space: nowrap; font-size: 11.5px; }
.tpl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.tpl-list li { display: flex; align-items: center; gap: 8px; padding: 8px; margin: 0 -8px; border-radius: 14px; transition: background-color 200ms, opacity 260ms, transform 260ms var(--ease-out); }
.tpl-list li:hover { background: #f5f5f5; }
.tpl-list li.leaving { opacity: 0; transform: translateX(16px); }
.tpl-main { min-width: 0; flex: 1; display: grid; }
.tpl-list .icon-only { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: transparent; border: none; color: #777; opacity: 0; transition: opacity 200ms, background-color 200ms; }
.tpl-list li:hover .icon-only, .tpl-list .icon-only:focus-visible { opacity: 1; }
.tpl-list .icon-only:hover { background: #e9e9e9; color: #111; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin: 4px 0 10px; }
label.check input { width: auto; }

/* ---------- campaign page ---------- */
.camp-hero { padding: 26px 28px; margin-bottom: 22px; }
.camp-hero-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.camp-pct { font-size: 48px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.camp-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.progress.big i { transition: width 1s var(--ease-out); }
.camp-counts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.camp-counts div { background: #f6f6f6; border-radius: 18px; padding: 12px 14px; display: grid; }
.camp-counts strong { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.camp-counts strong.bump { animation: bump 520ms var(--ease-spring); }
.camp-counts span { font-size: 12.5px; color: #777; }
.camp-message { margin-bottom: 22px; }
.camp-message summary { cursor: pointer; list-style: none; }
.camp-message summary::-webkit-details-marker { display: none; }
.camp-message .preview-body { background: #f6f6f6; border-radius: 16px; padding: 14px 16px; margin-top: 12px; max-height: none; }
tr.flash-row td { animation: row-flash 1.2s var(--ease-out); }
@keyframes row-flash { 0% { background: #ececec; } 100% { background: transparent; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .out-grid { grid-template-columns: minmax(0, 1fr); }
  .channel-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .campaign-grid { grid-template-columns: minmax(0, 1fr); }
  .out-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .camp-counts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wa-qr { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .composer { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: min(88vh, 720px); transform: translateY(105%); }
  .setup-banner { flex-direction: column; align-items: flex-start; }
  .campaign-audience { grid-template-columns: 1fr; }
  .selection-bar { bottom: 14px; padding-left: 14px; }
  .sel-btn { padding: 8px 11px !important; }
}
@media (prefers-reduced-motion: reduce) {
  .composer, .selection-bar, .composer-scrim { transition: none !important; }
  .bubble, .thread-connect, .wa-view { animation: none !important; }
}

/* hidden must win over the display rules above (state pills, QR grid…) */
#campaignPage [hidden], .composer [hidden], .campaign-box [hidden], #channelsPage [hidden], .selection-bar[hidden], #templatesCard [hidden], #tplModal [hidden] { display: none !important; }
#campaignModal { z-index: 130; }
