/* ============================================================
   ChatSend — Tema escuro estilo WhatsApp Web
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-body:        #111b21;
  --bg-sidebar:     #111b21;
  --bg-sidebar-hdr: #202c33;
  --bg-panel:       #0b141a;
  --bg-chat:        #0b141a;
  --bg-bubble-out:  #005c4b;
  --bg-bubble-in:   #202c33;
  --bg-input:       #202c33;
  --bg-hover:       #2a3942;
  --bg-active:      #2a3942;
  --bg-modal:       #233138;
  --text-primary:   #e9edef;
  --text-secondary: #8696a0;
  --text-muted:     #667781;
  --border:         #2a3942;
  --green:          #00a884;
  --green-light:    #25d366;
  --red:            #f15c6d;
  --yellow:         #ffd60a;
  --radius:         8px;
  --transition:     .15s ease;
  --font:           'Segoe UI', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.4;
  overflow: hidden;
}

.hidden { display: none !important; }

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout principal ───────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Nav lateral (ícones) ───────────────────────────────────── */
.nav-icons {
  width: 56px;
  background: var(--bg-sidebar-hdr);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-icons a {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 20px;
  transition: background var(--transition), color var(--transition);
}
.nav-icons a:hover, .nav-icons a.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}
.nav-icons a.active { color: var(--green); }
.nav-icons .spacer { flex: 1; }

/* ── Painel esquerdo (lista de conversas) ───────────────────── */
.sidebar {
  width: 360px;
  min-width: 280px;
  max-width: 400px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-header {
  background: var(--bg-sidebar-hdr);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
}
.sidebar-header h1 {
  font-size: 19px;
  font-weight: 600;
  flex: 1;
}
.sidebar-filters {
  padding: 0 12px 8px;
  background: var(--bg-sidebar-hdr);
  border-bottom: 1px solid var(--border);
}
.sidebar-filter {
  width: 100%;
  font-size: 12px;
  padding: 6px 10px;
}
.sidebar-search {
  padding: 8px 12px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
}
.sidebar-search input {
  width: 100%;
  background: var(--bg-input);
  border: none;
  border-radius: 8px;
  padding: 9px 14px 9px 38px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%238696a0' viewBox='0 0 24 24'%3E%3Cpath d='M21 21l-4.35-4.35M17 11A6 6 0 1 1 5 11a6 6 0 0 1 12 0z' stroke='%238696a0' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 18px;
}
.sidebar-search input::placeholder { color: var(--text-muted); }

.conv-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.conv-list::-webkit-scrollbar { width: 6px; }
.conv-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.conv-row {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  width: 100%;
  isolation: isolate;
}

.conv-actions {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
  background: var(--red);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(100%);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}
.conv-row.is-open .conv-actions {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
}

.conv-action-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}
.conv-action-btn:hover {
  background: rgba(0, 0, 0, 0.28);
  transform: scale(1.05);
}

.conv-slide {
  position: relative;
  z-index: 1;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: transform 0.22s ease, background var(--transition);
  touch-action: pan-y;
  cursor: pointer;
  user-select: none;
  background: var(--bg-sidebar);
  will-change: transform;
}
.conv-slide::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: inherit;
}
.conv-row.is-open .conv-slide {
  transform: translateX(-72px);
}
.conv-slide:hover { background: var(--bg-hover); }
.conv-slide.active { background: var(--bg-active); }

/* Prospecto (padrão) / etiquetas — cor aplicada via JS */
.conv-slide.conv-item--prospect,
.conv-slide.conv-item--tagged {
  padding-left: 12px;
  border-left-width: 4px;
  border-left-style: solid;
}
.conv-slide.conv-item--prospect {
  border-left-color: #4a90e2;
}

/* Conversa com mensagens não lidas */
.conv-slide.conv-item--unread {
  background-color: #152622;
  animation: conv-unread-pulse 2.5s ease-in-out infinite;
}
.conv-slide.conv-item--unread:hover { background-color: #1a2e28; }
.conv-slide.conv-item--unread.active {
  background-color: #1a332e;
  animation: none;
}

/* Conversa aberta mas última msg é do cliente — aguardando resposta */
.conv-slide.conv-item--awaiting-reply {
  background-color: #2a2418;
}
.conv-slide.conv-item--awaiting-reply:hover { background-color: #302a1c; }

@keyframes conv-unread-pulse {
  0%, 100% { background-color: #152622; }
  50%      { background-color: #1a332e; }
}

.avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--bg-input);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  overflow: hidden;
  color: var(--text-secondary);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.conv-info { flex: 1; min-width: 0; }
.conv-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
}
.conv-name {
  font-weight: 500;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-name--highlight { font-weight: 700; color: var(--text-primary); }
.conv-time { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.conv-time--unread { color: var(--green); font-weight: 700; }
.conv-bottom { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.conv-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.conv-preview--highlight { color: var(--text-primary); font-weight: 500; }
.conv-badges { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.badge-instance {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
  color: #fff;
}
.badge-unread {
  position: relative;
  background: var(--green);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  flex-shrink: 0;
}
.badge-unread--pulse {
  animation: badge-glow 2s ease-in-out infinite;
}
.badge-unread-ping {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--green);
  animation: badge-ping 1.6s cubic-bezier(0, 0, 0.2, 1) infinite;
  pointer-events: none;
}
.badge-unread-count {
  position: relative;
  z-index: 1;
  line-height: 1;
}
.badge-awaiting {
  background: #ff9800;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: badge-glow-orange 2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes badge-ping {
  0%   { transform: scale(1); opacity: 0.8; }
  75%  { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}
@keyframes badge-glow {
  0%, 100% { box-shadow: 0 0 4px rgba(0, 168, 132, 0.5); }
  50%      { box-shadow: 0 0 12px rgba(0, 168, 132, 0.95), 0 0 20px rgba(0, 168, 132, 0.35); }
}
@keyframes badge-glow-orange {
  0%, 100% { box-shadow: 0 0 4px rgba(255, 152, 0, 0.5); }
  50%      { box-shadow: 0 0 12px rgba(255, 152, 0, 0.9), 0 0 18px rgba(255, 152, 0, 0.35); }
}

/* ── Painel direito (chat) ──────────────────────────────────── */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
  min-width: 0;
  position: relative;
}
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 12px;
}
.chat-empty .icon { font-size: 64px; opacity: .4; }
.chat-empty p { font-size: 15px; }

.chat-header {
  background: var(--bg-sidebar-hdr);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 25;
  overflow: visible;
}
.chat-header .avatar { width: 40px; height: 40px; font-size: 16px; }
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-weight: 600; font-size: 16px; }
.chat-header-sub { font-size: 12px; color: var(--text-secondary); }
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.chat-qual-strip {
  width: 4px;
  height: 36px;
  border-radius: 4px;
  flex-shrink: 0;
  background: #4a90e2;
}
.chat-tags-menu {
  position: relative;
}
.chat-tags-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  max-width: 280px;
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
  z-index: 100;
  overflow: hidden;
}
.chat-tags-dropdown.is-saving {
  opacity: 0.7;
  pointer-events: none;
}
.chat-tags-dropdown-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  max-height: 260px;
  overflow-y: auto;
}
.chat-tags-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}
.chat-tags-dropdown-item:hover { background: var(--bg-hover); }
.chat-tags-dropdown-item input {
  accent-color: var(--green);
  flex-shrink: 0;
}
.chat-tags-dropdown-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chat-tags-dropdown-name {
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}
.chat-tags-dropdown-empty {
  margin: 0;
  padding: 14px 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.45;
}

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23182229' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.messages-area::-webkit-scrollbar { width: 6px; }
.messages-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Agrupador de data */
.date-divider {
  text-align: center;
  margin: 8px 0;
}
.date-divider span {
  background: var(--bg-modal);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 8px;
}

/* Bolhas — linha com swipe */
.msg-row {
  position: relative;
  overflow: hidden;
  margin: 2px 0;
  width: 100%;
  isolation: isolate;
}

.msg-actions {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%) translateX(calc(100% + 24px));
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}
.msg-row.is-open .msg-actions {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}
.msg-action-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.msg-action-btn:hover { transform: scale(1.06); }
.msg-action-btn:active { transform: scale(0.96); }
.msg-action-details { background: #54656f; }
.msg-action-delete  { background: var(--red); }

.msg-slide {
  position: relative;
  z-index: 1;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  transition: transform 0.22s ease;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  background: var(--bg-chat);
  will-change: transform;
}
.msg-slide::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg-chat);
  z-index: -1;
  pointer-events: none;
}
.msg-row.is-open .msg-slide {
  transform: translateX(-88px);
}
.msg-row--out .msg-slide { justify-content: flex-end; }
.msg-row--in  .msg-slide { justify-content: flex-start; }
.msg-slide:active { cursor: grabbing; }
.msg-slide > .msg-wrap {
  max-width: 78%;
  width: 100%;
}

.msg-wrap {
  display: flex;
  margin: 0;
}
.msg-wrap.out { justify-content: flex-end; }
.msg-wrap.in  { justify-content: flex-start; }

/* Mensagens recebidas aguardando resposta */
.msg-row--needs-reply .msg-wrap--needs-reply .bubble {
  box-shadow:
    0 0 0 2px rgba(255, 152, 0, 0.55),
    0 2px 14px rgba(255, 152, 0, 0.2);
  animation: msg-needs-reply 2.5s ease-in-out infinite;
  position: relative;
  z-index: 1;
}
.msg-row--needs-reply .msg-wrap--needs-reply::before {
  content: 'Aguardando resposta';
  display: block;
  width: 100%;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #ff9800;
  margin-bottom: 4px;
  padding-left: 4px;
  opacity: 0.9;
}
.msg-row--needs-reply .msg-wrap--needs-reply {
  flex-direction: column;
  align-items: flex-start;
}
@keyframes msg-needs-reply {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 152, 0, 0.45), 0 2px 10px rgba(255, 152, 0, 0.12); }
  50%      { box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.75), 0 0 18px rgba(255, 152, 0, 0.28); }
}

.bubble {
  max-width: 65%;
  padding: 7px 10px 5px;
  border-radius: 8px;
  position: relative;
  word-break: break-word;
}
.msg-wrap.out .bubble {
  background: var(--bg-bubble-out);
  border-bottom-right-radius: 2px;
}
.msg-wrap.in .bubble {
  background: var(--bg-bubble-in);
  border-bottom-left-radius: 2px;
}
.bubble-text { font-size: 14.5px; line-height: 1.45; word-break: break-word; }
.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 3px;
}
.bubble-time { font-size: 11px; color: var(--text-muted); }
.bubble-status { font-size: 13px; color: var(--text-muted); }
.bubble-status.read { color: #53bdeb; }

/* Mídia dentro das bolhas */
.bubble-image {
  max-width: 280px;
  max-height: 280px;
  border-radius: 6px;
  cursor: zoom-in;
  display: block;
  margin-bottom: 4px;
}
.bubble-audio { width: 220px; margin-bottom: 4px; }
.bubble-audio audio { width: 100%; position: relative; z-index: 2; pointer-events: auto; }
.bubble-video { margin-bottom: 4px; }
.bubble-video video { display: block; position: relative; z-index: 2; pointer-events: auto; }
.bubble-document {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,.06);
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
}
.bubble-document .doc-icon { font-size: 28px; }

/* ── Barra de input ─────────────────────────────────────────── */
.chat-input-area {
  background: var(--bg-sidebar-hdr);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.input-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.input-actions-left  { margin-right: 2px; }
.input-actions-right { margin-left: 2px; }

.btn-icon {
  width: 40px; height: 40px;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
  padding: 0;
}
.btn-icon-sm { width: 32px; height: 32px; font-size: 14px; }
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon.active { background: rgba(0,168,132,.18); color: var(--green); }
.btn-icon.recording { color: var(--red); animation: pulse 1s infinite; }
.btn-icon label,
label.btn-icon { cursor: pointer; margin: 0; }

@keyframes pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .4; }
}

.chat-input-field {
  flex: 1;
  position: relative;
  min-width: 0;
}

.chat-input-wrap {
  background: var(--bg-input);
  border-radius: 24px;
  padding: 10px 16px;
  min-height: 44px;
  max-height: 120px;
  overflow-y: auto;
  display: flex;
  align-items: center;
  position: relative;
}
.chat-input-wrap::-webkit-scrollbar { width: 4px; }
.chat-input-wrap::-webkit-scrollbar-thumb { background: var(--border); }

#msg-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  resize: none;
  min-height: 22px;
  max-height: 100px;
  line-height: 1.4;
  padding: 0;
}
#msg-input::placeholder { color: var(--text-muted); }

.btn-send {
  width: 44px; height: 44px;
  background: var(--green);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
  padding: 0;
}
.btn-send:hover { background: var(--green-light); box-shadow: 0 4px 12px rgba(0,168,132,.35); }

/* Template picker (popover) */
.template-picker {
  position: absolute;
  bottom: 72px;
  left: 72px;
  width: min(320px, calc(100vw - 120px));
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  z-index: 200;
  overflow: hidden;
}
.template-picker.hidden { display: none; }
.template-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.template-picker-list {
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
}
.template-picker-list::-webkit-scrollbar { width: 5px; }
.template-picker-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.template-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background var(--transition);
  color: var(--text-primary);
  font-family: var(--font);
}
.template-item:hover { background: var(--bg-hover); }
.template-item-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}
.template-item-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.template-empty {
  padding: 20px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Preview de arquivo para envio */
.attach-preview {
  background: var(--bg-modal);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 16px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.attach-preview img { height: 48px; border-radius: 4px; }
.attach-preview .remove { margin-left: auto; cursor: pointer; color: var(--text-muted); font-size: 18px; }
.attach-preview.hidden { display: none; }

/* ── Modal lightbox ─────────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 6px;
}
.lightbox-close {
  position: absolute;
  top: 16px; right: 20px;
  font-size: 32px;
  color: #fff;
  cursor: pointer;
  line-height: 1;
}

/* ── Modal de confirmação (fluxo) ───────────────────────────── */
.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}
.confirm-modal.open {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}
.confirm-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.confirm-modal-dialog {
  position: relative;
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px 22px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .55);
  text-align: center;
  transform: scale(.88) translateY(16px);
  opacity: 0;
  transition: transform .32s cubic-bezier(.34, 1.4, .64, 1), opacity .22s ease;
}
.confirm-modal.open .confirm-modal-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}
.confirm-modal-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(0, 168, 132, .15);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-modal-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}
.confirm-modal-text {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.confirm-modal-text strong {
  color: var(--green);
  font-weight: 600;
}
.confirm-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.confirm-modal-actions .btn {
  flex: 1;
  min-width: 0;
  padding: 10px 16px;
  font-size: 14px;
}
.confirm-modal-icon--danger {
  background: rgba(234, 67, 53, .15);
  color: var(--red);
}

/* Detalhes da mensagem */
.msg-details-dialog { text-align: left; max-width: 420px; }
.msg-details-list { margin: 0 0 20px; }
.msg-details-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.msg-details-row:last-child { border-bottom: none; }
.msg-details-label {
  color: var(--text-muted);
  font-weight: 500;
}
.msg-details-value {
  color: var(--text-primary);
  word-break: break-word;
}

/* ── Settings page ──────────────────────────────────────────── */
.settings-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px;
  gap: 24px;
}
.settings-page h2 { font-size: 18px; font-weight: 600; color: var(--text-primary); }

.card {
  background: var(--bg-modal);
  border-radius: var(--radius);
  padding: 20px;
}
.card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* Tabela de instâncias */
.instances-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.instances-table th,
.instances-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.instances-table th {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.instances-table tr:last-child td { border-bottom: none; }
.instances-table tr:hover td { background: rgba(255,255,255,.03); }

.color-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

/* Formulário */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--green);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group input[type="color"] {
  padding: 3px 6px;
  height: 38px;
  cursor: pointer;
}

.btn {
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity var(--transition), background var(--transition);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--green-light); }
.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled)  { opacity: .85; }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }
.btn-sm { padding: 5px 11px; font-size: 13px; }

/* ── Envios page ────────────────────────────────────────────── */
.envios-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px;
  gap: 20px;
}

/* Cards de stats — linha horizontal, largura total */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
}
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
.stat-card {
  background: var(--bg-modal);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  min-width: 0;
}
.stat-card .stat-val {
  font-size: 28px;
  font-weight: 700;
  color: var(--green);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}
.stat-card.red .stat-val   { color: var(--red); }
.stat-card.yellow .stat-val { color: var(--yellow); }

/* Termômetro por chip */
.chips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.chip-card {
  background: var(--bg-modal);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.chip-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.chip-badge {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chip-name { font-weight: 500; font-size: 14px; }
.chip-phone { font-size: 12px; color: var(--text-secondary); margin-left: auto; }
.thermometer-wrap {
  background: var(--bg-input);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 6px;
}
.thermometer-bar {
  height: 100%;
  border-radius: 4px;
  transition: width .5s ease, background .5s ease;
}
.chip-count { font-size: 12px; color: var(--text-secondary); text-align: right; }

/* Histórico de campanhas */
.campaign-list { display: flex; flex-direction: column; gap: 8px; }
.campaign-item {
  background: var(--bg-input);
  border-radius: 6px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background var(--transition);
}
.campaign-item:hover { background: var(--bg-hover); }
.campaign-item.selected { border-left: 3px solid var(--green); }
.campaign-item-info { flex: 1; min-width: 0; }
.campaign-item-name { font-weight: 500; font-size: 14px; }
.campaign-item-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.status-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge.draft         { background: #3d4450; color: #aaa; }
.status-badge.verifying     { background: #2d3d50; color: #7ab3e0; }
.status-badge.queued        { background: #2d4030; color: #7ed87e; }
.status-badge.running       { background: var(--green); color: #fff; }
.status-badge.paused        { background: #4d3d20; color: #ffaa44; }
.status-badge.paused_limit  { background: #4d2020; color: #ff8888; }
.status-badge.completed     { background: #1a3030; color: #44dd88; }
.status-badge.cancelled     { background: #3d2020; color: #ff6666; }

/* Barra de progresso da campanha */
.campaign-progress {
  background: var(--bg-input);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
}
.campaign-progress-bar {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  transition: width .5s ease;
}

/* Tabela de destinatários */
.recipients-table-wrap {
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}
.recipients-table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.recipients-table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.recipients-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 700px;
}
.recipients-table th,
.recipients-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.recipients-table th {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: var(--bg-modal);
}
.recipients-table td.name { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recipients-table td.site { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.send-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.send-status.pending      { background: #2d3d50; color: #7ab3e0; }
.send-status.sent         { background: #1a3020; color: #44cc77; }
.send-status.failed       { background: #3d1a1a; color: #ff7070; }
.send-status.limit        { background: #3d3020; color: #ffaa44; }
.send-status.no_whatsapp  { background: #2d2d2d; color: #888; }
.send-status.skipped      { background: #2d2d2d; color: #888; }

.wa-check { font-size: 14px; }

/* Controles de campanha */
.campaign-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Toast / Notificações ───────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}
.toast {
  background: var(--bg-modal);
  color: var(--text-primary);
  border-left: 4px solid var(--green);
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 14px;
  max-width: 320px;
  animation: slideIn .3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.toast.error  { border-left-color: var(--red); }
.toast.warn   { border-left-color: var(--yellow); }
@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

/* ── Spinner ────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsivo ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 100%; max-width: none; }
  .chat-panel { display: none; }
  .chat-panel.mobile-open { display: flex; position: fixed; inset: 0; z-index: 100; }
  .nav-icons { display: none; }
}

/* ── Scrollbar global ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Refinamentos globais ───────────────────────────────────── */
:root {
  --accent-gradient: linear-gradient(135deg, #00a884, #25d366);
  --blue:   #4a90e2;
  --purple: #9b59b6;
  --orange: #f0a500;
}

/* Sidebar header: logo com gradiente */
.sidebar-header h1 {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

/* Nav: ícones com tooltip no hover */
.nav-icons a {
  position: relative;
}
.nav-icons a[title]::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-modal);
  color: var(--text-primary);
  font-size: 12px;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  border: 1px solid var(--border);
  z-index: 999;
}
.nav-icons a:hover[title]::after { opacity: 1; }

/* Logout nav link */
.nav-logout { color: var(--text-secondary) !important; }
.nav-logout:hover { color: var(--red) !important; background: rgba(241,92,109,.15) !important; }

/* Botões refinados */
.btn {
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  letter-spacing: .01em;
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(0,168,132,.35);
}
.btn-sm { border-radius: 8px; }

/* ── Dashboard page ─────────────────────────────────────────── */
.dashboard-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px;
  gap: 20px;
}
.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.dashboard-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.dashboard-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

/* KPI cards — linha horizontal, largura total */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
}
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
.kpi-card {
  background: var(--bg-modal);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-left: 4px solid transparent;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  transition: transform .15s, box-shadow .15s;
  min-width: 0;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.kpi-green  { border-left-color: var(--green); }
.kpi-blue   { border-left-color: var(--blue); }
.kpi-orange { border-left-color: var(--orange); }
.kpi-purple { border-left-color: var(--purple); }
.kpi-teal   { border-left-color: #00bcd4; }
.kpi-red    { border-left-color: var(--red); }
.kpi-yellow { border-left-color: var(--yellow); }
.kpi-cyan   { border-left-color: #26c6da; }

.kpi-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-green  .kpi-icon { background: rgba(0,168,132,.15); color: var(--green); }
.kpi-blue   .kpi-icon { background: rgba(74,144,226,.15); color: var(--blue); }
.kpi-orange .kpi-icon { background: rgba(240,165,0,.15);  color: var(--orange); }
.kpi-purple .kpi-icon { background: rgba(155,89,182,.15); color: var(--purple); }
.kpi-teal   .kpi-icon { background: rgba(0,188,212,.15);  color: #00bcd4; }
.kpi-red    .kpi-icon { background: rgba(241,92,109,.15); color: var(--red); }
.kpi-yellow .kpi-icon { background: rgba(255,214,10,.15); color: var(--yellow); }
.kpi-cyan   .kpi-icon { background: rgba(38,198,218,.15); color: #26c6da; }
.kpi-icon svg { width: 22px; height: 22px; }

.kpi-body { flex: 1; min-width: 0; }
.kpi-val {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--text-primary);
}
.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.kpi-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.3;
}

/* Dashboard row (2 cols) */
.dashboard-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .dashboard-row { grid-template-columns: 1fr; }
}
.dashboard-col { display: flex; flex-direction: column; }

/* Chip thermometer (dashboard variant) */
.chip-therm {
  margin-bottom: 14px;
}
.chip-therm:last-child { margin-bottom: 0; }
.chip-therm-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.chip-therm-name { flex: 1; font-weight: 500; }
.chip-therm-count { font-weight: 600; font-size: 12px; }
.chip-therm-bar-wrap {
  background: var(--bg-input);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
}
.chip-therm-bar {
  height: 100%;
  border-radius: 4px;
  transition: width .5s ease;
}

/* Unread conversation items in dashboard */
.unread-conv-item {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  border-left: 3px solid var(--green);
  background: rgba(255,255,255,.03);
  margin-bottom: 8px;
  text-decoration: none;
  transition: background .15s;
}
.unread-conv-item:last-child { margin-bottom: 0; }
.unread-conv-item:hover { background: var(--bg-hover); text-decoration: none; }
.unread-conv-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.unread-conv-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.unread-badge {
  background: var(--green);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  margin-left: auto;
}

/* ── Templates page ─────────────────────────────────────────── */
.templates-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px;
  gap: 24px;
  width: 100%;
  min-width: 0;
}
.templates-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.templates-header h2 { font-size: 20px; font-weight: 700; margin: 0; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin: 0; }
.page-subtitle code {
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.templates-editor-card {
  width: 100%;
}
.templates-editor-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px;
}
.templates-form-grid {
  margin-bottom: 16px;
  grid-template-columns: 2fr 2fr 1fr;
  width: 100%;
}
@media (max-width: 800px) {
  .templates-form-grid { grid-template-columns: 1fr; }
}
.form-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.templates-flows-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.templates-flows-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0;
}
.flows-list {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}
@media (max-width: 1400px) {
  .flows-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .flows-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .flows-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .flows-list { grid-template-columns: 1fr; }
}
.flows-list-loading,
.flows-list-empty {
  grid-column: 1 / -1;
}
.flows-list-loading {
  display: flex;
  justify-content: center;
  padding: 32px;
}
.flows-list-empty {
  margin: 0;
  padding: 20px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.flow-list-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 14px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  min-width: 0;
  height: 100%;
}
.flow-list-info { flex: 1; min-width: 0; }
.flow-list-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flow-list-meta {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}
.flow-list-meta + .flow-list-meta { margin-top: 2px; }
.flow-list-meta code {
  font-size: 11px;
  color: var(--green);
  word-break: break-all;
}
.flow-list-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 4px;
}
.flow-list-actions .btn { flex: 1; min-width: 0; justify-content: center; }
.steps-toolbar-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.steps-toolbar-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.steps-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.steps-container { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.steps-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px 12px;
  margin: 0;
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.step-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.step-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.step-type-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
}
.step-type-text  { background: rgba(74,144,226,.15); color: var(--blue); }
.step-type-audio { background: rgba(0,168,132,.15); color: var(--green); }
.step-type-video { background: rgba(155,89,182,.15); color: var(--purple); }
.step-card-actions { display: flex; gap: 2px; }
.step-body {
  width: 100%;
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  resize: vertical;
  min-height: 72px;
  outline: none;
}
.step-body:focus { border-color: var(--green); }
.step-media { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.step-file-name { font-size: 13px; color: var(--text-secondary); }
.editor-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.editor-status { font-size: 13px; color: var(--text-secondary); }

/* ── Etiquetas (settings) ───────────────────────────────────── */
.tags-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  margin-bottom: 16px;
}
@media (max-width: 1400px) {
  .tags-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .tags-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .tags-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .tags-grid { grid-template-columns: 1fr; }
}
.tag-admin-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 0;
}
.tag-admin-meta { flex: 1; min-width: 0; width: 100%; }
.tag-admin-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.tag-admin-count { font-size: 12px; color: var(--text-muted); }
.tag-admin-item .btn { width: 100%; margin-top: auto; }
.tag-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--tag-color, var(--green));
  background: color-mix(in srgb, var(--tag-color, var(--green)) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--tag-color, var(--green)) 35%, transparent);
}
.tag-admin-form {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: 10px;
  align-items: end;
}
@media (max-width: 700px) {
  .tag-admin-form { grid-template-columns: 1fr; }
}

/* Flow autocomplete no chat */
.flow-autocomplete {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 -4px 24px rgba(0,0,0,.4);
  max-height: 220px;
  overflow-y: auto;
  z-index: 300;
}
.flow-autocomplete.hidden { display: none; }
.flow-ac-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font);
  border-bottom: 1px solid var(--border);
}
.flow-ac-item:last-child { border-bottom: none; }
.flow-ac-item:hover,
.flow-ac-item.active { background: var(--bg-hover); }
.flow-ac-shortcut {
  font-weight: 600;
  font-size: 14px;
  color: var(--green);
  margin-bottom: 2px;
}
.flow-ac-name { font-size: 12px; color: var(--text-muted); }
.flow-ac-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.flow-ac-empty {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.chat-input-wrap.flow-running { opacity: .6; pointer-events: none; }
.flow-progress-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-modal);
  border: 1px solid var(--green);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
