/* ==========================================================================
   ASK WICK — docked side panel
   Same trading-terminal identity as the chatroom (chatroom.css):
   hairline structure, flat tinted surfaces, candle motif, tabular
   numerals. Token set mirrors the chat shell under --wick-* names and
   flips to dark in theme_preferences.css.
   ========================================================================== */

.askwick {
  /* ---- palette (light; dark overrides in theme_preferences.css) ---- */
  --wick-green:       #0e9c68;
  --wick-green-2:     #077a4e;
  --wick-green-soft:  #e7f6ef;
  --wick-green-line:  #bfe6d3;

  --wick-text-1:      #0b1426;
  --wick-text-2:      #2c3a55;
  --wick-text-3:      #5d6b86;
  --wick-soft:        #8e9bb2;

  --wick-border:      #dde3ed;
  --wick-border-soft: #e9edf4;
  --wick-surface:     #ffffff;
  --wick-surface-2:   #f6f8fb;
  --wick-surface-3:   #e9edf4;

  --wick-user-bg:     #16223b;
  --wick-user-fg:     #f2f5fa;

  --wick-r-sm: 6px;  --wick-r-md: 10px;  --wick-r-lg: 14px;  --wick-r-pill: 999px;

  --wick-shadow-pop: 0 12px 32px -16px rgba(11, 20, 38, .28);

  --wick-mono: "SF Mono", ui-monospace, "Monaco", "Menlo", monospace;

  --wick-panel-w: 440px;
}

body.askwick-open { --askwick-w: 440px; }

/* ---------- Launcher button (sits in the sidebar) ----------
   Green Wick tile + hairline card. Works on the light sidebar and the
   dark one (tokens flip with the theme). */
.askwick-trigger {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0 0 18px;
  padding: 9px 12px;
  border-radius: var(--wick-r-lg);
  border: 1px solid var(--wick-border);
  background: var(--wick-surface-2);
  color: var(--wick-text-1);
  font-size: 13.5px;
  font-weight: 650;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s, transform 0.1s;
  font-family: inherit;
  overflow: hidden;
}
.askwick-trigger:hover {
  border-color: var(--wick-green-line);
  background: var(--wick-green-soft);
}
.askwick-trigger:active { transform: translateY(1px); }
.askwick-trigger:focus-visible {
  outline: 2px solid var(--wick-green);
  outline-offset: 2px;
}

.askwick.is-open .askwick-trigger,
body.askwick-open .askwick-trigger {
  background: var(--wick-green-soft);
  border-color: var(--wick-green-line);
}

/* The candle tile — Wick's mark, identical to the chatroom avatar */
.askwick-trigger-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--wick-r-md);
  background: var(--wick-green);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.askwick-trigger-icon svg { width: 14px; height: 14px; display: block; }

.askwick-trigger-label { flex: 1; text-align: left; letter-spacing: -.01em; }

.askwick-trigger-kbd {
  font-size: 10.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: var(--wick-r-sm);
  background: var(--wick-surface);
  border: 1px solid var(--wick-border);
  color: var(--wick-text-3);
  font-family: inherit;
  flex-shrink: 0;
}

.dashboard-container.is-collapsed .askwick-trigger-label,
.dashboard-container.is-collapsed .askwick-trigger-kbd {
  display: none;
}
.dashboard-container.is-collapsed .askwick-trigger {
  justify-content: center;
  padding: 9px 0;
}

/* ---------- Backdrop ---------- */
.askwick-backdrop {
  display: none;
}

/* ---------- Docked panel ---------- */
.askwick-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--wick-panel-w);
  background: var(--wick-surface);
  border-left: 1px solid var(--wick-border);
  box-shadow: var(--wick-shadow-pop);
  display: flex;
  flex-direction: column;
  z-index: 2500;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--wick-text-1);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
/* Open state is driven redundantly: any of the three signals slides the
   panel into view (Turbo swaps can replace any one of the three). */
.askwick.is-open .askwick-panel,
.askwick-panel.is-open,
body.askwick-open .askwick-panel { transform: translateX(0); }

/* Top edge: a quiet green rail — no animation, just the accent */
.askwick-ribbon {
  display: block;
  height: 2px;
  background: var(--wick-green);
  flex-shrink: 0;
}

/* ---------- Header ---------- */
.askwick-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--wick-border);
  background: var(--wick-surface);
  flex-shrink: 0;
}

.askwick-head-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* Candle mark — same glyph as the chatroom avatar */
.askwick-head-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--wick-r-md);
  background: var(--wick-green);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.askwick-head-mark svg { width: 16px; height: 16px; display: block; }

.askwick-head-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.askwick-head-text strong {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.015em;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.askwick-head-text span { font-size: 11.5px; color: var(--wick-soft); font-weight: 500; }

/* Online status — a quiet breathing dot (single, no rings) */
.askwick-status {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--wick-green);
}
.askwick-status::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--wick-green-line);
  animation: askwick-ring 2.4s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}

@keyframes askwick-ring {
  0%   { transform: scale(0.6); opacity: 0.9; }
  80%  { transform: scale(2);   opacity: 0;   }
  100% { transform: scale(2);   opacity: 0;   }
}

.askwick-head-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.askwick-head-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border-radius: var(--wick-r-md);
  border: 1px solid var(--wick-border);
  background: var(--wick-surface);
  color: var(--wick-text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.askwick-head-btn svg { width: 13px; height: 13px; }
.askwick-head-btn:hover {
  background: var(--wick-surface-2);
  color: var(--wick-text-1);
  border-color: var(--wick-border-soft);
}
.askwick-head-btn:focus-visible { outline: 2px solid var(--wick-green); outline-offset: 2px; }

.askwick-head-btn--icon { width: 32px; padding: 0; justify-content: center; }

/* ---------- Body / messages ---------- */
.askwick-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--wick-surface);
  scrollbar-width: thin;
}
/* FIX: children must never shrink. Scrollable column flex boxes squash
   items whose overflow is not visible — .askwick-think is overflow:
   hidden, so a long transcript would flatten reasoning panels into
   2px slivers (same bug as the chatroom's .chat-scroll). The body SCROLLS. */
.askwick-body > * { flex-shrink: 0; }
.askwick-body::-webkit-scrollbar { width: 6px; }
.askwick-body::-webkit-scrollbar-track { background: transparent; }
.askwick-body::-webkit-scrollbar-thumb { background: var(--wick-border-soft); border-radius: var(--wick-r-pill); }
.askwick-body::-webkit-scrollbar-thumb:hover { background: var(--wick-border); }

/* Welcome state — candle field, same motif as the chatroom empty state */
.askwick-welcome {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 8px;
  gap: 6px;
  margin: auto 0;
}
.askwick-welcome .chat-candles {
  width: 118px;
  height: 52px;
  margin: 0 0 10px;
}
.askwick-welcome h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.015em;
  color: var(--wick-text-1);
}
.askwick-welcome p {
  margin: 0;
  font-size: 12.5px;
  color: var(--wick-text-3);
  line-height: 1.55;
  max-width: 320px;
}

.askwick-chips { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 16px; }

.askwick-chip {
  position: relative;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--wick-r-lg);
  border: 1px solid var(--wick-border);
  background: var(--wick-surface-2);
  color: var(--wick-text-2);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s;
  font-family: inherit;
  line-height: 1.4;
}
.askwick-chip:hover {
  background: var(--wick-green-soft);
  border-color: var(--wick-green-line);
  color: var(--wick-green-2);
}
.askwick-chip:active { transform: translateY(1px); }
.askwick-chip:focus-visible { outline: 2px solid var(--wick-green); outline-offset: 2px; }

/* Messages */
.askwick-msg { display: flex; }
.askwick-msg--user { justify-content: flex-end; }
.askwick-msg--wick { justify-content: flex-start; }

.askwick-msg-body {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--wick-r-xl);
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.askwick-msg--user .askwick-msg-body {
  background: var(--wick-user-bg);
  color: var(--wick-user-fg);
  border-bottom-right-radius: var(--wick-r-sm);
}

.askwick-msg--wick .askwick-msg-body {
  background: var(--wick-surface-2);
  color: var(--wick-text-2);
  border: 1px solid var(--wick-border);
  border-bottom-left-radius: var(--wick-r-sm);
}
.askwick-msg--wick .askwick-msg-body strong { font-weight: 650; color: var(--wick-text-1); }

/* ---------- Streaming caret ---------- */
.askwick-msg--streaming .askwick-msg-body::after {
  content: '▍';
  display: inline-block;
  margin-left: 2px;
  color: var(--wick-green);
  animation: askwick-caret 1.1s steps(2, start) infinite;
  vertical-align: -1px;
}
.askwick-msg--streaming .askwick-msg-body { word-break: break-word; }

@keyframes askwick-caret {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* ---------- Tool-in-progress label + typing dots ---------- */
.askwick-typing-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--wick-soft);
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}
.askwick-msg--typing .askwick-msg-body {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}
.askwick-dot {
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--wick-green);
  animation: askwick-pulse 1.2s ease-in-out infinite;
}
.askwick-dot:nth-child(2) { animation-delay: 0.15s; }
.askwick-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes askwick-pulse {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30%           { opacity: 1;    transform: translateY(-2px); }
}

/* ---------- Scope / system event pill ---------- */
.askwick-event {
  display: flex;
  justify-content: center;
  padding: 2px 0;
}
.askwick-event span {
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--wick-text-3);
  background: var(--wick-surface-2);
  border: 1px solid var(--wick-border-soft);
  padding: 3px 10px;
  border-radius: var(--wick-r-pill);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ---------- Composer ---------- */
.askwick-composer {
  padding: 12px 16px 10px;
  border-top: 1px solid var(--wick-border);
  flex-shrink: 0;
  background: var(--wick-surface);
}

.askwick-composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.askwick-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
}

.askwick-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--wick-border);
  background: var(--wick-surface-2);
  border-radius: var(--wick-r-xl);
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--wick-text-1);
  font-family: inherit;
  max-height: 160px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  overflow-y: auto;
}
.askwick-input:focus {
  outline: none;
  background: var(--wick-surface);
  border-color: var(--wick-green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--wick-green) 12%, transparent);
}
.askwick-input::placeholder { color: var(--wick-soft); }

.askwick-send {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 0;
  border-radius: var(--wick-r-lg);
  background: var(--wick-green);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
}
.askwick-send:hover { background: var(--wick-green-2); }
.askwick-send:active { transform: scale(.96); }
.askwick-send:focus-visible { outline: 2px solid var(--wick-green); outline-offset: 2px; }
.askwick-send svg { width: 16px; height: 16px; }

.askwick-composer-hint {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--wick-soft);
  font-weight: 500;
}
.askwick-composer-hint-dot { color: var(--wick-border-soft); }
.askwick-composer-hint kbd {
  font-family: inherit;
  font-size: 10px;
  font-weight: 650;
  padding: 1px 5px;
  margin: 0 1px;
  border-radius: 4px;
  background: var(--wick-surface-2);
  border: 1px solid var(--wick-border-soft);
  color: var(--wick-text-3);
  display: inline-block;
}

/* ---------- Footer ---------- */
.askwick-foot {
  padding: 10px 16px 12px;
  font-size: 10.5px;
  color: var(--wick-soft);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
  align-items: center;
  border-top: 1px solid var(--wick-border);
  background: var(--wick-surface-2);
}
.askwick-foot a {
  color: var(--wick-text-2);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s;
}
.askwick-foot a:hover { color: var(--wick-green-2); }

/* ==========================================================================
   Markdown inside message bodies
   ========================================================================== */
.askwick-msg-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin: 8px 0;
  font-variant-numeric: tabular-nums;
}
.askwick-msg-body th,
.askwick-msg-body td {
  border: 1px solid var(--wick-border-soft);
  padding: 6px 10px;
  text-align: left;
  white-space: nowrap;
}
.askwick-msg-body th { background: var(--wick-surface-3); font-weight: 700; font-size: 11px; }
.askwick-msg-body strong { font-weight: 700; color: var(--wick-text-1); }
.askwick-msg-body a { color: var(--wick-green-2); }
.askwick-msg-body code {
  background: var(--wick-surface-3);
  padding: 1px 5px;
  border-radius: var(--wick-r-sm);
  font-size: 12px;
  font-family: var(--wick-mono);
}
.askwick-msg-body ul,
.askwick-msg-body ol { padding-left: 20px; margin: 6px 0; }
.askwick-msg-body p { margin: 6px 0; }
.askwick-msg-body p:first-child { margin-top: 0; }
.askwick-msg-body p:last-child  { margin-bottom: 0; }

/* ==========================================================================
   Reasoning panel — same treatment as the chatroom's .chat-think
   ========================================================================== */
.askwick-msg--thinkwrap {
  max-width: 100%;
  display: block;
}

.askwick-think {
  border: 1px solid var(--wick-border);
  background: var(--wick-surface-2);
  border-radius: var(--wick-r-md);
  overflow: hidden;
  font-size: 12.5px;
  max-width: 85%;
}

.askwick-think-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--wick-text-3);
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  transition: color 0.15s, background 0.15s;
}
.askwick-think-head:hover {
  color: var(--wick-text-2);
  background: var(--wick-surface-3);
}
.askwick-think-head:focus-visible { outline: 2px solid var(--wick-green); outline-offset: -2px; }

.askwick-think-chev {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.askwick-think.is-open .askwick-think-chev { transform: rotate(90deg); }

.askwick-think-label {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.askwick-think-body {
  display: none;
  padding: 10px 14px 12px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--wick-text-3);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
  font-family: var(--wick-mono);
  border-top: 1px solid var(--wick-border-soft);
}
.askwick-think.is-open .askwick-think-body { display: block; }

.askwick-think-body::-webkit-scrollbar { width: 5px; }
.askwick-think-body::-webkit-scrollbar-thumb { background: var(--wick-border-soft); border-radius: var(--wick-r-pill); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .askwick-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(11, 20, 38, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
    z-index: 2400;
  }
  .askwick.is-open .askwick-backdrop,
  body.askwick-open .askwick-backdrop { opacity: 1; pointer-events: auto; }
  .askwick-panel {
    width: 100%;
    max-width: 420px;
  }
  body.askwick-open { --askwick-w: 0px; }
}

@media (max-width: 480px) {
  .askwick-panel { max-width: 100vw; border-left: 0; }
  .askwick-head { padding: 12px 14px; }
  .askwick-head-text span { display: none; }
  .askwick-body { padding: 14px 14px 6px; }
  .askwick-composer { padding: 10px 12px 8px; }
  .askwick-foot { padding: 8px 12px 10px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .askwick-panel,
  .askwick-backdrop,
  .askwick-trigger,
  .askwick-chip,
  .askwick-send,
  .askwick-think-chev { transition: none !important; }
  .askwick-status::after,
  .askwick-dot,
  .askwick-msg--streaming .askwick-msg-body::after { animation: none !important; }
}
