/* ============================================================
   Claude Chat Plugin — Styles
   Supports: dark / light themes, bottom-right / bottom-left
   ============================================================ */

:root {
  --cc-font: 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* Dark theme (default) */
  --cc-bg:           #1a1a2e;
  --cc-bg-header:    #16213e;
  --cc-bg-input:     #0f3460;
  --cc-bg-user:      #0f3460;
  --cc-bg-bot:       #16213e;
  --cc-accent:       #e94560;
  --cc-accent-hover: #c73652;
  --cc-text:         #e0e0e0;
  --cc-text-muted:   #8a8a9a;
  --cc-border:       rgba(255,255,255,0.08);
  --cc-shadow:       0 8px 32px rgba(0,0,0,0.4);
  --cc-bubble-bg:    #e94560;
  --cc-bubble-color: #fff;
}

.cc-theme-light {
  --cc-bg:           #ffffff;
  --cc-bg-header:    #f0f4ff;
  --cc-bg-input:     #f8f9ff;
  --cc-bg-user:      #e8eeff;
  --cc-bg-bot:       #f4f5f7;
  --cc-accent:       #4361ee;
  --cc-accent-hover: #3451d1;
  --cc-text:         #1a1a2e;
  --cc-text-muted:   #6b7280;
  --cc-border:       rgba(0,0,0,0.08);
  --cc-shadow:       0 8px 32px rgba(0,0,0,0.15);
  --cc-bubble-bg:    #4361ee;
  --cc-bubble-color: #fff;
}

/* ── Floating bubble ── */
#cc-bubble {
  position: fixed;
  z-index: 9998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--cc-bubble-bg);
  color: var(--cc-bubble-color);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  bottom: 24px;
  font-size: 0em;
}
#cc-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(0,0,0,0.4);
}
#cc-bubble.cc-pos-right { right: 24px; }
#cc-bubble.cc-pos-left  { left: 24px; }

#cc-bubble svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  transition: opacity 0.2s;
}
#cc-bubble .cc-icon-close { display: none; }
#cc-bubble.cc-open .cc-icon-chat  { display: none; }
#cc-bubble.cc-open .cc-icon-close { display: block; }

/* Notification badge */
#cc-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: #ff4757;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.2s, transform 0.2s;
}
#cc-badge.visible {
  opacity: 1;
  transform: scale(1);
}

/* ── Chat window ── */
#cc-window {
  position: fixed;
  z-index: 9999;
  bottom: 92px;
  width: 380px;
  max-height: 560px;
  border-radius: 16px;
  overflow: hidden;
  font-family: var(--cc-font);
  background: var(--cc-bg);
  box-shadow: var(--cc-shadow);
  border: 1px solid var(--cc-border);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#cc-window.cc-pos-right { right: 24px; }
#cc-window.cc-pos-left  { left: 24px; }

#cc-window.cc-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ── */
#cc-header {
  background: var(--cc-bg-header);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--cc-border);
}
#cc-header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--cc-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#cc-header-avatar svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}
#cc-header-info { flex: 1; }
#cc-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--cc-text);
  margin: 0;
}
#cc-header-status {
  font-size: 11px;
  color: #4cd137;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
#cc-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4cd137;
  display: inline-block;
}
#cc-clear-btn {
  background: none;
  border: 1px solid var(--cc-border);
  color: var(--cc-text-muted);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

/* ── Messages ── */
#cc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
#cc-messages::-webkit-scrollbar { width: 4px; }
#cc-messages::-webkit-scrollbar-track { background: transparent; }
#cc-messages::-webkit-scrollbar-thumb {
  background: var(--cc-border);
  border-radius: 2px;
}

.cc-msg {
  display: flex;
  gap: 8px;
  animation: cc-fadeIn 0.2s ease;
}
@keyframes cc-fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cc-msg-user { flex-direction: row-reverse; }

.cc-msg-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--cc-text);
  word-break: break-word;
}
.cc-msg-user .cc-msg-bubble {
  background: var(--cc-bg-user);
  border-bottom-right-radius: 4px;
}
.cc-msg-bot .cc-msg-bubble {
  background: var(--cc-bg-bot);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--cc-border);
}

/* Markdown-like formatting in bot responses */
.cc-msg-bubble strong { font-weight: 600; }
.cc-msg-bubble em { font-style: italic; }
.cc-msg-bubble code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
}
.cc-msg-bubble ul, .cc-msg-bubble ol {
  margin: 4px 0 4px 16px;
  padding: 0;
}
.cc-msg-bubble li { margin: 2px 0; }
.cc-msg-bubble a {
  color: var(--cc-accent);
  text-decoration: underline;
}

.cc-msg-time {
  font-size: 10px;
  color: var(--cc-text-muted);
  align-self: flex-end;
  margin-bottom: 2px;
  white-space: nowrap;
}

/* Typing indicator */
.cc-typing .cc-msg-bubble {
  padding: 12px 16px;
}
.cc-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}
.cc-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cc-text-muted);
  animation: cc-bounce 1.2s infinite;
}
.cc-dots span:nth-child(2) { animation-delay: 0.2s; }
.cc-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cc-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

/* ── Input area ── */
#cc-input-area {
  padding: 12px 14px;
  background: var(--cc-bg-header);
  border-top: 1px solid var(--cc-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
#cc-input {
  flex: 1;
  background: rgba(160, 160, 160, 0.075);
  border: 1px solid var(--cc-border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--cc-text);
  resize: none;
  max-height: 100px;
  outline: none;
  font-family: var(--cc-font);
  line-height: 1.4;
  transition: border-color 0.15s;
}
#cc-input::placeholder { color: var(--cc-text-muted); }
#cc-input:focus { border-color: var(--cc-accent); }

#cc-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--cc-accent);
  color: #fff !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  margin: 0;
  transition: background 0.15s, transform 0.1s;
}
#cc-send-btn:active { transform: scale(0.94); }
#cc-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
#cc-send-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* ── Error banner ── */
#cc-error {
  padding: 8px 14px;
  background: rgba(233,69,96,0.15);
  border-top: 1px solid rgba(233,69,96,0.3);
  font-size: 12px;
  color: #e94560;
  text-align: center;
  display: none;
}
#cc-error.visible { display: block; }

/* ── Standalone /chat page ── */
.cc-page-wrapper {
  max-width: 760px;
  margin: 40px auto;
  padding: 0 16px;
}
.cc-page-wrapper #cc-window {
  position: static;
  width: 100%;
  max-height: 70vh;
  border-radius: 16px;
  opacity: 1;
  transform: none;
  pointer-events: all;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  #cc-window {
    width: calc(100vw - 32px);
    right: 16px !important;
    left: 16px !important;
    bottom: 80px;
  }
}
