/* =========================================================
   Kainovis — floating consultation widget + toast
   ========================================================= */

.widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  font-family: var(--font-sans);
}

.widget-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(92, 225, 194, 0.5);
  border-radius: 50%;
  background: linear-gradient(145deg, #5ce1c2, #2ec9a8);
  color: #04110d;
  box-shadow: 0 16px 42px rgba(46, 201, 168, 0.28);
  transition: transform 0.3s var(--ease), box-shadow 0.3s;
}

.widget-toggle:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 20px 48px rgba(46, 201, 168, 0.36);
}

.widget-toggle .icon {
  width: 24px;
  height: 24px;
}

.widget-toggle::before {
  content: "";
  position: absolute;
  inset: -6px;
  border: 1px solid rgba(92, 225, 194, 0.24);
  border-radius: 50%;
  animation: widget-ring 2.8s ease-out infinite;
}

.widget.is-open .widget-toggle::before {
  display: none;
}

@keyframes widget-ring {
  0% {
    opacity: 0.8;
    transform: scale(0.92);
  }

  70%,
  100% {
    opacity: 0;
    transform: scale(1.3);
  }
}

.widget-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border: 2px solid #070b10;
  border-radius: 50%;
  background: #f0b46a;
  color: #2b1a08;
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
}

.widget-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  display: flex;
  flex-direction: column;
  width: 372px;
  max-height: min(590px, calc(100vh - 130px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 18px;
  background: #0b131b;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.28s var(--ease), transform 0.28s var(--ease), visibility 0.28s;
}

.widget.is-open .widget-panel {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.widget-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.widget-head-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(92, 225, 194, 0.3);
  border-radius: 9px;
  background: rgba(92, 225, 194, 0.08);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
}

.widget-head-copy {
  flex: 1;
  min-width: 0;
}

.widget-head-copy b {
  display: block;
  color: #e6eef6;
  font-size: 12.5px;
  font-weight: 600;
}

.widget-head-copy span {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
  color: #718496;
  font-size: 9px;
}

.widget-head-copy span::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.widget-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: #8497a9;
  transition: background 0.2s, color 0.2s;
}

.widget-close:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.widget-close .icon {
  width: 14px;
  height: 14px;
}

.widget-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.widget-body::-webkit-scrollbar {
  width: 5px;
}

.widget-body::-webkit-scrollbar-thumb {
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.14);
}

.widget-msg {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.widget-msg--user {
  justify-content: flex-end;
}

.widget-msg-avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(92, 225, 194, 0.22);
  border-radius: 7px;
  background: rgba(92, 225, 194, 0.07);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
  flex: none;
}

.widget-bubble {
  max-width: 268px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 3px 11px 11px 11px;
  background: rgba(255, 255, 255, 0.045);
  color: #c2cfdb;
  font-size: 11.5px;
  line-height: 1.7;
}

.widget-msg--user .widget-bubble {
  border-color: rgba(92, 225, 194, 0.34);
  border-radius: 11px 3px 11px 11px;
  background: rgba(92, 225, 194, 0.13);
  color: #dff8f1;
}

.widget-bubble b {
  color: #eaf4f1;
  font-weight: 600;
}

.widget-bubble .demo-tag {
  display: inline-block;
  margin-bottom: 5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(240, 180, 106, 0.12);
  color: #e8bd87;
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.05em;
}

.widget-system {
  margin: 12px 0;
  color: #5f7285;
  font-size: 8.5px;
  line-height: 1.6;
  text-align: center;
}

.widget-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 14px 32px;
}

.widget-chip {
  padding: 5px 9px;
  border: 1px solid rgba(92, 225, 194, 0.2);
  border-radius: 999px;
  background: rgba(92, 225, 194, 0.04);
  color: #8ed8c8;
  font-size: 9.5px;
  transition: background 0.2s, border-color 0.2s;
}

.widget-chip:hover {
  border-color: rgba(92, 225, 194, 0.45);
  background: rgba(92, 225, 194, 0.1);
}

.widget-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 3px 11px 11px 11px;
  background: rgba(255, 255, 255, 0.04);
}

.widget-typing i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #7f93a6;
  animation: typing 1.2s infinite;
}

.widget-typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.widget-typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.widget-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.018);
}

.widget-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.widget-form textarea {
  flex: 1;
  min-height: 38px;
  max-height: 96px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  color: #dbe6f0;
  font-size: 11.5px;
  line-height: 1.5;
  resize: none;
}

.widget-form textarea::placeholder {
  color: #64778a;
}

.widget-form textarea:focus {
  outline: 0;
  border-color: rgba(92, 225, 194, 0.45);
}

.widget-send {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #04110d;
  flex: none;
  transition: background 0.2s, transform 0.2s;
}

.widget-send:hover {
  background: #7df0d6;
  transform: translateY(-1px);
}

.widget-send .icon {
  width: 16px;
  height: 16px;
}

.widget-note {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  color: #596d80;
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.02em;
}

.widget-note .icon {
  width: 10px;
  height: 10px;
  color: #6f8b87;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(440px, calc(100vw - 40px));
  padding: 12px 17px;
  border: 1px solid rgba(92, 225, 194, 0.28);
  border-radius: 10px;
  background: #0d1a1c;
  color: #c9e8e1;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 10px);
  transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
}

.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.toast .icon {
  width: 15px;
  height: 15px;
  color: var(--accent);
  flex: none;
}

.toast.is-error {
  border-color: rgba(255, 139, 139, 0.3);
  color: #ffd6d6;
}

.toast.is-error .icon {
  color: var(--danger);
}

@media (max-width: 520px) {
  .widget {
    right: 16px;
    bottom: 16px;
  }

  .widget-toggle {
    width: 52px;
    height: 52px;
  }

  .widget-panel {
    position: fixed;
    right: 12px;
    bottom: 80px;
    left: 12px;
    width: auto;
    max-height: calc(100vh - 108px);
  }

  .widget-bubble {
    max-width: 82vw;
  }
}
