/* Paleta Rosa Master — rosamaster.com.br (Wix site colors) */
:root {
  --rm-white: #ffffff;
  --rm-bg: #f5f5f5;
  --rm-surface: #ffffff;
  --rm-border: #e0e0e0;
  --rm-text: #323232;
  --rm-muted: #979797;
  --rm-text-soft: #656565;
  --rm-pink: #e4006a;
  --rm-pink-hover: #980047;
  --rm-pink-light: #f6a4ca;
  --rm-pink-soft: #fde8f1;
  --rm-brown: #8d634f;
  --rm-gold: #f6a500;

  --bg: var(--rm-bg);
  --surface: var(--rm-surface);
  --surface2: var(--rm-bg);
  --border: var(--rm-border);
  --text: var(--rm-text);
  --muted: var(--rm-muted);
  --accent: var(--rm-pink);
  --accent-hover: var(--rm-pink-hover);
  --accent-soft: var(--rm-pink-soft);
  --user-bg: var(--rm-pink);
  --user-text: var(--rm-white);
  --bot-bg: var(--rm-white);
  --input-bg: var(--rm-white);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: "Poppins", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 900px;
  margin: 0 auto;
  background: var(--surface);
  box-shadow: 0 0 24px rgba(50, 50, 50, 0.06);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 3px solid var(--accent);
  flex-shrink: 0;
}

header .brand-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

header .logo {
  height: 40px;
  width: auto;
  flex-shrink: 0;
}

header .brand {
  font-weight: 600;
  color: var(--accent);
  font-size: 1.05rem;
  line-height: 1.2;
}

header .sub {
  font-size: 0.72rem;
  color: var(--rm-text-soft);
  font-weight: 400;
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

select, button {
  font: inherit;
  font-size: 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  padding: 0.45rem 0.75rem;
}

label {
  font-size: 0.85rem;
  color: var(--rm-text-soft);
}

button {
  cursor: pointer;
  background: var(--surface2);
}

button:hover:not(:disabled) {
  border-color: var(--rm-pink-light);
  background: var(--accent-soft);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--rm-white);
  font-weight: 500;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0 1rem 0.5rem;
  min-height: 1.25rem;
  background: var(--bg);
}

.status.error { color: #e74c53; }
.status.busy { color: var(--rm-gold); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 92%;
}

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

.msg-row.assistant {
  align-self: flex-start;
}

.msg-row.assistant + .msg-row.assistant {
  margin-top: 0.4rem;
}

.msg-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-avatar-bot {
  background: var(--accent-soft);
  border: 2px solid var(--rm-pink-light);
  padding: 5px;
}

.msg-avatar-bot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.msg-avatar-user {
  background: var(--rm-brown);
  color: var(--rm-white);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 2px solid var(--rm-white);
  box-shadow: 0 1px 4px rgba(50, 50, 50, 0.12);
}

.msg {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.85rem;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.md-rendered {
  white-space: normal;
}

.msg .md-body > :first-child {
  margin-top: 0;
}

.msg .md-body > :last-child {
  margin-bottom: 0;
}

.msg .md-body p {
  margin: 0.5em 0;
}

.msg .md-body ul,
.msg .md-body ol {
  margin: 0.45em 0;
  padding-left: 1.35em;
}

.msg .md-body li {
  margin: 0.2em 0;
}

.msg .md-body li > p {
  margin: 0.15em 0;
}

.msg .md-body strong {
  font-weight: 600;
}

.msg .md-body h1,
.msg .md-body h2,
.msg .md-body h3 {
  margin: 0.65em 0 0.35em;
  font-size: 1em;
  font-weight: 600;
  line-height: 1.3;
}

.msg .md-body h1 { font-size: 1.05em; }
.msg .md-body h2 { font-size: 1em; }

.msg .md-body code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.88em;
  background: var(--accent-soft);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.msg.user .md-body code {
  background: rgba(255, 255, 255, 0.2);
}

.msg .md-body pre {
  margin: 0.5em 0;
  padding: 0.55em 0.7em;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.85em;
  line-height: 1.45;
}

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

.msg .md-body blockquote {
  margin: 0.5em 0;
  padding-left: 0.75em;
  border-left: 3px solid var(--rm-pink-light);
  color: var(--rm-text-soft);
}

.msg .md-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg.user .md-body a {
  color: var(--rm-white);
}

.msg .md-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.65em 0;
}

.msg .md-body table {
  border-collapse: collapse;
  font-size: 0.9em;
  margin: 0.5em 0;
  max-width: 100%;
}

.msg .md-body th,
.msg .md-body td {
  border: 1px solid var(--border);
  padding: 0.35em 0.5em;
  text-align: left;
}

.msg.user {
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(228, 0, 106, 0.18);
}

.msg.assistant {
  background: var(--bot-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(50, 50, 50, 0.04);
}

.msg.assistant.bubble-in {
  animation: bubbleIn 0.22s ease-out;
}

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

.msg.assistant.streaming::after {
  content: "▋";
  animation: blink 0.8s step-end infinite;
  margin-left: 2px;
  color: var(--accent);
}

@keyframes blink {
  50% { opacity: 0; }
}

.welcome {
  text-align: center;
  color: var(--rm-text-soft);
  margin: auto;
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

.welcome strong {
  color: var(--accent);
  font-weight: 600;
}

.composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.composer textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 140px;
  padding: 0.65rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
}

.composer textarea:focus {
  outline: 2px solid var(--rm-pink-light);
  outline-offset: 1px;
  border-color: var(--accent);
}

.composer textarea::placeholder {
  color: var(--muted);
}

.login-screen {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
}

.login-screen[hidden],
.app[hidden] {
  display: none !important;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 16px;
  padding: 1.75rem 1.5rem;
  box-shadow: 0 8px 32px rgba(50, 50, 50, 0.08);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.login-card .logo {
  height: 44px;
  width: auto;
  align-self: center;
}

.login-card h1 {
  margin: 0;
  font-size: 1.15rem;
  text-align: center;
  color: var(--accent);
  font-weight: 600;
}

.login-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--rm-text-soft);
  text-align: center;
  line-height: 1.4;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--rm-text-soft);
}

.login-card input {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
}

.login-card input:focus {
  outline: 2px solid var(--rm-pink-light);
  border-color: var(--accent);
}

.login-error {
  margin: 0;
  font-size: 0.82rem;
  color: #e74c53;
  text-align: center;
}

.glpi-badge {
  font-size: 0.72rem;
  text-align: center;
  padding: 0.35rem 1rem;
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-bottom: 1px solid var(--rm-pink-light);
}

.glpi-badge[hidden] {
  display: none !important;
}

@media (max-width: 600px) {
  header {
    flex-direction: column;
    align-items: stretch;
  }
  .controls {
    justify-content: space-between;
  }
  header .logo {
    height: 30px;
  }
  .msg-row { max-width: 95%; }
  .msg { font-size: 0.9rem; }
  .msg-avatar {
    width: 32px;
    height: 32px;
  }
}
