/*!
 * Cerebro Chatbot — widget styles.
 * Everything is scoped under #cerebro-root so it never collides with the host theme.
 */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

#cerebro-root {
  --cb-accent-1: #c01f4a; /* Willsec crimson */
  --cb-accent-2: #ff4d6d; /* bright highlight */
  --cb-accent-3: #8e1538; /* deep burgundy */
  --cb-accent-4: #2b3340; /* steel navy */

  /* Dark, semi-transparent panel (default) */
  --cb-panel: rgba(12, 15, 26, 0.92);
  --cb-panel-2: rgba(20, 24, 40, 0.86);
  --cb-line: rgba(255, 255, 255, 0.12);
  --cb-text: #eef2ff;
  --cb-muted: #9aa6c4;
  --cb-bubble-ai: rgba(255, 255, 255, 0.09);
  --cb-bubble-user: linear-gradient(135deg, var(--cb-accent-1), var(--cb-accent-3));
  --cb-field: rgba(255, 255, 255, 0.08);
  --cb-composer-bg: rgba(255, 255, 255, 0.04);
  --cb-header-tint: rgba(192, 31, 74, 0.2);

  --cb-radius: 5px;
  --cb-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --cb-font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", sans-serif;

  /* Configurable from the settings page */
  --cb-launcher-size: 98px;
  --cb-margin-bottom: 24px;
  --cb-margin-right: 24px;

  position: fixed;
  z-index: 2147483000;
  bottom: var(--cb-margin-bottom);
  right: var(--cb-margin-right);
  font-family: var(--cb-font);
  color: var(--cb-text);
  -webkit-font-smoothing: antialiased;
}

#cerebro-root *,
#cerebro-root *::before,
#cerebro-root *::after {
  box-sizing: border-box;
}

/* Light theme — auto on light-mode pages, or forced via .cb-theme-light.
   .cb-theme-dark keeps the dark frost even in light mode. */
@media (prefers-color-scheme: light) {
  #cerebro-root:not(.cb-theme-dark) {
    --cb-panel: rgba(255, 255, 255, 0.8);
    --cb-panel-2: rgba(255, 255, 255, 0.66);
    --cb-line: rgba(0, 0, 0, 0.1);
    --cb-text: #1b2230;
    --cb-muted: #5d6781;
    --cb-bubble-ai: rgba(20, 24, 40, 0.06);
    --cb-field: rgba(20, 24, 40, 0.05);
    --cb-composer-bg: rgba(20, 24, 40, 0.025);
    --cb-header-tint: rgba(192, 31, 74, 0.12);
  }
}
#cerebro-root.cb-theme-light {
  --cb-panel: rgba(255, 255, 255, 0.8);
  --cb-panel-2: rgba(255, 255, 255, 0.66);
  --cb-line: rgba(0, 0, 0, 0.1);
  --cb-text: #1b2230;
  --cb-muted: #5d6781;
  --cb-bubble-ai: rgba(20, 24, 40, 0.06);
  --cb-field: rgba(20, 24, 40, 0.05);
  --cb-composer-bg: rgba(20, 24, 40, 0.025);
  --cb-header-tint: rgba(192, 31, 74, 0.12);
}

/* ───────────────────────── Launcher ───────────────────────── */

.cb-launcher {
  position: relative;
  width: var(--cb-launcher-size);
  height: var(--cb-launcher-size);
  border: none;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  background: transparent;
  box-shadow: none;
  display: grid;
  place-items: center;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.cb-launcher:hover {
  transform: translateY(-3px) scale(1.04);
}
.cb-launcher:focus-visible {
  outline: 2px solid var(--cb-accent-2);
  outline-offset: 3px;
}
.cb-launcher canvas {
  width: calc(var(--cb-launcher-size) - 12px);
  height: calc(var(--cb-launcher-size) - 12px);
  display: block;
  pointer-events: none;
}
/* Rotating conic halo behind the launcher orb — the "Apple Intelligence" glow. */
.cb-launcher::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    var(--cb-accent-2),
    var(--cb-accent-3),
    var(--cb-accent-4),
    var(--cb-accent-1),
    var(--cb-accent-2)
  );
  filter: blur(9px);
  opacity: 0;
  z-index: -1;
  animation: cb-spin 6s linear infinite;
}
.cb-launcher__badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--cb-accent-4);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

@keyframes cb-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Activation ripple when the launcher is clicked */
.cb-ripple {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid var(--cb-accent-2);
  pointer-events: none;
  opacity: 0.75;
  animation: cb-ripple 0.75s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
@keyframes cb-ripple {
  to {
    transform: scale(2.6);
    opacity: 0;
    border-color: var(--cb-accent-3);
  }
}

/* ───────────────────────── Panel ───────────────────────── */

.cb-panel {
  position: absolute;
  bottom: 0; /* sit in the corner where the orb was */
  right: 0;
  width: 384px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: linear-gradient(180deg, var(--cb-panel-2) 0%, var(--cb-panel) 38%);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(14px) scale(0.94);
  pointer-events: none;
  transition: opacity 0.26s ease, transform 0.3s cubic-bezier(0.2, 0.9, 0.25, 1);
  border: 1px solid var(--cb-line);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
#cerebro-root.cb-open .cb-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
#cerebro-root.cb-open .cb-launcher {
  transform: scale(0.4);
  opacity: 0;
  pointer-events: none;
}

/* Header */
.cb-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--cb-line);
  background: radial-gradient(
    120% 140% at 0% 0%,
    var(--cb-header-tint),
    transparent 60%
  );
}
.cb-header__orb {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}
.cb-header__orb canvas {
  width: 42px;
  height: 42px;
  display: block;
}
.cb-header__meta {
  flex: 1 1 auto;
  min-width: 0;
}
.cb-header__name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1.2;
}
.cb-header__status {
  font-size: 12.5px;
  color: var(--cb-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.cb-header__status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px #34d399;
}
.cb-header__close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 5px;
  background: var(--cb-field);
  color: var(--cb-text);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.18s ease;
}
.cb-header__close:hover {
  background: rgba(192, 31, 74, 0.16);
}

/* Messages */
.cb-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.cb-messages::-webkit-scrollbar {
  width: 8px;
}
.cb-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 5px;
}

.cb-msg {
  max-width: 84%;
  padding: 11px 14px;
  font-size: 14.5px;
  line-height: 1.5;
  border-radius: 5px;
  word-wrap: break-word;
  animation: cb-pop 0.32s cubic-bezier(0.2, 0.9, 0.25, 1);
}
.cb-msg a {
  color: var(--cb-accent-2);
  text-decoration: underline;
}
.cb-msg--ai {
  align-self: flex-start;
  background: var(--cb-bubble-ai);
  border-bottom-left-radius: 5px;
  border: 1px solid var(--cb-line);
}
.cb-msg--user {
  align-self: flex-end;
  background: var(--cb-bubble-user);
  color: #fff;
  border-bottom-right-radius: 5px;
}
@keyframes cb-pop {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Typing indicator */
.cb-typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px 9px 10px;
  background: var(--cb-bubble-ai);
  border: 1px solid var(--cb-line);
  border-radius: 5px;
  border-bottom-left-radius: 5px;
}
.cb-typing-orb {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: block;
}
.cb-typing-dots {
  display: inline-flex;
  gap: 5px;
}
.cb-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cb-muted);
  animation: cb-bounce 1.2s infinite ease-in-out;
}
.cb-typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.cb-typing span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes cb-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* Quick replies */
.cb-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 16px 12px;
}
.cb-chip {
  border: 1px solid var(--cb-line);
  background: var(--cb-field);
  color: var(--cb-text);
  font-size: 13px;
  font-family: inherit;
  padding: 8px 13px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.cb-chip:hover {
  border-color: var(--cb-accent-2);
  background: rgba(255, 77, 109, 0.12);
  transform: translateY(-1px);
}

/* Booking form (inline card) */
.cb-form {
  align-self: stretch;
  background: var(--cb-composer-bg);
  border: 1px solid var(--cb-line);
  border-radius: 5px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: cb-pop 0.32s ease;
}
.cb-form__title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cb-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cb-field label {
  font-size: 12px;
  color: var(--cb-muted);
}
.cb-field input,
.cb-field textarea,
.cb-field select {
  width: 100%;
  background: var(--cb-field) !important;
  border: 1px solid var(--cb-line) !important;
  border-radius: 5px;
  color: var(--cb-text) !important;
  font-family: inherit;
  font-size: 14px;
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.cb-field input:focus,
.cb-field textarea:focus,
.cb-field select:focus {
  border-color: var(--cb-accent-2);
  box-shadow: 0 0 0 3px rgba(255, 77, 109, 0.16);
}
.cb-field textarea {
  resize: vertical;
  min-height: 58px;
}
.cb-form__row {
  display: flex;
  gap: 10px;
}
.cb-form__row .cb-field {
  flex: 1;
}
.cb-btn {
  border: none;
  border-radius: 5px;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background: #c01a47;
  transition: filter 0.18s ease, transform 0.1s ease;
}
.cb-btn:hover {
  filter: brightness(1.08);
}
.cb-btn:active {
  transform: scale(0.98);
}
.cb-btn[disabled] {
  opacity: 0.6;
  cursor: default;
}
.cb-form__hint {
  font-size: 11.5px;
  color: var(--cb-muted);
}

/* Composer */
.cb-composer {
  border-top: 1px solid var(--cb-line);
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--cb-composer-bg);
}
.cb-composer textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  background: transparent !important;
  border: none;
  outline: none;
  color: var(--cb-text) !important;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.45;
  padding: 8px 4px;
}
.cb-composer textarea::placeholder {
  color: var(--cb-muted);
}
.cb-send {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  background: #c01a47;
  color: #fff;
  display: grid;
  place-items: center;
  transition: filter 0.18s ease, transform 0.1s ease, opacity 0.18s ease;
}
.cb-send:hover {
  filter: brightness(1.1);
}
.cb-send:active {
  transform: scale(0.94);
}
.cb-send[disabled] {
  opacity: 0.4;
  cursor: default;
}
.cb-send svg {
  width: 18px;
  height: 18px;
}

.cb-footer {
  text-align: center;
  font-size: 11px;
  color: var(--cb-muted);
  padding: 0 0 9px;
}
.cb-footer a {
  color: var(--cb-muted);
}

/* Mobile: full-screen sheet */
@media (max-width: 480px) {
  #cerebro-root {
    bottom: 16px;
    right: 16px;
  }
  .cb-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cb-launcher::before {
    animation: none;
  }
  .cb-msg,
  .cb-form {
    animation: none;
  }
}
