/* ============================================================
   Hey Nex Mini Modal — CSS Component
   Portable voice assistant modal
   ============================================================
   PERSONNALISATION : modifier uniquement les variables :root
   ============================================================ */

:root {
  --hn-primary: #6366f1;
  --hn-primary-rgb: 99,102,241;
  --hn-primary-light: rgba(99,102,241,0.08);
  --hn-primary-gradient: linear-gradient(135deg,#6366f1,#8b5cf6);
  --hn-bg: #ffffff;
  --hn-bg-alt: #f8f9fc;
  --hn-border: #e8ecf4;
  --hn-text: #1e293b;
  --hn-text-dim: #64748b;
  --hn-text-light: #94a3b8;
  --hn-danger: #ef4444;
  --hn-width: 400px;
  --hn-max-height: 560px;
  --hn-z-index: 9999;
  --hn-bottom: 80px;
  --hn-right: 24px;
  --hn-radius: 18px;
}

/* ── Modal container ── */
#nexModal {
  display: none;
  position: fixed;
  bottom: var(--hn-bottom);
  right: var(--hn-right);
  width: var(--hn-width);
  max-height: var(--hn-max-height);
  z-index: var(--hn-z-index);
  border-radius: var(--hn-radius);
  overflow: hidden;
  background: var(--hn-bg);
  border: 1px solid var(--hn-border);
  box-shadow: 0 12px 48px rgba(var(--hn-primary-rgb),.15);
  flex-direction: column;
  animation: nexSlideUp .25s ease;
}
#nexModal.open { display: flex; }

@keyframes nexSlideUp {
  from { opacity:0; transform:translateY(16px); }
  to   { opacity:1; transform:translateY(0); }
}

/* ── Header ── */
.nex-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hn-border);
  background: linear-gradient(135deg, rgba(var(--hn-primary-rgb),.04), rgba(139,92,246,.04));
}
.nex-hdr-left { display:flex; align-items:center; gap:10px; }
.nex-av {
  width:36px; height:36px; border-radius:10px;
  background: linear-gradient(135deg, rgba(var(--hn-primary-rgb),.12), rgba(139,92,246,.12));
  display:flex; align-items:center; justify-content:center; font-size:17px;
}
.nex-title { font-size:14px; font-weight:600; color:var(--hn-text); }
.nex-sub   { font-size:11px; color:var(--hn-primary); }
.nex-close { background:none; border:none; color:var(--hn-text-dim); font-size:18px; cursor:pointer; padding:4px; border-radius:6px; }
.nex-close:hover { color:var(--hn-danger); }

/* ── Messages area ── */
.nex-msgs {
  flex:1; overflow-y:auto; padding:14px 16px;
  display:flex; flex-direction:column; gap:10px;
  min-height:200px; max-height:360px; background:var(--hn-bg-alt);
}
.nex-msgs::-webkit-scrollbar { width:3px; }
.nex-msgs::-webkit-scrollbar-thumb { background:rgba(var(--hn-primary-rgb),.15); border-radius:3px; }

/* ── Message bubbles ── */
.nex-m { display:flex; gap:8px; max-width:88%; animation:nexFade .2s ease; }
@keyframes nexFade { from{opacity:0;transform:translateY(6px);} to{opacity:1;transform:translateY(0);} }
.nex-m.user          { align-self:flex-end; flex-direction:row-reverse; }
.nex-m.assistant      { align-self:flex-start; }
.nex-m.user-pending   { align-self:flex-end; flex-direction:row-reverse; opacity:.6; }
.nex-m-av {
  width:26px; height:26px; border-radius:8px;
  display:flex; align-items:center; justify-content:center;
  font-size:12px; flex-shrink:0;
}
.nex-m.assistant .nex-m-av { background:linear-gradient(135deg,rgba(var(--hn-primary-rgb),.08),rgba(139,92,246,.08)); }
.nex-m.user .nex-m-av      { background:rgba(var(--hn-primary-rgb),.08); color:var(--hn-primary); font-weight:700; font-size:10px; }
.nex-m-bub { padding:10px 13px; border-radius:12px; font-size:13px; line-height:1.55; color:var(--hn-text); }
.nex-m.assistant .nex-m-bub { background:var(--hn-bg); border:1px solid var(--hn-border); border-bottom-left-radius:3px; }
.nex-m.user .nex-m-bub      { background:rgba(var(--hn-primary-rgb),.08); border:1px solid rgba(var(--hn-primary-rgb),.1); border-bottom-right-radius:3px; }
.nex-m-time { font-size:9px; color:var(--hn-text-light); margin-top:3px; }

/* ── Typing indicator ── */
.nex-typing {
  display:none; align-self:flex-start; padding:10px 14px;
  background:var(--hn-bg); border-radius:12px; border:1px solid var(--hn-border);
  gap:4px; align-items:center;
}
.nex-typing.show { display:flex; }
.nex-td { width:6px; height:6px; border-radius:50%; background:var(--hn-primary); animation:nexBounce 1.4s infinite; }
.nex-td:nth-child(2) { animation-delay:.2s; }
.nex-td:nth-child(3) { animation-delay:.4s; }
@keyframes nexBounce { 0%,60%,100%{transform:translateY(0);opacity:.3;} 30%{transform:translateY(-5px);opacity:1;} }

/* ── Input area ── */
.nex-input { display:flex; gap:8px; padding:12px 16px; border-top:1px solid var(--hn-border); align-items:center; background:var(--hn-bg); }
.nex-inp {
  flex:1; background:var(--hn-bg-alt); border:1px solid var(--hn-border); border-radius:10px;
  padding:10px 13px; color:var(--hn-text); font-size:13px; outline:none; font-family:inherit;
}
.nex-inp:focus { border-color:var(--hn-primary); }
.nex-inp::placeholder { color:var(--hn-text-light); }

/* ── Buttons ── */
.nex-btn-send, .nex-btn-mic {
  width:38px; height:38px; border-radius:10px; border:none;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; transition:all .15s; font-size:15px;
}
.nex-btn-send { background:var(--hn-primary-gradient); color:#fff; }
.nex-btn-send:hover { transform:scale(1.05); }
.nex-btn-send:disabled { opacity:.35; cursor:not-allowed; transform:none; }
.nex-btn-mic { background:rgba(139,92,246,.08); color:#8b5cf6; border:1px solid rgba(139,92,246,.12); }
.nex-btn-mic:hover { background:rgba(139,92,246,.15); }
.nex-btn-mic.rec { background:rgba(239,68,68,.08); color:var(--hn-danger); border-color:rgba(239,68,68,.2); animation:nexPulse 1.5s infinite; }
@keyframes nexPulse { 0%,100%{box-shadow:0 0 0 0 rgba(239,68,68,.2);} 50%{box-shadow:0 0 0 6px rgba(239,68,68,0);} }

/* ── Welcome screen ── */
.nex-welcome { text-align:center; padding:30px 16px; color:var(--hn-text-dim); }
.nex-welcome .nex-w-icon { font-size:32px; margin-bottom:10px; }
.nex-welcome h4 { color:var(--hn-text); font-size:14px; margin-bottom:6px; }
.nex-welcome p { font-size:12px; line-height:1.5; }

/* ── Misc ── */
.nex-expand { font-size:14px; color:var(--hn-text-dim); background:none; border:none; cursor:pointer; padding:4px; border-radius:6px; }
.nex-expand:hover { color:var(--hn-primary); background:var(--hn-primary-light); }

/* ── Responsive ── */
@media(max-width:480px) {
  #nexModal { right:8px; left:8px; width:auto; bottom:70px; }
}
