.ai-chat-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1060;
  font-family: "Roboto", sans-serif;
}

.ai-chat-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-800, #002e88) 0%, var(--blue-700, #0b45a8) 58%, var(--accent-500, #5e8ed6) 100%);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 18px 38px rgba(0, 46, 136, .24), 0 0 0 7px rgba(94, 142, 214, .14);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.ai-chat-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 44px rgba(0, 46, 136, .28), 0 0 0 9px rgba(94, 142, 214, .18);
}

.ai-chat-toggle i {
  font-size: 21px;
  line-height: 1;
}

.ai-chat-widget.is-open .ai-chat-toggle {
  background: linear-gradient(135deg, var(--blue-950, #000f2e) 0%, var(--blue-800, #002e88) 62%, var(--accent-500, #5e8ed6) 100%);
  box-shadow: 0 18px 38px rgba(0, 46, 136, .26), 0 0 0 7px rgba(94, 142, 214, .14);
}

.ai-chat-panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 32px));
  max-height: min(740px, calc(100vh - 110px));
  overflow: hidden;
  border: 1px solid rgba(0, 46, 136, .14);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-lg, 0 28px 70px rgba(0, 29, 86, .18)), 0 0 0 1px rgba(255, 255, 255, .82) inset;
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(.96);
  transform-origin: right bottom;
  transition: opacity .22s ease, transform .22s ease;
}

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

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  background: linear-gradient(135deg, var(--blue-950, #000f2e) 0%, var(--blue-800, #002e88) 72%, var(--accent-500, #5e8ed6) 100%);
  color: #fff;
}

.ai-chat-header strong,
.ai-chat-header span {
  display: block;
}

.ai-chat-header strong {
  font-size: 15px;
}

.ai-chat-header span {
  margin-top: 2px;
  color: rgba(255, 255, 255, .78);
  font-size: 12px;
}

.ai-chat-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  transition: background .2s ease, transform .2s ease;
}

.ai-chat-close:hover {
  background: rgba(255, 255, 255, .22);
  transform: rotate(90deg);
}

.ai-chat-messages {
  flex: 1;
  min-height: 300px;
  overflow-y: auto;
  padding: 16px;
  background: var(--surface-200, #f4f7fc);
}

.ai-chat-message {
  max-width: 86%;
  margin-bottom: 10px;
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
}

.ai-chat-message p {
  margin: 0;
  color: inherit;
  white-space: pre-wrap;
}

.ai-chat-inline-link {
  color: var(--blue-800, #002e88);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.ai-chat-message-user .ai-chat-inline-link {
  color: #fff;
}

.ai-chat-message-user {
  margin-left: auto;
  background: var(--blue-800, #002e88);
  color: #fff;
}

.ai-chat-message-user p {
  color: #fff;
}

.ai-chat-message-assistant {
  margin-right: auto;
  background: #fff;
  color: var(--ink-900, #152038);
  border: 1px solid rgba(0, 46, 136, .12);
  box-shadow: var(--shadow-sm, 0 8px 24px rgba(0, 46, 136, .08));
}

.ai-chat-loading {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
}

.ai-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 48px;
  padding: 4px 2px;
}

.ai-chat-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-800, #002e88), var(--accent-500, #5e8ed6));
  box-shadow: 0 4px 10px rgba(0, 46, 136, .18);
  animation: ai-chat-typing-dot 1.05s ease-in-out infinite;
}

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

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

@keyframes ai-chat-typing-dot {
  0%,
  70%,
  100% {
    opacity: .38;
    transform: translateY(0) scale(.86);
  }

  35% {
    opacity: 1;
    transform: translateY(-5px) scale(1);
  }
}

.ai-chat-cards,
.ai-chat-actions,
.ai-chat-suggestions {
  display: grid;
  gap: 8px;
}

.ai-chat-cards {
  margin: 4px 0 12px;
}

.ai-chat-card {
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line-color, #dde5f1);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-900, #152038);
  text-decoration: none;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.ai-chat-card-no-image {
  grid-template-columns: 1fr;
}

.ai-chat-card:hover {
  border-color: var(--accent-500, #5e8ed6);
  box-shadow: var(--shadow-sm, 0 8px 24px rgba(0, 46, 136, .08));
  transform: translateY(-1px);
}

.ai-chat-card img {
  width: 74px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
}

.ai-chat-card strong,
.ai-chat-card small {
  display: block;
}

.ai-chat-card strong {
  font-size: 13px;
}

.ai-chat-card small {
  margin-top: 3px;
  color: #687789;
  font-size: 12px;
}

.ai-chat-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
}

.ai-chat-actions a,
.ai-chat-suggestions button {
  border: 1px solid var(--line-color, #dde5f1);
  border-radius: 999px;
  background: #fff;
  color: var(--blue-800, #002e88);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.ai-chat-actions a:hover,
.ai-chat-suggestions button:hover {
  border-color: var(--accent-500, #5e8ed6);
  box-shadow: var(--shadow-sm, 0 8px 24px rgba(0, 46, 136, .08));
  transform: translateY(-1px);
}

.ai-chat-actions a {
  padding: 8px 10px;
  text-align: center;
}

.ai-chat-suggestions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 12px 16px 0;
  background: #fff;
}

.ai-chat-suggestions button {
  min-height: 34px;
  padding: 6px 10px;
}

.ai-chat-form {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
  padding: 12px 16px 16px;
  background: #fff;
}

.ai-chat-form textarea {
  min-height: 42px;
  max-height: 120px;
  overflow: hidden;
  resize: none;
  padding: 10px 12px;
  border: 1px solid rgba(0, 46, 136, .18);
  border-radius: 8px;
  color: var(--ink-900, #152038);
  font: inherit;
}

.ai-chat-form textarea:focus {
  border-color: var(--accent-600, #3d73c7);
  box-shadow: 0 0 0 3px rgba(94, 142, 214, .18);
  outline: 0;
}

.ai-chat-form button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--blue-800, #002e88);
  color: #fff;
}

.ai-chat-form.is-loading button {
  opacity: .65;
  pointer-events: none;
}

@media (max-width: 575.98px) {
  .ai-chat-widget {
    z-index: 1095;
    right: 16px;
    bottom: 16px;
  }

  .ai-chat-widget::before {
    display: none;
  }

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

  .ai-chat-toggle span {
    display: none;
  }

  .ai-chat-toggle {
    width: 54px;
    height: 54px;
    justify-content: center;
    padding: 0;
    position: relative;
    z-index: 3;
  }

  .ai-chat-widget.is-open .ai-chat-toggle {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: 12px;
    bottom: auto;
    z-index: 4;
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, .14);
    box-shadow: none;
  }

  .ai-chat-panel {
    position: fixed;
    inset: 0;
    z-index: 2;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
    transform: translateY(18px);
    transform-origin: center bottom;
  }

  .ai-chat-header {
    flex: 0 0 auto;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 64px 14px 15px;
  }

  .ai-chat-widget.is-open .ai-chat-close {
    display: none;
  }

  .ai-chat-messages {
    min-height: 0;
  }

  .ai-chat-suggestions {
    grid-template-columns: 1fr;
  }

  .ai-chat-form {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}
