/* Campus Coin assistant widget. Self-contained (no Tailwind), light + dark via html.dark */
#cc-chat {
  --cc-bg: #ffffff;
  --cc-surface: #f4f6ee;
  --cc-surface-2: #eaeee1;
  --cc-border: #dce2d3;
  --cc-text: #0d2b03;
  --cc-muted: #566650;
  --cc-brand: #0d2b03;
  --cc-on-brand: #c5f200;
  --cc-accent: #c5f200;
  --cc-user-bg: #0d2b03;
  --cc-user-text: #ffffff;
  --cc-bot-bg: #f4f6ee;
  --cc-error-bg: #fdecec;
  --cc-error-text: #8a1c1c;
  --cc-ok: #2f9e44;
  --cc-shadow: 0 24px 60px rgba(13, 43, 3, 0.28), 0 4px 14px rgba(13, 43, 3, 0.12);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--cc-text);
}

html.dark #cc-chat {
  --cc-bg: #141815;
  --cc-surface: #0f1210;
  --cc-surface-2: #1b211d;
  --cc-border: #262c28;
  --cc-text: #ecefe9;
  --cc-muted: #9aa49c;
  --cc-brand: #c6f432;
  --cc-on-brand: #0a0d0b;
  --cc-accent: #c6f432;
  --cc-user-bg: #c6f432;
  --cc-user-text: #0a0d0b;
  --cc-bot-bg: #1b211d;
  --cc-error-bg: #3a1717;
  --cc-error-text: #f3b4b4;
  --cc-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 4px 14px rgba(0, 0, 0, 0.4);
}

#cc-chat *, #cc-chat *::before, #cc-chat *::after { box-sizing: border-box; }

/* ---------- launcher ---------- */
#cc-chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9990;
  height: 56px;
  border: 0;
  border-radius: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0;
  background: var(--cc-brand);
  color: var(--cc-on-brand);
  box-shadow: 0 10px 28px rgba(13, 43, 3, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
html.dark #cc-chat-launcher { box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55); }
#cc-chat-launcher:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(13, 43, 3, 0.42); }
#cc-chat-launcher .cc-launcher-icon { width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; flex: none; }
#cc-chat-launcher .cc-launcher-label {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  transition: max-width 0.22s ease, opacity 0.18s ease, padding 0.22s ease;
}
#cc-chat-launcher:hover .cc-launcher-label,
#cc-chat-launcher:focus-visible .cc-launcher-label { max-width: 150px; opacity: 1; padding-left: 20px; }
#cc-chat-launcher[aria-expanded="true"] .cc-launcher-label { display: none; }
#cc-chat-launcher:focus-visible, #cc-chat-panel button:focus-visible, #cc-chat-input:focus-visible, #cc-chat-chips button:focus-visible {
  outline: 3px solid var(--cc-accent);
  outline-offset: 2px;
}
html:not(.dark) #cc-chat-panel button:focus-visible, html:not(.dark) #cc-chat-input:focus-visible { outline-color: #0d2b03; }
#cc-chat-launcher .cc-icon-close { display: none; }
#cc-chat-launcher[aria-expanded="true"] .cc-icon-open { display: none; }
#cc-chat-launcher[aria-expanded="true"] .cc-icon-close { display: block; }

/* ---------- panel ---------- */
#cc-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 90px;
  z-index: 9990;
  width: 400px;
  max-width: calc(100vw - 24px);
  height: 640px;
  max-height: calc(100vh - 114px);
  display: flex;
  flex-direction: column;
  background: var(--cc-bg);
  border: 1px solid var(--cc-border);
  border-radius: 22px;
  box-shadow: var(--cc-shadow);
  overflow: hidden;
  transform-origin: bottom right;
  animation: cc-pop 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#cc-chat-panel[hidden] { display: none; }
@keyframes cc-pop { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }

/* ---------- header ---------- */
#cc-chat .cc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px 14px 16px;
  background: #0d2b03;
  color: #fff;
  position: relative;
}
#cc-chat .cc-head::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: #c5f200; opacity: 0.9; }
html.dark #cc-chat .cc-head { background: #0c0f0d; border-bottom: 1px solid var(--cc-border); }
html.dark #cc-chat .cc-head::after { display: none; }
#cc-chat .cc-avatar {
  width: 40px; height: 40px; border-radius: 13px; flex: none;
  background: #c5f200; color: #0d2b03;
  display: flex; align-items: center; justify-content: center;
}
#cc-chat .cc-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
#cc-chat .cc-head-text strong { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
#cc-chat .cc-head-text span { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cc-chat .cc-dot { width: 7px; height: 7px; border-radius: 50%; background: #5fd36f; flex: none; box-shadow: 0 0 0 3px rgba(95, 211, 111, 0.25); }
#cc-chat .cc-head button {
  background: transparent; border: 0; color: #fff; opacity: 0.85; cursor: pointer;
  width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, opacity 0.15s ease;
}
#cc-chat .cc-head button:hover { opacity: 1; background: rgba(255, 255, 255, 0.14); }
#cc-chat-panel .cc-head button:focus-visible { outline-color: #c5f200; }

/* ---------- conversation ---------- */
#cc-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--cc-bg);
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
#cc-chat-log::-webkit-scrollbar { width: 8px; }
#cc-chat-log::-webkit-scrollbar-thumb { background: var(--cc-border); border-radius: 8px; }

/* welcome state */
#cc-chat .cc-welcome { display: flex; flex-direction: column; gap: 16px; margin: auto 0; padding: 4px 2px 8px; }
#cc-chat .cc-welcome-top { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
#cc-chat .cc-welcome-mark {
  width: 48px; height: 48px; border-radius: 16px; background: var(--cc-brand); color: var(--cc-on-brand);
  display: flex; align-items: center; justify-content: center;
}
#cc-chat .cc-welcome h3 { margin: 0; font-size: 20px; line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; }
#cc-chat .cc-welcome p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--cc-muted); }
#cc-chat .cc-ask { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--cc-muted); margin-bottom: -6px; }
#cc-chat .cc-sugg { display: flex; flex-direction: column; gap: 8px; }
#cc-chat .cc-sugg button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left;
  width: 100%; border: 1px solid var(--cc-border); background: var(--cc-surface); color: var(--cc-text);
  font: inherit; font-size: 13.5px; font-weight: 600; padding: 12px 14px; border-radius: 14px; cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
#cc-chat .cc-sugg button svg { flex: none; opacity: 0.5; transition: transform 0.15s ease, opacity 0.15s ease; }
#cc-chat .cc-sugg button:hover { border-color: var(--cc-brand); background: var(--cc-surface-2); }
#cc-chat .cc-sugg button:hover svg { opacity: 1; transform: translateX(2px); }

/* messages */
#cc-chat .cc-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
#cc-chat .cc-row-user { justify-content: flex-end; }
#cc-chat .cc-mini {
  width: 28px; height: 28px; border-radius: 10px; flex: none; margin-bottom: 18px;
  background: var(--cc-brand); color: var(--cc-on-brand); display: flex; align-items: center; justify-content: center;
}
#cc-chat .cc-col { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: 84%; }
#cc-chat .cc-row-user .cc-col { align-items: flex-end; }
#cc-chat .cc-msg {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
#cc-chat .cc-msg p { margin: 0 0 8px; }
#cc-chat .cc-msg p:last-child, #cc-chat .cc-msg ul:last-child { margin-bottom: 0; }
#cc-chat .cc-msg ul { margin: 4px 0 8px; padding-left: 20px; list-style: disc; } /* the site's reset removes list markers */
#cc-chat .cc-msg li::marker { color: var(--cc-muted); }
#cc-chat .cc-msg li { margin: 3px 0; }
#cc-chat .cc-msg strong { font-weight: 700; }
#cc-chat .cc-user { background: var(--cc-user-bg); color: var(--cc-user-text); border-bottom-right-radius: 6px; }
#cc-chat .cc-bot { background: var(--cc-bot-bg); color: var(--cc-text); border: 1px solid var(--cc-border); border-bottom-left-radius: 6px; }
#cc-chat .cc-error { background: var(--cc-error-bg); color: var(--cc-error-text); border-bottom-left-radius: 6px; }
#cc-chat .cc-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--cc-muted); padding: 0 4px; min-height: 18px; }
#cc-chat .cc-meta button {
  border: 0; background: transparent; color: var(--cc-muted); font: inherit; font-size: 11px; font-weight: 600; cursor: pointer;
  padding: 2px 6px; border-radius: 6px; display: inline-flex; align-items: center; gap: 4px;
}
#cc-chat .cc-meta button:hover { color: var(--cc-text); background: var(--cc-surface-2); }
#cc-chat .cc-meta .cc-retry { color: var(--cc-error-text); }
#cc-chat .cc-copy { opacity: 0; transition: opacity 0.15s ease; }
#cc-chat .cc-row:hover .cc-copy, #cc-chat .cc-copy:focus-visible, #cc-chat .cc-copy.cc-done { opacity: 1; }
@media (hover: none) { #cc-chat .cc-copy { opacity: 1; } }

#cc-chat .cc-typing { display: inline-flex; align-items: center; gap: 5px; padding: 14px 16px; }
#cc-chat .cc-typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--cc-muted); opacity: 0.5;
  animation: cc-bounce 1.1s infinite ease-in-out;
}
#cc-chat .cc-typing i:nth-child(2) { animation-delay: 0.15s; }
#cc-chat .cc-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes cc-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-5px); opacity: 1; } }

/* ---------- composer ---------- */
#cc-chat .cc-composer { padding: 8px 14px 4px; background: var(--cc-bg); }
#cc-chat-form {
  display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 14px;
  border: 1.5px solid var(--cc-border); border-radius: 18px; background: var(--cc-surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#cc-chat-form:focus-within { border-color: var(--cc-brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cc-brand) 16%, transparent); }
#cc-chat-input {
  flex: 1; resize: none; max-height: 110px; font: inherit; font-size: 14px; line-height: 1.45;
  padding: 8px 0; border: 0; background: transparent; color: var(--cc-text); outline: none;
}
#cc-chat-input:focus-visible { outline: none; }
#cc-chat-input::placeholder { color: var(--cc-muted); }
#cc-chat-send {
  flex: none; width: 38px; height: 38px; border: 0; border-radius: 13px; cursor: pointer;
  background: var(--cc-brand); color: var(--cc-on-brand); display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
#cc-chat-send:not(:disabled):hover { transform: translateY(-1px); }
#cc-chat-send:disabled { opacity: 0.35; cursor: not-allowed; }
#cc-chat .cc-foot { display: flex; justify-content: space-between; gap: 8px; padding: 6px 6px 0; font-size: 11px; color: var(--cc-muted); }
#cc-chat .cc-foot [hidden] { display: none; }
#cc-chat #cc-chat-count.cc-warn { color: var(--cc-error-text); font-weight: 700; }
#cc-chat .cc-note { margin: 0; padding: 6px 18px 12px; font-size: 10.5px; line-height: 1.4; color: var(--cc-muted); background: var(--cc-bg); text-align: center; }

/* ---------- phones: a full-height sheet ---------- */
@media (max-width: 520px) {
  #cc-chat-panel {
    right: 0; left: 0; bottom: 0; top: 0; width: 100%; max-width: none; height: 100%; max-height: none;
    border-radius: 0; border: 0; animation: cc-sheet 0.22s ease-out;
  }
  #cc-chat .cc-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  #cc-chat .cc-note { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  #cc-chat-input { font-size: 16px; } /* stops iOS zooming the page on focus */
  #cc-chat-launcher { right: 16px; bottom: 16px; }
  #cc-chat .cc-col { max-width: 88%; }
}
@keyframes cc-sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

@media print { #cc-chat { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
  #cc-chat-panel, #cc-chat-launcher, #cc-chat .cc-typing i, #cc-chat .cc-launcher-label { animation: none; transition: none; }
  #cc-chat-log { scroll-behavior: auto; }
}
