/* Innoventix Hub — floating AI chat panel */
.chat-panel {
  position: fixed;
  z-index: 70;
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: calc(max(20px, env(safe-area-inset-bottom, 0px)) + 58px + 12px + 58px + 12px);
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 140px));
  display: flex; flex-direction: column;
  background: #161616;
  border: 1px solid rgba(232,184,74,.28);
  border-radius: 20px;
  box-shadow: 0 28px 60px -18px rgba(0,0,0,.75), 0 0 0 1px rgba(255,255,255,.04);
  overflow: hidden;
  opacity: 0; transform: translateY(12px) scale(.98);
  pointer-events: none;
  transition: opacity .28s ease, transform .28s ease;
}
.chat-panel.is-open {
  opacity: 1; transform: none; pointer-events: auto;
}
.chat-panel[hidden] { display: none !important; }

.chat-panel-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #1e1e1e, #171717);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.chat-panel-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(232,184,74,.4);
}
.chat-panel-head strong {
  display: block; font-size: 14px; font-weight: 600; color: #f4f4f5;
}
.chat-panel-head span {
  display: block; font-size: 12px; color: #E8B84A; font-weight: 400;
}
.chat-panel-id { min-width: 0; flex: 1; }
.chat-panel-btn {
  width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 10px;
  background: rgba(255,255,255,.04);
  color: #c9c9d1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .2s ease, color .2s ease;
}
.chat-panel-min { margin-left: auto; }
.chat-panel-btn:hover { background: rgba(255,255,255,.09); color: #fff; }
.chat-panel-btn:focus-visible, .chat-chip:focus-visible, .chat-link:focus-visible, .chat-form button:focus-visible, .chat-hint a:focus-visible { outline: 2px solid #E8B84A; outline-offset: 2px; }

.chat-panel-body {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
.chat-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px; line-height: 1.55;
  font-weight: 400;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.chat-msg--bot {
  align-self: flex-start;
  background: #222;
  border: 1px solid rgba(255,255,255,.06);
  color: #e8e8ec;
  border-bottom-left-radius: 4px;
}
.chat-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #F0C96A, #E8B84A);
  color: #1a1a1a;
  font-weight: 500;
  border-bottom-right-radius: 4px;
}
.chat-msg--error {
  align-self: center;
  background: rgba(220,80,80,.12);
  border: 1px solid rgba(220,80,80,.35);
  color: #f0b4b4;
  font-size: 13px;
  max-width: 100%;
  text-align: center;
}
.chat-typing {
  align-self: flex-start;
  display: inline-flex; gap: 5px; align-items: center;
  padding: 12px 14px;
  background: #222;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.chat-typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #E8B84A;
  opacity: .35;
  animation: chatDot 1.2s ease-in-out infinite;
}
.chat-typing i:nth-child(2) { animation-delay: .15s; }
.chat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chatDot {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.chat-panel-foot {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
  background: #141414;
}
.chat-form {
  display: flex; gap: 8px; align-items: flex-end;
}
.chat-form textarea {
  flex: 1; resize: none;
  min-height: 44px; max-height: 110px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.1);
  background: #1c1c1c;
  color: #f4f4f5;
  font: inherit; font-size: 14px; line-height: 1.4;
}
.chat-form textarea:focus {
  outline: none;
  border-color: rgba(232,184,74,.55);
}
.chat-form button[type="submit"] {
  width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 12px; cursor: pointer;
  background: linear-gradient(135deg, #F0C96A, #E8B84A);
  color: #1a1a1a;
  display: inline-flex; align-items: center; justify-content: center;
}
.chat-form button[type="submit"]:disabled {
  opacity: .45; cursor: not-allowed;
}
.chat-hint {
  margin: 8px 2px 0;
  font-size: 12px; color: #9a9aa4; text-align: center;
}

.chat-msg { animation: chatIn .22s ease both; }
@keyframes chatIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.chat-quick, .chat-links { display: flex; flex-wrap: wrap; gap: 8px; animation: chatIn .22s ease both; }
.chat-quick { margin-top: 2px; }
.chat-chip {
  min-height: 36px; padding: 8px 13px;
  border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(232,184,74,.45);
  background: rgba(232,184,74,.06);
  color: #f1d48a; font: inherit; font-size: 13px; font-weight: 500; line-height: 1.2;
  transition: background .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
}
.chat-chip:hover { background: rgba(232,184,74,.16); border-color: #E8B84A; color: #fff; transform: translateY(-1px); }
.chat-link {
  display: inline-flex; align-items: center; min-height: 34px; padding: 7px 12px;
  border-radius: 10px; font-size: 13px; font-weight: 500; text-decoration: none;
  background: #222; border: 1px solid rgba(255,255,255,.1); color: #e8e8ec;
  transition: background .2s ease, border-color .2s ease;
}
.chat-link:hover { border-color: rgba(232,184,74,.55); background: #262626; }
.chat-link--primary { background: linear-gradient(135deg, #F0C96A, #E8B84A); color: #1a1a1a; border-color: transparent; }
.chat-link--primary:hover { background: linear-gradient(135deg, #F5D27C, #EBBF55); }
.chat-hint a { color: #c9cdd6; text-decoration: underline; text-underline-offset: 2px; }
.chat-hint a:hover { color: #E8B84A; }
.chat-panel .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) {
  .chat-panel, .chat-msg, .chat-quick, .chat-links { transition: none; animation: none; }
  .chat-typing i { animation: none; opacity: .8; }
}

@media (max-width: 720px) {
  .chat-panel {
    inset: 0;
    width: 100%; height: 100%;
    right: 0; bottom: 0; left: 0; top: 0;
    border-radius: 0;
    border: 0;
    height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .chat-chip { min-height: 40px; font-size: 14px; }
  .chat-link { min-height: 40px; }
  .chat-form textarea { font-size: 16px; } /* no iOS zoom on focus */
  html.chat-open .wa-float, html.chat-open .chat-float { visibility: hidden; }
  html.chat-open, html.chat-open body { overflow: hidden; }
}
