/* Content Compass Embed Widget (MVP) */
:root {
  --cc-primary: #5B3EFB;
  --cc-accent: #3EE5AE;
  --cc-text: #1F1F1F;
  --cc-bg: #FAFAFA;
  --cc-border: #F0F0F0;
  --cc-shadow: rgba(0, 0, 0, 0.1);
  --cc-error: #DC3232;
}

.ccw-widget {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 350px;
  height: 500px;
  background: var(--cc-bg);
  border-radius: 12px;
  box-shadow: 0 5px 20px var(--cc-shadow);
  display: none;
  flex-direction: column;
  z-index: 2147483646;
  overflow: hidden;
}

.ccw-header {
  padding: 7px 15px;
  background: var(--cc-primary);
  color: var(--cc-header-text, #fff);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ccw-title { margin: 0; font-size: 16px; font-weight: 500; color: #fff}
.ccw-min { background: none; border: none; color: var(--cc-header-text, #fff); cursor: pointer; font-size: 18px; margin-bottom: 0;}

.ccw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ccw-msg { max-width: 80%; padding: 10px 14px; border-radius: 14px; line-height: 1.4; font-size: 14px; }
.ccw-msg.user { align-self: flex-end; background: var(--cc-primary); color: #fff; border-bottom-right-radius: 5px; }
.ccw-msg.assistant {max-width: 100%; align-self: flex-start; background: #f0f0f0; color: var(--cc-chat-text, var(--cc-text)); border-bottom-left-radius: 5px; }
.ccw-msg.assistant p { margin: 0 0 10px; }
.ccw-msg.assistant p:last-child { margin-bottom: 0; }
.ccw-msg.assistant a { color: var(--cc-primary); text-decoration: underline; }

.ccw-input { display: flex; gap: 8px; padding: 10px; background: var(--cc-bg); }
.ccw-input textarea { flex: 1; resize: none; min-height: 40px; max-height: 120px; padding: 8px 12px; border-radius: 18px; border: 1px solid var(--cc-border); font-size: 14px; }
.ccw-input textarea:focus { outline: none; box-shadow: none; border-color: var(--cc-border); }
.ccw-input button { background: var(--cc-primary); color: #fff; border: none; border-radius: 18px; padding: 8px 14px; cursor: pointer; font-size: 14px; }

.ccw-toggle {
  position: fixed; bottom: 20px; right: 20px; z-index: 2147483646;
  background: var(--cc-primary); color: #fff; border: none; border-radius: 25px; height: 50px; padding: 0 16px; cursor: pointer;
  box-shadow: 0 2px 10px var(--cc-shadow); display: inline-flex; align-items: center; gap: 8px;
}

/* When the toggle is placed inside the footer, make it look like an inline button */
.ccw-aux-group .ccw-toggle {
  position: static !important;
  top: auto !important; right: auto !important; bottom: auto !important; left: auto !important;
  z-index: auto !important;
  height: auto;
  padding: 8px 12px;
  border-radius: 18px;
}

/* Floating aux buttons (New Chat, History) */
.ccw-aux-group {
  position: fixed;
  bottom: 35px; /* align vertically with toggle */
  right: 100px; /* to the left of toggle (which is at right:20px) */
  display: none;
  gap: 8px;
  z-index: 2147483646;
}
.ccw-aux-btn {
  background: #fff;
  color: var(--cc-primary);
  border: none;
  border-radius: 18px;
  padding: 8px 12px;
  cursor: pointer;
  box-shadow: 0 2px 10px var(--cc-shadow);
  font-size: 13px;
}
.ccw-aux-btn:hover { filter: brightness(0.98); }
/* Keep both aux buttons white, no border */
.ccw-aux-btn.ccw-new { background: #fff; color: var(--cc-primary); border: none; }

/* History panel */
.ccw-history-panel {
  position: fixed;
  bottom: 80px;
  right: 390px; /* sits to the left of widget (350 + 20 margin) */
  width: 280px;
  max-height: 420px;
  background: var(--cc-bg);
  border: 1px solid var(--cc-border);
  border-radius: 12px;
  box-shadow: 0 5px 20px var(--cc-shadow);
  display: none;
  overflow: hidden;
  z-index: 2147483646;
}
.ccw-history-header {
  background: var(--cc-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
}
.ccw-history-title { font-weight: 500; }
.ccw-history-close { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; }
.ccw-history-list { max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; }
.ccw-history-empty { padding: 12px; color: #666; font-size: 13px; }
.ccw-history-item {
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--cc-border);
  padding: 10px 12px;
  cursor: pointer;
}
.ccw-history-item:hover { background: rgba(0,0,0,0.03); }
.ccw-history-item-title { font-size: 14px; color: var(--cc-text); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ccw-history-item-meta { font-size: 12px; color: #888; }

.ccw-typing { display: none; align-items: center; gap: 6px; padding: 8px; background: #f0f0f0; border-radius: 10px; align-self: flex-start; }
.ccw-dot { width: 8px; height: 8px; background: var(--cc-primary); border-radius: 50%; opacity: 0.4; animation: ccw-typing 1s infinite; }
.ccw-dot:nth-child(2){ animation-delay: .2s } .ccw-dot:nth-child(3){ animation-delay: .4s }
@keyframes ccw-typing { 0%,100%{opacity:.4} 50%{opacity:1} }

@media (max-width: 480px) {
  .ccw-widget { width: calc(100% - 20px); height: calc(100% - 120px); bottom: 100px; right: 10px; }
  /* Keep aux buttons aligned with the toggle and within viewport */
  .ccw-aux-group { width: auto; right: 90px; left: auto; bottom: 35px; }
  .ccw-history-panel { right: 10px; left: 10px; width: auto; bottom: calc(100px + 10px + 50px); }
}
