/* SAGCO chatbot widget — fixed bottom-right FAB + chat panel. */

.sagco-chat {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1070;
  font-family: inherit;
}

/* Floating button */
.sagco-chat-fab {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  background: #1b2958;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.35);
  transition: transform 0.2s ease, background-color 0.2s ease;
  position: relative;
}

.sagco-chat-fab:hover {
  background: #9d1631;
  transform: translateY(-2px);
}

.sagco-chat-fab svg {
  width: 26px;
  height: 26px;
}

.sagco-chat-fab .sagco-chat-ico-close {
  display: none;
}

.sagco-chat.open .sagco-chat-fab .sagco-chat-ico-open {
  display: none;
}

.sagco-chat.open .sagco-chat-fab .sagco-chat-ico-close {
  display: block;
}

/* Panel */
.sagco-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.9rem);
  width: min(360px, calc(100vw - 2.5rem));
  height: min(520px, calc(100vh - 7.5rem));
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.35);
  border: 1px solid #e6eaf1;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}

.sagco-chat.open .sagco-chat-panel {
  opacity: 1;
  visibility: visible;
  transform: none;
}

/* Header */
.sagco-chat-head {
  background: linear-gradient(120deg, #1b2958, #24356b);
  color: #fff;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.sagco-chat-head-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sagco-chat-head-dot svg {
  width: 18px;
  height: 18px;
}

.sagco-chat-head-title {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
}

/* Company logo replaces the title wordmark — white pill so the
   navy/red mark stays legible on the navy header. */
.sagco-chat-head-logo {
  height: 24px;
  width: auto;
  max-width: 150px;
  object-fit: contain;
  background: #fff;
  padding: 3px 9px;
  border-radius: 7px;
  display: inline-block;
  vertical-align: middle;
}

/* The `hidden` attribute must beat the flex display rules below —
   otherwise the lead form, body and composer all show at once. */
.sagco-chat-lead[hidden],
.sagco-chat-body[hidden],
.sagco-chat-form[hidden] {
  display: none !important;
}

.sagco-chat-head-sub {
  font-size: 0.72rem;
  opacity: 0.75;
}

/* Scrollable body */
.sagco-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #f7f9fc;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Bubbles */
.sagco-chat-msg {
  max-width: 85%;
  padding: 0.6rem 0.85rem;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.sagco-chat-msg-bot {
  background: #fff;
  color: #26303f;
  border: 1px solid #e6eaf1;
  border-start-start-radius: 4px;
  align-self: flex-start;
}

.sagco-chat-msg-user {
  background: #1b2958;
  color: #fff;
  border-start-end-radius: 4px;
  align-self: flex-end;
}

/* Bot link cards */
.sagco-chat-links {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-self: stretch;
  max-width: 85%;
}

.sagco-chat-link {
  display: block;
  background: #fff;
  border: 1px solid #e6eaf1;
  border-inline-start: 3px solid #9d1631;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  text-decoration: none !important;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.sagco-chat-link:hover {
  border-color: #9d1631;
  transform: translateY(-1px);
}

.sagco-chat-link-title {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  color: #1b2958;
}

.sagco-chat-link-snippet {
  display: block;
  font-size: 0.75rem;
  color: #6b7484;
  margin-top: 0.15rem;
  line-height: 1.45;
}

/* Suggestion chips */
.sagco-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.sagco-chat-chip {
  border: 1px solid #d8dfe9;
  background: #fff;
  color: #1b2958;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.32rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.sagco-chat-chip:hover {
  background: #1b2958;
  color: #fff;
}

/* Typing indicator */
.sagco-chat-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 0.7rem 0.9rem;
}

.sagco-chat-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9aa5b8;
  animation: sagcoChatDot 1.1s infinite ease-in-out;
}

.sagco-chat-typing i:nth-child(2) { animation-delay: 0.15s; }
.sagco-chat-typing i:nth-child(3) { animation-delay: 0.3s; }

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

/* Lead form */
.sagco-chat-lead {
  padding: 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 1;
}

.sagco-chat-lead p {
  font-size: 0.85rem;
  color: #4c5667;
  margin: 0;
}

.sagco-chat-lead input {
  border: 1px solid #d8dfe9;
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sagco-chat-lead input:focus {
  border-color: #1b2958;
  box-shadow: 0 0 0 3px rgba(27, 41, 88, 0.12);
}

.sagco-chat-lead-error {
  color: #9d1631;
  font-size: 0.78rem;
  min-height: 1em;
}

.sagco-chat-lead-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

.sagco-chat-lead-submit {
  flex: 1;
  background: #9d1631;
  border: 0;
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.sagco-chat-lead-submit:hover {
  background: #7f1228;
}

.sagco-chat-lead-skip {
  background: transparent;
  border: 1px solid #d8dfe9;
  color: #5a6478;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.sagco-chat-lead-skip:hover {
  color: #1b2958;
  border-color: #1b2958;
}

/* Composer */
.sagco-chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem;
  border-top: 1px solid #e6eaf1;
  background: #fff;
  flex-shrink: 0;
}

.sagco-chat-form input {
  flex: 1;
  border: 1px solid #d8dfe9;
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  font-size: 0.88rem;
  outline: none;
  min-width: 0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sagco-chat-form input:focus {
  border-color: #1b2958;
  box-shadow: 0 0 0 3px rgba(27, 41, 88, 0.1);
}

.sagco-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: #9d1631;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

.sagco-chat-send:hover {
  background: #7f1228;
}

.sagco-chat-send svg {
  width: 17px;
  height: 17px;
}

[dir="rtl"] .sagco-chat-send svg {
  transform: scaleX(-1);
}

/* Small screens — the panel fills most of the viewport */
@media (max-width: 480px) {
  .sagco-chat {
    right: 0.9rem;
    bottom: 0.9rem;
  }

  .sagco-chat-panel {
    width: calc(100vw - 1.8rem);
    height: min(70vh, 480px);
  }
}
