/**
 * Version Notes:
 * File: /pwa/css/chat.css
 * Version: 0.3.0
 * Last Modified: 2026-07-30 08:25 PM
 * Changes:
 * - Chat interface: messages, input, typing indicator
 * - Clean Claude/ChatGPT style — no bubbles, clean separation
 * - v0.1.0: user messages right-aligned (avatar on the far right)
 * - v0.2.0: per-message actions (ellipsis button, popover menu, delete-confirm modal)
 * - v0.3.0: council working-indicator bubble (.council-status, councilPulse dots)
 */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 16px;
  padding: 20px 24px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  animation: messageIn 200ms ease;
  position: relative;
}

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

.message-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.message.assistant .message-avatar {
  background: var(--accent-muted);
  color: var(--text-secondary);
}

.message.assistant .message-avatar .icon {
  width: 18px;
  height: 18px;
}

.message.user .message-avatar {
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 13px;
  font-weight: 600;
}

/* User messages: avatar on the far right, content right-aligned.
   Assistant messages keep the default left-aligned row. */
.message.user {
  flex-direction: row-reverse;
}

.message.user .message-content {
  text-align: right;
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-content p {
  margin: 0 0 8px;
  word-wrap: break-word;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content strong {
  font-weight: 600;
}

.message-content code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
}

.message-content pre {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 16px;
  overflow-x: auto;
  margin: 8px 0;
}

.message-content pre code {
  background: none;
  padding: 0;
}

.message-time {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* Typing indicator */
.message.typing .message-content {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typingBounce 1.4s ease-in-out infinite;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Council working-indicator bubble (v0.3.0) — singleton rendered by
   js/council-status.js as the last child of #chat-messages. The outer
   .message class already provides the messageIn fade-in. */
.message.council-status .message-content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
  padding: 8px 14px;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

.council-dot {
  width: 7px;
  height: 7px;
  min-width: 7px;
  border-radius: 50%;
  background: var(--info);
  animation: councilPulse 1.4s ease-in-out infinite;
}

.council-dot:nth-child(2) { animation-delay: 0.25s; }
.council-dot:nth-child(3) { animation-delay: 0.5s; }

/* Slow scale/opacity pulse — reads as "working", not "typing". */
@keyframes councilPulse {
  0%, 100% { transform: scale(0.8); opacity: 0.35; }
  50% { transform: scale(1.15); opacity: 1; }
}

.council-status-text {
  font-size: 0.9em;
  font-style: italic;
  color: var(--text-secondary);
}

/* ============================================
   CHAT INPUT
   ============================================ */
.chat-input-area {
  padding: 12px 24px 24px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-lg);
  padding: 8px 12px;
  transition: border-color var(--transition);
}

.chat-input-wrapper:focus-within {
  border-color: var(--input-focus);
}

.chat-input-wrapper textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 200px;
  min-height: 24px;
  padding: 4px 0;
}

.chat-input-wrapper textarea::placeholder {
  color: var(--text-tertiary);
}

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border: none;
  background: var(--accent);
  color: var(--text-inverse);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition);
  opacity: 0.5;
}

.send-btn:hover { opacity: 0.8; }
.send-btn.active { opacity: 1; }

.send-btn .icon {
  width: 16px;
  height: 16px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .message {
    padding: 16px;
    gap: 12px;
  }

  .chat-input-area {
    padding: 8px 12px 16px;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
  }
}


/* ============================================
   PER-MESSAGE ACTIONS (Copy / Share / Delete)
   ============================================ */
.message-actions {
  position: absolute;
  top: 12px;
  opacity: 0;
  transition: opacity var(--transition);
}

/* Anchor to the content's outer edge — right for assistant, left for the
   row-reverse user messages — so it never collides with the avatar. */
.message.assistant .message-actions { right: 20px; }
.message.user .message-actions { left: 20px; }

.message:hover .message-actions { opacity: 1; }

/* Touch devices have no hover — keep the affordance discoverable. */
@media (hover: none) {
  .message-actions { opacity: 0.55; }
}

.msg-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.msg-action-btn:hover {
  background: var(--accent-muted);
  color: var(--text-primary);
}

/* Shared popover menu (appended to <body>, positioned fixed) */
.msg-menu {
  position: fixed;
  display: none;
  min-width: 140px;
  padding: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 2000;
}

.msg-menu.open { display: block; }

.msg-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.msg-menu-item:hover { background: var(--bg-tertiary); }
.msg-menu-item.danger { color: #dc3545; }

/* Delete confirmation modal (reuses .login-overlay backdrop) */
.chat-confirm-card {
  width: 100%;
  max-width: 340px;
  padding: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  text-align: left;
}

.chat-confirm-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.chat-confirm-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
}

.chat-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}


/* v0.2.0 2026-07-15: controls row under the composer (Claude-app style) + MODE pill */
.chat-controls-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 24px 10px; position: relative;
}
.chat-mode-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--border-primary);
  background: var(--bg-secondary); color: var(--text-secondary);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.chat-mode-pill:hover { color: var(--text-primary); border-color: var(--border-active); }
.chat-mode-pill .icon { stroke: currentColor; }
.chat-mode-menu {
  position: absolute; bottom: calc(100% + 4px); left: 24px;
  display: flex; flex-direction: column; min-width: 150px;
  background: var(--bg-elevated); border: 1px solid var(--border-secondary);
  border-radius: 12px; padding: 4px; z-index: 60;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.chat-mode-menu-item {
  text-align: left; padding: 8px 12px; border-radius: 8px;
  background: none; border: none; color: var(--text-primary);
  font-size: 14px; cursor: pointer;
}
.chat-mode-menu-item:hover { background: var(--bg-hover); }

/* === END OF FILE (FILENAME: /pwa/css/chat.css) === */
