/* ==================== ASKLOBITO MOBILE-FIRST ==================== */

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

input,
textarea,
select,
button {
  max-width: 100%;
}

/* ── Focus visível acessível ── */
.nav-item:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(33, 89, 42, 0.55);
  outline-offset: 2px;
}

/* ── Select options legíveis ── */
select option,
select optgroup {
  color: #0a0a0a;
  background-color: #ffffff;
}

/* ── Nav item ativo ── */
.nav-item {
  position: relative;
  min-width: 0;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.nav-item[aria-current="page"] {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
}

.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  border-radius: 999px;
  background: #F5C518;
  opacity: 0.9;
}

/* ── Spinner ── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0,0,0,0.12);
  border-top: 2px solid #21592A;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ================================================================
   MOBILE  ≤ 640px  —  chat input fixo no rodapé
   ================================================================ */
@media (max-width: 640px) {
  body {
    overflow: auto !important;
  }

  /* Dá espaço para o input fixo não cobrir mensagens */
  #chat-messages {
    padding-bottom: 120px !important;
  }

  /* Input fixo no rodapé — compacto */
  .chat-input-mobile {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 9999 !important;
    background: #ffffff !important;
    border-top: 1px solid rgba(0,0,0,0.08) !important;
    border-radius: 0 !important;
    padding: 8px 12px !important;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.06) !important;
  }

  /* Linha interna: textarea + botão lado a lado */
  .chat-input-mobile > div {
    padding: 0 !important;
    gap: 8px !important;
    align-items: flex-end !important;
  }

  /* Textarea compacto */
  #chat-input {
    font-size: 16px !important; /* evita zoom no iOS */
    min-height: 40px !important;
    padding: 10px 12px !important;
  }

  /* Botão de envio: quadrado compacto, NÃO full-width */
  #send-button {
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    border-radius: 12px !important;
  }

  /* Esconde hint de teclado no mobile */
  .chat-input-mobile .hidden.sm\:block {
    display: none !important;
  }

  /* Esconde badges do header no mobile (já tem topbar) */
  #page-chat header .max-w-5xl > div:last-child > div:nth-child(1),
  #page-chat header .max-w-5xl > div:last-child > div:nth-child(2),
  #page-chat header label {
    display: none !important;
  }

  /* Página chat sem overflow oculto no mobile */
  #page-chat > div {
    height: auto !important;
    overflow: visible !important;
  }
}

/* ================================================================
   MOBILE PEQUENO  ≤ 480px
   ================================================================ */
@media (max-width: 480px) {
  html, body {
    overflow-x: hidden;
  }

  /* Botão adjuntar: só ícone */
  #upload-button span {
    display: none;
  }

  #upload-button {
    width: 36px !important;
    padding: 0 !important;
    justify-content: center !important;
  }

  #upload-button svg {
    margin: 0 !important;
    display: block !important;
  }
}

/* ================================================================
   TABLET  768px – 1023px
   ================================================================ */
@media (min-width: 768px) and (max-width: 1023px) {
  #sidebar {
    width: 14rem;
  }

  #page-history .grid {
    grid-template-columns: 14rem 1fr;
  }

  #page-chat .max-w-5xl,
  #page-docs .max-w-5xl,
  #page-admin .max-w-6xl,
  #page-account .max-w-xl,
  #page-login .max-w-md,
  #page-register .max-w-md {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* ================================================================
   DESKTOP MÉDIO  1024px – 1439px
   ================================================================ */
@media (min-width: 1024px) and (max-width: 1439px) {
  #sidebar {
    width: 16rem;
  }

  #page-history .grid {
    grid-template-columns: 16rem 1fr;
  }
}

/* ================================================================
   DESKTOP GRANDE  1440px – 1919px
   ================================================================ */
@media (min-width: 1440px) and (max-width: 1919px) {
  #page-history .grid {
    grid-template-columns: 18rem 1fr;
  }
}

/* ================================================================
   WIDESCREEN  ≥ 1920px
   ================================================================ */
@media (min-width: 1920px) {
  #page-chat header .max-w-5xl,
  #page-chat .max-w-5xl {
    max-width: 80rem;
  }

  #page-history .max-w-6xl {
    max-width: 88rem;
  }

  #page-admin .max-w-6xl {
    max-width: 80rem;
  }
}
