.ai-assistant-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1060;
  font-family: Inter, Arial, sans-serif;
}

.ai-assistant-widget,
.ai-assistant-widget * {
  box-sizing: border-box;
}

.ai-assistant-robot {
  position: relative;
  width: 104px;
  height: 104px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  outline: none;
  animation: aiAssistantFloat 4s ease-in-out infinite;
}

.ai-assistant-robot img {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 12px 24px rgba(0, 97, 255, 0.25));
  transition: transform 180ms ease, filter 180ms ease;
}

.ai-assistant-halo {
  position: absolute;
  inset: 12px;
  z-index: 1;
  border-radius: 999px;
  background: rgba(0, 123, 255, 0.18);
  box-shadow: 0 0 24px rgba(0, 123, 255, 0.35);
  animation: aiAssistantPulse 2.6s ease-in-out infinite;
}

.ai-assistant-robot:hover img,
.ai-assistant-widget.is-open .ai-assistant-robot img {
  transform: scale(1.06);
  filter: drop-shadow(0 14px 28px rgba(0, 97, 255, 0.34));
}

.ai-assistant-panel {
  position: absolute;
  right: 0;
  bottom: 118px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 150px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(0, 97, 255, 0.12);
  border-radius: 20px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
  transform-origin: right bottom;
  transition: opacity 180ms ease, transform 180ms ease;
}

.ai-assistant-widget.is-open .ai-assistant-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.ai-assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  color: #fff;
  background: linear-gradient(135deg, #006dff 0%, #18a8ff 100%);
}

.ai-assistant-header > div:first-child {
  min-width: 0;
}

.ai-assistant-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.ai-assistant-subtitle {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.35;
  opacity: 0.88;
  overflow-wrap: anywhere;
}

.ai-assistant-header-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
}

.ai-assistant-close,
.ai-assistant-end {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  font-size: 24px;
  line-height: 28px;
  cursor: pointer;
}

.ai-assistant-end {
  font-size: 15px;
  line-height: 30px;
}

.ai-assistant-messages {
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #f6f8fb;
}

.ai-assistant-message {
  display: flex;
  margin-bottom: 10px;
}

.ai-assistant-message.is-customer {
  justify-content: flex-end;
}

.ai-assistant-message.is-system {
  justify-content: center;
}

.ai-assistant-bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 16px;
  color: #111827;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  font-size: 14px;
  line-height: 1.42;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ai-assistant-message.is-customer .ai-assistant-bubble {
  color: #fff;
  background: #006dff;
  border-bottom-right-radius: 6px;
}

.ai-assistant-message.is-ai .ai-assistant-bubble,
.ai-assistant-message.is-admin .ai-assistant-bubble {
  border-bottom-left-radius: 6px;
}

.ai-assistant-message.is-system .ai-assistant-bubble {
  max-width: 94%;
  color: #64748b;
  background: transparent;
  box-shadow: none;
  text-align: center;
  font-size: 12px;
}

.ai-assistant-typing {
  padding: 0 16px 8px;
  background: #f6f8fb;
}

.ai-assistant-typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-radius: 50%;
  background: #60a5fa;
  animation: aiAssistantTyping 1s ease-in-out infinite;
}

.ai-assistant-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.ai-assistant-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

.ai-assistant-new {
  display: block;
  margin: 10px 16px;
  padding: 10px 14px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: #006dff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.ai-assistant-new[hidden] {
  display: none;
}

.ai-assistant-widget.is-closed .ai-assistant-end,
.ai-assistant-widget.is-blocked .ai-assistant-end {
  display: none;
}

.ai-assistant-form {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
}

.ai-assistant-input {
  flex: 1;
  min-height: 42px;
  max-height: 110px;
  resize: none;
  border: 1px solid #d8e0ea;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 20px;
  outline: none;
}

.ai-assistant-input:focus {
  border-color: #1e88ff;
  box-shadow: 0 0 0 3px rgba(30, 136, 255, 0.12);
}

.ai-assistant-send {
  width: 42px;
  min-width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: #006dff;
  cursor: pointer;
}

.ai-assistant-form.is-disabled,
.ai-assistant-input:disabled,
.ai-assistant-send:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

@keyframes aiAssistantFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

@keyframes aiAssistantPulse {
  0%, 100% { transform: scale(0.92); opacity: 0.55; }
  50% { transform: scale(1.18); opacity: 0.16; }
}

@keyframes aiAssistantTyping {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 767px) {
  .ai-assistant-widget {
    right: 12px;
    bottom: 76px;
    bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .ai-assistant-robot {
    width: 76px;
    height: 76px;
  }

  .ai-assistant-halo {
    inset: 8px;
  }

  .ai-assistant-panel {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 96px;
    bottom: calc(96px + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    height: 560px;
    height: min(560px, calc(100vh - 124px));
    height: min(560px, calc(100dvh - 124px));
    max-height: calc(100vh - 124px);
    max-height: calc(100dvh - 124px);
    border-radius: 18px;
    transform-origin: right bottom;
  }

  .ai-assistant-header {
    padding: 12px 14px;
    gap: 8px;
  }

  .ai-assistant-title {
    font-size: 15px;
  }

  .ai-assistant-subtitle {
    font-size: 11px;
  }

  .ai-assistant-close,
  .ai-assistant-end {
    width: 30px;
    height: 30px;
    font-size: 22px;
    line-height: 28px;
  }

  .ai-assistant-end {
    font-size: 14px;
  }

  .ai-assistant-messages {
    padding: 12px;
  }

  .ai-assistant-bubble {
    max-width: 88%;
    font-size: 13px;
    line-height: 1.4;
  }

  .ai-assistant-message.is-system .ai-assistant-bubble {
    max-width: 100%;
  }

  .ai-assistant-new {
    margin: 8px 12px 10px;
  }

  .ai-assistant-form {
    gap: 7px;
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .ai-assistant-input {
    min-height: 40px;
    max-height: 92px;
    border-radius: 13px;
    font-size: 13px;
    line-height: 19px;
  }

  .ai-assistant-send {
    width: 40px;
    min-width: 40px;
    height: 40px;
    border-radius: 13px;
  }
}

@media (max-width: 380px) {
  .ai-assistant-widget {
    right: 10px;
    bottom: 72px;
    bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .ai-assistant-robot {
    width: 68px;
    height: 68px;
  }

  .ai-assistant-panel {
    left: 10px;
    right: 10px;
    bottom: 86px;
    bottom: calc(86px + env(safe-area-inset-bottom));
    height: min(540px, calc(100vh - 108px));
    height: min(540px, calc(100dvh - 108px));
    max-height: calc(100vh - 108px);
    max-height: calc(100dvh - 108px);
  }

  .ai-assistant-title {
    font-size: 14px;
  }

  .ai-assistant-subtitle {
    font-size: 10.5px;
  }
}

@media (max-width: 767px) and (max-height: 560px) {
  .ai-assistant-widget {
    bottom: 58px;
    bottom: calc(58px + env(safe-area-inset-bottom));
  }

  .ai-assistant-robot {
    width: 62px;
    height: 62px;
  }

  .ai-assistant-panel {
    top: 8px;
    left: 10px;
    right: 10px;
    bottom: 76px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    height: auto;
    max-height: none;
    border-radius: 16px;
  }

  .ai-assistant-header {
    padding: 10px 12px;
  }

  .ai-assistant-subtitle {
    display: none;
  }

  .ai-assistant-messages {
    padding: 10px;
  }

  .ai-assistant-form {
    padding: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-assistant-robot,
  .ai-assistant-halo,
  .ai-assistant-typing span {
    animation: none;
  }

  .ai-assistant-panel,
  .ai-assistant-robot img {
    transition: none;
  }
}
