/* AI chat — site theme (Inter, blue #2E63EB / #1E4FCB, ink #16233F) */
.ai-trigger {
  position: fixed;
  bottom: 170px;
  right: 28px;
  z-index: 2147483647;
  cursor: pointer;
  background: linear-gradient(135deg, #2E63EB, #1E4FCB);
  border-radius: 14px;
  padding: 18px 32px;
  color: #fff;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(46, 99, 235, 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: #1E4FCB;
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(46, 99, 235, 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(46, 99, 235, 0.4); }
  50% { box-shadow: 0 4px 24px rgba(46, 99, 235, 0.65), 0 0 0 6px rgba(46, 99, 235, 0.08); }
}
.ai-trigger:not(.ai-trigger--open):not(:hover) {
  animation: ai-pulse 2.5s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .ai-trigger:not(.ai-trigger--open):not(:hover) {
    animation: none;
  }
  .ai-panel__title-dot {
    animation: none;
  }
  .ai-panel__thinking-dot {
    animation: none;
  }
  .ai-msg {
    animation: none;
  }
}
.ai-trigger--open {
  animation: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.ai-trigger.ai-trigger--jivo {
  transform: translateY(var(--ai-trigger-jivo-shift, 0));
}
.ai-trigger.ai-trigger--jivo:hover {
  transform: translateY(calc(var(--ai-trigger-jivo-shift, 0) - 2px));
}
.ai-trigger.ai-trigger--jivo-hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ai-panel {
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  height: 100dvh;
  width: 400px;
  max-width: 100vw;
  z-index: 2147483646;
  background: #ffffff;
  border-left: 1px solid #E7E9EF;
  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: 'Inter', system-ui, sans-serif;
}
.ai-panel--open {
  transform: translateX(0);
}

.ai-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid #16233F;
  flex-shrink: 0;
  background: linear-gradient(135deg, #2E63EB, #16233F);
}
.ai-panel__title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Inter', system-ui, sans-serif;
  min-width: 0;
}
.ai-panel__title-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
  animation: ai-dot 1.5s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes ai-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.ai-panel__header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.ai-panel__call {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 10px;
  border-radius: 8px;
  color: #fff;
  text-decoration: none;
  transition: background 0.2s ease;
}
.ai-panel__call:hover {
  background: rgba(255, 255, 255, 0.2);
}
.ai-panel__call svg {
  width: 20px;
  height: 20px;
}
.ai-panel__call:focus-visible,
.ai-panel__close:focus-visible,
.ai-panel__send:focus-visible,
.ai-chip:focus-visible,
.ai-order-btn:focus-visible,
.ai-order-submit:focus-visible,
.ai-order-cancel:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.ai-panel__close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 24px;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  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;
  font-family: 'Inter', system-ui, sans-serif;
}
.ai-panel__messages::-webkit-scrollbar {
  width: 6px;
}
.ai-panel__messages::-webkit-scrollbar-track {
  background: transparent;
}
.ai-panel__messages::-webkit-scrollbar-thumb {
  background: #B9C4D2;
  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;
  font-family: 'Inter', system-ui, sans-serif;
}
@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, #2E63EB 0%, #1E4FCB 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg--bot {
  align-self: flex-start;
  background: #F6F8FC;
  color: #16233F;
  border: 1px solid #E7E9EF;
  border-bottom-left-radius: 4px;
}
.ai-msg--bot strong {
  color: #16233F;
  font-weight: 600;
}
.ai-msg--bot em {
  color: #2E63EB;
  font-style: italic;
}
.ai-msg--bot a {
  color: #2E63EB;
  font-weight: 600;
  text-decoration: underline;
}
.ai-msg--bot a:hover {
  color: #1E4FCB;
}
.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;
  margin: 0 20px;
  align-self: flex-start;
  background: #F6F8FC;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  border: 1px solid #E7E9EF;
}
.ai-panel__thinking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #B9C4D2;
  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: #B9C4D2; }
  40% { background: #2E63EB; }
}

/* Quick-action chips under the input */
.ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 20px 0;
  flex-shrink: 0;
  background: #ffffff;
}
.ai-chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 1.5px solid #E7E9EF;
  border-radius: 999px;
  background: #F6F8FC;
  color: #16233F;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.ai-chip:hover {
  border-color: #2E63EB;
  background: #fff;
}
button.ai-chip {
  appearance: none;
}

.ai-panel__input-area {
  padding: 16px 20px;
  border-top: 1px solid #E7E9EF;
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  background: #ffffff;
}
.ai-panel__input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border: 1.5px solid #E7E9EF;
  border-radius: 8px;
  background: #ffffff;
  color: #16233F;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  transition: border-color 0.2s ease;
}
.ai-panel__input:focus {
  outline: none;
  border-color: #2E63EB;
}
.ai-panel__input::placeholder {
  color: #5B6577;
}
.ai-panel__disclaimer {
  padding: 6px 20px 10px;
  font-size: 10px;
  color: #5B6577;
  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, #2E63EB 0%, #1E4FCB 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(46, 99, 235, 0.4);
}
.ai-panel__send svg {
  width: 20px;
  height: 20px;
}
.ai-panel__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Order form (styles moved out of JS inline styles) */
.ai-order-container {
  padding: 0 20px;
}
.ai-order-btn {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
  padding: 14px;
  background: linear-gradient(135deg, #2E63EB, #1E4FCB);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.ai-order-btn:hover {
  box-shadow: 0 4px 15px rgba(46, 99, 235, 0.4);
}
.ai-order-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ai-order-form__card {
  max-width: 100%;
  background: #F6F8FC;
  border: 2px solid #2E63EB;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.ai-order-form__title {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 12px;
  color: #2E63EB;
}
.ai-order-input {
  width: 100%;
  min-height: 44px;
  padding: 12px 16px;
  border: 1.5px solid #E7E9EF;
  border-radius: 8px;
  background: #fff;
  color: #16233F;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  margin-bottom: 10px;
  box-sizing: border-box;
}
.ai-order-input:focus {
  outline: none;
  border-color: #2E63EB;
}
.ai-order-input::placeholder {
  color: #5B6577;
}
.ai-order-form__row {
  display: flex;
  gap: 10px;
}
.ai-order-submit {
  flex: 1;
  min-height: 44px;
  padding: 12px;
  background: linear-gradient(135deg, #2E63EB, #1E4FCB);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.ai-order-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ai-order-cancel {
  flex: 1;
  min-height: 44px;
  padding: 12px;
  background: #e2e8f0;
  color: #475569;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  cursor: pointer;
}
.ai-order-error {
  color: #d17c7c;
  font-size: 13px;
  margin-top: 8px;
  display: none;
}
.ai-order-error--visible {
  display: block;
}

/* 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;
}

/* Hide JivoSite label (yellow "Отправьте нам сообщение" tag) */
#jvLabelWrap {
  display: none !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;
  }
}

/* Mobile: bottom sheet almost fullscreen */
@media (max-width: 560px) {
  .ai-panel {
    top: auto;
    bottom: 8px;
    left: 8px;
    right: 8px;
    width: calc(100vw - 16px);
    min-width: 0;
    max-height: 92dvh;
    height: 92dvh;
    border-left: none;
    border: 1px solid #E7E9EF;
    border-radius: 16px;
    overflow: hidden;
    transform: translateY(calc(100% + 16px));
  }
  .ai-panel--open {
    transform: translateY(0);
  }
}

/* patch hide trigger */
.ai-trigger{display:none !important; visibility:hidden !important; pointer-events:none !important;}
