/* ================================================================== */
/* SLICC Follower — Chat WebView Styles (iOS)                         */
/* Dark theme adapted from packages/webapp/src/ui/styles/chat.css     */
/* ================================================================== */

:root {
  --bg-base: #1a1a1a;
  --bg-layer-1: #1e1e1e;
  --bg-layer-2: #252525;
  --bg-elevated: #2c2c2c;
  --bg-sunken: #141414;

  --content-default: #e8e8e8;
  --content-secondary: #a1a1a1;
  --content-tertiary: #8a8a8a;
  --content-disabled: #5a5a5a;

  --accent: #7155fa;
  --accent-hover: #6248e0;
  --negative: #e34850;
  --positive: #2d9d78;

  --border-subtle: #3a3a3a;

  --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  --font-mono: 'SF Mono', 'Menlo', 'Courier New', monospace;
  --radius-s: 4px;
  --radius-default: 8px;
  --radius-bubble: 16px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg-base);
  color: var(--content-default);
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

#messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px;
  padding-bottom: env(safe-area-inset-bottom, 80px);
  min-height: 100vh;
}

/* ── Message bubbles ─────────────────────────────────────────────── */

.msg {
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-size: 15px;
  line-height: 1.5;
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* User messages — right-aligned purple bubble */
.msg--user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-bubble) var(--radius-bubble) 4px var(--radius-bubble);
  padding: 10px 14px;
  max-width: 85%;
  font-weight: 500;
}

.msg--user a {
  color: #c8bbff !important;
  text-decoration: underline;
}
.msg--user a:hover {
  color: #fff !important;
}
.msg--user code {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.9em;
}

/* Assistant messages — left-aligned, transparent bg */
.msg--assistant {
  align-self: flex-start;
  max-width: 100%;
}

.msg--assistant .msg__content {
  color: var(--content-default);
}

/* Lick messages — compact with indicator */
.msg--lick {
  align-self: flex-start;
  max-width: 100%;
  border-left: 3px solid var(--content-tertiary);
  padding-left: 10px;
  opacity: 0.8;
}

.msg--lick .msg__lick-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--content-tertiary);
  margin-bottom: 4px;
}

/* Queued messages */
.msg--queued {
  opacity: 0.55;
}

/* ── Markdown content ────────────────────────────────────────────── */

.msg__content p {
  margin: 0.4em 0;
}
.msg__content p:first-child {
  margin-top: 0;
}
.msg__content p:last-child {
  margin-bottom: 0;
}

.msg__content h1,
.msg__content h2,
.msg__content h3,
.msg__content h4,
.msg__content h5,
.msg__content h6 {
  margin: 0.8em 0 0.4em;
  font-weight: 600;
  line-height: 1.3;
}
.msg__content h1 {
  font-size: 1.4em;
}
.msg__content h2 {
  font-size: 1.2em;
}
.msg__content h3 {
  font-size: 1.1em;
}

.msg__content strong {
  font-weight: 700;
}
.msg__content em {
  font-style: italic;
}

.msg__content a {
  color: #7ba4f7;
  text-decoration: none;
}

/* Lists */
.msg__content ul,
.msg__content ol {
  padding-left: 1.4em;
  margin: 0.4em 0;
}
.msg__content li {
  margin: 0.2em 0;
}

/* Images */
.msg__content img {
  max-width: 100%;
  border-radius: var(--radius-default);
  margin: 8px 0;
}

/* Blockquotes */
.msg__content blockquote {
  border-left: 3px solid var(--border-subtle);
  padding-left: 12px;
  margin: 0.5em 0;
  color: var(--content-secondary);
}

/* ── Tool calls — collapsible sections ───────────────────────────── */

.msg__tools {
  margin-top: 8px;
}

.tool-call {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-default);
  margin: 6px 0;
  overflow: hidden;
}

.tool-call summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 12px;
  background: var(--bg-layer-2);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--content-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tool-call summary::-webkit-details-marker {
  display: none;
}

.tool-call summary::before {
  content: '\25B8';
  font-size: 10px;
  transition: transform 0.15s ease;
  display: inline-block;
}
.tool-call[open] summary::before {
  transform: rotate(90deg);
}

.tool-call__name {
  font-weight: 600;
  color: var(--content-default);
}

.tool-call__body {
  padding: 8px 12px;
  background: var(--bg-sunken);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--content-secondary);
  max-height: 200px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.tool-call--error .tool-call__body {
  border-top: 2px solid var(--negative);
  color: var(--negative);
}

.tool-call--success .tool-call__body {
  border-top: 1px solid var(--border-subtle);
}

/* ── Streaming indicator ─────────────────────────────────────────── */

.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 16px;
  background: var(--accent);
  margin-left: 2px;
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
  border-radius: 1px;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

.streaming-dots {
  display: inline-flex;
  gap: 4px;
  padding: 8px 0;
}
.streaming-dots span {
  width: 6px;
  height: 6px;
  background: var(--content-tertiary);
  border-radius: 50%;
  animation: pulse 1.4s ease-in-out infinite;
}
.streaming-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.streaming-dots span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── Syntax highlighting tokens ──────────────────────────────────── */

.tok-keyword {
  color: #c792ea;
}
.tok-string {
  color: #c3e88d;
}
.tok-number {
  color: #f78c6c;
}
.tok-comment {
  color: #616161;
  font-style: italic;
}
.tok-fn {
  color: #82aaff;
}

/* ── Smooth scroll ───────────────────────────────────────────────── */

html {
  scroll-behavior: smooth;
}

/* Hide scrollbar for cleaner mobile look */
body::-webkit-scrollbar {
  display: none;
}
body {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.msg__content a:hover {
  text-decoration: underline;
}

/* Inline code */
.msg__content code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: var(--radius-s);
  font-family: var(--font-mono);
  font-size: 0.88em;
}

/* Code blocks */
.msg__content pre {
  background: var(--bg-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-default);
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.msg__content pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
}
