/* ── AI Chat slide-over ───────────────────────────────────────────────────────── */

.ws-ai-chat-panel {
  position: fixed;
  inset: 0;
  z-index: 600;
}

.ws-ai-chat-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 37, 54, 0.3);
}

.ws-ai-chat-drawer {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 400px;
  max-width: 100vw;
  background: var(--surface-elevated);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(10, 37, 54, 0.12);
}

/* Header */
.ws-ai-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.ws-ai-chat-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand-navy);
  margin: 0 0 0.25rem;
}

.ws-ai-chat-context {
  font-size: 0.75rem;
  color: var(--brand-gold);
  font-weight: 600;
  display: block;
}

.ws-ai-chat-close {
  background: none;
  border: none;
  font-size: 1.375rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.ws-ai-chat-close:hover { color: var(--brand-navy); }

/* Messages */
.ws-ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

.ws-ai-msg { display: flex; }
.ws-ai-msg--user      { justify-content: flex-end; }
.ws-ai-msg--assistant { justify-content: flex-start; }

.ws-ai-msg__bubble {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.ws-ai-msg--user .ws-ai-msg__bubble {
  background: var(--brand-navy);
  color: var(--surface-canvas);
  border-bottom-right-radius: 4px;
}

.ws-ai-msg--assistant .ws-ai-msg__bubble {
  background: var(--surface-recessed);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

/* Source citations */
.ws-ai-msg__sources {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.ws-ai-msg__source {
  background: var(--surface-recessed);
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  cursor: pointer;
  transition: background 0.15s;
}
.ws-ai-msg__source:hover {
  background: var(--brand-gold);
  color: var(--brand-navy);
}

/* Typing indicator */
.ws-ai-typing .ws-ai-msg__bubble { padding: 0.875rem 1rem; }

.ws-ai-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  margin: 0 2px;
  animation: ws-bounce 1.2s infinite ease-in-out;
}

.ws-ai-dot:nth-child(2) { animation-delay: 0.2s; }
.ws-ai-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ws-bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-5px); }
}

/* Quick-prompt chips */
.ws-ai-chat-chips {
  padding: 0.5rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  flex-shrink: 0;
  border-top: 1px solid var(--border-subtle);
  min-height: 0;
}

.ws-ai-chip {
  background: var(--surface-recessed);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 20px;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-sans);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ws-ai-chip:hover {
  background: var(--brand-navy);
  color: var(--surface-canvas);
  border-color: var(--brand-navy);
}

/* Composer */
.ws-ai-chat-composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  align-items: flex-end;
  background: var(--surface-elevated);
}

.ws-ai-chat-input {
  flex: 1;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.15s;
}
.ws-ai-chat-input:focus { border-color: var(--brand-navy); }

.ws-ai-chat-send {
  background: var(--brand-navy);
  color: var(--surface-canvas);
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.ws-ai-chat-send:hover { background: var(--brand-gold); color: var(--brand-navy); }

/* ── AI buttons embedded in views ─────────────────────────────────────────────── */

/* Toolbar AI button */
.ws-ai-btn {
  background: var(--brand-gold);
  color: var(--brand-navy);
  border: none;
  border-radius: 6px;
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.ws-ai-btn:hover { background: var(--brand-gold-deep); }

/* Floating AI FAB */
.ws-ai-fab {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--brand-navy);
  color: var(--brand-gold);
  border: none;
  border-radius: 28px;
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(10, 37, 54, 0.2);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.ws-ai-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(10, 37, 54, 0.25);
}

/* Matters toolbar wrapper */
.ws-matters-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

/* Avatar name in topbar */
.ws-avatar-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #F3FAFF;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Admin badge in sidebar */
.sb-nav-admin-badge {
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--brand-gold);
  color: var(--brand-navy);
  margin-left: auto;
}

/* Mobile */
@media (max-width: 768px) {
  .ws-ai-chat-drawer {
    width: 100%;
    top: auto;
    height: 80vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(10, 37, 54, 0.12);
  }

  .ws-ai-fab {
    bottom: 1rem;
    right: 1rem;
  }
}
