/* RESET */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Inter, sans-serif;
  transition: 0.2s ease;
}

body {
  display: flex;
  height: 100vh;
  background: #f9fafb;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */

.sidebar {
  width: 260px;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.sidebar.min {
  width: 72px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  width: 42px;
  cursor: pointer;
}

.collapse {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #1f2937;
}

/* MENU */

.menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 17px;
  color: #111;
}

.menu a:hover {
  background: #f3f4f6;
}

/* HISTÓRICO */

.history {
  margin-top: 10px;
  flex: 1;
  font-size: 13px;
  color: #6b7280;
}

/* PERFIL */

.bottom {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10a37f, #222dc5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: bold;
}

.info strong {
  font-size: 14px;
}
.info small {
  font-size: 12px;
  color: #6b7280;
}

/* LOGIN */

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid #10a37f;
  background: #fff;
  color: #10a37f;
  padding: 8px;
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
}

.login-btn:hover {
  background: #10a37f;
  color: #fff;
}

/* MIN */

.sidebar.min span,
.sidebar.min small,
.sidebar.min .info {
  display: none;
}

.sidebar.min .menu a {
  justify-content: center;
}

/* ===== CHAT ===== */

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
}

/* TOPO */

.chat-top {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.chat-actions {
  display: flex;
  gap: 10px;
}

/* BOTÕES TOPO */

.attach-top,
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: #10a37f;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* MENSAGENS */

.messages {
  flex: 1;
  padding: 30px 12%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.msg {
  background: #f3f4f6;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  max-width: 75%;
  animation: fade 0.3s;
}

.msg.user {
  align-self: flex-end;
  background: #10a37f;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.bot {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* INPUT */

.input-area {
  padding: 16px;
  display: flex;
  justify-content: center;
  background: #fff;
  border-top: 1px solid #e5e7eb;
}

.input-container {
  width: 100%;
  max-width: 850px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

/* PREVIEW */

.file-preview {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f3f4f6;
  padding: 10px 14px;
  border-radius: 12px;
}

.file-preview span {
  font-size: 13px;
  color: #111;
}

.file-preview button {
  border: none;
  background: none;
  cursor: pointer;
  color: #ef4444;
}

/* BOTÕES */

.attach-inside,
.mic,
.send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #f3f4f6;
  cursor: pointer;
}

.send {
  background: #10a37f;
  color: #fff;
}

.attach-inside {
  background-color: #10a37f;
  color: #fff;
}

/* INPUT */

.input-wrapper input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  padding: 6px;
}

/* SUPORTE PARA QUEBRA DE LINHA */
.input-wrapper textarea {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  padding: 6px;
  resize: none;
  background: transparent;
  font-family: inherit;
  line-height: 1.4;
  max-height: 140px;
  overflow-y: auto;
}


/* MENU ANEXO */

.attach-menu {
  position: absolute;
  bottom: 95px;
  right: 1100px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 12px;
  display: none;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* ITEM DO CHAT */
.chat-item {
  position: relative;       /* referência pro menu */
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
  overflow: visible;        /* 🔥 ESSENCIAL */
}


.chat-item:hover {
  /* background: bisque; */
  transform: translateX(3px);
}

/* TÍTULO */
.chat-title {
  display: block;
  max-width: 100%;
  color: #000000;
  font-size: 14px;
  font-weight: 500;

  white-space: nowrap;       /* impede quebrar linha */
  overflow: hidden;          /* esconde o excesso */
  text-overflow: ellipsis;   /* adiciona ... */
}

.chat-info {
  flex: 1;           /* ocupa o espaço disponível */
  min-width: 0;      /* 🔥 ESSENCIAL para o ellipsis funcionar em flex */
}

/* BOTÃO MENU MOBILE */
.menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: none;
  background: #f3f4f6;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}


/* MENU WRAPPER */
.chat-menu-wrapper {
  position: relative;
  flex-shrink: 0;
}

/* BOTÃO ⋮ */
.chat-menu-btn {
  background: none;
  border: none;
  color: #000000;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s ease, color 0.2s ease;
}

.chat-menu-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}


/* DROPDOWN */
.chat-dropdown {
  position: absolute;
  left: 28px;
  top: calc(100% + 6px);
  background: #2b2b2b;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.45);
  display: none;
  flex-direction: column;
  min-width: 140px;
  padding: 6px 0;
  z-index: 9999; /* acima de tudo */
  animation: fadeIn 0.15s ease-out;
}



.chat-menu-wrapper.open .chat-dropdown {
  display: flex;
}


.chat-dropdown button {
  background: none;
  border: none;
  color: #ffffff;
  padding: 8px 14px;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s ease;
}

.chat-dropdown button:hover {
  background: rgba(255,255,255,0.08);
}


@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}



/* RESPONSIVO */

@media (max-width: 900px) {
  .messages {
    padding: 20px 6%;
  }
}

@media (max-width: 600px) {
  .sidebar {
    position: absolute;
    z-index: 50;
  }
  .messages {
    padding: 20px;
  }
}

/* DARK MODE */

body.dark {
  background: #0b0f1a;
  color: #e5e7eb;
}

body.dark .sidebar,
body.dark .chat,
body.dark .chat-top,
body.dark .input-area {
  background: #020617;
  border-color: #1f2937;
}

body.dark .menu a {
  color: #cbd5f5;
}

body.dark .menu a:hover {
  background: #0f172a;
}

body.dark .collapse {
  color: #fff;
}

body.dark .msg.bot {
  background: #0f172a;
}

body.dark .file-preview {
  background: #0f172a;
  border: 1px solid #1f2937;
}

body.dark .input-wrapper {
  background: #020617;
  border: 1px solid #1f2937;
}

body.dark .input-wrapper input {
  color: #fff;
}

body.dark .input-wrapper input::placeholder {
  color: #64748b;
}

body.dark .input-wrapper textarea {
  color: #fff;
}

body.dark .input-wrapper textarea::placeholder {
  color: #64748b;
}


body.dark .file-preview span {
  color: #fff;
}

body.dark .mic {
  background: #0f172a;
  color: #cbd5f5;
}

body.dark .send {
  background: #10a37f;
}

body.dark .attach-menu {
  background: #020617;
  border-color: #1f2937;
}

body.dark .login-btn {
  background: #0f172a;
}

body.dark .chat-item {
  background-color: #0d133a18;
}

body.dark .chat-title{
  color: #fff;
}

body.dark .chat-menu-btn{
  color: #fff;
}

body.dark .menu-toggle {
  background: #0f172a;
  color: #fff;
}

/* ANIMA */

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
  }
}

/* Histórico de Chats*/
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px;
  border-bottom: 1px solid #eee;
}
.history-item:last-child {
  border-bottom: none;
}
.history-item button {
  margin-left: 5px;
  padding: 2px 6px;
  font-size: 12px;
}

.mic.active {
  background-color: #28a745; /* cor quando selecionado */
}

body.dark .mic.active {
  background-color: #28a745; /* cor quando selecionado */
}


/* =========================
   RESPONSIVIDADE SEM QUEBRAR DESKTOP
========================= */

/* NOTEBOOKS MENORES */
@media (max-width: 1200px) {
  .messages {
    padding: 24px 6%;
  }

  .msg {
    max-width: 85%;
  }

  .input-container {
    max-width: 95%;
  }
}

/* ================= TABLETS ================= */
@media (max-width: 900px) {

  body {
    overflow-x: hidden;
  }

  /* SIDEBAR VIRA MENU OVERLAY */
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    height: 100%;
    z-index: 200;
    transition: left 0.3s ease;
    box-shadow: 4px 0 25px rgba(0,0,0,0.15);
  }

  .sidebar.open {
    left: 0;
  }

  /* CHAT OCUPA TUDO */
  .chat {
    width: 100%;
  }

  .messages {
    padding: 20px 5%;
  }

  .msg {
    max-width: 90%;
  }

  /* INPUT MAIS COMPACTO */
  .input-area {
    padding: 14px;
  }

  .input-wrapper {
    padding: 10px 12px;
  }

  /* MENU ANEXO POSIÇÃO CERTA */
  .attach-menu {
    right: 20px !important;
    left: auto !important;
    bottom: 90px;
  }
}

/* ================= CELULARES ================= */
@media (max-width: 600px) {

  body {
    height: 100dvh;
  }

  /* TOPO */
  .chat-top {
    padding: 12px;
  }

  .chat-top h3 {
    font-size: 16px;
  }

  /* MENSAGENS */
  .messages {
    padding: 16px 12px;
    gap: 12px;
  }

  .msg {
    max-width: 95%;
    font-size: 13px;
    padding: 12px 14px;
  }

  /* INPUT */
  .input-area {
    padding: 10px;
  }

  .input-container {
    gap: 6px;
  }

  .input-wrapper {
    padding: 8px 10px;
    gap: 6px;
    border-radius: 14px;
  }

  .input-wrapper input {
    font-size: 13px;
  }

  /* BOTÕES */
  .attach-inside,
  .mic,
  .send {
    width: 34px;
    height: 34px;
  }

  /* PREVIEW */
  .file-preview {
    flex-direction: column;
    align-items: flex-start;
    font-size: 12px;
  }

  /* SIDEBAR MAIS ESTREITA */
  .sidebar {
    width: 240px;
  }

  /* MENU ANEXO */
  .attach-menu {
    bottom: 80px;
    right: 12px !important;
  }
}

/* TELAS MUITO PEQUENAS */
@media (max-width: 400px) {
  .msg {
    font-size: 12px;
  }

  .chat-top h3 {
    font-size: 14px;
  }

  .input-wrapper input {
    font-size: 12px;
  }
}


/* ================= SIDEBAR MOBILE ================= */
@media (max-width: 900px) {

  .menu-toggle {
    display: flex;
  }

  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    height: 100%;
    z-index: 300;
    transition: left 0.3s ease;
    box-shadow: 4px 0 25px rgba(0,0,0,0.2);
  }

  .sidebar.open {
    left: 0;
  }

  /* ESCURECE FUNDO QUANDO MENU ABERTO */
  .overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
    z-index: 200;
    display: none;
  }

  .overlay.show {
    display: block;
  }
}
