:root {
  --bg-light-start: #ECECED;
  --bg-light-end: #FFFFFF;
  --bg-dark-start: #6A6A6A;
  --bg-dark-end: #1A1A1A;

  --cyan: #1BA1D8;
  --magenta: #C80289;
  --yellow: #FDEF2D;

  --text-dark: #1A1A1A;
  --text-light: #FFFFFF;
  --text-muted: #6A6A6A;

  --font-base: 'Noto Sans', Arial, 'Open Sans', Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-base);
  color: var(--text-dark);
  background: linear-gradient(120deg, var(--bg-light-start), var(--bg-light-end));
  min-height: 100vh;
}

.brand-underline {
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--yellow));
  border: none;
}

/* ---------- Login ---------- */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--bg-light-end);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(26, 26, 26, 0.12);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-card img.logo {
  max-width: 220px;
  margin-bottom: 8px;
}

.login-card h1 {
  font-size: 20px;
  font-weight: 900;
  margin: 16px 0 4px;
}

.login-card p.subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 24px;
}

.field {
  text-align: left;
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #d6d6d7;
  font-family: var(--font-base);
  font-size: 15px;
}

.field input:focus {
  outline: 2px solid var(--magenta);
  outline-offset: 1px;
}

.btn-primary {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: var(--magenta);
  color: var(--text-light);
  font-family: var(--font-base);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.error-message {
  color: var(--magenta);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

/* ---------- Chat ---------- */

.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.chat-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-light-end);
  border-right: 1px solid #e3e3e4;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.btn-new-conversation {
  border: 1px solid var(--magenta);
  background: transparent;
  color: var(--magenta);
  font-family: var(--font-base);
  font-weight: 700;
  font-size: 13.5px;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}

.btn-new-conversation:hover {
  background: var(--magenta);
  color: var(--text-light);
}

.conversation-search {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid #d6d6d7;
  font-family: var(--font-base);
  font-size: 13px;
}

.conversation-search:focus {
  outline: 2px solid var(--magenta);
  outline-offset: 1px;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.conversation-item:hover {
  background: #f3f3f3;
}

.conversation-item.active {
  background: #fbe8f3;
  border-left-color: var(--magenta);
}

.conversation-item .conv-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item .conv-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.conversation-empty {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 10px 12px;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-light-end);
  box-shadow: 0 1px 0 rgba(26, 26, 26, 0.06);
}

.chat-header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header .brand img {
  height: 32px;
}

.chat-header .brand img.lisa-avatar {
  height: 40px;
  width: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--magenta);
}

.lisa-avatar-login {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--magenta);
  margin-top: 14px;
}

.chat-header .brand .title {
  font-weight: 900;
  font-size: 16px;
}

.chat-header .brand .subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.chat-header .user-info {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.chat-header button.logout {
  background: none;
  border: 1px solid #d6d6d7;
  border-radius: 8px;
  padding: 6px 12px;
  font-family: var(--font-base);
  font-size: 13px;
  cursor: pointer;
  color: var(--text-dark);
}

.chat-header button.logout:hover {
  background: #f3f3f3;
}

.chat-header a.header-link {
  color: var(--magenta);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.chat-header a.header-link:hover {
  text-decoration: underline;
}

/* ---------- Base de conhecimento (revisao de KB-SUGESTAO) ---------- */

.kb-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.kb-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.kb-toolbar select {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid #d6d6d7;
  font-family: var(--font-base);
  font-size: 13.5px;
}

.kb-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.kb-card {
  background: var(--bg-light-end);
  border: 1px solid #e3e3e4;
  border-left: 3px solid var(--cyan);
  border-radius: 12px;
  padding: 16px 18px;
}

.kb-title {
  font-weight: 900;
  font-size: 15px;
  margin-bottom: 2px;
}

.kb-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.kb-field {
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 4px;
}

.kb-field-label {
  font-weight: 700;
  margin-right: 6px;
}

.kb-field-label::after {
  content: ':';
}

.kb-raw {
  font-size: 12.5px;
  white-space: pre-wrap;
  background: #f6f6f6;
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
}

.kb-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.kb-actions button {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-family: var(--font-base);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.kb-actions button:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-approve {
  background: var(--cyan);
  color: var(--text-light);
}

.btn-reject {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid #d6d6d7 !important;
}

main.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.msg {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 14.5px;
  white-space: pre-wrap;
}

.msg.user {
  align-self: flex-end;
  background: var(--magenta);
  color: var(--text-light);
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  background: var(--bg-light-end);
  border: 1px solid #e3e3e4;
  border-bottom-left-radius: 4px;
  max-width: 100%;
}

.msg-wrap {
  align-self: flex-start;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 78%;
}

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg.assistant .avatar-tag {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--magenta);
  margin-bottom: 4px;
}

/* Conteudo markdown renderizado nas respostas da Lisa */
.msg.assistant .md {
  white-space: normal;
}

.msg .md ul,
.msg .md ol {
  margin: 6px 0;
  padding-left: 22px;
}

.msg .md li {
  margin: 3px 0;
}

.msg .md pre {
  background: #f6f6f6;
  border: 1px solid #e3e3e4;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0;
  overflow-x: auto;
  white-space: pre-wrap;
  font-size: 12.5px;
}

.msg .md code {
  background: #f0f0f1;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.92em;
}

.msg .md pre code {
  background: none;
  padding: 0;
}

.msg .md .md-h {
  font-weight: 700;
  margin: 10px 0 4px;
}

.msg .md .md-gap {
  height: 9px;
}

.msg .md hr {
  border: none;
  border-top: 1px solid #e3e3e4;
  margin: 10px 0;
}

.msg.system-note {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
}

.typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.2s infinite ease-in-out;
}

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

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

footer.chat-input {
  display: flex;
  gap: 10px;
  padding: 16px 24px 24px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

footer.chat-input textarea {
  flex: 1;
  resize: none;
  border-radius: 12px;
  border: 1px solid #d6d6d7;
  padding: 12px 14px;
  font-family: var(--font-base);
  font-size: 14.5px;
  min-height: 48px;
  max-height: 160px;
}

footer.chat-input textarea:focus {
  outline: 2px solid var(--magenta);
  outline-offset: 1px;
}

footer.chat-input button {
  border: none;
  border-radius: 12px;
  background: var(--magenta);
  color: var(--text-light);
  font-family: var(--font-base);
  font-weight: 700;
  padding: 0 22px;
  cursor: pointer;
}

footer.chat-input button:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---------- Dentro do painel do Line Manager (iframe estreito) ---------- */

body.embutido header.chat-header {
  padding: 8px 12px;
}

body.embutido .chat-header .brand .subtitle,
body.embutido #user-name {
  display: none;
}

body.embutido .chat-header .user-info {
  gap: 8px;
}

body.embutido .chat-layout {
  position: relative;
}

/* A lista de conversas vira uma gaveta sobre o chat, aberta pelo botao "Conversas". */
body.embutido .sidebar {
  position: absolute;
  inset: 0 auto 0 0;
  width: min(280px, 85%);
  z-index: 5;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  transform: translateX(-105%);
  transition: transform 0.2s ease;
}

body.embutido.conversas-abertas .sidebar {
  transform: none;
}
