@layer theme, base, components, utilities;

body {
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  background-color: #f0f2f5;
  scroll-behavior: smooth;
}
:root {
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --sage-50: #f5f7f5;
  --sage-100: #e6ebe7;
  --sage-200: #cfd8d2;
  --sage-300: #b7c5be;
  --sage-400: #9baea4;
  --sage-500: #7f9889;
  --sage-600: #667a6d;
  --sage-700: #4e5e52;
  --sage-800: #38463c;
  --sage-900: #212d24;

  --primary-50: #e6f7f0;
  --primary-100: #c0ead7;
  --primary-200: #99d4b9;
  --primary-300: #66bb97;
  --primary-400: #2fa976;
  --primary-500: #00824f;
  --primary-600: #006c41;
  --primary-700: #005735;
  --primary-800: #003f27;
  --primary-900: #002a1b;

  --body-primary: var(--gray-900);
  --box-primary: var(--gray-800);
  --h2-primary: rgb(11, 26, 19);
  --h2-primary-dark: rgb(11, 26, 19);
  --h2-accent-light: #f5f3f9;
  --div-primary-green: var(--sage-800);
  --div-primary-green-dark: var(--sage-900);
  --text-color-primary: #33a272;
  --bg-gradient-primary-500: linear-gradient(
      0deg,
      var(--primary-500),
      var(--primary-500)
    ),
    radial-gradient(
      68.91% 100% at 50% 0%,
      rgba(153, 212, 185, 0.4) 0%,
      rgba(0, 130, 79, 0.4) 100%
    );
  --bg-gradient-primary-600: linear-gradient(
      0deg,
      var(--primary-600),
      var(--primary-600)
    ),
    radial-gradient(
      68.91% 100% at 50% 0%,
      rgba(153, 212, 185, 0.45),
      rgba(0, 130, 79, 0.45)
    );
}

.bg-menu-header-primary {
  background: var(--gray-700);
}
.btn-bg-primary {
  background: var(--bg-gradient-primary-500);
}

.btn-bg-primary:hover {
  background: var(--bg-gradient-primary-600);
  cursor: pointer;
  transition: background 0.25s ease;
}

.btn-bg-primary.selected,
.btn-bg-primary:active {
  background: linear-gradient(0deg, var(--primary-800), var(--primary-800)),
    radial-gradient(
      68.91% 100% at 50% 0%,
      rgba(153, 212, 185, 0.5),
      rgba(0, 130, 79, 0.5)
    );
}
.btn-header-and-footer-primary {
  background: var(--gray-800);
  border: 1px solid var(--gray-700);
  color: white;
  border-radius: 8px;
  padding: 8px 12px;
}
.btn-header-and-footer-primary:hover {
  background: var(--gray-900);
}

.bg-primary {
  background: var(--gray-900);
}
.bg-sg-900 {
  background: var(--sage-900);
  border: none;
}
.bg-header-primary {
  border-bottom: 1px solid var(--gray-700);
  background: var(--gray-800);
}
.bg-div-primary {
  background-color: var(--div-primary-green);
  border: none;
}
.bg-h2-primary {
  background-color: var(--box-primary);
}
.text-color-primary {
  color: var(--text-color-primary);
}
.text-h2-primary {
  color: var(--h2-primary);
}

.hidden-select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.custom-select-wrapper {
  position: relative;
}

.custom-select-display {
  user-select: none;
}

.custom-select-options {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: var(--bg-gradient-primary-500);
  border-radius: 0.5rem;
  padding: 0.25rem 0;
  display: none;
  z-index: 50;
}

.custom-select-options div {
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: white;
}

.custom-select-options div:hover {
  background: var(--bg-gradient-primary-600);
}
.icon-color-primary {
  color: var(--text-color-primary);
}
.card {
  transition: all 0.3s ease-in-out;
}
.card:hover {
  transform: translateY(-5px);
}
.risk-result-card {
  transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-origin: top;
}
.risk-result-card.hidden {
  transform: scaleY(0);
  opacity: 0;
  height: 0;
}
.risk-result-card.visible {
  transform: scaleY(1);
  opacity: 1;
  height: auto;
}

/* Questionnaire Styles */
.questionnaire-step {
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}
.questionnaire-step.hidden {
  opacity: 0;
  transform: translateX(-20px);
  position: absolute;
  pointer-events: none;
}
#questionnaire-progress-bar {
  transition: width 0.4s ease-out;
}
.questionnaire-btn.selected {
  transform: scale(1.05);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.6);
}

/* Chatbot Styles */
#chatbot-container {
  height: 700px;
  display: flex;
  flex-direction: column;
  position: relative;
}
#chatbot-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1rem;
  padding-bottom: 0.5rem !important; /* ajustada dinamicamente via JS */
  gap: 0.5rem;
}
.bot-message,
.user-message {
  padding: 0.75rem 1rem;
  max-width: 80%;
  word-wrap: break-word;
}
.bot-message {
  background-color: var(--sage-800);
  color: white;
  border-radius: 1rem 1rem 1rem 0;
  align-self: flex-start;
  position: relative;
  padding-left: 2.25rem; /* espaço para avatar */
}
.bot-message::before {
  content: "SB";
  position: absolute;
  left: -0.75rem;
  top: -0.5rem;
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  background: var(--h2-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.user-message {
  background-color: var(--h2-primary-dark);
  color: white;
  border-radius: 1rem 1rem 0 1rem;
  align-self: flex-end;
}
#chatbot-options {
  padding: 1rem;
  border: 1px solid var(--div-primary-green);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 40%;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--box-primary);
  box-shadow: inset 0 6px 6px -6px rgba(0, 0, 0, 0.15);
}
@media (max-width: 640px) {
  #chatbot-options {
    max-height: 45%;
  }
}
.chatbot-option-btn {
  color: white;
  padding: 0.75rem;
  border-radius: 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.chatbot-option-btn:focus-visible {
  outline: 3px solid #94a3b8;
  outline-offset: 2px;
}
.chatbot-option-btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}
/* Chat chips and crumb */
#chat-crumb {
  font-size: 12px;
  color: white;
  margin-bottom: 0.25rem;
}
#chat-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.chat-chip {
  background: var(--div-primary-green);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  font-size: 12px;
  cursor: pointer;
}
.chat-chip:hover {
  background: var(--div-primary-green-dark);
}
/* Message timestamps */
.msg-time {
  display: block;
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
}
.user-message .msg-time {
  color: white;
}
.bot-message .msg-time {
  color: white;
}
/* Typing indicator */
.typing-indicator span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #9ca3af;
  animation: typing 1.4s infinite;
}
.typing-indicator span:nth-child(1) {
  animation-delay: 0.2s;
}
.typing-indicator span:nth-child(2) {
  animation-delay: 0.4s;
}
.typing-indicator span:nth-child(3) {
  animation-delay: 0.6s;
}
@keyframes typing {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

/* Sticky top nav */
.site-nav {
  backdrop-filter: saturate(180%) blur(6px);
}
.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  position: static;
  width: auto;
  height: auto;
  padding: 0.5rem 1rem;
  background: #fff;
  border-radius: 0.5rem;
}

/* Back to top */
#back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: none;
}
#back-to-top.show {
  display: inline-flex;
}

/* Dicas rápidas - transição suave no texto */
#tips-rotator {
  transition: opacity 0.25s ease-in-out;
}

/* Safe area para iOS no rodapé do chat */
#chatbot-options {
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}
/* Preferências do usuário: reduzir movimento */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  #tips-rotator {
    transition: none;
  }
}

/* Impressão: foco no conteúdo útil */
@media print {
  .site-nav,
  #back-to-top,
  #chat-quick-chips,
  #chatbot-options {
    display: none !important;
  }
  body {
    background: white;
  }
  .container {
    max-width: 100% !important;
    padding: 0 !important;
  }
  header,
  section,
  footer {
    box-shadow: none !important;
  }
}
