/* ============ AI WORKSPACE ============ */
#aiWorkspaceSidebar { transition: transform .28s cubic-bezier(.16,1,.3,1); }
@media (max-width: 767px) {
  #aiWorkspaceSidebar {
    position: absolute; inset: 0 auto 0 0; width: 82%; max-width: 300px; z-index: 20;
    background: #fff; box-shadow: 16px 0 36px -12px rgba(18,19,26,0.28);
    transform: translateX(-100%);
  }
  #aiWorkspaceSidebar.ws-sidebar-open { transform: translateX(0); }
}
.ws-typing-dot {
  width: 6px; height: 6px; border-radius: 999px; background: #9497AC;
  display: inline-block; animation: wsTypingBounce 1.2s ease-in-out infinite;
}
.ws-typing-dot:nth-child(2) { animation-delay: .15s; }
.ws-typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes wsTypingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Lightweight markdown rendering for AI chat bubbles */
.ws-md .ws-md-p { margin: 0 0 .55em; }
.ws-md .ws-md-p:last-child { margin-bottom: 0; }
.ws-md .ws-md-h1, .ws-md .ws-md-h2, .ws-md .ws-md-h3, .ws-md .ws-md-h4 { font-weight: 800; margin: .3em 0 .4em; color: #12131A; }
.ws-md .ws-md-h1 { font-size: 1.05em; }
.ws-md .ws-md-h2 { font-size: 1.02em; }
.ws-md .ws-md-h3, .ws-md .ws-md-h4 { font-size: 1em; }
.ws-md .ws-md-ul, .ws-md .ws-md-ol { margin: .3em 0 .6em; padding-left: 1.3em; }
.ws-md .ws-md-ul { list-style: disc; }
.ws-md .ws-md-ol { list-style: decimal; }
.ws-md .ws-md-ul li, .ws-md .ws-md-ol li { margin: .2em 0; }
.ws-md .ws-md-code { background: #EEEEF6; color: #4547C4; border-radius: 5px; padding: .1em .35em; font-family: 'JetBrains Mono', monospace; font-size: .92em; }
.ws-md .ws-md-pre { background: #12131A; color: #E7E8F0; border-radius: 12px; padding: .8em 1em; overflow-x: auto; margin: .4em 0 .6em; }
.ws-md .ws-md-pre code { font-family: 'JetBrains Mono', monospace; font-size: .85em; white-space: pre; }
.ws-md-table-wrap { overflow-x: auto; margin: .4em 0 .6em; border-radius: 10px; border: 1px solid #E7E8F0; }
.ws-md-table { border-collapse: collapse; width: 100%; font-size: .95em; }
.ws-md-table th, .ws-md-table td { border-bottom: 1px solid #E7E8F0; padding: .45em .7em; text-align: left; }
.ws-md-table th { background: #F5F6FA; font-weight: 800; font-size: .92em; }
.ws-md-table tr:last-child td { border-bottom: none; }
.ws-md .ws-md-blockquote { border-left: 3px solid #B4B6F7; background: #F7F7FE; color: #4A4C64; margin: .4em 0 .6em; padding: .55em .9em; border-radius: 0 10px 10px 0; font-style: italic; }
.ws-md .ws-md-hr { border: none; border-top: 1px solid #E7E8F0; margin: .8em 0; }

/* ============ AI WORKSPACE — POLISH (Sprint 3.2) ============ */

/* Panel resizing (tablet/desktop) */
#aiWorkspacePanel { transition: width .18s ease; }
#aiWorkspacePanel.ws-resizing { transition: none; user-select: none; }
#wsResizeHandle {
  position: absolute; left: -5px; top: 0; bottom: 0; width: 10px; cursor: col-resize; z-index: 5;
  display: none;
}
#wsResizeHandle::after {
  content: ''; position: absolute; left: 4px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 44px; border-radius: 999px; background: #E3E4FD; transition: background .15s ease;
}
#wsResizeHandle:hover::after, #wsResizeHandle.active::after { background: #6366F1; }
@media (min-width: 768px) { #wsResizeHandle { display: block; } }

/* Conversation rows: pin + timestamp + menu */
.ws-conv-row.pinned { background: #FBFBFF; }
.ws-conv-pin-icon { color: #F59E0B; }
.ws-conv-menu-btn { opacity: 0; transition: opacity .12s ease, background .12s ease; }
.group:hover .ws-conv-menu-btn, .ws-conv-menu-btn:focus-visible, .ws-conv-menu-btn.menu-open { opacity: 1; }
/* Touch devices never trigger :hover, so without this the "more actions"
   button on each conversation row would be effectively invisible (and
   easy to miss) on phones/tablets — only reachable by guessing where to
   tap, or via the long-press/right-click context menu. */
@media (pointer: coarse) {
  .ws-conv-menu-btn { opacity: 1; }
}
.ws-conv-row { position: relative; }
.ws-conv-row.active-row::before {
  content: ''; position: absolute; left: -6px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; border-radius: 999px; background: linear-gradient(180deg,#6366F1,#8B5CF6);
  animation: wsBarIn .18s cubic-bezier(.16,1,.3,1) both;
}
@keyframes wsBarIn { 0% { opacity: 0; height: 20%; } 100% { opacity: 1; height: 60%; } }

#wsContextMenu {
  position: fixed; z-index: 200; min-width: 168px; background: #fff; border: 1px solid #E7E8F0;
  border-radius: 12px; box-shadow: 0 4px 12px -4px rgba(18,19,26,0.08), 0 16px 36px -12px rgba(18,19,26,0.20);
  padding: 6px; animation: popIn .14s cubic-bezier(.16,1,.3,1) both;
}
.ws-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 7px 9px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; color: #33354A; transition: background .1s ease;
}
.ws-menu-item:hover { background: #F5F6FA; }
.ws-menu-item.danger { color: #E11D48; }
.ws-menu-item.danger:hover { background: #FFF1F3; }
.ws-menu-divider { height: 1px; background: #EEEEF4; margin: 4px 2px; }

/* Message-level hover actions */
.ws-msg-actions { opacity: 0; transition: opacity .12s ease; }
.ws-msg-row:hover .ws-msg-actions, .ws-msg-actions:focus-within { opacity: 1; }
.ws-msg-actions button { transition: color .1s ease, transform .1s ease; }
.ws-msg-actions button:active { transform: scale(.88); }

/* Streaming caret */
.ws-caret { display: inline-block; width: 2px; height: 1em; background: #6366F1; margin-left: 1px; vertical-align: text-bottom; animation: wsCaretBlink .8s step-end infinite; }
@keyframes wsCaretBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Message search highlight */
mark.ws-hl { background: #FDE68A; color: #12131A; border-radius: 3px; padding: 0 1px; }
mark.ws-hl.ws-hl-active { background: #F59E0B; color: #fff; }

/* Code blocks */
.ws-code-wrap { margin: .5em 0 .7em; border-radius: 12px; overflow: hidden; background: #12131A; border: 1px solid rgba(255,255,255,0.06); }
.ws-code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px 6px 14px; background: rgba(255,255,255,0.04); border-bottom: 1px solid rgba(255,255,255,0.06); }
.ws-code-lang { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #9497AC; }
.ws-code-copy { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: #C4C6D6; padding: 3px 7px; border-radius: 6px; transition: background .12s ease, color .12s ease; }
.ws-code-copy:hover { background: rgba(255,255,255,0.08); color: #fff; }
.ws-code-wrap pre.ws-md-pre { margin: 0; border-radius: 0; background: transparent; }
.ws-code-wrap pre.ws-md-pre code.hljs { background: transparent; padding: 0; }

/* Input area: char counter, drag & drop, paperclip */
#wsInputWrap { position: relative; }
.ws-char-counter { font-variant-numeric: tabular-nums; }
.ws-char-counter.near-limit { color: #D97706; }
.ws-char-counter.over-limit { color: #E11D48; }
#wsDropOverlay {
  position: absolute; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center;
  background: rgba(99,102,241,0.06); border: 2px dashed #B4B6F7; border-radius: 16px; backdrop-filter: blur(1px);
}
#wsDropOverlay.active { display: flex; }
textarea#aiWorkspaceInput { transition: height .1s ease; }

/* Empty state quick actions */
.ws-quick-action { transition: transform .12s ease, border-color .12s ease, background .12s ease; }
.ws-quick-action:hover { transform: translateY(-1px); }
.ws-quick-action:active { transform: translateY(0) scale(.98); }

/* Skeleton bubbles shown briefly while the workspace panel/conversation is loading */
.ws-skel-row { display: flex; gap: 8px; align-items: flex-start; animation: fadeIn .15s ease both; }
.ws-skel-row.right { justify-content: flex-end; }
.ws-skel-avatar { width: 24px; height: 24px; border-radius: 8px; flex-shrink: 0; }
.ws-skel-bubble { height: 14px; border-radius: 10px; }
.ws-skel-stack { display: flex; flex-direction: column; gap: 6px; }

/* Mobile: workspace fills the screen, input safe-area */
@media (max-width: 767px) {
  #aiWorkspacePanel { width: 100% !important; min-width: 0 !important; }
}

/* Smooth message mount */
.ws-msg-row { animation: fadeUp .22s cubic-bezier(.16,1,.3,1) both; }
