/* ==========================================================================
   Demo modal — appel en direct avec l'agent IA
   ========================================================================== */

/* === Bouton flottant en bas à droite === */
.demo-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 80;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1.25rem 0.85rem 1rem;
  background: var(--gradient);
  color: white;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: 0 10px 24px -8px rgba(99,102,241,0.55);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
}
.demo-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px -8px rgba(99,102,241,0.7);
}
.demo-fab .ico {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.demo-fab .ico svg { width: 16px; height: 16px; }
.demo-fab .ico::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.55);
  animation: fab-pulse 1.8s infinite;
}
@keyframes fab-pulse {
  0%   { transform: scale(0.8); opacity: 0.9; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* === Backdrop / modal === */
.demo-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: dm-fade 0.2s ease;
}
.demo-modal.open { display: flex; }
@keyframes dm-fade { from { opacity: 0; } to { opacity: 1; } }

.demo-card {
  width: 100%;
  max-width: 460px;
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  position: relative;
  animation: dm-pop 0.25s ease;
}
@keyframes dm-pop {
  from { transform: translateY(15px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.demo-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-light);
  background: var(--bg-elev);
  z-index: 4;
  transition: background 0.15s, color 0.15s;
}
.demo-close:hover { background: var(--border); color: var(--text-dark); }
.demo-close svg { width: 16px; height: 16px; }

/* === Header (avatar + état) === */
.demo-head {
  padding: 2rem 1.5rem 1.25rem;
  text-align: center;
  background: linear-gradient(180deg, var(--bg-soft), white);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.demo-orb {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--gradient);
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: white;
  box-shadow: 0 10px 30px -8px rgba(99,102,241,0.45);
}
.demo-orb svg { width: 38px; height: 38px; }
.demo-orb::before,
.demo-orb::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(99,102,241,0.45);
  animation: orb-ring 2.4s infinite ease-out;
}
.demo-orb::after { animation-delay: 1.2s; }
@keyframes orb-ring {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.65); opacity: 0; }
}
.demo-orb.idle::before,
.demo-orb.idle::after { display: none; }

.demo-orb.speaking { animation: orb-bob 1.1s infinite ease-in-out; }
@keyframes orb-bob {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}

.demo-name {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-dark);
  letter-spacing: -0.02em;
}
.demo-role {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 0.15rem;
}
.demo-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  font-family: var(--font-mono);
}
.demo-status .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.2s, box-shadow 0.2s;
}
.demo-status.live .dot { background: var(--danger); box-shadow: 0 0 6px var(--danger); animation: liveDot 1.2s infinite; }
.demo-status.connected .dot { background: var(--success); box-shadow: 0 0 6px var(--success); }
.demo-status.ringing .dot { background: var(--warning); box-shadow: 0 0 6px var(--warning); animation: liveDot 0.8s infinite; }

.demo-timer {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

/* === Body conversation === */
.demo-body {
  padding: 1.25rem;
  background: var(--bg-soft);
  max-height: 320px;
  min-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.demo-bubble {
  max-width: 85%;
  padding: 0.6rem 0.95rem;
  border-radius: 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
  animation: bubbleIn 0.35s ease both;
}
.demo-bubble.bot {
  background: white;
  color: var(--text-dark);
  border: 1px solid var(--border);
  border-bottom-left-radius: 0.3rem;
  align-self: flex-start;
  box-shadow: var(--shadow-sm);
}
.demo-bubble.client {
  background: var(--gradient);
  color: white;
  border-bottom-right-radius: 0.3rem;
  align-self: flex-end;
  box-shadow: 0 4px 12px -2px rgba(99,102,241,0.4);
}
.demo-bubble.system {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-style: italic;
  padding: 0.3rem 0.5rem;
}
.demo-typing {
  display: inline-flex;
  gap: 4px;
  padding: 0.2rem 0;
}
.demo-typing span {
  width: 6px; height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}
.demo-typing span:nth-child(2) { animation-delay: 0.15s; }
.demo-typing span:nth-child(3) { animation-delay: 0.3s; }

/* === Quick replies === */
.demo-suggest {
  padding: 0.5rem 1rem 0.75rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  background: white;
  border-top: 1px solid var(--border);
}
.demo-suggest button {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  transition: all 0.15s;
  cursor: pointer;
}
.demo-suggest button:hover {
  background: white;
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

/* === Input row (texte + mic + raccrocher) === */
.demo-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: white;
  border-top: 1px solid var(--border);
}
.demo-input input {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.6rem 1rem;
  font-size: 0.92rem;
  color: var(--text-dark);
  font-family: inherit;
}
.demo-input input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.18);
}
.demo-input button {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-elev);
  color: var(--text-light);
  transition: all 0.15s;
  cursor: pointer;
  flex-shrink: 0;
}
.demo-input button:hover { background: var(--primary); color: white; }
.demo-input button.send { background: var(--gradient); color: white; }
.demo-input button.send:hover { filter: brightness(1.1); }
.demo-input button.mic.listening {
  background: var(--danger);
  color: white;
  animation: liveDot 1s infinite;
}
.demo-input button svg { width: 16px; height: 16px; }

/* === Footer info === */
.demo-foot {
  padding: 0.85rem 1.25rem;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-light);
}
.demo-foot a {
  color: var(--primary);
  font-weight: 600;
}
.demo-foot a:hover { text-decoration: underline; }
.demo-foot .lang {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
}

/* === Connecting / ringing screen === */
.demo-stage {
  text-align: center;
  padding: 2.5rem 1.5rem;
}
.demo-stage h3 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-dark);
  margin: 1rem 0 0.4rem;
}
.demo-stage p {
  font-size: 0.9rem;
  color: var(--text-light);
  max-width: 320px;
  margin: 0 auto 1.5rem;
  line-height: 1.55;
}
.demo-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 280px;
  margin: 0 auto;
}
.demo-actions .btn { width: 100%; justify-content: center; }
.demo-actions .or {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0.25rem 0;
}
.demo-actions .or::before, .demo-actions .or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.demo-actions .phone-number {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  text-align: center;
  display: block;
  text-decoration: none;
  transition: all 0.15s;
}
.demo-actions .phone-number:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: white;
}

/* Hidden helper */
.demo-hide { display: none !important; }

/* === Mobile === */
@media (max-width: 480px) {
  .demo-fab {
    bottom: 1rem;
    right: 1rem;
    padding: 0.7rem 1rem 0.7rem 0.75rem;
    font-size: 0.82rem;
  }
  .demo-fab .label-long { display: none; }
  .demo-card { max-width: 100%; }
  .demo-head { padding: 1.5rem 1rem 1rem; }
  .demo-orb { width: 80px; height: 80px; }
}
