.ai-trigger {
  position: fixed;
  bottom: 170px;
  right: 28px;
  z-index: 2147483647;
  cursor: pointer;
  background: #FF6B35;
  border-radius: 14px;
  padding: 18px 32px;
  color: #fff;
  font-family: 'Roboto', sans-serif;
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(255, 107, 53, 0.4);
  transition: opacity 0.3s ease, visibility 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease, background 0.2s ease;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.ai-trigger:hover {
  background: #E85D2C;
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(255, 107, 53, 0.5);
}
.ai-trigger__icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}
.ai-trigger__text-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.ai-trigger__main {
  font-size: 17px;
  font-weight: 700;
}
.ai-trigger__sub {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.85;
  margin-top: 2px;
}

@keyframes ai-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(255, 107, 53, 0.4); }
  50% { box-shadow: 0 4px 24px rgba(255, 107, 53, 0.65), 0 0 0 6px rgba(255, 107, 53, 0.08); }
}
.ai-trigger:not(.ai-trigger--open):not(:hover) {
  animation: ai-pulse 2.5s ease-in-out infinite;
}
.ai-trigger--open {
  animation: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ai-panel {
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  height: 100svh;
  width: min(400px, 33vw);
  min-width: 320px;
  z-index: 2147483646;
  background: #ffffff;
  border-left: 1px solid #C4CBCE;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -4px 0 40px rgba(0, 0, 0, 0.15);
  font-family: 'Roboto', sans-serif;
}
.ai-panel--open {
  transform: translateX(0);
}

.ai-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #C4CBCE;
  flex-shrink: 0;
  background: #0093CA;
}
.ai-panel__title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-panel__title-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #FFBD00;
  box-shadow: 0 0 8px rgba(255, 189, 0, 0.6);
  animation: ai-dot 1.5s ease-in-out infinite;
}
@keyframes ai-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.ai-panel__close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  line-height: 1;
}
.ai-panel__close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.ai-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}
.ai-panel__messages::-webkit-scrollbar {
  width: 6px;
}
.ai-panel__messages::-webkit-scrollbar-track {
  background: transparent;
}
.ai-panel__messages::-webkit-scrollbar-thumb {
  background: #C4CBCE;
  border-radius: 3px;
}

.ai-msg {
  max-width: 90%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  animation: ai-msg-in 0.25s ease-out;
}
@keyframes ai-msg-in {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}
.ai-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #0093CA 0%, #1e8bc3 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg--bot {
  align-self: flex-start;
  background: #EBF3F6;
  color: #333333;
  border: 1px solid #C4CBCE;
  border-bottom-left-radius: 4px;
}
.ai-msg--bot strong {
  color: #272727;
  font-weight: 600;
}
.ai-msg--bot em {
  color: #0093CA;
  font-style: italic;
}
.ai-msg--bot a {
  color: #0093CA;
  font-weight: 600;
  text-decoration: underline;
}
.ai-msg--bot a:hover {
  color: #006699;
}
.ai-msg--error {
  align-self: flex-start;
  background: rgba(211, 124, 124, 0.15);
  color: #d17c7c;
  border: 1px solid rgba(211, 124, 124, 0.3);
  border-bottom-left-radius: 4px;
}

.ai-panel__thinking {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  align-self: flex-start;
  background: #EBF3F6;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  border: 1px solid #C4CBCE;
}
.ai-panel__thinking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ADBEC6;
  animation: ai-think 1.2s ease-in-out infinite;
}
.ai-panel__thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-panel__thinking-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-think {
  0%, 80%, 100% { background: #ADBEC6; }
  40% { background: #0093CA; }
}

.ai-panel__input-area {
  padding: 16px 20px;
  border-top: 1px solid #C4CBCE;
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  background: #ffffff;
}
.ai-panel__input {
  flex: 1;
  height: 44px;
  padding: 0 16px;
  border: 2px solid #ADBEC6;
  border-radius: 8px;
  background: #ffffff;
  color: #333333;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  transition: border-color 0.2s ease;
}
.ai-panel__input:focus {
  outline: none;
  border-color: #0093CA;
}
.ai-panel__input::placeholder {
  color: #ADBEC6;
}
.ai-panel__disclaimer {
  padding: 6px 20px 10px;
  font-size: 10px;
  color: #ADBEC6;
  text-align: center;
  line-height: 1.3;
  flex-shrink: 0;
}
.ai-panel__send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #0093CA 0%, #1e8bc3 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.ai-panel__send:hover {
  box-shadow: 0 4px 15px rgba(0, 147, 202, 0.4);
}
.ai-panel__send svg {
  width: 20px;
  height: 20px;
}
.ai-panel__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Override third-party widget z-index — must be below AI chat */
jdiv, [class*="calltouch"], [id*="calltouch"], [data-calltouch], [data-calltouch-widget] {
  z-index: 100 !important;
}

@media (max-width: 768px) {
  .ai-panel {
    width: 100vw;
    min-width: 100vw;
  }
  .ai-trigger {
    bottom: 20px;
    right: 20px;
    padding: 10px 16px;
  }
  .ai-trigger__main {
    font-size: 12px;
  }
}