/* Sil chat — message bubbles, input area, typing indicators */

/* OAuth result toast */
.oauth-toast {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: opacity 0.3s, transform 0.3s;
}
.oauth-success {
  background: #065f46;
  color: #d1fae5;
}
.oauth-error {
  background: #7f1d1d;
  color: #fecaca;
}
.oauth-toast-hide {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px);
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
}

.chat-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.chat-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--accent);
}

.turn-counter {
  font-size: 0.8rem;
  color: var(--muted);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.message {
  display: flex;
  gap: 0.625rem;
  max-width: 85%;
  line-height: 1.5;
  animation: fadeIn 0.3s ease-out;
}

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

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.avatar-sil {
  background: var(--accent);
  color: white;
}

.avatar-user {
  background: var(--border);
  color: var(--muted);
}

.bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.user .bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 2px;
  white-space: pre-wrap;
}

.message.assistant {
  align-self: flex-start;
}

.message.assistant .bubble {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
}

.message.assistant .bubble hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.5rem 0;
}

.message.assistant .bubble pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
  overflow-x: auto;
  font-size: 0.875rem;
}

.message.assistant .bubble code {
  font-family: "SF Mono", "Fira Code",
    "Fira Mono", Menlo, monospace;
  font-size: 0.875em;
}

.message.assistant .bubble code:not(pre code) {
  background: var(--bg);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
}

.message.typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  max-width: fit-content;
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
  padding: 0.5rem 0.75rem;
  align-items: center;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.message.error {
  background: var(--error-bg);
  color: var(--error);
  align-self: center;
  font-size: 0.875rem;
}

.message.system {
  color: var(--muted);
  align-self: center;
  font-size: 0.85em;
  font-style: italic;
  text-align: center;
  padding: 4px 0;
  max-width: 100%;
}

#chat-form {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

#chat-form input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
}

#chat-form input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.4);
}

#chat-form button {
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  font-weight: 600;
}

#chat-form button:hover {
  background: var(--accent-hover);
}

#chat-form button:disabled,
#chat-form input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Chat header right section */

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Conversation page layout */

.conv-page {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.conv-page .messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Input area (textarea, no send button) */

.input-area {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 0.5rem 1rem;
  background: var(--card-bg);
}

.input-area form {
  display: flex;
}

.input-area textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.625rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.4;
  max-height: 150px;
  overflow-y: auto;
}

.input-area textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.4);
}

/* Content block styles */

.sil-table {
  margin: 0.5rem 0;
  overflow-x: auto;
}

.sil-table table {
  width: 100%;
  border-collapse: collapse;
}

.sil-table th {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  text-align: left;
}

.sil-table th,
.sil-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.sil-tree details {
  margin-left: 1rem;
}

.sil-tree summary {
  cursor: pointer;
}

.sil-list {
  margin: 0.25rem 0;
  padding-left: 1.5rem;
}

.sil-dialog {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0.5rem 0;
}

.sil-dialog p {
  margin: 0.5rem 0;
}

.sil-dialog-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.sil-dialog-btn {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  cursor: pointer;
  font-weight: 500;
}

.sil-dialog-btn:hover {
  background: var(--accent-hover);
}

.sil-svg {
  margin: 0.5rem 0;
  overflow-x: auto;
}

.sil-map {
  margin: 0.5rem 0;
  overflow: hidden;
}

.sil-map iframe {
  display: block;
  width: 100%;
}

/* Ice-breakers */

.ice-breakers {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 1rem;
  max-width: 400px;
}

.ice-welcome {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.ice-breaker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--fg);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s;
  text-align: left;
}

.ice-breaker:hover {
  border-color: var(--accent);
}

.ice-icon {
  flex-shrink: 0;
  font-size: 1.1rem;
}
