/* ============================================
   Key Level Typebot - Estilos (visual refinado)
   ============================================ */

/* Paleta verde gamer */
:root {
  --kl-purple: #00e676;        /* verde principal (neon) */
  --kl-purple-dark: #00c853;   /* verde escuro */
  --kl-purple-light: #69f0ae;  /* verde claro/brilho */
  --kl-blue: #00b0ff;          /* azul secundário */
  --kl-blue-light: #40c4ff;    /* azul claro */
  --kl-pink: #64dd17;          /* verde-lima para destaques */
  --kl-pink-light: #b2ff59;    /* verde-lima mais claro */
  --kl-bg-dark: #1E1E2E;
  --kl-bg-darker: #16162a;
  --kl-panel: rgba(30, 30, 46, 0.96);
  --kl-panel-solid: #101820;
  --kl-border: rgba(0, 230, 118, 0.35);
  --kl-border-hover: rgba(0, 230, 118, 0.65);
  --kl-glow: rgba(0, 230, 118, 0.35);
  --kl-glow-strong: rgba(0, 230, 118, 0.6);
  --text-primary: #FFFFFF;
  --text-muted: #CCCCCC;
  --text-dim: #AAAAAA;
  --bg-chat: #16162a;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 32px rgba(0, 230, 118, 0.18);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Exo 2', system-ui, sans-serif;
  background: var(--kl-bg-darker);
  min-height: 100vh;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
  overflow-x: hidden;
}

.page-bg {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(160deg, rgba(22, 22, 42, 0.97) 0%, rgba(30, 30, 46, 0.92) 50%, rgba(22, 22, 42, 0.96) 100%),
    url('https://portalatosbrasilia.com.br/wp-content/uploads/2024/09/gamer.jpg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  z-index: 0;
}

.page-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 230, 118, 0.05) 2px,
    rgba(0, 230, 118, 0.05) 4px
  );
  pointer-events: none;
}

/* Container principal */
.container {
  width: 100%;
  max-width: 560px;
  height: 88vh;
  max-height: 720px;
  display: flex;
  flex-direction: column;
  background: var(--kl-panel);
  border-radius: var(--radius-xl);
  border: 1px solid var(--kl-border);
  box-shadow:
    var(--shadow-soft),
    var(--shadow-glow),
    0 0 0 1px rgba(0, 230, 118, 0.15) inset;
  overflow: hidden;
  position: relative;
  z-index: 1;
  backdrop-filter: blur(16px);
  animation: containerIn 0.5s ease-out;
}

@keyframes containerIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Wrapper app + anúncio */
.app-wrap {
  display: flex;
  align-items: stretch;
  gap: 1.25rem;
  width: 100%;
  max-width: 800px;
  position: relative;
  z-index: 1;
}

.app-wrap .container {
  flex: 0 1 560px;
  min-width: 0;
}

/* Sidebar keylevelTV */
.ad-sidebar {
  flex: 0 0 240px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 1rem;
  background: var(--kl-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--kl-border);
  box-shadow: var(--shadow-soft), var(--shadow-glow);
  backdrop-filter: blur(12px);
  align-self: center;
  max-height: 720px;
  overflow-y: auto;
  animation: containerIn 0.5s ease-out 0.1s both;
}

/* Publicação keylevelTV – TOP 10 filmes e séries */
.keyleveltv-pub {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.keyleveltv-brand {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--kl-purple-light);
  letter-spacing: 0.06em;
  text-align: center;
  margin: 0 0 0.5rem 0;
  text-shadow: 0 0 10px var(--kl-glow);
}

.keyleveltv-cta {
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 0.75rem 0;
  padding: 0.75rem;
  background: linear-gradient(135deg, rgba(0, 230, 118, 0.18) 0%, rgba(0, 176, 255, 0.12) 100%);
  border: 1px solid var(--kl-border);
  border-radius: var(--radius-sm);
}

.keyleveltv-cta strong {
  color: var(--kl-purple-light);
}

.keyleveltv-card {
  background: rgba(22, 22, 42, 0.7);
  border: 1px solid var(--kl-border);
  border-radius: var(--radius-md);
  padding: 0.9rem;
}

.keyleveltv-title {
  font-family: 'Exo 2', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--kl-purple-light);
  margin: 0 0 0.25rem 0;
  text-shadow: 0 0 8px var(--kl-glow);
}

.keyleveltv-periodo {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin: 0 0 0.6rem 0;
  letter-spacing: 0.02em;
}

.keyleveltv-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.keyleveltv-list li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.2rem 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(124, 88, 247, 0.08);
}

.keyleveltv-list li:last-child {
  border-bottom: none;
}

.keyleveltv-pos {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--kl-purple-light);
  background: rgba(124, 88, 247, 0.2);
  border-radius: 4px;
}

/* Header */
.header {
  background: linear-gradient(180deg, rgba(0, 230, 118, 0.14) 0%, rgba(0, 230, 118, 0.06) 60%, transparent 100%);
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--kl-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.header-mascote {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--kl-purple-light);
  box-shadow: 0 0 18px var(--kl-glow-strong);
  flex-shrink: 0;
}

.header-icon {
  font-size: 1.25rem;
  color: var(--kl-purple-light);
  text-shadow: 0 0 12px var(--kl-glow);
  flex-shrink: 0;
}

.header-titles {
  text-align: left;
  min-width: 0;
}

.header h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  line-height: 1.25;
}

.header h1 .header-sub {
  color: var(--kl-pink-light);
  font-weight: 800;
  text-shadow: 0 0 20px rgba(231, 90, 215, 0.4);
}

.header p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.btn-discord {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  min-height: 44px;
  min-width: 44px;
  background: linear-gradient(135deg, #5865f2 0%, #4752c4 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  font-family: 'Exo 2', sans-serif;
  transition: all var(--transition);
  box-shadow: 0 2px 12px rgba(88, 101, 242, 0.4);
}

.btn-discord:hover {
  background: linear-gradient(135deg, #6772f5 0%, #5865f2 100%);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 24px rgba(88, 101, 242, 0.5);
  color: #fff;
  transform: translateY(-1px);
}

.btn-discord:active {
  transform: translateY(0) scale(0.98);
}

.btn-discord-icon {
  font-size: 1rem;
  opacity: 1;
}

.btn-inicio {
  padding: 0.5rem 1rem;
  background: rgba(124, 88, 247, 0.12);
  color: var(--kl-purple-light);
  border: 1px solid var(--kl-border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: 'Exo 2', sans-serif;
  transition: all var(--transition);
}

.btn-inicio:hover {
  background: rgba(124, 88, 247, 0.22);
  border-color: var(--kl-border-hover);
  box-shadow: 0 0 20px var(--kl-glow);
  color: #fff;
}

.btn-inicio:active {
  transform: scale(0.98);
}

/* Botões de atalho */
.opcoes-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  padding: 0.75rem 0;
}

.opcao-btn {
  padding: 0.5rem 0.9rem;
  background: rgba(124, 88, 247, 0.08);
  color: var(--text-muted);
  border: 1px solid var(--kl-border);
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Exo 2', sans-serif;
  font-weight: 500;
}

.opcao-btn:hover {
  background: rgba(124, 88, 247, 0.18);
  border-color: var(--kl-border-hover);
  color: var(--kl-purple-light);
  box-shadow: 0 0 16px var(--kl-glow);
  transform: translateY(-1px);
}

.opcao-btn:active {
  transform: translateY(0);
}

/* Área do chat */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  background: var(--bg-chat);
  background-image: radial-gradient(ellipse 120% 80% at 50% 0%, rgba(0, 230, 118, 0.08) 0%, transparent 55%);
}

.chat::-webkit-scrollbar {
  width: 6px;
}

.chat::-webkit-scrollbar-track {
  background: rgba(0, 230, 118, 0.08);
  border-radius: 3px;
}

.chat::-webkit-scrollbar-thumb {
  background: rgba(0, 230, 118, 0.6);
  border-radius: 3px;
}

.chat::-webkit-scrollbar-thumb:hover {
  background: var(--kl-purple-light);
}

/* Mensagens */
.msg {
  max-width: 90%;
  padding: 0.9rem 1.15rem;
  border-radius: var(--radius-md);
  line-height: 1.55;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
  animation: msgIn 0.3s ease-out;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(0, 230, 118, 0.45) 0%, rgba(0, 176, 255, 0.25) 100%);
  color: #fff;
  border: 1px solid rgba(0, 230, 118, 0.7);
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 230, 118, 0.35);
}

.msg.bot {
  align-self: flex-start;
  background: rgba(34, 34, 51, 0.9);
  border: 1px solid rgba(0, 230, 118, 0.35);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-soft);
}

.msg.bot strong {
  color: var(--kl-purple-light);
  font-weight: 600;
}

.msg.bot code {
  background: rgba(0, 230, 118, 0.14);
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  font-size: 0.88em;
  border: 1px solid rgba(0, 230, 118, 0.4);
  color: var(--kl-purple-light);
}

.msg.bot a {
  color: var(--kl-purple-light);
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 230, 118, 0.7);
  transition: all 0.2s;
}

.msg.bot a:hover {
  color: var(--kl-blue-light);
  border-bottom-color: var(--kl-purple-light);
  text-shadow: 0 0 10px var(--kl-glow);
}

.msg.bot .msg-ia-badge {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--kl-pink-light);
  opacity: 0.95;
  letter-spacing: 0.08em;
}

/* Área de input */
.input-area {
  padding: 1rem;
  background: linear-gradient(0deg, rgba(22, 22, 42, 0.98) 0%, rgba(30, 30, 46, 0.6) 100%);
  border-top: 1px solid var(--kl-border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

/* Link Discord do suporte (abaixo do chat, acima do input) */
.chat-discord-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 1rem;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, rgba(88, 101, 242, 0.35) 0%, rgba(88, 101, 242, 0.2) 100%);
  color: #b4b9ff;
  border: 1px solid rgba(88, 101, 242, 0.5);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  font-family: 'Exo 2', sans-serif;
  transition: all var(--transition);
  min-height: 44px;
}

.chat-discord-link:hover {
  background: linear-gradient(135deg, #5865f2 0%, #4752c4 100%);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 16px rgba(88, 101, 242, 0.4);
}

.chat-discord-icon {
  font-size: 0.85rem;
  opacity: 0.95;
}

.header-contador {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.header-contador strong {
  font-weight: 700;
  color: var(--kl-purple-light);
  min-width: 1.5em;
  text-align: center;
}

.input-wrap {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
}

#userInput {
  flex: 1;
  padding: 0.9rem 1.15rem;
  border: 1px solid var(--kl-border);
  border-radius: var(--radius-md);
  background: rgba(30, 30, 46, 0.9);
  color: var(--text-primary);
  font-size: 0.95rem;
  resize: none;
  min-height: 80px;
  max-height: 200px;
  font-family: 'Exo 2', sans-serif;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#userInput::placeholder {
  color: var(--text-dim);
}

#userInput:focus {
  outline: none;
  border-color: var(--kl-purple);
  box-shadow: 0 0 24px var(--kl-glow);
}

#sendBtn {
  padding: 0.85rem 1.25rem;
  background: linear-gradient(135deg, var(--kl-purple) 0%, var(--kl-purple-dark) 50%, var(--kl-blue) 100%);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: 'Exo 2', sans-serif;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(124, 88, 247, 0.4);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#sendBtn:hover {
  box-shadow: 0 0 28px var(--kl-glow-strong);
  transform: translateY(-2px);
}

#sendBtn:active {
  transform: translateY(0);
}

#sendBtn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.send-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.send-text {
  display: inline;
}

/* Mensagem de boas-vindas */
.welcome {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 0.75rem 1rem;
  font-weight: 500;
  line-height: 1.45;
}

/* Loading */
.msg.loading {
  color: var(--text-muted);
}

.msg.loading::after {
  content: '';
  animation: dots 1.2s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* Responsivo – tablet */
@media (max-width: 720px) {
  .ad-sidebar {
    display: none;
  }

  .app-wrap {
    max-width: 100%;
  }

  .container {
    max-width: 100%;
  }
}

/* Responsivo – celular */
@media (max-width: 480px) {
  body {
    padding: 0.5rem;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .container {
    height: 92vh;
    height: 92dvh;
    max-height: none;
    border-radius: var(--radius-lg);
    width: 100%;
  }

  .header {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .header-brand {
    min-width: 0;
    flex: 1 1 auto;
  }

  .header h1 {
    font-size: 1.05rem;
  }

  .header p {
    font-size: 0.72rem;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .btn-discord,
  .btn-inicio {
    min-height: 44px;
    min-width: 44px;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }

  .btn-discord-text {
    display: inline;
  }

  .btn-inicio .btn-inicio-text {
    display: inline;
  }

  .chat {
    padding: 0.75rem;
    -webkit-overflow-scrolling: touch;
  }

  .opcoes-wrap {
    padding: 0.5rem 0;
    gap: 0.4rem;
  }

  .opcao-btn {
    padding: 0.55rem 0.85rem;
    font-size: 0.8rem;
    min-height: 44px;
  }

  .input-area {
    padding: 0.75rem 1rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }

  .chat-discord-link {
    margin-bottom: 0.6rem;
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    min-height: 44px;
  }

  .input-wrap {
    gap: 0.5rem;
  }

  #userInput {
    min-height: 72px;
    padding: 0.75rem 1rem;
    font-size: 16px;
  }

  #sendBtn {
    padding: 0.75rem 1rem;
    min-height: 44px;
    min-width: 44px;
  }

  #sendBtn .send-text {
    display: none;
  }

  .send-icon {
    margin: 0;
    font-size: 1.2rem;
  }

  .msg {
    max-width: 95%;
    padding: 0.8rem 1rem;
    font-size: 0.9rem;
  }

  .welcome {
    font-size: 0.82rem;
    padding: 0.6rem 0.75rem;
  }
}
