/* Коломбо AI-консультант */
:root {
  --ai-brand: #11aabb;
  --ai-brand-hover: #0e96a5;
  --ai-ink: #1a1d26;
  --ai-ink-soft: #5c6473;
  --ai-surface: #ffffff;
  --ai-bg: #f4f7f9;
  --ai-border: #e2e8f0;
  --ai-shadow: 0 8px 32px rgba(26, 29, 38, 0.16);
  --ai-radius: 16px;
  --ai-font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#callombo-ai-root,
#callombo-ai-root *,
#callombo-ai-root *::before,
#callombo-ai-root *::after {
  box-sizing: border-box;
}

#callombo-ai-root {
  position: fixed;
  bottom: 30px;
  z-index: 10001;
  font-family: var(--ai-font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ai-ink);
}

#callombo-ai-root.callombo-ai-root--left {
  left: 30px;
  right: auto;
}

#callombo-ai-root.callombo-ai-root--right {
  right: 30px;
  left: auto;
}

#callombo-ai-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: #ffffff;
  z-index: 10000;
  pointer-events: none;
}

#callombo-ai-backdrop.is-open {
  display: block;
  pointer-events: auto;
}

#callombo-ai-toggle {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--ai-brand);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--ai-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  position: relative;
  z-index: 2;
}

#callombo-ai-toggle:hover {
  background: var(--ai-brand-hover);
  transform: scale(1.04);
}

#callombo-ai-toggle svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

#callombo-ai-panel {
  position: absolute;
  bottom: 68px;
  width: min(360px, calc(100vw - 60px));
  height: min(520px, calc(100vh - 120px));
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius);
  box-shadow: var(--ai-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 1;
}

.callombo-ai-root--left #callombo-ai-panel {
  left: 0;
  right: auto;
}

.callombo-ai-root--right #callombo-ai-panel {
  right: 0;
  left: auto;
}

#callombo-ai-panel.is-open {
  display: flex;
}

#callombo-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--ai-brand), #0d8a99);
  color: #fff;
}

#callombo-ai-header strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
}

#callombo-ai-header span {
  font-size: 12px;
  opacity: 0.9;
}

.callombo-ai-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

#callombo-ai-clear {
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

#callombo-ai-clear:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.28);
}

#callombo-ai-clear:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#callombo-ai-clear[hidden] {
  display: none;
}

#callombo-ai-close {
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

#callombo-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: var(--ai-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-msg a {
  color: inherit;
  text-decoration: underline;
}

.ai-msg--bot {
  align-self: flex-start;
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-bottom-left-radius: 4px;
}

.ai-msg--user {
  align-self: flex-end;
  background: var(--ai-brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-msg--typing {
  align-self: flex-start;
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  color: var(--ai-ink-soft);
  font-style: italic;
}

#callombo-ai-footer {
  border-top: 1px solid var(--ai-border);
  padding: 12px;
  background: var(--ai-surface);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

#callombo-ai-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
  min-width: 0;
  max-width: 100%;
  width: 100%;
}

#callombo-ai-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--ai-border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px; /* без зума iOS при фокусе */
  line-height: 1.35;
  resize: none;
  min-height: 42px;
  max-height: 120px;
}

#callombo-ai-input:focus {
  outline: none;
  box-shadow: none;
  border-color: var(--ai-brand);
}

#callombo-ai-send {
  border: none;
  border-radius: 10px;
  background: var(--ai-brand);
  color: #fff;
  padding: 0 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  flex: 0 0 auto;
  min-width: 64px;
  max-width: 30%;
}

#callombo-ai-send:hover:not(:disabled) {
  background: var(--ai-brand-hover);
}

#callombo-ai-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#callombo-ai-hint {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--ai-ink-soft);
  text-align: center;
}

html.callombo-ai-scroll-lock,
body.callombo-ai-scroll-lock {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
}

/* Мобильный: чат на весь экран, как Jivo / Verbox */
@media (max-width: 767px) {
  #callombo-ai-root.callombo-ai-root--left,
  #callombo-ai-root.callombo-ai-root--right {
    left: 30px;
    right: 30px;
  }

  #callombo-ai-root.callombo-ai-root--left {
    right: auto;
  }

  #callombo-ai-root.callombo-ai-root--right {
    left: auto;
  }

  #callombo-ai-root.is-open {
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    width: 100%;
    height: 100%;
  }

  #callombo-ai-root.is-open #callombo-ai-toggle {
    display: none;
  }

  #callombo-ai-root.is-open #callombo-ai-panel {
    position: fixed;
    inset: 0;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    height: 100dvh;
    max-height: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    overflow-x: hidden;
    overscroll-behavior: none;
    touch-action: none;
    z-index: 1;
    background: var(--ai-surface);
    /* без transition — анимация top/height как раз давала «отрыв» шапки */
  }

  #callombo-ai-root.is-open #callombo-ai-header {
    flex-shrink: 0;
    min-width: 0;
    max-width: 100%;
    padding-top: max(14px, env(safe-area-inset-top));
    touch-action: none;
  }

  #callombo-ai-root.is-open #callombo-ai-messages {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  #callombo-ai-root.is-open #callombo-ai-footer {
    flex-shrink: 0;
    min-width: 0;
    max-width: 100%;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    touch-action: none;
  }
}
