/* ===========================================================
   conversations.css — WhatsApp-style chat thread + lead detail
                       tab strip (shared with tasks tab)
   =========================================================== */

/* ===== Tab strip inside the slide-over detail panel ===== */
.detail-tabs {
  display: flex;
  gap: 2px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  margin: 0 -20px 16px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 2;
  overflow-x: auto;
  scrollbar-width: thin;
}
.detail-tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.1s, border-color 0.1s;
  font-family: inherit;
}
.detail-tab:hover { color: var(--fg); }
.detail-tab.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}
.detail-tab .tab-badge {
  display: inline-block;
  background: var(--selected);
  color: var(--fg);
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}
.detail-tab.active .tab-badge {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.detail-tab-panel { display: none; }
.detail-tab-panel.active { display: block; }

/* ===== Conversation tab ===== */
.conv-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 360px;
}
.conv-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}
.conv-toolbar .conv-meta {
  margin-right: auto;
  font-size: 11px;
  color: var(--fg-subtle);
}
.conv-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--conv-bg, #f3f4f6);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 220px;
  max-height: 50vh;
  overflow-y: auto;
}
[data-theme="dark"] .conv-thread { --conv-bg: #0b141a; }

/* Date separator between days */
.conv-date-sep {
  align-self: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 12px;
  margin: 6px 0 2px;
  box-shadow: var(--shadow-sm);
  text-transform: capitalize;
}
.conv-thread.empty {
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  font-size: 12px;
  text-align: center;
  padding: 32px 24px;
}

.conv-row {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  gap: 2px;
}
.conv-row.left  { align-self: flex-start; align-items: flex-start; }
.conv-row.right { align-self: flex-end;   align-items: flex-end; }
.conv-row.center {
  align-self: center;
  align-items: center;
  max-width: 92%;
}

.conv-bubble {
  background: var(--bg);
  color: var(--fg);
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}
.conv-row.left  .conv-bubble {
  background: var(--bg);
  border-bottom-left-radius: 4px;
}
.conv-row.right .conv-bubble {
  background: #dcfce7; /* whatsapp-ish green */
  border-color: #bbf7d0;
  color: #064e3b;
  border-bottom-right-radius: 4px;
}
[data-theme="dark"] .conv-row.left .conv-bubble {
  background: var(--bg-elev);
  border-color: var(--line-strong);
}
[data-theme="dark"] .conv-row.right .conv-bubble {
  background: #005c4b; /* whatsapp dark green */
  border-color: #0a6e5a;
  color: #e7fce3;
}
[data-theme="dark"] .conv-row.right .conv-meta { color: #34d399; }
.conv-row.center .conv-bubble.sys {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--fg-muted);
  font-size: 11px;
  font-style: italic;
  padding: 4px 8px;
  text-align: center;
}
.conv-row.center .conv-bubble.note {
  background: #fef9c3;
  border: 1px solid #fde68a;
  color: #713f12;
  font-size: 12px;
  text-align: left;
  padding: 8px 12px;
  border-radius: var(--radius);
  max-width: 100%;
}
[data-theme="dark"] .conv-row.center .conv-bubble.note {
  background: #2a230a;
  border-color: #4d3f10;
  color: #fde68a;
}
/* Pensamiento de Claudia (no enviado al cliente) — violeta punteado, mismo
   lenguaje visual que la sección Conversaciones (inbox.css .thought). */
.conv-row.right .conv-bubble.thought {
  background: color-mix(in srgb, #7c5cd6 9%, var(--bg-elev));
  border: 1.5px dashed color-mix(in srgb, #7c5cd6 50%, transparent);
  color: var(--fg-muted);
  box-shadow: none;
}
.conv-thought-label {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #7c5cd6;
}
[data-theme="dark"] .conv-row.right .conv-bubble.thought {
  background: color-mix(in srgb, #8b6ee8 16%, var(--bg-elev));
  border-color: color-mix(in srgb, #8b6ee8 55%, transparent);
  color: var(--fg-muted);
}
[data-theme="dark"] .conv-thought-label { color: #a78bfa; }
.conv-row .conv-meta {
  font-size: 10px;
  color: var(--fg-subtle);
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}
.conv-row.right .conv-meta { color: #047857; }
.conv-row.center .conv-meta { font-style: italic; }
.conv-note-label {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #92400e;
  background: rgba(146, 64, 14, 0.08);
  padding: 1px 6px;
  border-radius: 999px;
  margin-right: 6px;
}

/* Internal note (Claudia's automated narration) — blue-grey, distinct from manual yellow notes */
.conv-row.center .conv-bubble.internal-note {
  background: #f0f4f8;
  border: 1px solid #cbd5e1;
  color: #374151;
}
[data-theme="dark"] .conv-row.center .conv-bubble.internal-note {
  background: #131c2b;
  border-color: #2c3a52;
  color: #cbd5e1;
}
[data-theme="dark"] .conv-row.center .conv-bubble.internal-note .conv-note-label {
  color: #93b4f5;
  background: rgba(147, 180, 245, 0.12);
}
.conv-row.center .conv-bubble.internal-note .conv-note-label {
  color: #1e40af;
  background: rgba(30, 64, 175, 0.08);
}

/* Note composer */
.conv-composer {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.conv-composer textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  resize: vertical;
  min-height: 60px;
  outline: none;
  transition: border-color 0.1s, box-shadow 0.1s;
}
.conv-composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(157, 0, 255, 0.12);
}
.conv-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.conv-composer-hint {
  font-size: 11px;
  color: var(--fg-subtle);
}

/* Loading spinner reused */
.spinner-inline {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
