/* ==========================================================================
   DGREAT.AI — Sacha chat widget
   Uses the site tokens from styles.css; sits under the cookie banner
   (z-index 9999) so consent always stays on top.
   ========================================================================== */

.sacha {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9000;
  font-family: var(--font-body, "Inter", sans-serif);
}

/* ---------- launcher ---------------------------------------------------- */
.sacha__fab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.13));
  border-radius: 999px;
  background: var(--surface, #0f1114);
  color: var(--text, #eef0f5);
  font: 600 14px/1 var(--font-body, "Inter", sans-serif);
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), var(--shadow-glow-purple, 0 0 24px rgba(122, 60, 255, 0.35));
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.sacha__fab:hover { transform: translateY(-2px); border-color: var(--purple, #7a3cff); }
.sacha__fab:focus-visible { outline: 2px solid var(--green, #00ff9d); outline-offset: 3px; }

.sacha__fab-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green, #00ff9d);
  box-shadow: 0 0 10px var(--green, #00ff9d);
  animation: sacha-pulse 2s ease-in-out infinite;
}
@keyframes sacha-pulse { 50% { opacity: 0.45; } }

.sacha.is-open .sacha__fab { display: none; }

/* ---------- the greeting bubble that appears on its own ----------------- */
.sacha__teaser {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: min(300px, calc(100vw - 40px));
  margin: 0 0 12px auto;
  padding: 12px 14px;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.13));
  border-radius: 16px 16px 4px 16px;
  background: var(--surface, #0f1114);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  /* animated state: slides up and settles */
  opacity: 0;
  transform: translateY(14px) scale(0.96);
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.sacha__teaser.is-in { opacity: 1; transform: none; }
.sacha__teaser[hidden] { display: none; }
.sacha__teaser:hover { border-color: var(--purple, #7a3cff); }

.sacha__teaser-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gradient-primary, linear-gradient(120deg, #00ff9d, #7a3cff));
  color: #050607;
  font: 700 14px/1 var(--font-mono, monospace);
}
.sacha__teaser-text {
  flex: 1;
  margin: 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text, #eef0f5);
}
.sacha__teaser-close {
  flex: none;
  width: 22px;
  height: 22px;
  margin: -4px -4px 0 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim, #5a6070);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.sacha__teaser-close:hover { color: var(--text, #eef0f5); }

/* ---------- panel ------------------------------------------------------- */
.sacha__panel {
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 40px));
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.13));
  border-radius: var(--radius-lg, 24px);
  background: var(--bg-alt, #090a0c);
  color: var(--text, #eef0f5);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.sacha__panel[hidden] { display: none; }

.sacha__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.07));
  background: var(--surface, #0f1114);
}
.sacha__avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient-primary, linear-gradient(120deg, #00ff9d, #7a3cff));
  color: #050607;
  font: 700 16px/1 var(--font-mono, monospace);
}
.sacha__who { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.sacha__title { font: 700 15px/1.2 var(--font-heading, sans-serif); }
.sacha__subtitle { font-size: 12px; color: var(--text-muted, #9aa0b0); }
.sacha__close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted, #9aa0b0);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.sacha__close:hover { background: var(--border, rgba(255, 255, 255, 0.07)); color: var(--text, #eef0f5); }

/* ---------- messages ---------------------------------------------------- */
.sacha__log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sacha__msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.sacha__msg--model {
  align-self: flex-start;
  background: var(--surface, #0f1114);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.07));
  border-bottom-left-radius: 4px;
}
.sacha__msg--user {
  align-self: flex-end;
  background: var(--purple, #7a3cff);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.sacha__msg--typing { color: var(--text-muted, #9aa0b0); font-style: italic; }
.sacha__msg--error { border-color: rgba(255, 110, 110, 0.4); }

/* ---------- suggestions ------------------------------------------------- */
.sacha__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.sacha__chips:empty { display: none; }
.sacha__chip {
  padding: 7px 12px;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.13));
  border-radius: 999px;
  background: transparent;
  color: var(--text, #eef0f5);
  font: 500 12.5px/1.3 var(--font-body, sans-serif);
  text-align: left;
  cursor: pointer;
}
.sacha__chip:hover { border-color: var(--green, #00ff9d); color: var(--green, #00ff9d); }

/* ---------- composer ---------------------------------------------------- */
.sacha__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.07));
}
.sacha__input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.13));
  border-radius: 12px;
  background: var(--surface, #0f1114);
  color: var(--text, #eef0f5);
  font: 14px/1.4 var(--font-body, sans-serif);
  resize: none;
}
.sacha__input:focus { outline: none; border-color: var(--purple, #7a3cff); }
.sacha__send {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--green, #00ff9d);
  color: #050607;
  font: 700 18px/1 var(--font-body, sans-serif);
  cursor: pointer;
}
.sacha__send:disabled { opacity: 0.5; cursor: wait; }

.sacha__notice {
  margin: 0;
  padding: 0 16px 12px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-dim, #5a6070);
}
.sacha__notice a { color: var(--text-muted, #9aa0b0); }

/* ---------- phones ------------------------------------------------------ */
@media (max-width: 520px) {
  .sacha { right: 16px; bottom: 16px; }
  .sacha.is-open { inset: 0; }
  .sacha__panel {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: 0;
  }
  .sacha__fab-label { display: none; }
  .sacha__fab { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .sacha__fab-dot { animation: none; }
  .sacha__fab { transition: none; }
  .sacha__teaser { transition: none; opacity: 1; transform: none; }
}
