/* AI Consultant Widget — scoped styles.
   Everything lives under .aicw-* class names to avoid clashing with the host page.
   Theme: warm cocoa + gold, matching the "Морфей — Отель люкс" site palette. No pink. */

.aicw-root {
  --aicw-brand: #b6824a;
  --aicw-brand-hover: #8f6531;
  --aicw-text: #2f2620;
  --aicw-muted: #7a6d5c;
  --aicw-bg: #ffffff;
  --aicw-bg-soft: #f7f1e8;
  --aicw-border: rgba(59, 39, 34, 0.12);
  --aicw-radius: 4px;
  --aicw-font: 'Manrope', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  position: fixed;
  z-index: 2147483000;
  font-family: var(--aicw-font);
  bottom: 24px;
  right: 24px;
}

.aicw-root * {
  box-sizing: border-box;
}

/* Launcher button */
.aicw-launcher {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--aicw-brand), var(--aicw-brand-hover));
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px -8px rgba(59, 39, 34, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.aicw-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px -6px rgba(59, 39, 34, 0.55);
}

.aicw-launcher svg {
  width: 28px;
  height: 28px;
}

.aicw-launcher .aicw-icon-close {
  display: none;
}

.aicw-root.aicw-open .aicw-icon-chat {
  display: none;
}

.aicw-root.aicw-open .aicw-icon-close {
  display: block;
}

/* Panel */
.aicw-panel {
  position: absolute;
  bottom: 78px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--aicw-bg);
  border-radius: var(--aicw-radius);
  border: 1px solid rgba(59, 39, 34, 0.1);
  box-shadow: 0 24px 60px -14px rgba(59, 39, 34, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.aicw-root.aicw-open .aicw-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

@media (max-width: 480px) {
  .aicw-panel {
    position: fixed;
    inset: 0;
    bottom: 0;
    right: 0;
    width: 100vw;
    /* 100vh on mobile browsers includes the space behind the address bar,
       which pushes the input row off-screen. 100dvh tracks the actual
       visible viewport; vh stays as a fallback for older browsers. */
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .aicw-root {
    bottom: 16px;
    right: 16px;
  }
  /* On mobile the panel goes fullscreen, so the floating launcher would
     otherwise sit on top of the input row. The header's own close (×)
     button is the only close control needed while the panel is open. */
  .aicw-root.aicw-open .aicw-launcher {
    display: none;
  }
}

/* Header */
.aicw-header {
  background: linear-gradient(135deg, var(--aicw-brand), var(--aicw-brand-hover));
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.aicw-header-title {
  font-family: 'Philosopher', serif;
  font-weight: 700;
  font-size: 1.05rem;
}

.aicw-header-sub {
  font-size: 0.78rem;
  opacity: 0.85;
  margin-top: 2px;
}

.aicw-header-close {
  background: rgba(255, 255, 255, 0.16);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.aicw-header-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Messages */
.aicw-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--aicw-bg-soft);
}

.aicw-msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.aicw-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--aicw-brand), var(--aicw-brand-hover));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.aicw-msg-assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--aicw-text);
  border: 1px solid var(--aicw-border);
  border-bottom-left-radius: 4px;
}

.aicw-msg-error {
  align-self: center;
  background: #fdecea;
  color: #7a271a;
  border: 1px solid #f5c2c0;
  font-size: 0.85rem;
}

/* Quick actions */
.aicw-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
  max-width: 100%;
}

.aicw-chip {
  background: #fff;
  border: 1px solid var(--aicw-border);
  color: var(--aicw-brand-hover);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.aicw-chip:hover {
  background: var(--aicw-brand);
  color: #fff;
  border-color: var(--aicw-brand);
}

/* WhatsApp CTA — keeps WhatsApp's own official green; that's a recognizable
   action color, not the widget's brand color, so it stays as-is. */
.aicw-whatsapp-cta {
  align-self: flex-start;
  max-width: 90%;
  background: #fff;
  border: 1px solid var(--aicw-border);
  border-radius: 14px;
  padding: 12px;
}

.aicw-whatsapp-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #25D366;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  justify-content: center;
}

.aicw-whatsapp-btn:hover {
  background: #20bd5a;
}

/* Typing indicator */
.aicw-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--aicw-border);
  border-radius: 14px;
}

.aicw-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--aicw-muted);
  animation: aicw-bounce 1.2s infinite ease-in-out;
}

.aicw-typing span:nth-child(2) { animation-delay: 0.15s; }
.aicw-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes aicw-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Input row */
.aicw-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--aicw-border);
  background: #fff;
  flex-shrink: 0;
}

.aicw-input {
  flex: 1;
  border: 1px solid var(--aicw-border);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-family: var(--aicw-font);
  outline: none;
  color: var(--aicw-text);
}

.aicw-input:focus {
  border-color: var(--aicw-brand);
}

.aicw-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--aicw-brand), var(--aicw-brand-hover));
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.aicw-send:hover {
  filter: brightness(1.08);
}

.aicw-send:disabled {
  opacity: 0.5;
  cursor: default;
}

.aicw-send svg {
  width: 18px;
  height: 18px;
}
