/* Reset simples */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050509;
  color: #f5f5f5;
}

/* Utilidades */
.hidden {
  display: none !important;
}

/* ----------------- LOGIN ----------------- */

#login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #1a1b29, #050509 60%);
}

.login-card {
  background: rgba(15, 16, 26, 0.96);
  padding: 2.5rem 2.75rem;
  border-radius: 1.25rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.login-card h1 {
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  font-size: 0.9rem;
  color: #9da3c0;
  margin-bottom: 1.5rem;
}

.login-card label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.login-card input {
  margin-top: 0.25rem;
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: 0.55rem;
  border: 1px solid #26283b;
  background: #0f101a;
  color: #f5f5f5;
}

.login-card input:focus {
  outline: 1px solid #3f82ff;
  border-color: #3f82ff;
}

#login-btn {
  margin-top: 0.75rem;
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: 0.7rem;
  border: none;
  background: linear-gradient(135deg, #ff4757, #ff9f43);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

#login-btn:hover {
  filter: brightness(1.05);
}

.login-error {
  margin-top: 0.75rem;
  color: #ff6b81;
  font-size: 0.85rem;
}

/* ----------------- TOPO ----------------- */

.topbar {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: rgba(9, 10, 20, 0.98);
  border-bottom: 1px solid #18192a;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.topbar-divider {
  width: 1px;
  height: 20px;
  background: #26283b;
}

.topbar-user {
  font-size: 0.9rem;
  color: #9da3c0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Botões */

.primary-btn,
.secondary-btn,
.danger-btn {
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.primary-btn {
  background: linear-gradient(135deg, #ff4757, #ff9f43);
  color: #fff;
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-btn {
  background: #151625;
  color: #e5e7ff;
  border: 1px solid #2b2c45;
}

.danger-btn {
  background: #ff4757;
  color: #fff;
}

/* ----------------- LAYOUT PRINCIPAL ----------------- */

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  height: calc(100vh - 54px);
}

/* ----------------- SIDEBAR ----------------- */

.sidebar {
  border-right: 1px solid #18192a;
  background: radial-gradient(circle at top left, #17182a, #050509 55%);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 1rem 1.2rem 0.2rem;
}

.sidebar-header h2 {
  font-size: 1.1rem;
}

.sidebar-header small {
  font-size: 0.8rem;
  color: #9da3c0;
}

.sidebar-search {
  padding: 0.6rem 1.2rem 0.8rem;
}

.sidebar-search input {
  width: 100%;
  padding: 0.4rem 0.7rem;
  border-radius: 0.6rem;
  border: 1px solid #26283b;
  background: #0f101a;
  color: #f5f5f5;
  font-size: 0.85rem;
}

.conversation-list {
  list-style: none;
  overflow-y: auto;
  padding: 0.4rem 0.4rem 0.8rem;
}

/* Scroll */
.conversation-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
  width: 6px;
}
.conversation-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
  background: #26283b;
  border-radius: 999px;
}

/* ITEM DA CONVERSA */

.conversation-item {
  padding: 0.55rem 0.7rem;
  border-radius: 0.6rem;
  margin: 0 0.4rem 0.25rem;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: background 0.12s ease-out, transform 0.05s ease-out;
  border: 1px solid transparent;
}

.conversation-item:hover {
  background: rgba(36, 37, 61, 0.95);
}

.conversation-item.selected {
  border-color: #ff6b81;
  background: rgba(40, 42, 70, 0.95);
}

.conv-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.conv-phone {
  font-weight: 600;
}

.conv-time {
  font-size: 0.7rem;
  color: #9da3c0;
}

.conv-row-middle {
  margin-top: 0.1rem;
  font-size: 0.76rem;
  color: #b3b9d6;
}

.conv-row-bottom {
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
}

.conv-estado {
  color: #9da3c0;
}

/* Status pill pequeno na lista */
.status-pill-small {
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 500;
}

/* Cores de status */
.status-bot {
  background: rgba(46, 204, 113, 0.12);
  color: #2ecc71;
}

.status-pending {
  background: rgba(241, 196, 15, 0.13);
  color: #f1c40f;
}

.status-human {
  background: rgba(52, 152, 219, 0.16);
  color: #3498db;
}

/* ----------------- CHAT ----------------- */

.chat {
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top right, #18192c, #050509 60%);
}

.chat-placeholder {
  margin: auto;
  text-align: center;
  max-width: 360px;
  color: #a3a7c5;
}

.chat-placeholder h2 {
  margin-bottom: 0.5rem;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 54px); /* altura total menos a topbar */
}


.chat-header {
  padding: 0.9rem 1.3rem;
  border-bottom: 1px solid #18192a;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h2 {
  font-size: 1rem;
}

.chat-subtitle {
  font-size: 0.78rem;
  color: #9da3c0;
  margin-top: 0.15rem;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Status pill grande no topo do chat */
.status-pill {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Cores status principal */
.status-pill.bot {
  background: rgba(46, 204, 113, 0.12);
  color: #2ecc71;
}
.status-pill.pending {
  background: rgba(241, 196, 15, 0.13);
  color: #f1c40f;
}
.status-pill.human {
  background: rgba(52, 152, 219, 0.16);
  color: #3498db;
}

/* Mensagens */

.chat-messages {
  flex: 1;
  min-height: 0; /* ESSENCIAL para evitar overflow */
  padding: 0.9rem 1.3rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Bolhas */
.bubble {
  max-width: 70%;
  padding: 0.45rem 0.65rem;
  border-radius: 0.7rem;
  font-size: 0.85rem;
  line-height: 1.3;
  position: relative;
  word-wrap: break-word;
}

.bubble-meta {
  margin-top: 0.1rem;
  font-size: 0.65rem;
  opacity: 0.75;
}

/* Cliente (direita / verde) */
.bubble.client {
  align-self: flex-end;
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: #0b1015;
  border-bottom-right-radius: 0.15rem;
}

/* BOT (esquerda / cinza) */
.bubble.bot {
  align-self: flex-start;
  background: #181a2b;
  border-bottom-left-radius: 0.15rem;
}

/* Atendente (esquerda / azul) */
.bubble.attendant {
  align-self: flex-start;
  background: #202846;
  border-bottom-left-radius: 0.15rem;
}

/* Nome do atendente no topo da mensagem */
.bubble-attendant-name {
  font-size: 0.7rem;
  color: #9bd2ff;
  margin-bottom: 0.15rem;
}

/* Área de input */

.chat-input-area {
  padding: 0.6rem 0.9rem;
  border-top: 1px solid #18192a;
  display: flex;
  gap: 0.6rem;
  background: #0f101a;
  flex-shrink: 0; /* evita que a barra desça ou desapareça */
}


.chat-input-area textarea {
  flex: 1;
  resize: none;
  border-radius: 0.6rem;
  border: 1px solid #26283b;
  background: #0f101a;
  color: #f5f5f5;
  padding: 0.45rem 0.6rem;
  font-size: 0.86rem;
}

/* ----------------- RESPONSIVO ----------------- */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: 50%;
  }

  .chat {
    height: 50%;
  }
}

.typing {
  font-size: 0.8rem;
  color: #9bd2ff;
  margin-right: 0.8rem;
}
