/* Saitola chat — ненавязчивый виджет */
.saitola-chat-launcher {
  position: fixed;
  z-index: 88;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  width: 3.25rem;
  height: 3.25rem;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: linear-gradient(135deg, #0891b2, #7c3aed);
  color: #fff;
  box-shadow: 0 4px 24px rgba(8, 145, 178, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease, box-shadow 0.2s;
}

.saitola-chat-launcher.is-visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.saitola-chat-launcher:hover {
  box-shadow: 0 6px 28px rgba(124, 58, 237, 0.4);
}

.saitola-chat-launcher svg {
  width: 1.35rem;
  height: 1.35rem;
}

body.has-sticky .saitola-chat-launcher {
  bottom: calc(5.25rem + env(safe-area-inset-bottom));
}

body.cookie-visible .saitola-chat-launcher {
  bottom: calc(5.5rem + env(safe-area-inset-bottom));
}

body.has-sticky.cookie-visible .saitola-chat-launcher {
  bottom: calc(9.5rem + env(safe-area-inset-bottom));
}

@media (min-width: 769px) {
  body.has-sticky .saitola-chat-launcher {
    bottom: calc(1rem + env(safe-area-inset-bottom));
  }
}

.saitola-chat-panel {
  position: fixed;
  z-index: 89;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(5rem + env(safe-area-inset-bottom));
  width: min(22rem, calc(100vw - 2rem));
  max-height: min(28rem, 70vh);
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--bg-elevated, #fff);
  box-shadow: 0 12px 48px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

[data-theme="dark"] .saitola-chat-panel {
  background: rgba(12, 12, 18, 0.98);
  border-color: rgba(255, 255, 255, 0.1);
}

.saitola-chat-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

body.has-sticky .saitola-chat-panel {
  bottom: calc(9.25rem + env(safe-area-inset-bottom));
}

body.cookie-visible .saitola-chat-panel {
  bottom: calc(9.5rem + env(safe-area-inset-bottom));
}

@media (min-width: 769px) {
  body.has-sticky .saitola-chat-panel {
    bottom: calc(5rem + env(safe-area-inset-bottom));
  }
}

.saitola-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--header-bg, rgba(248, 250, 252, 0.95));
}

[data-theme="dark"] .saitola-chat-header {
  background: rgba(255, 255, 255, 0.04);
}

.saitola-chat-header strong {
  font-size: 0.9rem;
  font-weight: 600;
}

.saitola-chat-header span {
  display: block;
  font-size: 0.7rem;
  color: var(--muted, #64748b);
  font-weight: 400;
}

.saitola-chat-close {
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted, #64748b);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.saitola-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 12rem;
}

.saitola-chat-msg {
  max-width: 92%;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8125rem;
  line-height: 1.5;
  word-break: break-word;
}

.saitola-chat-msg--bot {
  align-self: flex-start;
  background: var(--bg-muted, #f1f5f9);
  color: var(--text, #0f172a);
  border-bottom-left-radius: 4px;
}

[data-theme="dark"] .saitola-chat-msg--bot {
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
}

.saitola-chat-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #0891b2, #7c3aed);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.saitola-chat-msg a {
  color: inherit;
  text-decoration: underline;
}

.saitola-chat-typing {
  font-size: 0.75rem;
  color: var(--muted, #64748b);
  padding: 0 1rem 0.35rem;
  min-height: 1.1rem;
}

.saitola-chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border, #e2e8f0);
}

.saitola-chat-input {
  flex: 1;
  min-height: 42px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  font: inherit;
  font-size: 0.875rem;
  background: var(--input-bg, #fff);
  color: var(--text, #0f172a);
  resize: none;
}

.saitola-chat-send {
  min-width: 42px;
  min-height: 42px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #0891b2, #7c3aed);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0 0.65rem;
}

.saitola-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .saitola-chat-panel.is-open {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
  }
}
