/* NakFix — assistant IA en interface téléphone */
.chat {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  font-family: var(--font-body);
}

.chat-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(155deg, #a873ff, #742ee8 68%, #5b20c7);
  color: #fff;
  box-shadow: 0 14px 34px -12px rgba(124, 58, 237, .85), inset 0 1px 1px rgba(255,255,255,.35);
  transition: transform .2s ease, box-shadow .2s ease;
}
.chat-toggle:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 18px 40px -12px rgba(124,58,237,.95); }
.chat-toggle svg { width: 25px; height: 25px; }
.chat-toggle .icon-close { display: none; }
.chat-toggle.is-open .icon-chat { display: none; }
.chat-toggle.is-open .icon-close { display: block; }
.chat-toggle::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 2px solid rgba(167, 118, 255, .38);
  border-radius: 50%;
  animation: chat-ring 2.6s ease-out infinite;
  pointer-events: none;
}
@keyframes chat-ring { 0% { transform: scale(.9); opacity: .8; } 70%, 100% { transform: scale(1.35); opacity: 0; } }

/* Le panneau prend la forme d’un iPhone, posé au-dessus du bouton. */
.chat-panel {
  position: fixed;
  right: 20px;
  bottom: 94px;
  z-index: 81;
  width: min(370px, calc((100dvh - 120px) * .52), calc(100vw - 24px));
  height: min(720px, calc(100dvh - 120px));
  padding: 9px;
  overflow: visible;
  border: 1px solid rgba(255,255,255,.36);
  border-radius: 52px;
  background: linear-gradient(145deg, #777780 0%, #323238 13%, #101014 42%, #3b3b43 78%, #17171b 100%);
  box-shadow: 0 40px 90px -28px rgba(0,0,0,.92), 0 0 0 2px #050506, inset 0 1px 0 rgba(255,255,255,.5), inset 0 -1px 0 rgba(255,255,255,.18);
  transform-origin: bottom right;
  animation: chat-phone-in .28s cubic-bezier(.22,1,.36,1);
}
.chat-panel[hidden] { display: none !important; }
.chat-panel::before, .chat-panel::after {
  content: "";
  position: absolute;
  left: -3px;
  width: 3px;
  border-radius: 3px 0 0 3px;
  background: linear-gradient(180deg, #777780, #29292f);
}
.chat-panel::before { top: 120px; height: 44px; box-shadow: 0 62px 0 #44444b; }
.chat-panel::after { top: 208px; height: 68px; }
@keyframes chat-phone-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }

.chat-phone { width: 100%; height: 100%; padding: 2px; overflow: hidden; border-radius: 43px; background: #030304; }
.chat-phone-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 40px;
  background: radial-gradient(110% 38% at 50% 0%, rgba(113,63,177,.17), transparent 75%), linear-gradient(180deg, #101014 0%, #070709 100%);
  color: #f7f5fb;
}
.chat-phone-screen::before {
  content: "";
  position: absolute;
  z-index: 5;
  top: 8px;
  left: 50%;
  width: 92px;
  height: 26px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  background: #020203;
  box-shadow: inset 0 1px 2px rgba(255,255,255,.06);
  transform: translateX(-50%);
  pointer-events: none;
}
.chat-device-status {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  height: 34px;
  padding: 7px 22px 0;
  color: #fff;
  font-size: 11px;
}
.chat-device-status strong { font-size: 11px; font-weight: 800; }
.chat-device-icons { display: flex; align-items: center; gap: 3px; height: 12px; }
.chat-device-icons i { display: block; width: 3px; border-radius: 2px 2px 0 0; background: #fff; }
.chat-device-icons i:first-child { height: 5px; }
.chat-device-icons i:nth-child(2) { height: 8px; }
.chat-device-icons b { position: relative; width: 13px; height: 7px; margin-left: 3px; border: 1px solid #fff; border-radius: 2px; }
.chat-device-icons b::after { content: ""; position: absolute; top: 1px; right: -3px; width: 2px; height: 3px; border-radius: 0 2px 2px 0; background: #fff; }

.chat-head {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  flex: none;
  min-height: 105px;
  padding: 7px 13px 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  background: linear-gradient(180deg, rgba(255,255,255,.015), transparent);
}
.chat-close, .chat-head-action { display: grid; place-items: center; width: 36px; height: 36px; }
.chat-close { border: 0; border-radius: 50%; background: transparent; color: #a985ff; transition: background .18s ease; }
.chat-close:hover { background: rgba(157,123,250,.13); }
.chat-close svg { width: 23px; height: 23px; }
.chat-profile { display: flex; min-width: 0; flex-direction: column; align-items: center; gap: 5px; }
.chat-avatar { display: grid; place-items: center; width: 38px; height: 38px; overflow: hidden; flex: none; border: 2px solid rgba(169,125,255,.8); border-radius: 50%; background: linear-gradient(150deg, #a873ff, #5b20c7); box-shadow: 0 0 18px rgba(139,92,246,.32); }
.chat-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chat-head-text { display: flex; flex-direction: column; align-items: center; min-width: 0; gap: 3px; line-height: 1.2; }
.chat-head-text strong { overflow: hidden; max-width: 180px; color: #fff; font-size: .78rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.chat-status { display: flex; align-items: center; gap: 5px; color: #aaa5b2; font-size: .64rem; }
.chat-status .dot { width: 6px; height: 6px; border-radius: 50%; background: #8c8496; }
.chat-status.is-online .dot { background: #65d995; box-shadow: 0 0 0 3px rgba(101,217,149,.12); }
.chat-status.is-offline .dot { background: #ff727e; }
.chat-head-action { color: #a985ff; font-size: 13px; letter-spacing: 2px; }
.chat-desc { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.chat-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 11px;
  min-height: 80px;
  padding: 18px 14px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.16) transparent;
}
.chat-log::-webkit-scrollbar { width: 5px; }
.chat-log::-webkit-scrollbar-thumb { border-radius: 99px; background: rgba(255,255,255,.15); }
.msg { max-width: 87%; padding: 11px 14px; border: 1px solid transparent; border-radius: 19px; font-size: .88rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; animation: msg-in .2s ease-out; }
@keyframes msg-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.msg-bot { align-self: flex-start; border-color: rgba(255,255,255,.08); border-bottom-left-radius: 6px; background: #242328; color: #f1eff5; }
.msg-user { align-self: flex-end; border-color: rgba(205,177,255,.2); border-bottom-right-radius: 6px; background: linear-gradient(145deg, #9c4dff, #762de4 72%, #6423cc); color: #fff; font-weight: 550; box-shadow: 0 5px 18px rgba(124,58,237,.2); }
.msg-error { align-self: flex-start; border-color: rgba(255,100,110,.3); background: rgba(130,30,45,.3); color: #ffc6cb; }
.msg.is-typing { opacity: .68; }

.chat-suggest { display: flex; flex: none; gap: 7px; padding: 4px 14px 11px; overflow-x: auto; scrollbar-width: none; }
.chat-suggest::-webkit-scrollbar { display: none; }
.chat-suggest button { flex: 0 0 auto; padding: 7px 11px; border: 1px solid rgba(178,145,255,.28); border-radius: 999px; background: rgba(139,92,246,.09); color: #d8c8ff; font: inherit; font-size: .68rem; white-space: nowrap; transition: background .18s ease, border-color .18s ease; }
.chat-suggest button:hover { border-color: rgba(178,145,255,.55); background: rgba(139,92,246,.18); }
.chat-form { display: flex; align-items: center; gap: 8px; flex: none; margin: 0 12px; padding: 5px 6px 5px 14px; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; background: rgba(255,255,255,.055); box-shadow: inset 0 1px 2px rgba(0,0,0,.28); }
.chat-input { min-width: 0; flex: 1; height: 38px; padding: 0; border: 0; outline: 0; background: transparent; color: #fff; font: inherit; font-size: 16px; }
.chat-input::placeholder { color: #96919d; opacity: 1; }
.chat-send { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border: 0; border-radius: 50%; background: linear-gradient(145deg, #a873ff, #762de4); color: #fff; box-shadow: 0 4px 12px rgba(124,58,237,.35); transition: transform .18s ease, filter .18s ease; }
.chat-send:hover { transform: scale(1.06); filter: brightness(1.08); }
.chat-send svg { width: 19px; height: 19px; }
.chat-input:focus-visible, .chat-send:focus-visible, .chat-suggest button:focus-visible, .chat-close:focus-visible { outline: 2px solid #cbb3ff; outline-offset: 3px; }
.chat-foot { flex: none; margin: 8px 16px 5px; color: #827d89; font-size: .62rem; line-height: 1.35; text-align: center; }
.chat-home-indicator { align-self: center; width: 96px; height: 4px; flex: none; margin: 4px 0 5px; border-radius: 99px; background: rgba(255,255,255,.82); }

.chat-banned[hidden] { display: none !important; }
.chat-banned { position: absolute; z-index: 7; inset: 140px 22px auto; display: flex; flex-direction: column; align-items: center; padding: 22px; border: 1px solid rgba(255,100,110,.35); border-radius: 22px; background: rgba(19,16,22,.97); box-shadow: 0 16px 42px rgba(0,0,0,.6); color: #fff; text-align: center; }
.chat-banned-badge { display: grid; place-items: center; width: 45px; height: 45px; margin-bottom: 12px; border-radius: 50%; background: rgba(255,100,110,.13); color: #ff929b; }
.chat-banned-badge svg { width: 22px; height: 22px; }
.chat-banned > strong { font-size: 1rem; }
.chat-banned p { margin: 8px 0 0; color: #c1bbc8; font-size: .82rem; line-height: 1.5; }
.chat-banned a { color: #c7adff; text-decoration: underline; }

.chat-toggle:focus-visible { outline: 3px solid #d1baff; outline-offset: 4px; }
@media (max-width: 520px) {
  .chat { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .chat-panel {
    right: 0;
    bottom: calc(82px + env(safe-area-inset-bottom));
    left: 0;
    width: min(calc(100vw - 20px), calc((100dvh - 114px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * .53));
    height: min(740px, calc(100dvh - 114px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    margin: 0 auto;
  }
  .chat-phone { padding: 2px; }
  .chat-head { min-height: 96px; }
  .chat-log { padding-right: 11px; padding-left: 11px; }
  .msg { max-width: 90%; font-size: .86rem; }
  .chat-suggest { padding-right: 11px; padding-left: 11px; }
}
@media (max-height: 610px) {
  .chat-panel { bottom: 82px; height: calc(100dvh - 98px); }
  .chat-head { min-height: 78px; grid-template-columns: 36px minmax(0,1fr) 36px; padding-bottom: 7px; }
  .chat-avatar { width: 31px; height: 31px; }
  .chat-log { padding-top: 10px; gap: 8px; }
  .chat-suggest { padding-bottom: 7px; }
  .chat-foot { margin-top: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-toggle::after { display: none; }
  .chat-panel, .msg { animation: none; }
}