/* Helio WhatsApp module — layout tipo bandeja + canales */
.wa-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: calc(100vh - 140px);
}
.wa-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.wa-head-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #25d366;
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
}
.wa-head h3 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1.25rem;
}
.wa-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 62ch;
}

.wa-channels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.wa-channel {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--panel);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.wa-channel:hover { border-color: #25d36688; }
.wa-channel.active {
  border-color: #25d366;
  box-shadow: 0 0 0 1px #25d36655, 0 8px 20px rgba(37, 211, 102, 0.12);
}
.wa-channel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.wa-channel strong { font-size: 0.98rem; }
.wa-badge {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8f8ef;
  color: #128c7e;
}
.wa-badge.off { background: #f1f5f9; color: #64748b; }
.wa-channel small { color: var(--muted); font-size: 0.8rem; line-height: 1.35; display: block; }

.wa-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 14px;
  align-items: stretch;
  min-height: 520px;
}
.wa-workspace-full {
  grid-template-columns: 1fr;
}
@media (max-width: 980px) {
  .wa-workspace { grid-template-columns: 1fr; }
}

.wa-main, .wa-side {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 480px;
}

.wa-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 10px 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft, #f8fafc);
}
.wa-tab {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted, #64748b);
  border-radius: 10px 10px 0 0;
  cursor: pointer;
}
.wa-tab.active {
  background: var(--panel, #fff);
  color: var(--ink, #0f172a);
  box-shadow: none;
  border: 1px solid var(--line);
  border-bottom-color: var(--panel, #fff);
}
.wa-tab-config {
  margin-left: auto;
  color: #0f766e;
}
.wa-tab-config:hover {
  color: #0f172a;
  background: #ecfeff;
}

.wa-config-drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}
.wa-config-drawer.is-open {
  pointer-events: auto;
}
.wa-config-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.wa-config-drawer.is-open .wa-config-backdrop {
  opacity: 1;
}
.wa-config-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(420px, 100vw);
  background: #fff;
  border-left: 1px solid var(--line, #e2e8f0);
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}
.wa-config-drawer.is-open .wa-config-panel {
  transform: translateX(0);
}
.wa-config-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line, #e2e8f0);
}
.wa-config-head h4 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}
.wa-config-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 18px 28px;
}
.wa-config-section {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-subtle, #eef2f7);
}
.wa-config-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}
.wa-config-section h5 {
  margin: 0 0 8px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #0f172a;
}
.wa-config-panel-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.wa-config-panel-body .btn {
  width: 100%;
  justify-content: center;
}
.wa-config-panel-body .wa-qr-box {
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 16px;
  text-align: center;
}
.wa-config-panel-body .wa-qr-box img {
  display: block;
  width: 100%;
  height: auto;
}
.wa-config-panel-body h5 {
  margin: 0;
  font-size: 0.95rem;
}
.wa-config-hr {
  border: 0;
  border-top: 1px solid var(--line, #e2e8f0);
  margin: 4px 0;
}
.wa-config-msg { margin: 0; text-align: center; }
.wa-config-ok {
  margin: 0;
  font-weight: 700;
  color: #15803d;
  font-size: 1rem;
}

.wa-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wa-pane-body { flex: 1; min-height: 0; padding: 12px; overflow: auto; }

.wa-chat-layout {
  display: grid;
  grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
  gap: 0;
  height: 100%;
  min-height: 420px;
}
@media (max-width: 700px) {
  .wa-chat-layout { grid-template-columns: 1fr; }
}
.wa-chat-list {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fafbfc;
}
.wa-chat-list input {
  margin: 10px;
  width: calc(100% - 20px);
}
.wa-chat-items { overflow: auto; flex: 1; }
.wa-chat-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  border: 0;
  width: 100%;
  background: transparent;
  text-align: left;
  border-bottom: 1px solid var(--line-subtle);
}
.wa-chat-item:hover, .wa-chat-item.active { background: #e8f7fa; }
.wa-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.wa-chat-item strong {
  display: block;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-chat-item span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-chat-item time { font-size: 0.68rem; color: var(--muted); }
.wa-unread {
  background: #25d366;
  color: #fff;
  border-radius: 999px;
  font-size: 0.65rem;
  padding: 1px 6px;
  font-weight: 700;
}

.wa-thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #ece5dd;
}
.wa-thread-head {
  padding: 10px 14px;
  background: #f0f2f5;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.wa-thread-msgs {
  flex: 1;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wa-bubble {
  max-width: min(78%, 420px);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-data);
}
.wa-bubble.in {
  align-self: flex-start;
  background: #fff;
  border-top-left-radius: 2px;
}
.wa-bubble.out {
  align-self: flex-end;
  background: #d9fdd3;
  border-top-right-radius: 2px;
}
.wa-bubble small {
  display: block;
  margin-top: 4px;
  font-size: 0.68rem;
  color: #64748b;
  text-align: right;
}
.wa-thread-empty {
  margin: auto;
  text-align: center;
  color: #475569;
  background: rgba(255,255,255,0.75);
  padding: 16px 20px;
  border-radius: 12px;
  max-width: 280px;
}
.wa-composer {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #f0f2f5;
  border-top: 1px solid var(--line);
}
.wa-composer input { flex: 1; }
.wa-composer .btn { flex-shrink: 0; }

.wa-side { padding: 0; }
.wa-side-inner { padding: 16px; display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.wa-side h4 { margin: 0 0 4px; font-size: 1rem; }
.wa-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: #e8f8ef;
  color: #0f5c45;
}
.wa-status-pill.warn { background: #fff8ed; color: #7a4e12; }
.wa-status-pill.bad { background: #fdf2f2; color: #8a2e2e; }
.wa-phone-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
}
.wa-phone-card strong { display: block; font-family: var(--font-data); }
.wa-side .btn { width: 100%; justify-content: center; }
.wa-qr-box {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  background: #fff;
  min-height: 120px;
}
.wa-qr-box img { max-width: 220px; width: 100%; height: auto; }
.wa-muted { color: var(--muted); font-size: 0.8rem; }

.wa-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; font-family: var(--font-data); }
.wa-table th, .wa-table td { padding: 10px 8px; border-bottom: 1px solid var(--line-subtle); text-align: left; vertical-align: top; }
.wa-table th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: #64748b; }

.wa-plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.wa-plan {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}
.wa-plan.current { border-color: #25d366; background: #f3fcf6; }
.wa-plan h5 { margin: 0 0 6px; }
.wa-plan ul { margin: 8px 0 0; padding-left: 18px; color: #475569; font-size: 0.82rem; }
.wa-form-grid { display: grid; gap: 10px; }
.wa-form-grid label { display: grid; gap: 4px; font-size: 0.82rem; font-weight: 600; }
.wa-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

/* ── Dark mode WhatsApp ── */
html[data-theme="dark"] .wa-badge {
  background: rgba(37, 211, 102, 0.18);
  color: #6ee7b7;
}
html[data-theme="dark"] .wa-badge.off {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}
html[data-theme="dark"] .wa-tab-config { color: #5eead4; }
html[data-theme="dark"] .wa-tab-config:hover {
  color: var(--ink);
  background: rgba(0, 195, 255, 0.1);
}
html[data-theme="dark"] .wa-config-panel {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
}
html[data-theme="dark"] .wa-config-section h5,
html[data-theme="dark"] .wa-config-head h4 {
  color: var(--ink);
}
html[data-theme="dark"] .wa-config-panel-body .wa-qr-box,
html[data-theme="dark"] .wa-qr-box {
  background: #fff; /* QR needs light canvas */
  border-color: var(--line);
}
html[data-theme="dark"] .wa-config-ok { color: #6ee7b7; }
html[data-theme="dark"] .wa-chat-list {
  background: var(--panel-soft);
}
html[data-theme="dark"] .wa-chat-item:hover,
html[data-theme="dark"] .wa-chat-item.active {
  background: rgba(0, 195, 255, 0.1);
}
html[data-theme="dark"] .wa-thread {
  background: #1a2834;
}
html[data-theme="dark"] .wa-thread-head,
html[data-theme="dark"] .wa-composer {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="dark"] .wa-bubble.in {
  background: var(--panel);
  color: var(--ink);
}
html[data-theme="dark"] .wa-bubble.out {
  background: #1f4d3a;
  color: #e8f5ef;
}
html[data-theme="dark"] .wa-bubble small { color: var(--muted); }
html[data-theme="dark"] .wa-thread-empty {
  color: var(--muted);
  background: rgba(19, 34, 48, 0.85);
}
html[data-theme="dark"] .wa-status-pill {
  background: rgba(37, 211, 102, 0.18);
  color: #a7f3d0;
}
html[data-theme="dark"] .wa-status-pill.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}
html[data-theme="dark"] .wa-status-pill.bad {
  background: var(--danger-bg);
  color: var(--danger-text);
}
html[data-theme="dark"] .wa-phone-card,
html[data-theme="dark"] .wa-plan {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="dark"] .wa-plan.current {
  background: rgba(37, 211, 102, 0.12);
  border-color: #25d366;
}
html[data-theme="dark"] .wa-plan ul { color: var(--muted); }
html[data-theme="dark"] .wa-table th { color: var(--muted); }

/* ── WhatsApp flotante estilo celular ── */
#wa-float-root {
  position: fixed;
  right: 18px;
  bottom: 88px;
  z-index: 55;
  width: min(340px, calc(100vw - 24px));
  pointer-events: none;
}
.wa-phone {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  height: min(640px, calc(100vh - 100px));
  background: #111b21;
  border: 3px solid #1f2c34;
  border-radius: 28px;
  overflow: hidden;
  box-shadow:
    0 22px 50px rgba(15, 23, 42, 0.35),
    inset 0 0 0 1px rgba(255,255,255,0.06);
  animation: wa-float-in 0.2s ease;
  position: relative;
}
.wa-phone[hidden] { display: none !important; }
.wa-phone-notch {
  height: 10px;
  flex: 0 0 auto;
  background: #111b21;
  position: relative;
}
.wa-phone-notch::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 4px;
  transform: translateX(-50%);
  width: 72px;
  height: 5px;
  border-radius: 999px;
  background: #0b141a;
}
.wa-phone-home {
  height: 14px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: #111b21;
}
.wa-phone-home::after {
  content: "";
  width: 86px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
}
@keyframes wa-float-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
.wa-float-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #075E54;
  color: #fff;
  flex: 0 0 auto;
}
.wa-float-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.wa-float-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #25D366;
  box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.25);
  flex-shrink: 0;
}
.wa-float-head strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.15;
}
.wa-float-head small {
  display: block;
  opacity: 0.85;
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.wa-float-icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
}
.wa-float-back-btn { font-size: 1.5rem; font-weight: 700; }
.wa-float-icon-btn:hover { background: rgba(255,255,255,0.22); }
.wa-float-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.wa-float-search {
  padding: 8px 10px;
  background: #f0f2f5;
  border-bottom: 1px solid #e4e7ec;
}
.wa-float-search input {
  width: 100%;
  border: 0;
  border-radius: 999px;
  background: #fff;
  padding: 8px 12px;
  font-size: 0.86rem;
}
.wa-float-list {
  overflow: auto;
  flex: 1;
  background: #fff;
}
.wa-float-chat {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 8px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid #f1f5f9;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  cursor: pointer;
  color: #0f172a;
}
.wa-float-chat:hover { background: #f8fafc; }
.wa-float-chat-meta { min-width: 0; }
.wa-float-chat-meta strong,
.wa-float-chat-meta span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-float-chat-meta span {
  font-size: 0.75rem;
  color: #64748b;
}
.wa-float-chat-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.wa-float-chat time {
  font-size: 0.68rem;
  color: #94a3b8;
}
.wa-float-thread {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: #ece5dd;
}
.wa-float-msgs {
  flex: 1;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wa-float-composer {
  background: #f0f2f5;
  padding: 8px;
}
.wa-float-composer input {
  border-radius: 999px !important;
}
.wa-float-composer .btn {
  border-radius: 999px;
  min-width: 42px;
  padding-inline: 0;
}
.wa-float-link {
  padding: 18px 16px;
  text-align: center;
  display: grid;
  gap: 12px;
  place-items: center;
  color: #0f172a;
}
.wa-float-qr {
  width: min(220px, 100%);
  aspect-ratio: 1;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  display: grid;
  place-items: center;
  padding: 10px;
}
.wa-float-qr img {
  width: 100%;
  height: auto;
  display: block;
}
html[data-theme="dark"] .wa-float-body,
html[data-theme="dark"] .wa-float-list {
  background: #0b141a;
  color: #e8f4fa;
}
html[data-theme="dark"] .wa-float-search {
  background: #111b21;
  border-color: #1f2c34;
}
html[data-theme="dark"] .wa-float-chat {
  color: #e8f4fa;
  border-color: #1f2c34;
}
html[data-theme="dark"] .wa-float-chat:hover { background: #15202b; }
html[data-theme="dark"] .wa-float-thread { background: #0b141a; }
html[data-theme="dark"] .wa-float-composer { background: #111b21; }
html[data-theme="dark"] .wa-float-link { color: #e8f4fa; }
.dash-fab-wa.is-open {
  transform: rotate(45deg) scale(1.02);
  background: #128C7E;
}
@media (max-width: 720px) {
  #wa-float-root {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: 78px;
  }
  .wa-phone {
    height: min(70vh, 620px);
    border-radius: 22px;
  }
}
