/* ═══════════════════════════════════════════════════════════════════════ */
/* MÓDULO CONVERSACIONES — Tracking manual WhatsApp                        */
/* ═══════════════════════════════════════════════════════════════════════ */

.conv-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,37,64,.7);
  backdrop-filter: blur(4px);
  z-index: 9100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.conv-modal-overlay.show {
  display: flex;
  animation: convFadeIn .2s ease;
}
@keyframes convFadeIn { from{opacity:0} to{opacity:1} }

.conv-modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 720px;
  height: 85vh;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
  animation: convSlideUp .3s ease;
}
@keyframes convSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.conv-modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid #e8edf2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #f8fafc, #fff);
  flex-shrink: 0;
}
.conv-modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #0A2540;
  font-family: 'Sora', sans-serif;
}
.conv-modal-close {
  background: rgba(0,0,0,.06);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.conv-modal-close:hover { background: rgba(0,0,0,.12); }

.conv-modal-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #ECE5DD; /* Color de fondo tipo WhatsApp */
}

/* ═══ STATS ═══ */
.conv-stats {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #e8edf2;
  overflow-x: auto;
}
.conv-stat {
  background: #f1f5f9;
  padding: 6px 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
  flex-shrink: 0;
}
.conv-stat strong {
  font-size: 16px;
  font-weight: 700;
  color: #0A2540;
  line-height: 1;
}
.conv-stat span {
  font-size: 10px;
  color: #64748b;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.conv-stat.urgente {
  background: #fef3c7;
  color: #92400e;
}
.conv-stat.urgente strong {
  color: #92400e;
}

/* ═══ CHAT ═══ */
.conv-chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background-image:
    radial-gradient(rgba(0,0,0,0.02) 1px, transparent 1px);
  background-size: 20px 20px;
}

.conv-sep-dia {
  text-align: center;
  font-size: 11px;
  color: #64748b;
  background: rgba(255,255,255,.85);
  padding: 4px 12px;
  border-radius: 20px;
  width: max-content;
  margin: 12px auto;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.conv-msg {
  display: flex;
  margin: 6px 0;
}
.conv-msg.conv-sal {
  justify-content: flex-end;
}
.conv-msg.conv-rec {
  justify-content: flex-start;
}

.conv-msg-bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 12px;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.conv-sal .conv-msg-bubble {
  background: #DCF8C6;
  border-bottom-right-radius: 2px;
}
.conv-rec .conv-msg-bubble {
  background: #fff;
  border-bottom-left-radius: 2px;
}

.conv-msg-texto {
  font-size: 14px;
  line-height: 1.4;
  color: #0A2540;
  word-wrap: break-word;
}

.conv-msg-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 10px;
  color: #64748b;
}
.conv-msg-canal {
  font-weight: 600;
}
.conv-msg-hora {
  font-style: italic;
}
.conv-msg-del {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  opacity: 0;
  transition: opacity .2s;
}
.conv-msg-bubble:hover .conv-msg-del {
  opacity: 0.6;
}
.conv-msg-del:hover { opacity: 1; }

/* ═══ EMPTY STATE ═══ */
.conv-empty {
  text-align: center;
  padding: 40px 20px;
  background: rgba(255,255,255,.9);
  border-radius: 12px;
  margin: 20px;
}
.conv-empty h4 {
  margin: 0 0 6px;
  font-size: 16px;
}
.conv-empty p {
  color: #64748b;
  font-size: 13px;
  margin: 0;
  line-height: 1.5;
}

/* ═══ LOADING ═══ */
.conv-loading {
  text-align: center;
  padding: 60px 20px;
}
.conv-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e8edf2;
  border-top-color: #F5923A;
  border-radius: 50%;
  margin: 0 auto;
  animation: convSpin .8s linear infinite;
}
@keyframes convSpin { to { transform: rotate(360deg); } }

/* ═══ FOOTER (input + tabs) ═══ */
.conv-modal-footer {
  background: #fff;
  border-top: 1px solid #e8edf2;
  flex-shrink: 0;
}

.conv-tabs {
  display: flex;
  border-bottom: 1px solid #e8edf2;
}
.conv-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .2s;
  font-family: inherit;
}
.conv-tab:hover { background: #f8fafc; }
.conv-tab.on {
  color: #F5923A;
  border-bottom-color: #F5923A;
  background: #fff8f1;
}

#convInputArea {
  padding: 14px 18px;
}
#convTexto {
  width: 100%;
  border: 1.5px solid #e8edf2;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  min-height: 60px;
}
#convTexto:focus { border-color: #F5923A; }

.conv-input-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: flex-end;
}

.conv-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s;
}
.conv-btn-primary {
  background: #25D366;
  color: #fff;
}
.conv-btn-primary:hover {
  background: #1faa50;
  transform: translateY(-1px);
}

/* ═══ BOTÓN TRIGGER (donde se inyecta) ═══ */
.conv-trigger-btn {
  background: linear-gradient(135deg, #25D366, #1faa50);
  color: #fff;
  border: none;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all .2s;
  position: relative;
}
.conv-trigger-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,211,102,.3);
}
.conv-trigger-btn .conv-badge {
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
  font-weight: 800;
}

/* Mobile */
@media (max-width: 640px) {
  .conv-modal { height: 100vh; max-height: 100vh; border-radius: 0; }
  .conv-modal-header { padding: 12px 14px; }
  .conv-stats { padding: 8px 12px; gap: 4px; }
  .conv-stat { padding: 4px 8px; min-width: 60px; }
  .conv-stat strong { font-size: 14px; }
  .conv-chat { padding: 10px; }
  .conv-msg-bubble { max-width: 85%; }
  #convInputArea { padding: 10px 14px; }
  .conv-tabs { font-size: 11px; }
}
