/* ============================================================
   PevIA Chat — style.css
   Minimalista clean · branco · tipografia fina
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600&display=swap');

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #F9FAFB;
  --surface:     #FFFFFF;
  --border:      #E5E7EB;
  --border-lt:   #F3F4F6;
  --primary:     #111827;
  --accent:      #2563EB;
  --accent-lt:   #EFF6FF;
  --accent-dk:   #1D4ED8;
  --muted:       #6B7280;
  --light:       #9CA3AF;
  --bubble-user: #111827;
  --bubble-ai:   #FFFFFF;
  --text-user:   #FFFFFF;
  --text-ai:     #111827;
  --success:     #10B981;
  --danger:      #EF4444;
  --warn:        #F59E0B;
  --shadow-sm:   0 1px 2px rgba(0,0,0,.05);
  --shadow:      0 2px 8px rgba(0,0,0,.08);
  --shadow-md:   0 4px 24px rgba(0,0,0,.10);
  --radius-sm:   8px;
  --radius:      14px;
  --radius-lg:   20px;
  --font:        'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  --header-h:    60px;
  --input-h:     72px;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ════════════════════════════════════════════════════════════
   LOGIN
   ════════════════════════════════════════════════════════════ */
.login-page {
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-wrap {
  width: 100%;
  max-width: 400px;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.login-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
}

.login-logo-mark {
  width: 36px; height: 36px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
}

.login-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
}

.login-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 28px;
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 18px;
}
.alert-erro {
  background: #FEF2F2;
  color: var(--danger);
  border: 1px solid #FECACA;
}

.login-form { display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
}

.field input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--primary);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.input-wrap { position: relative; }
.input-wrap input { padding-right: 44px; }

.toggle-senha {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--light);
  display: flex; align-items: center; transition: color .15s;
}
.toggle-senha:hover, .toggle-senha.active { color: var(--accent); }
.toggle-senha svg { width: 18px; height: 18px; }

.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  background: var(--primary);
  color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s, transform .1s;
}
.btn-primary:hover { background: #1f2937; }
.btn-primary:active { transform: scale(.98); }
.btn-primary svg { width: 16px; height: 16px; }
.btn-full { width: 100%; }

.login-footer {
  text-align: center;
  font-size: 12px;
  color: var(--light);
  margin-top: 20px;
}

.login-brand {
  margin-top: 24px;
  font-size: 12px;
  color: var(--light);
}
.login-brand strong { color: var(--muted); }

/* ════════════════════════════════════════════════════════════
   CHAT APP
   ════════════════════════════════════════════════════════════ */
.chat-page {
  overflow: hidden;
  background: var(--bg);
}

.chat-app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 680px;
  margin: 0 auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* ── Header ─────────────────────────────────────────────── */
.chat-header {
  height: var(--header-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.chat-header-info {
  display: flex; align-items: center; gap: 12px;
}

.avatar-wrap { position: relative; }

.chat-avatar {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}

.status-dot {
  width: 10px; height: 10px;
  background: var(--success);
  border: 2px solid var(--surface);
  border-radius: 50%;
  position: absolute; bottom: 0; right: 0;
  transition: background .3s;
}
.status-dot.offline { background: var(--light); }

.chat-name { font-size: 15px; font-weight: 600; }
.chat-status { font-size: 12px; color: var(--muted); }

.chat-header-actions { display: flex; gap: 4px; }

/* ── Mensagens ──────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}

/* Boas-vindas */
.msg-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 40px 20px 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  animation: fadeIn .4s ease;
}

.welcome-avatar {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

/* Mensagem */
.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: msgIn .2s ease;
  max-width: 100%;
}

.msg-usuario { flex-direction: row-reverse; }

.msg-avatar-sm {
  width: 28px; height: 28px;
  background: var(--border);
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

.msg-bubble {
  max-width: min(75%, 480px);
  padding: 10px 14px;
  border-radius: var(--radius);
  position: relative;
  word-wrap: break-word;
}

.msg-usuario .msg-bubble {
  background: var(--bubble-user);
  color: var(--text-user);
  border-bottom-right-radius: 4px;
}

.msg-assistente .msg-bubble {
  background: var(--bubble-ai);
  color: var(--text-ai);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.msg-text {
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.msg-hora {
  display: block;
  font-size: 10px;
  margin-top: 4px;
  opacity: .5;
  text-align: right;
}

/* Imagem */
.msg-image {
  max-width: 240px; max-height: 240px;
  border-radius: var(--radius-sm);
  display: block;
  cursor: pointer;
}

/* Áudio */
.msg-audio {
  display: flex; align-items: center; gap: 8px;
}
.msg-audio svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .6; }
.msg-audio audio { height: 32px; max-width: 200px; }

/* Documento */
.msg-doc {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500;
  text-decoration: none;
  color: inherit;
}
.msg-usuario .msg-doc { color: rgba(255,255,255,.9); }
.msg-doc svg { width: 18px; height: 18px; flex-shrink: 0; }
.msg-doc:hover { opacity: .8; }

/* Typing indicator */
.typing-indicator .msg-bubble {
  padding: 12px 16px;
  display: flex; gap: 5px; align-items: center;
}
.dot {
  width: 6px; height: 6px;
  background: var(--light);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.dot:nth-child(2) { animation-delay: .2s; }
.dot:nth-child(3) { animation-delay: .4s; }

/* ── Input Bar ──────────────────────────────────────────── */
.chat-input-bar {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 12px 10px;
  flex-shrink: 0;
}

/* Preview arquivo */
.file-preview {
  margin-bottom: 8px;
}
.file-preview-inner {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--accent-lt);
  border: 1px solid #BFDBFE;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
}
.file-preview-inner button {
  background: none; border: none; cursor: pointer;
  color: var(--accent); display: flex; padding: 2px;
}
.file-preview-inner button svg { width: 14px; height: 14px; }

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.chat-textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--primary);
  background: var(--bg);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 140px;
  overflow-y: auto;
  transition: border-color .15s;
}
.chat-textarea:focus { border-color: var(--accent); background: var(--surface); }
.chat-textarea::placeholder { color: var(--light); }

/* Icon buttons */
.icon-btn {
  width: 40px; height: 40px;
  border: none; border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.icon-btn:hover { background: var(--bg); color: var(--primary); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.recording { color: var(--danger); background: #FEF2F2; }

/* Botão enviar */
.btn-send {
  width: 40px; height: 40px;
  border: none; border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.btn-send:hover { background: var(--accent); }
.btn-send:active { transform: scale(.93); }
.btn-send svg { width: 18px; height: 18px; }
.btn-send:disabled { background: var(--border); cursor: not-allowed; }

/* Menu anexar */
.attach-menu-wrap { position: relative; }

.attach-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  min-width: 160px;
  animation: popUp .15s ease;
  z-index: 50;
}

.attach-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 12px 16px;
  background: none; border: none;
  font-family: var(--font); font-size: 13px; font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  transition: background .12s;
  text-align: left;
}
.attach-item:hover { background: var(--bg); }
.attach-item svg { width: 17px; height: 17px; color: var(--muted); }

/* Barra de gravação */
.record-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px 0;
  font-size: 13px; color: var(--danger);
  font-weight: 500;
  animation: fadeIn .2s ease;
}
.record-dot {
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  animation: pulse 1s infinite;
}
.record-label { color: var(--muted); font-weight: 400; font-size: 12px; }

/* ── Animações ───────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .3; }
}

@keyframes popUp {
  from { opacity: 0; transform: translateY(6px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .chat-app { border: none; }
  .msg-bubble { max-width: 85%; }
  .login-card { padding: 28px 20px; }
}

/* ── Botão Compartilhar ──────────────────────────────────── */
.btn-share {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  padding: 4px; margin-left: 6px;
  border-radius: 6px; color: var(--light); opacity: 0;
  transition: opacity .2s, color .15s, background .15s;
  vertical-align: middle;
}
.btn-share svg { width: 14px; height: 14px; }
.btn-share:hover { color: var(--accent); background: var(--accent-lt); }
.msg-bubble:hover .btn-share,
.msg-bubble:focus-within .btn-share { opacity: 1; }
@media (hover: none) { .btn-share { opacity: 0.5; } }

/* ── PWA Splash Screen ───────────────────────────────────── */
.pwa-splash {
  position: fixed; inset: 0; z-index: 9999;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  animation: splashAutoHide 3s ease forwards;
}
.pwa-splash.splash-hide {
  animation: splashOut .5s ease forwards !important;
}
.splash-inner {
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  animation: splashIn .4s ease both;
}
.splash-logo {
  width: 88px; height: 88px; border-radius: 22px; overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  animation: splashPulse 2s ease infinite;
}
.splash-logo img { width: 88px; height: 88px; object-fit: cover; display: block; }
.splash-brand { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.splash-name {
  font-family: var(--font); font-size: 26px; font-weight: 700;
  color: var(--primary); letter-spacing: -.5px;
  animation: splashFadeUp .5s ease .3s both;
}
.splash-tagline {
  font-family: var(--font); font-size: 12px; font-weight: 400;
  color: var(--muted); letter-spacing: .4px;
  animation: splashFadeUp .5s ease .5s both;
}
.splash-dots { display: flex; gap: 6px; animation: splashFadeUp .4s ease .6s both; }
.splash-dots span {
  width: 6px; height: 6px; background: var(--light);
  border-radius: 50%; animation: splashDot 1.2s ease infinite;
}
.splash-dots span:nth-child(2) { animation-delay: .2s; }
.splash-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes splashAutoHide {
  0%, 75% { opacity: 1; }
  100%    { opacity: 0; visibility: hidden; pointer-events: none; }
}
@keyframes splashOut {
  from { opacity: 1; }
  to   { opacity: 0; visibility: hidden; pointer-events: none; }
}
@keyframes splashIn    { from { opacity:0; transform:scale(.94); } to { opacity:1; transform:none; } }
@keyframes splashFadeUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
@keyframes splashPulse  { 0%,100%{transform:scale(1);} 50%{transform:scale(1.03);} }
@keyframes splashDot    { 0%,60%,100%{transform:translateY(0);opacity:.4;} 30%{transform:translateY(-5px);opacity:1;} }

/* ── Avatares com logo ───────────────────────────────────── */
/* Header avatar */
.chat-avatar { overflow: hidden; }
.chat-avatar img.avatar-logo {
  width: 38px; height: 38px;
  border-radius: 50%; object-fit: cover; display: block;
}
/* Bolha do assistente */
.msg-avatar-sm { overflow: hidden; background: transparent; }
.msg-avatar-sm img.avatar-logo-sm {
  width: 28px; height: 28px;
  border-radius: 50%; object-fit: cover; display: block;
}
/* Boas-vindas */
.welcome-avatar { overflow: hidden; background: transparent; }
.welcome-avatar img.avatar-logo-welcome {
  width: 56px; height: 56px;
  border-radius: 50%; object-fit: cover; display: block;
}
