﻿:root {
  font-family: "source-sans-pro", sans-serif;
  font-size: 0.875rem;
  color-scheme: light;
  --bg: #0a1f2d ;
  --surface: #0a1f2d ;
  --line: #0a1f2d ;
  --text: #10212f;
  --muted: #4d6477;
  --brand: #0a6db4;
  --brand-dark: #07558d;
  --user: #e2effa;
  --bot: #f2f7fc;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
}

body {
  background: radial-gradient(circle at top, #f8fbff 0%, var(--bg) 60%);
  color: var(--text);
}

.chat-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(11, 32, 52, 0.12);
}

.chat-header {
  border-bottom: 1px solid var(--line);
  padding: 20px;
  flex-shrink: 0;
}

.chat-header h1 {
  margin: 0;
  font-size: 24px;
}

.chat-header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.messages {
  flex: 1 1 auto;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-row {
  max-width: min(78%, 720px);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Agente à esquerda */
.message-row.bot {
  align-self: flex-start;
  text-align: left;
}

/* Utilizador à direita */
.message-row.user {
  align-self: flex-end;
  text-align: right;
}

.message {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  line-height: 1.45;
  white-space: normal;
  background: var(--bot);
  text-align: left;
}

.message-row.user .message {
  background: var(--user);
  white-space: pre-wrap;
}

.message-meta {
  font-size: 12px;
  color: #6d8395;
  padding: 0 6px;
}

.message-row.bot .message-meta {
  text-align: left;
}

.message-row.user .message-meta {
  text-align: right;
}

.bot-rich p {
  margin: 0 0 10px;
}

.bot-rich p:last-child {
  margin-bottom: 0;
}

.bot-list {
  margin: 2px 0 10px 20px;
  padding: 0;
}

.bot-list:last-child {
  margin-bottom: 0;
}

.bot-list li {
  margin: 0 0 4px;
}

.inline-code {
  font-family: "Cascadia Code", "Consolas", "Courier New", monospace;
  font-size: 0.95em;
  background: #e8eef5;
  border: 1px solid #c9d7e4;
  border-radius: 6px;
  padding: 1px 6px;
}

.bot-code-block {
  margin: 8px 0 12px;
  border: 1px solid #c9d7e4;
  border-radius: 10px;
  overflow: hidden;
  background: #f8fbff;
}

.bot-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: "source-sans-pro", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #4d6477;
  padding: 8px 12px;
  background: #e8f0f8;
  border-bottom: 1px solid #c9d7e4;
}

.bot-code-lang {
  white-space: nowrap;
}

.copy-code-btn {
  border: 1px solid #9fb6ca;
  background: #ffffff;
  color: #23465f;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
}

.copy-code-btn:hover {
  background: #f2f7fc;
}

.copy-code-btn.is-copied {
  border-color: #67b68a;
  color: #1e6f45;
  background: #ebf8f0;
}

.bot-code-block pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  background: #10212f;
}

.bot-code-block code {
  font-family: "Cascadia Code", "Consolas", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #e7eef6;
  white-space: pre;
  display: block;
}

.message.thinking {
  padding: 10px 14px;
}

.thinking-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.thinking-icon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid #9ab1c3;
  border-top-color: #0a6db4;
  animation: spin 0.9s linear infinite;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 20px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #6f879a;
  animation: typingPulse 1s ease-in-out infinite;
}

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

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

@keyframes typingPulse {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.composer {
  border-top: 1px solid var(--line);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

textarea {
  flex: 1;
  width: 100%;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  resize: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 0.875rem;
  padding: 10px 12px;
  color: var(--text);
}

textarea:focus,
button:focus {
  outline: 2px solid #6fb7eb;
  outline-offset: 2px;
}

button {
  height: 44px;
  min-height: 44px;
  border: 1px solid var(--brand-dark);
  background: var(--brand);
  color: #fff;
  border-radius: 10px;
  padding: 0 18px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

button[disabled] {
  opacity: 0.7;
  cursor: not-allowed;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-thumb {
  background: #bfd0dd;
  border-radius: 999px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 760px) {
  .chat-shell {
    border-radius: 0;
  }

  .message-row {
    max-width: 100%;
  }

  .composer {
    padding: 12px;
  }

  textarea {
    height: 42px;
    min-height: 42px;
    max-height: 42px;
  }

  button {
    height: 42px;
    min-height: 42px;
  }
}