/* ========================================
   NTT DATA — Chat Institucional
   Baseado em br.nttdata.com
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght@300;400;500;600;700&display=swap');

:root {
  /* NTT DATA Brand — baseado em br.nttdata.com */
  --ntt-dark: #141414;
  --ntt-dark-elevated: #1C1C1C;
  --ntt-blue: #0072BC;
  --ntt-blue-hover: #005A96;
  --ntt-blue-light: #0091E6;
  --ntt-blue-subtle: #E8F4FD;
  --ntt-green: #00A651;

  /* Surface */
  --bg-page: #F5F5F5;
  --bg-chat: #FFFFFF;
  --bg-input: #F5F5F5;
  --bg-bot-bubble: #F0F2F5;
  --bg-user-bubble: var(--ntt-blue);

  /* Text */
  --text-primary: #1A1A1A;
  --text-secondary: #5C5C5C;
  --text-muted: #8C8C8C;
  --text-on-dark: #FFFFFF;
  --text-on-blue: #FFFFFF;

  /* Borders */
  --border-light: #E5E5E5;
  --border-medium: #D0D0D0;

  /* Shadows */
  --shadow-container: 0 2px 24px rgba(0, 0, 0, 0.08), 0 8px 48px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 100px;

  /* Transition */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg-page);
  font-family: 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  line-height: 1.6;
}

/* ===== CHAT CONTAINER ===== */
.chat-container {
  width: 100%;
  max-width: 880px;
  height: 94vh;
  background: var(--bg-chat);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-container);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ===== HEADER — Dark navbar como br.nttdata.com ===== */
.chat-header {
  padding: 0 28px;
  height: 64px;
  background: var(--ntt-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-logo {
  height: 22px;
  width: auto;
  flex-shrink: 0;
  filter: brightness(1);
}

.header-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.header-info h1 {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-on-dark);
  letter-spacing: 0.01em;
  line-height: 1;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 400;
  margin-top: 3px;
}

.status-dot {
  width: 6px;
  height: 6px;
  background: var(--ntt-green);
  border-radius: 50%;
  animation: statusPulse 2.5s ease-in-out infinite;
}

@keyframes statusPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

#reindex {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Noto Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 7px 16px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.25s var(--ease);
  white-space: nowrap;
}

#reindex:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
  color: var(--text-on-dark);
}

#reindex:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#reindex svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ===== CHAT LOG ===== */
#log {
  flex-grow: 1;
  padding: 28px 28px 12px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
  background: var(--bg-chat);
}

#log::-webkit-scrollbar {
  width: 5px;
}

#log::-webkit-scrollbar-track {
  background: transparent;
}

#log::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

#log::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== MESSAGES ===== */
.msg {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  animation: msgIn 0.3s var(--ease);
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 82%;
}

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

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

/* Avatars */
.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.msg-avatar.user-avatar {
  background: var(--ntt-dark);
  color: var(--text-on-dark);
}

.msg-avatar.bot-avatar {
  background: var(--ntt-blue);
  color: var(--text-on-blue);
}

.msg-avatar svg {
  width: 15px;
  height: 15px;
}

/* Bubbles */
.bubble {
  padding: 12px 16px;
  line-height: 1.6;
  font-size: 0.9rem;
  word-break: break-word;
}

.bubble-user {
  background: var(--ntt-blue);
  color: var(--text-on-blue);
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
}

.bubble-bot {
  background: var(--bg-bot-bubble);
  color: var(--text-primary);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
}

.bubble pre {
  white-space: pre-wrap;
  font-family: 'Noto Sans', sans-serif;
  margin: 0;
  font-size: inherit;
  color: inherit;
  line-height: inherit;
}

/* ===== META & DETAILS (fontes consultadas, segurança) ===== */
.msg-meta {
  margin-top: 6px;
  padding-left: 42px;
}

.msg-meta details {
  margin-top: 4px;
}

.msg-meta details summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--ntt-blue);
  font-size: 0.78rem;
  transition: color 0.2s var(--ease);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.msg-meta details summary::-webkit-details-marker {
  display: none;
}

.msg-meta details summary::before {
  content: '›';
  display: inline-block;
  font-size: 1rem;
  font-weight: 700;
  transition: transform 0.2s var(--ease);
  color: var(--ntt-blue);
}

.msg-meta details[open] summary::before {
  transform: rotate(90deg);
}

.msg-meta details summary:hover {
  color: var(--ntt-blue-hover);
}


.raw-answer-pre {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 6px;
  margin-left: 2px;
  white-space: pre-wrap;
  font-family: 'Noto Sans', sans-serif;
  padding: 8px 10px;
  background: var(--bg-input);
  border-radius: 6px;
}

/* ===== TYPING INDICATOR ===== */
#typing-indicator {
  display: none;
  padding: 0 28px 12px;
}

.typing-bubble {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.typing-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ntt-blue);
  color: var(--text-on-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.typing-avatar svg {
  width: 15px;
  height: 15px;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  background: var(--bg-bot-bubble);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
}

.typing-dots .dot {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: dotBounce 1.4s ease-in-out infinite;
}

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

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

@keyframes dotBounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  30% {
    transform: translateY(-4px);
    opacity: 1;
    background: var(--ntt-blue);
  }
}

/* ===== INPUT FORM ===== */
.form-container {
  padding: 16px 28px 20px;
  background: var(--bg-chat);
  border-top: 1px solid var(--border-light);
}

#form {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-pill);
  padding: 4px 4px 4px 22px;
  transition: all 0.25s var(--ease);
}

#form:focus-within {
  border-color: var(--ntt-blue);
  box-shadow: 0 0 0 3px rgba(0, 114, 188, 0.08);
  background: var(--bg-chat);
}

#q {
  flex-grow: 1;
  border: none;
  background: transparent;
  padding: 12px 0;
  font-size: 0.9rem;
  font-family: 'Noto Sans', sans-serif;
  color: var(--text-primary);
  outline: none;
}

#q::placeholder {
  color: var(--text-muted);
}

.send-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--ntt-blue);
  color: var(--text-on-blue);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.send-btn:hover {
  background: var(--ntt-blue-hover);
  transform: scale(1.05);
}

.send-btn:active {
  transform: scale(0.95);
}

.send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

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

/* Footer */
.footer-meta {
  margin-top: 10px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.footer-meta strong {
  color: var(--text-secondary);
  font-weight: 600;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  body {
    padding: 0;
  }

  .chat-container {
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }

  .chat-header {
    padding: 0 16px;
    height: 56px;
  }

  .header-logo {
    height: 18px;
  }

  .header-info h1 {
    font-size: 0.8rem;
  }

  #reindex span {
    display: none;
  }

  #reindex {
    padding: 7px 10px;
  }

  #log {
    padding: 20px 16px 8px;
  }

  .form-container {
    padding: 12px 16px 16px;
  }

  .msg-row {
    max-width: 90%;
  }

  .msg-meta {
    padding-left: 42px;
  }
}

@media (max-width: 380px) {

  .header-divider,
  .header-info {
    display: none;
  }
}

/* ===== TERMS OF USE MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s var(--ease);
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: var(--bg-chat);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-container);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(0);
  transition: transform 0.3s var(--ease);
}

.modal-overlay.hidden .modal-content {
  transform: translateY(20px);
}

.modal-header {
  background: var(--ntt-dark);
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.modal-header img {
  height: 24px;
  width: auto;
  align-self: flex-start;
}

.modal-header h2 {
  color: var(--text-on-dark);
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
}

.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex-grow: 1;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

.modal-body h3 {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  margin: 20px 0 10px;
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body p {
  margin-bottom: 12px;
}

.modal-body ul {
  margin-bottom: 12px;
  padding-left: 20px;
}

.modal-body li {
  margin-bottom: 6px;
}

.modal-footer {
  padding: 20px 28px;
  background: var(--bg-input);
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
}

.checkbox-container {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 500;
  user-select: none;
}

.checkbox-container input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--ntt-blue);
}

.ntt-btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-pill);
  font-family: 'Noto Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  width: 100%;
}

.ntt-btn.primary {
  background: var(--ntt-blue);
  color: var(--text-on-blue);
}

.ntt-btn.primary:hover:not(:disabled) {
  background: var(--ntt-blue-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 114, 188, 0.3);
}

.ntt-btn.primary:disabled {
  background: var(--border-medium);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}