.whatsapp-injected {
  display: inline-flex;
  align-items: center;
}

/* Mantém os atalhos da agenda visualmente separados da ação de edição. */
.row-action + .whatsapp-injected {
  margin-inline-start: .5rem;
}

.whatsapp-action {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: .42rem;
  white-space: nowrap;
}

.whatsapp-action span {
  color: #2f9288;
  font-size: .76rem;
}

.whatsapp-composer,
.whatsapp-settings {
  display: grid;
  gap: 1rem;
}

.modal-card.wide:has(.whatsapp-composer) {
  width: min(920px, calc(100vw - 32px));
  padding: clamp(1.25rem, 2.4vw, 2rem);
}

.modal-card.wide:has(.whatsapp-composer) > h2 {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.8rem !important;
  font-weight: 760;
  letter-spacing: -.035em;
}

.whatsapp-composer-intro,
.whatsapp-settings-intro {
  position: relative;
  overflow: hidden;
  border: 1px solid #d1e6e1;
  background:
    radial-gradient(circle at 88% 10%, rgba(240, 125, 87, .13), transparent 32%),
    linear-gradient(125deg, #eef9f6 0%, #fbfdfc 58%, #fff8f3 100%);
  box-shadow: 0 14px 36px rgba(31, 73, 71, .06);
}

.whatsapp-composer-intro {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  border-radius: 20px;
}

.whatsapp-composer-intro > span,
.whatsapp-settings-intro > span {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border: 1px solid rgba(37, 145, 132, .08);
  border-radius: 16px;
  background: linear-gradient(145deg, #dff3ee, #f1faf8);
  color: #177d73;
  font-size: 1.08rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
}

.whatsapp-composer-intro small,
.whatsapp-settings-intro small {
  display: block;
  margin-bottom: .28rem;
  color: #d96848;
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.whatsapp-composer-intro h3,
.whatsapp-settings-intro h3 {
  margin: 0;
  color: #15233d;
  font-size: 1.17rem;
  line-height: 1.25;
}

.whatsapp-composer-intro p,
.whatsapp-settings-intro p {
  margin: .3rem 0 0;
  color: #687b80;
  font-size: .9rem;
  line-height: 1.45;
}

.whatsapp-composer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: .9rem;
}

.whatsapp-composer label,
.whatsapp-settings label {
  display: grid;
  gap: .42rem;
  min-width: 0;
  color: #40545d;
  font-size: .82rem;
  font-weight: 750;
}

.whatsapp-composer select,
.whatsapp-composer textarea,
.whatsapp-settings input:not([type="checkbox"]),
.whatsapp-settings textarea {
  width: 100%;
  margin: 0;
  border: 1px solid #d5e1de;
  border-radius: 14px;
  background-color: #fff;
  color: #1c2b3e;
  font: inherit;
  font-size: .9rem;
  font-weight: 550;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(21, 45, 55, .025), inset 0 1px 0 rgba(255, 255, 255, .8);
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.whatsapp-composer select,
.whatsapp-settings input:not([type="checkbox"]) {
  min-height: 48px;
  padding: .75rem .9rem;
}

.whatsapp-composer select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.75rem;
  background-image:
    linear-gradient(45deg, transparent 50%, #537077 50%),
    linear-gradient(135deg, #537077 50%, transparent 50%);
  background-position:
    calc(100% - 19px) calc(50% - 2px),
    calc(100% - 14px) calc(50% - 2px);
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
  cursor: pointer;
}

.whatsapp-composer select:hover,
.whatsapp-composer textarea:hover,
.whatsapp-settings input:not([type="checkbox"]):hover,
.whatsapp-settings textarea:hover {
  border-color: #b9d2cd;
  background-color: #fdfefe;
}

.whatsapp-composer select:focus,
.whatsapp-composer textarea:focus,
.whatsapp-settings input:not([type="checkbox"]):focus,
.whatsapp-settings textarea:focus {
  outline: 0;
  border-color: #48a79d;
  box-shadow: 0 0 0 4px rgba(48, 150, 139, .13), 0 8px 22px rgba(30, 94, 88, .06);
}

.whatsapp-message-field {
  position: relative;
}

.whatsapp-message-field textarea,
.whatsapp-template-card textarea {
  padding: .9rem 1rem;
  resize: vertical;
}

.whatsapp-message-field textarea {
  min-height: 160px;
}

.whatsapp-message-field > small {
  display: block;
  margin-top: .35rem;
  color: #819096;
  font-size: .7rem;
  font-weight: 600;
  text-align: right;
}

.whatsapp-preview-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: #6d7f85;
  font-size: .76rem;
}

.whatsapp-honesty,
.whatsapp-history-note {
  display: flex;
  align-items: flex-start;
  gap: .72rem;
  padding: .82rem .95rem;
  border: 1px solid #f3ddd1;
  border-radius: 14px;
  background: #fff7f2;
  color: #765a50;
  font-size: .78rem;
  line-height: 1.45;
}

.whatsapp-honesty strong,
.whatsapp-history-note strong {
  white-space: nowrap;
  color: #c45e42;
}

.whatsapp-composer-actions {
  position: sticky;
  bottom: -.25rem;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: .65rem;
  flex-wrap: wrap;
  padding: .7rem 0 .1rem;
  background: linear-gradient(180deg, rgba(250, 249, 245, 0), #faf9f5 30%);
}

.whatsapp-composer-actions button {
  min-height: 44px;
  border-radius: 13px;
}

.whatsapp-after-open {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid #b9ded6;
  border-radius: 18px;
  background: #eff9f6;
}

.whatsapp-after-open div {
  display: grid;
  gap: .18rem;
}

.whatsapp-after-open strong { color: #18766e; }
.whatsapp-after-open span { color: #637a7c; font-size: .8rem; }

.whatsapp-no-phone {
  display: grid;
  justify-items: center;
  gap: .65rem;
  padding: 2rem;
  text-align: center;
}

.whatsapp-no-phone > span {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 22px;
  background: #e6f5f1;
  color: #25897f;
  font-size: 1.5rem;
}

.whatsapp-no-phone h3,
.whatsapp-no-phone p { margin: 0; }
.whatsapp-no-phone p { max-width: 480px; color: #6f7f84; }

.whatsapp-history-panel { display: grid; gap: 1rem; }
.whatsapp-history-list { display: grid; gap: .65rem; }

.whatsapp-history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .9rem;
  padding: 1rem;
  border: 1px solid #e1e9e6;
  border-radius: 18px;
  background: #fff;
}

.whatsapp-history-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: #e8f6f2;
  color: #258d82;
}

.whatsapp-history-item div { display: grid; gap: .16rem; }
.whatsapp-history-item small { color: #74858a; }

.whatsapp-history-status {
  padding: .38rem .65rem;
  border-radius: 999px;
  background: #fff0e5;
  color: #ad613f;
  font-size: .7rem;
  font-weight: 800;
}

.whatsapp-history-status.confirmed_sent { background: #dff2ec; color: #19766d; }

.whatsapp-settings-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.3rem;
  border-radius: 20px;
}

.whatsapp-general-settings {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(160px, 210px) auto;
  align-items: end;
  gap: 1rem;
  padding: 1.15rem;
}

.whatsapp-settings .check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: .7rem;
  cursor: pointer;
  user-select: none;
}

.whatsapp-settings .check input[type="checkbox"] {
  appearance: none !important;
  -webkit-appearance: none !important;
  position: relative;
  width: 42px !important;
  min-width: 42px;
  height: 24px !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: #cbd8d5 !important;
  box-shadow: inset 0 1px 3px rgba(25, 55, 60, .14) !important;
  cursor: pointer;
  transition: background-color .2s ease, box-shadow .2s ease;
}

.whatsapp-settings .check input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(20, 54, 60, .22);
  transition: transform .2s ease;
}

.whatsapp-settings .check input[type="checkbox"]:checked {
  background: #2f968b !important;
}

.whatsapp-settings .check input[type="checkbox"]:checked::before {
  transform: translateX(18px);
}

.whatsapp-settings .check input[type="checkbox"]:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 4px rgba(47, 150, 139, .16), inset 0 1px 3px rgba(25, 55, 60, .12) !important;
}

.whatsapp-general-settings .check {
  align-self: center;
}

.whatsapp-general-settings .check span {
  display: grid;
  gap: .12rem;
  line-height: 1.25;
}

.whatsapp-general-settings .check strong,
.whatsapp-general-settings .check small {
  display: block;
}

.whatsapp-general-settings .check small,
.whatsapp-general-settings label > small {
  color: #74868b;
  font-size: .7rem;
  font-weight: 550;
}

.whatsapp-general-settings button { min-height: 48px; margin: 0; border-radius: 14px; }

.whatsapp-variable-guide {
  padding: .85rem 1rem;
  border: 1px dashed #cadbd7;
  border-radius: 16px;
  background: rgba(255, 255, 255, .58);
  color: #687b80;
  font-size: .76rem;
}

.whatsapp-variable-guide strong {
  display: block;
  margin-bottom: .48rem;
  color: #334951;
}

.whatsapp-variable-guide span {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}

.whatsapp-variable-guide code {
  padding: .34rem .55rem;
  border: 1px solid #d7e7e3;
  border-radius: 999px;
  background: #eff8f5;
  color: #277b73;
  font-family: inherit;
  font-size: .7rem;
  font-weight: 750;
}

.whatsapp-template-filter {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  width: fit-content;
  max-width: 100%;
  padding: .3rem;
  border: 1px solid #dce8e5;
  border-radius: 16px;
  background: rgba(255, 255, 255, .72);
}

.whatsapp-template-filter button {
  min-height: 38px;
  padding: .58rem .78rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #65777d;
  font: inherit;
  font-size: .75rem;
  font-weight: 750;
  transition: background-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.whatsapp-template-filter button:hover {
  background: #edf6f3;
  color: #277d74;
}

.whatsapp-template-filter button.active {
  background: #2f9187;
  color: #fff;
  box-shadow: 0 7px 18px rgba(47, 145, 135, .18);
}

.whatsapp-template-filter button:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 4px rgba(47, 150, 139, .16);
}

.whatsapp-template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.whatsapp-template-card {
  display: grid;
  gap: .85rem;
  min-width: 0;
  padding: 1.15rem;
  border: 1px solid #dce7e4;
  border-radius: 20px;
  background: linear-gradient(155deg, #fff, #fcfdfd);
  box-shadow: 0 12px 34px rgba(22, 49, 52, .045);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.whatsapp-template-card:hover {
  transform: translateY(-2px);
  border-color: #c8dcd7;
  box-shadow: 0 16px 38px rgba(22, 49, 52, .07);
}

.whatsapp-template-card > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
}

.whatsapp-template-card > div:first-child > span {
  color: #d66d4e;
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.whatsapp-template-card textarea {
  min-height: 132px;
  line-height: 1.5;
}

.whatsapp-template-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .6rem;
  flex-wrap: wrap;
}

.whatsapp-template-actions small {
  margin-right: auto;
  color: #809095;
  font-size: .7rem;
}

.whatsapp-template-actions button {
  min-height: 40px;
  border-radius: 12px;
}

.integration-panel div b { white-space: nowrap; }

@media (max-width: 800px) {
  .whatsapp-composer-grid,
  .whatsapp-template-grid,
  .whatsapp-general-settings { grid-template-columns: 1fr; }

  .whatsapp-preview-meta,
  .whatsapp-after-open { align-items: flex-start; flex-direction: column; }

  .whatsapp-composer-actions { position: static; background: transparent; }
  .whatsapp-composer-actions > * { flex: 1 1 100%; }
  .whatsapp-history-item { grid-template-columns: auto 1fr; }
  .whatsapp-history-status { grid-column: 2; justify-self: start; }
}

@media (max-width: 520px) {
  .modal-card.wide:has(.whatsapp-composer) { width: calc(100vw - 16px); padding: 1rem; }
  .whatsapp-composer-intro { align-items: flex-start; padding: 1rem; }
  .whatsapp-composer-intro > span { width: 44px; height: 44px; flex-basis: 44px; border-radius: 14px; }
  .whatsapp-composer-intro h3 { font-size: 1.05rem; }
  .whatsapp-preview-meta { gap: .35rem; }
  .whatsapp-honesty { display: grid; gap: .25rem; }
}
