/* ============================================================
   ZYRA CRM — Dialer Widget Flotante (Sesión 7)
   Fixed bottom-right, z-index 1000, 4 estados visuales
   ============================================================ */

/* ── BASE ── */
#dialer-widget {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 260px;
  z-index: 1000;
  background: #4A1A6B;
  color: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(74,26,107,.4), 0 2px 8px rgba(0,0,0,.18);
  font-family: 'DM Sans', sans-serif;
  overflow: hidden;
  transition: height .22s ease, background .3s;
  user-select: none;
}

#dialer-widget[data-estado="inactivo"]   { height: 80px; }
#dialer-widget[data-estado="timbrando"]  { height: 160px; }
#dialer-widget[data-estado="en_llamada"] { height: 160px; background: #2D1040; }
#dialer-widget[data-estado="finalizada"] { height: 160px; }

/* ── BODY ── */
.d-body {
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  height: 100%; box-sizing: border-box;
}

/* ── FILA SUPERIOR ── */
.d-top {
  display: flex; align-items: center; gap: 10px;
}

/* ── ICONO WRAP ── */
.d-icono-wrap {
  position: relative; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.d-icono { font-size: 1.4rem; line-height: 1; position: relative; z-index: 1; }

/* Pulso jade (estado TIMBRANDO) */
.d-pulse {
  display: none;
  position: absolute; inset: -4px;
  border-radius: 50%; border: 2px solid #5DCAA5;
  animation: dPulso 1s ease-in-out infinite;
}
[data-estado="timbrando"] .d-pulse  { display: block; }
[data-estado="timbrando"] .d-icono  { animation: dPhonePulse 1s ease-in-out infinite; }

@keyframes dPulso {
  0%,100% { transform: scale(1);   opacity: .85; }
  50%      { transform: scale(1.4); opacity: .25; }
}
@keyframes dPhonePulse {
  0%,100% { transform: scale(1);    }
  50%      { transform: scale(1.15); }
}

/* Ondas audio (estado EN_LLAMADA) */
.d-ondas {
  display: none; align-items: flex-end; gap: 3px; height: 20px;
}
[data-estado="en_llamada"] .d-ondas          { display: flex; }
[data-estado="en_llamada"] .d-icono          { display: none; }
[data-estado="en_llamada"] .d-pulse          { display: none; }

.d-onda { width: 3px; border-radius: 2px; background: #5DCAA5; animation: dOnda .8s ease-in-out infinite; }
.d-onda:nth-child(1) { height: 8px;  animation-delay: 0s;   }
.d-onda:nth-child(2) { height: 16px; animation-delay: .15s; }
.d-onda:nth-child(3) { height: 10px; animation-delay: .3s;  }

@keyframes dOnda {
  0%,100% { transform: scaleY(1);   }
  50%      { transform: scaleY(1.7); }
}

/* ── INFO ── */
.d-info { flex: 1; min-width: 0; }
.d-nombre {
  font-size: .82rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: rgba(255,255,255,.9);
}
[data-estado="inactivo"] .d-nombre { color: rgba(255,255,255,.5); }

.d-estado-txt {
  font-size: .7rem; color: rgba(255,255,255,.55); margin-top: 2px;
}
[data-estado="en_llamada"] .d-estado-txt { color: #5DCAA5; font-weight: 700; }
[data-estado="finalizada"]  .d-estado-txt { color: #D85A30; }

/* ── TIMER ── */
.d-timer {
  font-size: 1.55rem; font-weight: 700; letter-spacing: .05em;
  color: #fff; line-height: 1; flex-shrink: 0;
}
[data-estado="en_llamada"] .d-timer  { color: #5DCAA5; }
[data-estado="timbrando"]  .d-timer  { font-size: .88rem; color: rgba(255,255,255,.6); }
[data-estado="inactivo"]   .d-timer  { display: none; }
[data-estado="finalizada"] .d-timer  { font-size: 1rem; color: rgba(255,255,255,.7); }

/* ── BOTONES ── */
.d-btns { display: flex; gap: 6px; }
[data-estado="inactivo"] .d-btns { display: none; }

.d-btn {
  flex: 1; border: none; border-radius: 8px;
  padding: .5rem .4rem; font-size: .75rem; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: opacity .15s;
}
.d-btn:hover { opacity: .85; }
.d-btn-rojo  { background: #D85A30; color: #fff; }
.d-btn-verde { background: #5DCAA5; color: #fff; }
.d-btn-gris  { background: rgba(255,255,255,.15); color: #fff; }

/* ── BADGE INTENTOS (en ficha cliente) ── */
.intento-badge {
  display: inline-block; padding: .18em .65em;
  border-radius: 999px; font-size: .75rem; font-weight: 700;
}
.intento-badge-1 { background: #e9e9e7; color: #4a4a47; }
.intento-badge-2 { background: #fef3c7; color: #92400e; }
.intento-badge-3 { background: #ffe4d6; color: #D85A30; border: 1px solid #D85A30; }

/* ── ALERTA SUPERVISOR ── */
#alerta-supervisor {
  position: fixed; top: 72px; right: 16px;
  background: #F59E0B; color: #fff;
  padding: .55rem 1rem; border-radius: 10px;
  font-size: .82rem; font-weight: 700;
  z-index: 999; box-shadow: 0 4px 16px rgba(245,158,11,.35);
  display: none;
  animation: dAlertaIn .3s ease;
}
@keyframes dAlertaIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── MOBILE ── */
@media (max-width: 767px) {
  #dialer-widget {
    bottom: 56px; right: 0; left: 0; width: 100%;
    border-radius: 16px 16px 0 0;
  }
}
