/* Front-end assistant */
.cudeai-assistant {
  --cudeai-primary: #ea5e00;
  --cudeai-on-primary: #fff;
  --cudeai-primary-rgb: 234, 94, 0;
  --cudeai-header-bg: #fff3e3;
  --cudeai-header-text: #4c2367;
  --cudeai-bot-bg: #fff7e7;
  --cudeai-bot-text: #2d2133;
  --cudeai-user-bg: #4c2367;
  --cudeai-on-user: #fff;
}

.cudeai-assistant *,
.cudeai-assistant *::before,
.cudeai-assistant *::after { box-sizing: border-box; font-family: inherit; }

.cudeai-assistant button { cursor: pointer; }

/* Floating widget button */
#cudeai-assistant-launcher {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 99999;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  background: #ea5e00;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .22);
}

#cudeai-assistant-launcher:hover { filter: brightness(.9); }

.cudeai-assistant button:focus-visible,
.cudeai-assistant-input:focus-visible {
  outline: 3px solid rgba(var(--cudeai-primary-rgb), .38);
  outline-offset: 2px;
}

#cudeai-assistant-launcher:focus-visible {
  outline: 3px solid #ea5e00;
  outline-offset: 2px;
}

/* Image launcher variant (56x56 circle) */
#cudeai-assistant-launcher.cudeai-launcher--image {
  width: 56px;
  height: 56px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#cudeai-assistant-launcher.cudeai-launcher--image .cudeai-launcher-avatar {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background-size: cover;
  background-position: center;
}

/* Panel */
#cudeai-assistant-panel {
  position: fixed;
  right: 18px;
  bottom: 84px;
  width: 350px;
  max-width: calc(100vw - 36px);
  height: 500px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border: 1px solid rgba(15, 23, 42, .1);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .22);
  overflow: hidden;
  z-index: 99999;
  display: none;
}

#cudeai-assistant-panel.cudeai-open { display: block; }

#cudeai-assistant-panel .cudeai-assistant-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Header */
.cudeai-assistant-header {
  min-height: 64px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(var(--cudeai-primary-rgb), .16);
  background: var(--cudeai-header-bg);
  color: var(--cudeai-header-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cudeai-assistant-identity,
.cudeai-assistant-header-actions {
  display: flex;
  align-items: center;
}

.cudeai-assistant-identity { gap: 9px; min-width: 0; }
.cudeai-assistant-header-actions { gap: 4px; flex: 0 0 auto; }

.cudeai-assistant-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.25;
}

.cudeai-brand-avatar {
  flex: 0 0 auto;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fff;
}

.cudeai-brand-avatar img {
  display: block;
  width: 100%;
  height: 100%;
}

.cudeai-header-avatar {
  width: 36px;
  height: 36px;
  padding: 3px;
  border: 1px solid rgba(var(--cudeai-primary-rgb), .3);
  box-shadow: 0 3px 10px rgba(15, 23, 42, .12);
}

.cudeai-assistant-reset,
.cudeai-assistant-close {
  border: 0;
  color: var(--cudeai-header-text);
}

.cudeai-assistant-reset {
  background: rgba(255, 255, 255, .52);
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.cudeai-assistant-reset:hover { filter: brightness(.94); }

.cudeai-assistant-close {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 21px;
  line-height: 28px;
}

.cudeai-assistant-close:hover { background: rgba(255, 255, 255, .52); }

/* Messages */
.cudeai-assistant-body {
  min-height: 0;
  padding: 14px 12px;
  overflow-y: auto;
  flex: 1;
  background: #fff;
}

.cudeai-msg {
  margin: 0 0 12px;
  display: flex;
  align-items: flex-end;
}

.cudeai-msg-user { justify-content: flex-end; }
.cudeai-msg-bot { gap: 8px; }

.cudeai-bot-avatar {
  width: 32px;
  height: 32px;
  padding: 2px;
  border: 1px solid rgba(var(--cudeai-primary-rgb), .28);
  box-shadow: 0 2px 7px rgba(15, 23, 42, .1);
}

.cudeai-bubble {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.cudeai-msg-bot.cudeai-msg-has-avatar .cudeai-bubble {
  max-width: calc(85% - 40px);
}

.cudeai-msg-bot .cudeai-bubble {
  border: 1px solid rgba(var(--cudeai-primary-rgb), .22);
  border-bottom-left-radius: 4px;
  background: var(--cudeai-bot-bg);
  color: var(--cudeai-bot-text);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .06);
}

.cudeai-msg-user .cudeai-bubble {
  border-bottom-right-radius: 4px;
  background: var(--cudeai-user-bg);
  color: var(--cudeai-on-user);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .14);
}

/* Composer */
.cudeai-assistant-footer {
  border-top: 1px solid rgba(15, 23, 42, .09);
  padding: 10px;
  display: flex;
  gap: 8px;
  background: #fff;
}

.cudeai-assistant-input {
  min-width: 0;
  flex: 1;
  border: 1px solid rgba(15, 23, 42, .22);
  border-radius: 10px;
  padding: 10px;
  color: var(--cudeai-bot-text);
  background: #fff;
  font-size: 14px;
}

.cudeai-assistant-input:focus { border-color: var(--cudeai-primary); }

.cudeai-assistant-send {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--cudeai-primary);
  color: var(--cudeai-on-primary);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(var(--cudeai-primary-rgb), .2);
  transition: background-color .15s ease, transform .15s ease;
}

.cudeai-assistant-send:hover {
  filter: brightness(.9);
  transform: translateY(-1px);
}

.cudeai-assistant-send:disabled {
  cursor: wait;
  opacity: .65;
  transform: none;
}

/* Embedded */
.cudeai-assistant-embed .cudeai-assistant-embed-shell {
  border: 1px solid rgba(15, 23, 42, .14);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  max-width: 720px;
}

.cudeai-assistant-embed .cudeai-assistant-body { height: 420px; }

/* Rich reply content */
.cudeai-bubble p { margin: 0 0 10px; }
.cudeai-bubble p:last-child { margin-bottom: 0; }

.cudeai-bubble ul,
.cudeai-bubble ol { margin: 0 0 10px; padding-left: 20px; }

.cudeai-bubble ul:last-child,
.cudeai-bubble ol:last-child { margin-bottom: 0; }

.cudeai-bubble li { margin: 0 0 4px; }
.cudeai-bubble li:last-child { margin-bottom: 0; }
.cudeai-bubble strong { font-weight: 700; }
.cudeai-bubble em { font-style: italic; }

.cudeai-bubble code {
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(15, 23, 42, .08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em;
}

.cudeai-msg-user .cudeai-bubble code { background: rgba(255, 255, 255, .18); }
.cudeai-bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.cudeai-bubble a:hover { text-decoration-thickness: 2px; }

/* Typing dots */
.cudeai-typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 99px;
  background: var(--cudeai-primary);
  animation: wfDot 1.2s infinite ease-in-out;
}

.cudeai-typing-dot:nth-child(2) { animation-delay: .15s; }
.cudeai-typing-dot:nth-child(3) { animation-delay: .3s; }

@keyframes wfDot {
  0%, 80%, 100% { transform: translateY(0); opacity: .35; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 480px) {
  #cudeai-assistant-panel {
    right: 10px;
    bottom: 82px;
    width: calc(100vw - 20px);
    max-width: none;
    height: min(520px, calc(100vh - 105px));
  }

  #cudeai-assistant-launcher {
    right: 10px;
    bottom: 14px;
  }

  .cudeai-assistant-title { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .cudeai-assistant-send { transition: none; }
  .cudeai-typing-dot { animation: none; opacity: .65; }
}
