/* ── Reset & root ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:      #1B5E96;   /* azul Marconi */
  --primary-dark: #0F3E6A;
  --accent:       #C8681E;   /* laranja Marconi */
  --accent-light: #FDF0E6;
  --bubble-bot:   #F3F4F6;
  --bubble-user:  var(--primary);
  --text-main:    #1F2937;
  --text-muted:   #6B7280;
  --bg:           #F9FAFB;
  --border:       #E5E7EB;
  --danger:       #DC2626;
  --radius:       14px;
  --shadow:       0 4px 24px rgba(0,0,0,.12);
  --font:         'Segoe UI', system-ui, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  color: var(--text-main);
}

/* ── Accessibility ──────────────────────────────────────────  */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Wrapper ────────────────────────────────────────────────  */
.chat-wrapper {
  width: 100%;
  max-width: 480px;
  height: min(720px, 95dvh);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}

/* ── Header ─────────────────────────────────────────────────  */
.chat-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1.1rem;
  background: var(--primary);
  color: #fff;
}

.logo {
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  padding: 2px;
  flex-shrink: 0;
}

.header-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.agent-name {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.company-name {
  font-size: .75rem;
  opacity: .85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #4ADE80;
  box-shadow: 0 0 0 2px rgba(255,255,255,.4);
  flex-shrink: 0;
}

/* ── Skills bar ──────────────────────────────────────────────  */
.skills-bar {
  padding: .4rem 1rem;
  background: var(--accent-light);
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
  color: var(--accent);
  font-weight: 600;
}

/* ── Messages ────────────────────────────────────────────────  */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.message {
  display: flex;
  max-width: 82%;
}

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

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

.bubble {
  padding: .65rem .9rem;
  border-radius: var(--radius);
  font-size: .92rem;
  line-height: 1.55;
  word-break: break-word;
}

.message.assistant .bubble {
  background: var(--bubble-bot);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.message.user .bubble {
  background: var(--bubble-user);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── Typing indicator ────────────────────────────────────────  */
.typing-wrap { align-self: flex-start; }

.bubble.typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: .7rem 1rem;
  background: var(--bubble-bot);
  border-bottom-left-radius: 4px;
}

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce .9s infinite;
}
.dot:nth-child(2) { animation-delay: .15s; }
.dot:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40%           { transform: translateY(-6px); opacity: 1; }
}

/* ── Footer ─────────────────────────────────────────────────  */
.chat-footer {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  background: #fff;
}

.user-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .6rem .85rem;
  font-family: var(--font);
  font-size: .92rem;
  line-height: 1.45;
  max-height: 130px;
  overflow-y: auto;
  outline: none;
  color: var(--text-main);
  background: var(--bg);
  transition: border-color .2s;
  field-sizing: content;
}

.user-input:focus {
  border-color: var(--primary);
  background: #fff;
}

.user-input:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.send-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s, transform .1s;
}

.send-btn svg { width: 18px; height: 18px; }

.send-btn:hover:not(:disabled) { background: var(--primary-dark); }
.send-btn:active:not(:disabled) { transform: scale(.94); }
.send-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Responsive ──────────────────────────────────────────────  */
@media (max-width: 520px) {
  body { padding: 0; }
  .chat-wrapper {
    max-width: 100%;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }
}
