/* =========================================================
   SMARTER.YACHTS AI SUPPORT ASSISTANT
   BUGFIX VERSION
   All chat component rules are scoped to #syChatbot.
   ========================================================= */

/* Page-level layout only */
.sy-chatbot-page {
  padding-top: 104px;
  padding-bottom: 72px;
  min-height: 100vh;
  overflow-x: clip;
}

.sy-chatbot-page .sy-chatbot-container {
  max-width: 1180px;
}

.sy-chatbot-page .sy-chatbot-intro {
  max-width: 900px;
  margin-bottom: 34px;
}

.sy-chatbot-page .sy-chatbot-intro h1 {
  margin: 8px 0 14px;
}

.sy-chatbot-page .sy-chatbot-intro p {
  max-width: 820px;
  font-size: 18px;
  line-height: 1.65;
}

/* Absolute safety: nothing inside the chatbot may exceed its width */
#syChatbot,
#syChatbot *,
#syChatbot *::before,
#syChatbot *::after {
  box-sizing: border-box;
}

#syChatbot {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--card-border, #d3e0e5);
  border-radius: 24px;
  background: var(--color-surface-white, #fff);
  box-shadow: 0 18px 54px rgba(19, 50, 66, .10);
  color: var(--color-text-on-light, #17304f);
}

/* Never allow any chatbot image to use its intrinsic dimensions */
#syChatbot img {
  display: block !important;
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  object-fit: contain !important;
}

/* Top bar */
#syChatbot .sy-chatbot-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  width: 100%;
  min-width: 0;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border-subtle, rgba(23,67,115,.14));
  background: var(--color-surface-white, #fff);
}

#syChatbot .sy-chatbot-agent {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

#syChatbot .sy-chatbot-agent-avatar {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  min-width: 54px;
  max-width: 54px;
  min-height: 54px;
  max-height: 54px;
  overflow: hidden;
  border: 1px solid var(--color-border-subtle, rgba(23,67,115,.14));
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 5px 18px rgba(19,50,66,.08);
}

#syChatbot .sy-chatbot-agent-avatar > img {
  width: 44px !important;
  height: 44px !important;
  min-width: 0 !important;
  max-width: 44px !important;
  min-height: 0 !important;
  max-height: 44px !important;
  margin: 0 !important;
}

#syChatbot .sy-chatbot-agent-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#syChatbot .sy-chatbot-agent-copy strong {
  color: var(--color-text-on-light, #17304f);
  font-size: 16px;
  line-height: 1.3;
}

#syChatbot .sy-chatbot-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  color: var(--color-text-on-light-soft, #74889d);
  font-size: 12px;
}

#syChatbot .sy-chatbot-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--color-success, #168057);
  box-shadow: 0 0 0 3px rgba(22,128,87,.10);
}

#syChatbot .sy-chatbot-status.is-busy .sy-chatbot-status-dot {
  background: var(--color-warning, #d69c15);
  box-shadow: 0 0 0 3px rgba(214,156,21,.10);
}

#syChatbot .sy-chatbot-new {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid var(--color-border-subtle, rgba(23,67,115,.14));
  border-radius: 12px;
  background: var(--color-surface-white, #fff);
  color: var(--color-brand-primary, #1e5aa8);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  transition: background-color .2s ease, border-color .2s ease;
}

#syChatbot .sy-chatbot-new:hover {
  border-color: var(--color-brand-primary, #1e5aa8);
  background: var(--color-card-hover, #f7faff);
}

#syChatbot .sy-chatbot-new svg {
  display: block;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* Messages */
#syChatbot .sy-chatbot-messages {
  width: 100%;
  min-width: 0;
  min-height: 460px;
  height: min(58vh, 650px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 36px 30px 26px;
  background:
    radial-gradient(circle at top left, rgba(30,90,168,.035), transparent 34%),
    var(--color-page-end, #f4f7fb);
  scroll-behavior: smooth;
}

#syChatbot .sy-chatbot-message {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  min-width: 0;
  margin: 0 0 28px;
}

#syChatbot .sy-chatbot-message--user {
  flex-direction: row-reverse;
}

#syChatbot .sy-chatbot-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  min-width: 42px;
  max-width: 42px;
  min-height: 42px;
  max-height: 42px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 50%;
}

#syChatbot .sy-chatbot-avatar--assistant {
  border: 1px solid var(--color-border-subtle, rgba(23,67,115,.14));
  background: #fff;
  box-shadow: 0 5px 16px rgba(19,50,66,.07);
}

#syChatbot .sy-chatbot-avatar--assistant > img {
  width: 34px !important;
  height: 34px !important;
  min-width: 0 !important;
  max-width: 34px !important;
  min-height: 0 !important;
  max-height: 34px !important;
  margin: 0 !important;
}

#syChatbot .sy-chatbot-avatar--user {
  border: 1px solid var(--color-border-subtle, rgba(23,67,115,.14));
  background: var(--color-section-deep, #e9f0f8);
  color: var(--color-brand-primary, #1e5aa8);
}

#syChatbot .sy-chatbot-avatar--user svg {
  display: block;
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#syChatbot .sy-chatbot-message-content {
  width: auto;
  max-width: min(78%, 790px);
  min-width: 0;
}

#syChatbot .sy-chatbot-message--user .sy-chatbot-message-content {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#syChatbot .sy-chatbot-message-meta {
  margin: 0 4px 7px;
  color: var(--color-text-on-light-soft, #74889d);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
}

#syChatbot .sy-chatbot-bubble {
  width: fit-content;
  max-width: 100%;
  padding: 15px 17px;
  overflow-wrap: anywhere;
  border: 1px solid var(--color-border-subtle, rgba(23,67,115,.14));
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(19,50,66,.05);
}

#syChatbot .sy-chatbot-message--assistant .sy-chatbot-bubble {
  border-top-left-radius: 6px;
}

#syChatbot .sy-chatbot-message--user .sy-chatbot-bubble {
  border-top-right-radius: 6px;
  border-color: var(--color-brand-primary, #1e5aa8);
  background: var(--color-brand-primary, #1e5aa8);
  color: #fff;
  box-shadow: 0 7px 18px rgba(30,90,168,.14);
}

#syChatbot .sy-chatbot-bubble p {
  display: block;
  width: auto;
  max-width: none;
  margin: 0;
  color: inherit;
  font-size: 15px;
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#syChatbot .sy-chatbot-markdown p {
  margin: 0 0 10px;
  white-space: normal;
}

#syChatbot .sy-chatbot-markdown p:last-child,
#syChatbot .sy-chatbot-markdown ul:last-child,
#syChatbot .sy-chatbot-markdown ol:last-child {
  margin-bottom: 0;
}

#syChatbot .sy-chatbot-markdown ul,
#syChatbot .sy-chatbot-markdown ol {
  margin: 0 0 10px;
  padding-left: 22px;
}

#syChatbot .sy-chatbot-markdown a {
  color: var(--color-brand-primary, #1e5aa8);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Sources */
#syChatbot .sy-chatbot-sources {
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px solid var(--color-border-subtle, rgba(23,67,115,.14));
}

#syChatbot .sy-chatbot-sources strong {
  display: block;
  margin-bottom: 7px;
  color: var(--color-text-on-light-soft, #74889d);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

#syChatbot .sy-chatbot-sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

#syChatbot .sy-chatbot-sources a,
#syChatbot .sy-chatbot-source-label {
  display: inline-flex;
  align-items: center;
  min-height: 29px;
  padding: 5px 9px;
  border: 1px solid var(--color-border-subtle, rgba(23,67,115,.14));
  border-radius: 999px;
  background: var(--color-card-hover, #f7faff);
  color: var(--color-brand-primary, #1e5aa8);
  font-size: 11px;
  line-height: 1.2;
  text-decoration: none;
}

/* Typing */
#syChatbot .sy-chatbot-typing .sy-chatbot-bubble {
  min-width: 84px;
}

#syChatbot .sy-chatbot-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 16px;
}

#syChatbot .sy-chatbot-typing-dots i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-on-light-soft, #74889d);
  animation: syChatbotTyping 1.15s infinite ease-in-out;
}

#syChatbot .sy-chatbot-typing-dots i:nth-child(2) {
  animation-delay: .12s;
}

#syChatbot .sy-chatbot-typing-dots i:nth-child(3) {
  animation-delay: .24s;
}

@keyframes syChatbotTyping {
  0%, 60%, 100% {
    opacity: .32;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* Composer */
#syChatbot .sy-chatbot-composer-wrap {
  width: 100%;
  min-width: 0;
  padding: 18px 24px 20px;
  border-top: 1px solid var(--color-border-subtle, rgba(23,67,115,.14));
  background: #fff;
}

#syChatbot .sy-chatbot-form {
  width: 100%;
  min-width: 0;
  padding: 13px 13px 11px 16px;
  border: 1px solid var(--field-border, #bdccdc);
  border-radius: 18px;
  background: var(--field-background, #fff);
  box-shadow: 0 7px 24px rgba(19,50,66,.06);
  transition: border-color .2s ease, box-shadow .2s ease;
}

#syChatbot .sy-chatbot-form:focus-within {
  border-color: var(--field-border-focus, #1e5aa8);
  box-shadow: var(--field-focus-ring, 0 0 0 3px rgba(30,90,168,.10));
}

#syChatbot .sy-chatbot-form textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 96px;
  max-height: 220px;
  margin: 0;
  padding: 4px 2px 10px;
  resize: none;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--field-text, #17304f);
  box-shadow: none;
  font: inherit;
  font-size: 16px;
  line-height: 1.55;
}

#syChatbot .sy-chatbot-form textarea::placeholder {
  color: var(--field-placeholder, #74889d);
}

#syChatbot .sy-chatbot-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 42px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border-subtle, rgba(23,67,115,.14));
}

#syChatbot .sy-chatbot-hint {
  color: var(--color-text-on-light-soft, #74889d);
  font-size: 11px;
}

#syChatbot .sy-chatbot-form button[type="submit"] {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  flex: 0 0 auto;
  min-width: 102px;
  min-height: 42px;
  margin: 0;
  padding: 9px 15px;
  border: 1px solid var(--color-brand-primary, #1e5aa8);
  border-radius: 12px;
  background: var(--color-brand-primary, #1e5aa8);
  color: #fff;
  box-shadow: none;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

#syChatbot .sy-chatbot-form button[type="submit"]:hover {
  border-color: var(--color-brand-hover, #174b8f);
  background: var(--color-brand-hover, #174b8f);
}

#syChatbot .sy-chatbot-form button[type="submit"] svg {
  display: block;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#syChatbot button:disabled,
#syChatbot textarea:disabled {
  opacity: .52;
  cursor: not-allowed;
}

#syChatbot .sy-chatbot-footnote {
  margin: 10px 3px 0;
  color: var(--color-text-on-light-soft, #74889d);
  font-size: 11px;
  line-height: 1.45;
}

#syChatbot .sy-chatbot-error .sy-chatbot-bubble {
  border-color: var(--color-error-border-light, #e5aaaa);
  background: var(--color-error-surface-soft, #fff7f7);
  color: var(--color-error-text, #8c2424);
}

#syChatbot .sy-chatbot-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Mobile */
@media (max-width: 760px) {
  .sy-chatbot-page {
    padding-top: 86px;
    padding-bottom: 36px;
  }

  .sy-chatbot-page .sy-chatbot-container {
    padding-left: 12px;
    padding-right: 12px;
  }

  .sy-chatbot-page .sy-chatbot-intro {
    padding: 0 8px;
    margin-bottom: 22px;
  }

  .sy-chatbot-page .sy-chatbot-intro p {
    font-size: 16px;
  }

  #syChatbot {
    border-radius: 18px;
  }

  #syChatbot .sy-chatbot-topbar {
    padding: 14px;
  }

  #syChatbot .sy-chatbot-agent-avatar {
    width: 44px;
    height: 44px;
    min-width: 44px;
    max-width: 44px;
    min-height: 44px;
    max-height: 44px;
  }

  #syChatbot .sy-chatbot-agent-avatar > img {
    width: 36px !important;
    height: 36px !important;
    max-width: 36px !important;
    max-height: 36px !important;
  }

  #syChatbot .sy-chatbot-agent-copy strong {
    max-width: 220px;
    font-size: 14px;
  }

  #syChatbot .sy-chatbot-new {
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
  }

  #syChatbot .sy-chatbot-new span {
    display: none;
  }

  #syChatbot .sy-chatbot-messages {
    min-height: 390px;
    height: 55vh;
    padding: 26px 12px 18px;
  }

  #syChatbot .sy-chatbot-message {
    gap: 8px;
    margin-bottom: 23px;
  }

  #syChatbot .sy-chatbot-avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
    max-width: 34px;
    min-height: 34px;
    max-height: 34px;
    margin-top: 18px;
  }

  #syChatbot .sy-chatbot-avatar--assistant > img {
    width: 28px !important;
    height: 28px !important;
    max-width: 28px !important;
    max-height: 28px !important;
  }

  #syChatbot .sy-chatbot-avatar--user svg {
    width: 18px;
    height: 18px;
  }

  #syChatbot .sy-chatbot-message-content {
    max-width: calc(100% - 46px);
  }

  #syChatbot .sy-chatbot-bubble {
    padding: 13px 14px;
  }

  #syChatbot .sy-chatbot-bubble p {
    font-size: 14px;
  }

  #syChatbot .sy-chatbot-composer-wrap {
    padding: 12px;
  }

  #syChatbot .sy-chatbot-form {
    padding: 12px;
    border-radius: 15px;
  }

  #syChatbot .sy-chatbot-form textarea {
    min-height: 82px;
    font-size: 16px;
  }

  #syChatbot .sy-chatbot-hint {
    display: none;
  }

  #syChatbot .sy-chatbot-composer-actions {
    justify-content: flex-end;
  }
}


/* First-use AI transparency notice */
body.sy-ai-notice-open { overflow: hidden; }
.sy-ai-notice[hidden] { display: none !important; }
.sy-ai-notice { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 24px; }
.sy-ai-notice-backdrop { position: absolute; inset: 0; background: rgba(15, 35, 60, .46); backdrop-filter: blur(2px); }
.sy-ai-notice-dialog { position: relative; width: min(640px, 100%); max-height: calc(100vh - 48px); overflow: auto; background: #fff; border: 1px solid #d7e0ea; border-radius: 22px; box-shadow: 0 24px 70px rgba(19, 43, 72, .22); padding: 30px 32px; color: #24364b; }
.sy-ai-notice-dialog h2 { margin: 6px 0 18px; color: #1d3552; }
.sy-ai-notice-dialog p { margin: 0 0 14px; line-height: 1.6; }
.sy-ai-notice-actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 24px; }
.sy-ai-notice-link { color: #1e5aa8; text-decoration: none; }
.sy-ai-notice-link:hover { text-decoration: underline; }
.sy-ai-notice-actions button { border: 0; border-radius: 10px; background: #1e5aa8; color: #fff; padding: 11px 22px; font: inherit; font-weight: 600; cursor: pointer; }
.sy-ai-notice-actions button:hover { filter: brightness(.96); }
@media (max-width: 600px) { .sy-ai-notice { padding: 14px; } .sy-ai-notice-dialog { padding: 24px 20px; border-radius: 18px; } .sy-ai-notice-actions { align-items: stretch; flex-direction: column-reverse; } .sy-ai-notice-actions button { width: 100%; } }
