/* =======================================================================
   P I X I A   C H A T   –   U L T R A   M O D E R N   P R E M I U M
   Desenvolvido para Richard
   Estética: ChatGPT 2025 + Claude + Perplexity
   ======================================================================= */

/* RESET */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* VIEWPORT FIX PARA MOBILE */
html, body {
  width: 100%;
  height: 100dvh; /* obrigatório no mobile */
  max-height: 100dvh;
  overflow: hidden;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0b0f17;
  color: #e8eaed;
}

/* SMOOTHING */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
}

/* APP */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;  /* evita corte no iOS/Android */
  max-height: 100dvh;
  width: 100%;
  overflow: hidden; /* impede o input de sumir */
}

/* ======================================================================= */
/* HEADER / TOPBAR */
/* ======================================================================= */

.topbar {
  padding: 18px 20px;
  background: rgba(14, 18, 27, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.topbar-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.topbar-subtitle {
  font-size: 0.8rem;
  opacity: 0.6;
  margin-top: 4px;
}

.topbar-status {
  margin-top: 6px;
  font-size: 0.75rem;
  color: #00e3b2;
}

/* ======================================================================= */
/* CHAT AREA */
/* ======================================================================= */

.main {
  flex: 1;
  overflow: hidden;
  display: flex;
}

.chat-area {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Messages container */
.messages {
  flex: 1;
  min-height: 0;  /* FIX ESSENCIAL no mobile */
  overflow-y: auto;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

/* ======================================================================= */
/* BALÕES — ULTRA MODERN */
/* ======================================================================= */

.message-row {
  display: flex;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.assistant {
  justify-content: flex-start;
}

/* BALÕES */
.message-bubble {
  max-width: 78%;
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 0.96rem;
  line-height: 1.65;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  color: #e8eaed;
}

/* BALÃO ASSISTENTE */
.message-row.assistant .message-bubble {
  background: rgba(255,255,255,0.07);
  border-top-left-radius: 6px;
}

/* BALÃO USUÁRIO */
.message-row.user .message-bubble {
  background: linear-gradient(135deg, #009dff, #00ffc3);
  color: #000;
  font-weight: 500;
  border-top-right-radius: 6px;
}

/* META */
.message-meta {
  font-size: 0.72rem;
  opacity: 0.6;
  margin-bottom: 6px;
}

/* ======================================================================= */
/* MARKDOWN PERFEITO */
/* ======================================================================= */

.message-body { white-space: normal; }

/* parágrafos */
.message-body p { margin: 10px 0; }

/* negrito */
.message-body strong {
  font-weight: 700;
  color: #ffffff;
}

/* itálico */
.message-body em {
  font-style: italic;
  opacity: 0.9;
}

/* listas */
.message-body ul,
.message-body ol {
  padding-left: 22px;
  margin: 10px 0;
}
.message-body li {
  margin: 6px 0;
}

/* quotes */
.message-body blockquote {
  border-left: 4px solid #00e3b2;
  padding-left: 12px;
  opacity: 0.8;
  margin: 12px 0;
  font-style: italic;
}

/* inline code */
.message-body code {
  background: rgba(255,255,255,0.12);
  padding: 3px 6px;
  border-radius: 6px;
  font-family: Consolas, monospace;
  font-size: 0.86rem;
}

/* code block */
.message-body pre {
  background: #111722;
  border: 1px solid #1f2533;
  padding: 14px;
  border-radius: 12px;
  margin: 16px 0;
  overflow-x: auto;
}
.message-body pre code {
  background: none;
  padding: 0;
  color: #e3e7ef;
}

/* links */
.message-body a {
  color: #00e3b2;
  text-decoration: none;
}
.message-body a:hover {
  text-decoration: underline;
}

/* hr */
.message-body hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 16px 0;
}

/* ======================================================================= */
/* INPUT BAR */
/* ======================================================================= */

.chat-input-bar {
  display: flex;
  gap: 10px;
  padding: 14px;
  background: rgba(14,18,27,0.9);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0; /* impede sobreposição */
}

.chat-textarea {
  flex: 1;
  resize: none;
  border-radius: 14px;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.08);
  background: #0b0f17;
  color: #e8eaed;
  font-size: 0.95rem;
  max-height: 30dvh; /* FIX teclado mobile */
}

.chat-textarea:focus {
  outline: 1px solid rgba(0,255,200,0.3);
}

.btn-primary {
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #00ffc3, #00a2ff);
  font-size: 0.9rem;
  color: #000;
  font-weight: 600;
  transition: 0.15s;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,255,200,0.45);
}

/* ======================================================================= */
/* SCROLLBAR */
/* ======================================================================= */

.messages::-webkit-scrollbar { width: 10px; }
.messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 100px;
}

/* ======================================================================= */
/* TYPING DOTS - ASSISTANT THINKING */
/* ======================================================================= */

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.typing-indicator .dot {
  width: 7px;
  height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  opacity: 0.5;
  animation: blink 1.4s infinite both;
}

.typing-indicator .dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-indicator .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0% { opacity: 0.2; transform: translateY(0); }
  20% { opacity: 1; transform: translateY(-2px); }
  40%, 100% { opacity: 0.2; transform: translateY(0); }
}
