/* crm.css — estilos da área de CRM (fase 3). Reusa os tokens do design system
   (assets/styles.css) e as classes base de app (app/account.css). Aqui só o que
   é específico do CRM: funil de etiquetas, lista de contatos e ficha (modal). */

/* ── Sub-navegação do CRM (Agenda · Pipeline · Campanhas) ────────────────────── */
.crm-subnav { display: flex; gap: 4px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.crm-subnav-btn {
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--txt-2);
  font: inherit; font-size: 15px; font-weight: 600; padding: 10px 14px; margin-bottom: -1px;
  cursor: pointer; white-space: nowrap;
}
.crm-subnav-btn:hover { color: var(--txt); }
.crm-subnav-btn.on { color: var(--green); border-bottom-color: var(--green); }

/* "Em breve" (aba Campanhas sem backend ainda) */
.crm-soon { position: relative; }
.crm-soon-badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent);
  border: 1px solid var(--green-2); border-radius: 999px; padding: 3px 10px; margin-bottom: 12px;
}

/* ── Funil de etiquetas: linha rolável de "pílulas" com contagem ─────────────── */
.crm-funnel { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; }
.crm-funnel .hint { margin: 0; }
.crm-tag {
  flex: 0 0 auto; min-width: 132px; text-align: left; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--green-2); border-radius: var(--radius-sm);
  padding: 10px 12px; color: var(--txt); font: inherit;
}
.crm-tag:hover { border-color: var(--green-2); }
.crm-tag.is-active { border-color: var(--green); box-shadow: 0 0 0 1px var(--green) inset; }
.crm-tag-name { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-tag-count { font-size: 22px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.crm-tag-flow { display: block; margin-top: 6px; font-size: 11px; color: var(--txt-3); }
.crm-tag-flow .pos { color: var(--green); }
.crm-tag .crm-tag-src { font-size: 10px; color: var(--txt-3); text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Busca + chip de filtro ativo ────────────────────────────────────────────── */
.crm-search-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.crm-search-row input {
  flex: 1; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--txt); font: inherit;
}
.crm-search-row input::placeholder { color: var(--txt-3); }
.crm-search-row input:focus { border-color: var(--green-2); outline: none; }
.crm-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
  padding: 3px 9px; border-radius: 999px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--txt-2);
}
.crm-chip-filter { cursor: pointer; border-color: var(--green-2); color: var(--txt); white-space: nowrap; }
.crm-chip-filter::after { content: "✕"; font-size: 10px; color: var(--txt-3); }

/* ── Lista de contatos ───────────────────────────────────────────────────────── */
.crm-count { font-size: 13px; color: var(--txt-3); font-weight: 600; }
.crm-head-actions { display: flex; align-items: center; gap: 12px; }
.crm-refresh {
  background: none; border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--txt-2); font: inherit; font-size: 12px; padding: 5px 11px; cursor: pointer;
}
.crm-refresh:hover { color: var(--txt); border-color: var(--green-2); }
.crm-list { list-style: none; margin: 0; padding: 0; }
.crm-empty { color: var(--txt-3); font-size: 14px; padding: 14px 2px; }
.crm-list li { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.crm-list li.crm-empty { display: block; border-bottom: 0; }
.crm-list li:last-child { border-bottom: 0; }
.crm-check { flex: 0 0 auto; width: 16px; height: 16px; accent-color: var(--green); cursor: pointer; }
.crm-selall { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--txt-2); padding: 6px 2px 8px; cursor: pointer; }
.crm-selall input { width: 16px; height: 16px; accent-color: var(--green); cursor: pointer; }
.crm-item {
  display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: left;
  padding: 11px 4px; border: 0; background: none; color: var(--txt); font: inherit; cursor: pointer;
}
.crm-item:hover { background: var(--panel-2); }

/* Barra de seleção múltipla (excluir em lote) */
.crm-selbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 10px; margin-bottom: 6px; border-radius: var(--radius-sm);
  background: var(--panel-2); border: 1px solid var(--line);
}
.crm-sel-count { font-size: 13px; font-weight: 600; color: var(--txt); }
.crm-selbar-actions { display: flex; gap: 8px; }
.crm-btn-danger { background: #e5484d; border: 1px solid #e5484d; color: #fff; }
.crm-btn-danger:hover { background: #d13d42; border-color: #d13d42; }
.crm-btn-danger:disabled { opacity: 0.6; cursor: default; }
.crm-avatar {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--txt-2);
}
.crm-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.crm-item-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-item-sub { font-size: 12px; color: var(--txt-3); margin-top: 2px; }
.crm-item-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.crm-tagchip { font-size: 10px; padding: 2px 7px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt-2); }

/* ── Campanhas: lista + relatório/ROI ────────────────────────────────────────── */
.crm-camp-list { list-style: none; margin: 0; padding: 0; }
.crm-camp-list li { border-bottom: 1px solid var(--line); }
.crm-camp-list li:last-child { border-bottom: 0; }
.crm-camp-list li.crm-empty { border-bottom: 0; }
.crm-camp-item {
  display: block; width: 100%; text-align: left; padding: 12px 4px;
  border: 0; background: none; color: var(--txt); font: inherit; cursor: pointer;
}
.crm-camp-item:hover { background: var(--panel-2); }
.crm-camp-name { font-weight: 600; font-size: 14px; }
.crm-camp-meta { font-size: 12px; color: var(--txt-3); margin-top: 3px; }
.crm-camp-title { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.crm-camp-sub { font-size: 12px; color: var(--txt-3); margin: 2px 0 6px; }
.crm-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 16px 0; }
.crm-stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.crm-stat-num { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.crm-stat-num.pos { color: var(--green); }
.crm-stat-lbl { font-size: 11px; color: var(--txt-3); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 5px; }
.crm-roi-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.crm-roi-box { flex: 1; min-width: 160px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.crm-roi-box .crm-stat-num { font-size: 20px; }

/* ── Ficha do contato (modal) ────────────────────────────────────────────────── */
.crm-modal-overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
.crm-modal {
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0; padding: 20px;
}
.crm-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.crm-modal-head h3 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.crm-modal-close { background: none; border: 0; color: var(--txt-3); font-size: 18px; cursor: pointer; line-height: 1; padding: 4px; }
.crm-modal-close:hover { color: var(--txt); }
.crm-detail .crm-field { margin-bottom: 14px; }
.crm-detail label { display: block; font-size: 12px; color: var(--txt-3); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.04em; }
.crm-detail .crm-val { font-size: 14px; color: var(--txt); word-break: break-word; }
.crm-detail input, .crm-detail textarea {
  width: 100%; padding: 9px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--txt); font: inherit;
}
.crm-detail input:focus, .crm-detail textarea:focus { border-color: var(--green-2); outline: none; }
.crm-detail textarea { min-height: 72px; resize: vertical; }
.crm-detail .crm-tags-view { display: flex; flex-wrap: wrap; gap: 5px; }

@media (min-width: 640px) {
  .crm-modal-overlay { align-items: center; }
  .crm-modal { border-radius: var(--radius); }
}

/* ── Pipeline (kanban) ───────────────────────────────────────────────────────── */
.crm-pipe-actions { display: flex; gap: 8px; align-items: center; }
.crm-pipe-select {
  padding: 7px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel-2); color: var(--txt); font: inherit; font-size: 13px;
}
.crm-board { display: flex; gap: 14px; overflow-x: auto; padding: 8px 2px 12px; align-items: flex-start; }
.crm-board .hint { margin: 0; }
.crm-col {
  flex: 0 0 264px; width: 264px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px;
}
.crm-col.is-drop { border-color: var(--green); box-shadow: 0 0 0 1px var(--green) inset; background: color-mix(in srgb, var(--green) 8%, var(--panel-2)); }
.crm-col-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.crm-col-name { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }
.crm-col-name.won { color: var(--green); }
.crm-col-name.lost { color: var(--txt-3); }
.crm-col-meta { font-size: 11px; color: var(--txt-3); white-space: nowrap; }
.crm-col-body { display: flex; flex-direction: column; gap: 9px; min-height: 96px; }
.crm-col-empty { font-size: 12px; color: var(--txt-3); padding: 10px 2px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }
.crm-deal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; cursor: grab; color: var(--txt); touch-action: none; user-select: none;
}
.crm-deal:hover { border-color: var(--green-2); }
.crm-deal.dragging { opacity: 0.35; cursor: grabbing; }
.crm-deal-ghost { position: fixed; z-index: 99; pointer-events: none; opacity: 0.95;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5); transform: rotate(1.5deg); cursor: grabbing; }
.crm-deal.won { border-left: 3px solid var(--green); }
.crm-deal.lost { border-left: 3px solid var(--txt-3); opacity: 0.72; }
.crm-deal-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-deal-contact { font-size: 11px; color: var(--txt-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-deal-val { font-size: 13px; font-weight: 700; margin-top: 5px; }
.crm-board-empty { text-align: center; padding: 8px 0 4px; }

/* ── Modal de negócio: busca de contato + seletor de situação ─────────────────── */
.crm-ac { position: relative; }
.crm-ac-list {
  position: absolute; left: 0; right: 0; top: 2px; z-index: 5;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  max-height: 200px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.crm-ac-item { display: block; width: 100%; text-align: left; padding: 9px 11px; border: 0;
  border-bottom: 1px solid var(--line); background: none; color: var(--txt); font: inherit; cursor: pointer; }
.crm-ac-item:last-child { border-bottom: 0; }
.crm-ac-item:hover { background: var(--panel-2); }
.crm-seg { display: flex; gap: 6px; }
.crm-seg-btn {
  flex: 1; padding: 8px 6px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel-2); color: var(--txt-2); font: inherit; font-size: 13px; cursor: pointer;
}
.crm-seg-btn.on { border-color: var(--green); color: var(--green); font-weight: 600; }
