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

:root {
  --cyan: #00e5ff;
  --cyan-dim: rgba(0,229,255,0.12);
  --cyan-glow: rgba(0,229,255,0.35);
  --cyan-soft: rgba(0,229,255,0.06);
  --glass: rgba(255,255,255,0.03);
  --glass-border: rgba(255,255,255,0.09);
  --bg: #030d13;
  --surface: #061620;
  --text: #e0f7fa;
  --text-dim: rgba(224,247,250,0.45);
  --text-muted: rgba(224,247,250,0.25);
  --user-bubble: rgba(0,229,255,0.08);
  --ai-bubble: rgba(255,255,255,0.03);
}

html { height: 100%; }
body { height: 100%; height: 100dvh; background: var(--bg); color: var(--text); font-family: 'Rajdhani', sans-serif; overflow: hidden; }

body::before {
  content: ''; position: fixed; inset: 0;
  background-image: linear-gradient(rgba(0,229,255,0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(0,229,255,0.03) 1px, transparent 1px);
  background-size: 60px 60px; pointer-events: none; z-index: 0;
}

.orb { position: fixed; border-radius: 50%; filter: blur(160px); pointer-events: none; z-index: 0; }
.orb-1 { width:700px;height:700px;background:rgba(0,80,100,0.2);top:-300px;left:-300px; }
.orb-2 { width:500px;height:500px;background:rgba(0,229,255,0.05);bottom:-200px;right:-200px; }

/* ── LOGIN ── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 20px; }

.panel {
  position: relative; z-index: 1; width: 100%; max-width: 420px; padding: 48px 36px;
  background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(24px);
  clip-path: polygon(0 0, calc(100% - 24px) 0, 100% 24px, 100% 100%, 24px 100%, 0 calc(100% - 24px));
  animation: fadeIn 0.8s ease forwards;
}
.panel::after { content: ''; position: absolute; top: 0; right: 0; width: 40px; height: 40px; border-top: 1px solid var(--cyan); border-right: 1px solid var(--cyan); clip-path: polygon(0 0, 100% 0, 100% 100%); }
.panel::before { content: ''; position: absolute; bottom: 0; left: 0; width: 40px; height: 40px; border-bottom: 1px solid var(--cyan); border-left: 1px solid var(--cyan); clip-path: polygon(0 0, 0 100%, 100% 100%); }

.logo-wrap { text-align: center; margin-bottom: 36px; }
.logo-hex { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; clip-path: polygon(50% 0%,100% 25%,100% 75%,50% 100%,0% 75%,0% 25%); background: var(--cyan-dim); border: 1px solid var(--cyan); box-shadow: 0 0 30px var(--cyan-glow); margin-bottom: 16px; }
.logo-hex svg { width: 28px; height: 28px; fill: var(--cyan); }
.logo-title { font-family: 'Orbitron', monospace; font-size: 28px; font-weight: 900; letter-spacing: 6px; color: var(--cyan); text-shadow: 0 0 20px var(--cyan-glow); }
.logo-sub { font-size: 11px; letter-spacing: 3px; color: var(--text-dim); margin-top: 4px; text-transform: uppercase; }

.field { margin-bottom: 20px; }
label { display: block; font-size: 10px; letter-spacing: 3px; color: var(--text-dim); text-transform: uppercase; margin-bottom: 8px; }
input[type="text"], input[type="password"] {
  width: 100%; background: rgba(0,229,255,0.04); border: 1px solid rgba(0,229,255,0.2);
  color: var(--text); font-family: 'Rajdhani', sans-serif; font-size: 16px; font-weight: 500;
  padding: 12px 16px; outline: none; transition: border-color 0.3s, box-shadow 0.3s;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  -webkit-appearance: none;
}
input[type="text"]:focus, input[type="password"]:focus { border-color: var(--cyan); box-shadow: 0 0 16px rgba(0,229,255,0.2); }
input[type="text"]::placeholder, input[type="password"]::placeholder { color: var(--text-dim); }

.erro { background: rgba(255,60,60,0.1); border: 1px solid rgba(255,60,60,0.3); color: #ff6b6b; font-size: 13px; letter-spacing: 1px; padding: 10px 14px; margin-bottom: 20px; text-align: center; }

.btn-primary {
  width: 100%; margin-top: 8px; padding: 14px; background: transparent; border: 1px solid var(--cyan);
  color: var(--cyan); font-family: 'Orbitron', monospace; font-size: 13px; font-weight: 700;
  letter-spacing: 4px; text-transform: uppercase; cursor: pointer; position: relative; overflow: hidden;
  transition: color 0.3s, box-shadow 0.3s;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
  -webkit-appearance: none;
}
.btn-primary::before { content: ''; position: absolute; inset: 0; background: var(--cyan); transform: translateX(-100%); transition: transform 0.3s ease; }
.btn-primary:hover::before { transform: translateX(0); }
.btn-primary:hover { color: var(--bg); box-shadow: 0 0 30px var(--cyan-glow); }
.btn-primary span { position: relative; z-index: 1; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.divider { display: flex; align-items: center; gap: 12px; margin: 28px 0 0; color: var(--text-dim); font-size: 10px; letter-spacing: 2px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--glass-border); }

/* ── CHAT LAYOUT ── */
.chat-page { overflow: hidden; }
.layout { position: relative; z-index: 1; display: grid; grid-template-columns: 280px 1fr; height: 100dvh; }

/* ── SIDEBAR ── */
.sidebar { background: var(--surface); border-right: 1px solid var(--glass-border); display: flex; flex-direction: column; padding: 32px 24px; position: relative; overflow: hidden; }
.sidebar::after { content: ''; position: absolute; top: 0; right: 0; width: 1px; height: 100%; background: linear-gradient(to bottom, transparent, var(--cyan), transparent); opacity: 0.3; }

.logo-area { margin-bottom: 40px; }
.logo-name { font-family: 'Orbitron', monospace; font-size: 22px; font-weight: 900; letter-spacing: 5px; color: var(--cyan); text-shadow: 0 0 16px var(--cyan-glow); }
.logo-tagline { font-size: 10px; letter-spacing: 2px; color: var(--text-dim); margin-top: 3px; text-transform: uppercase; }
.logo-area .logo-hex { width: 52px; height: 52px; margin-bottom: 14px; display: flex; align-items: center; justify-content: center; clip-path: polygon(50% 0%,100% 25%,100% 75%,50% 100%,0% 75%,0% 25%); background: var(--cyan-dim); border: 1px solid var(--cyan); box-shadow: 0 0 24px var(--cyan-glow); }
.logo-area .logo-hex svg { width: 22px; height: 22px; fill: var(--cyan); }

.btn-new { width: 100%; padding: 11px 16px; background: transparent; border: 1px solid rgba(0,229,255,0.25); color: var(--cyan); font-family: 'Orbitron', monospace; font-size: 10px; letter-spacing: 2px; cursor: pointer; display: flex; align-items: center; gap: 10px; clip-path: polygon(0 0,calc(100% - 10px) 0,100% 10px,100% 100%,10px 100%,0 calc(100% - 10px)); transition: all 0.2s; margin-bottom: 32px; }
.btn-new:hover { background: var(--cyan-dim); border-color: var(--cyan); box-shadow: 0 0 16px rgba(0,229,255,0.15); }
.btn-new svg { width: 14px; height: 14px; stroke: var(--cyan); fill: none; stroke-width: 2; }

.sidebar-label { font-size: 9px; letter-spacing: 3px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 12px; }
.history-list { flex: 1; overflow-y: auto; }
.history-list::-webkit-scrollbar { width: 3px; }
.history-list::-webkit-scrollbar-thumb { background: rgba(0,229,255,0.2); border-radius: 2px; }

.history-item { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; font-size: 13px; color: var(--text-dim); cursor: pointer; border-left: 2px solid transparent; transition: all 0.2s; margin-bottom: 2px; }
.history-item:hover, .history-item.active { color: var(--text); border-left-color: var(--cyan); background: var(--cyan-soft); }
.history-titulo { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-del-conv { display: none; flex-shrink: 0; margin-left: 6px; background: transparent; border: none; cursor: pointer; color: rgba(255,100,100,0.5); padding: 2px; line-height: 0; transition: color 0.2s; }
.history-item:hover .btn-del-conv { display: flex; }
.btn-del-conv:hover { color: #ff7070; }

.sidebar-footer { border-top: 1px solid var(--glass-border); padding-top: 20px; margin-top: 20px; }
.user-info { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.user-avatar { width: 32px; height: 32px; background: var(--cyan-dim); border: 1px solid var(--cyan); clip-path: polygon(50% 0%,100% 25%,100% 75%,50% 100%,0% 75%,0% 25%); display: flex; align-items: center; justify-content: center; font-family: 'Orbitron', monospace; font-size: 11px; color: var(--cyan); flex-shrink: 0; }
.user-name { font-size: 14px; font-weight: 600; color: var(--text); }
.user-role { font-size: 10px; letter-spacing: 1px; color: var(--text-dim); }
.btn-logout { width: 100%; padding: 9px; background: transparent; border: 1px solid rgba(255,100,100,0.2); color: rgba(255,120,120,0.6); font-family: 'Rajdhani', sans-serif; font-size: 11px; letter-spacing: 2px; text-align: center; cursor: pointer; transition: all 0.2s; text-transform: uppercase; }
.btn-logout:hover { border-color: rgba(255,100,100,0.5); color: #ff7070; background: rgba(255,100,100,0.05); }

/* ── MAIN ── */
.main { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; min-width: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--glass-border); background: var(--glass); backdrop-filter: blur(8px); flex-shrink: 0; }
.topbar-title { font-family: 'Orbitron', monospace; font-size: 11px; letter-spacing: 3px; color: var(--text-dim); }
.status-dot { display: flex; align-items: center; gap: 8px; font-size: 10px; letter-spacing: 2px; color: var(--text-dim); white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #00ff88; box-shadow: 0 0 8px rgba(0,255,136,0.6); animation: blink 2s ease-in-out infinite; flex-shrink: 0; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.4} }

.messages { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 24px 20px; display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth; min-height: 0; }
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: rgba(0,229,255,0.15); border-radius: 2px; }

.welcome { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; text-align: center; padding: 40px 20px; animation: fadeUp 0.8s ease forwards; }
.welcome-icon { width: 72px; height: 72px; clip-path: polygon(50% 0%,100% 25%,100% 75%,50% 100%,0% 75%,0% 25%); background: var(--cyan-dim); border: 1px solid var(--cyan); box-shadow: 0 0 40px var(--cyan-glow); display: flex; align-items: center; justify-content: center; margin-bottom: 20px; }
.welcome-icon svg { width: 32px; height: 32px; fill: var(--cyan); }
.welcome h2 { font-family: 'Orbitron', monospace; font-size: 20px; font-weight: 900; letter-spacing: 4px; color: var(--text); margin-bottom: 12px; }
.welcome p { font-size: 15px; color: var(--text-dim); max-width: 400px; line-height: 1.6; margin-bottom: 28px; }
.quick-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.quick-btn { padding: 9px 16px; background: var(--glass); border: 1px solid var(--glass-border); color: var(--text-dim); font-family: 'Rajdhani', sans-serif; font-size: 13px; cursor: pointer; clip-path: polygon(0 0,calc(100% - 8px) 0,100% 8px,100% 100%,8px 100%,0 calc(100% - 8px)); transition: all 0.2s; }
.quick-btn:hover { border-color: var(--cyan); color: var(--cyan); background: var(--cyan-soft); }

.msg { display: flex; gap: 10px; animation: fadeUp 0.3s ease forwards; }
.msg.user { flex-direction: row-reverse; }
.avatar { width: 32px; height: 32px; flex-shrink: 0; clip-path: polygon(50% 0%,100% 25%,100% 75%,50% 100%,0% 75%,0% 25%); display: flex; align-items: center; justify-content: center; font-family: 'Orbitron', monospace; font-size: 10px; }
.avatar.vitra { background: var(--cyan-dim); border: 1px solid var(--cyan); color: var(--cyan); }
.avatar.user { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15); color: var(--text-dim); }
.bubble { max-width: 78%; padding: 12px 16px; font-size: 14px; line-height: 1.65; position: relative; word-break: break-word; }
.msg.vitra .bubble { background: var(--ai-bubble); border: 1px solid var(--glass-border); clip-path: polygon(0 0,calc(100% - 12px) 0,100% 12px,100% 100%,12px 100%,0 calc(100% - 12px)); }
.msg.user .bubble { background: var(--user-bubble); border: 1px solid rgba(0,229,255,0.18); clip-path: polygon(12px 0,100% 0,100% calc(100% - 12px),calc(100% - 12px) 100%,0 100%,0 12px); }
.bubble-time { display: block; font-size: 10px; letter-spacing: 1px; color: var(--text-muted); margin-top: 6px; }
.msg.user .bubble-time { text-align: right; }
.msg-arquivo { color: var(--cyan); font-size: 13px; }

.typing-dots { display: flex; gap: 5px; padding: 4px 0; }
.typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); animation: bounce 1.2s ease-in-out infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,80%,100%{transform:translateY(0);opacity:0.4} 40%{transform:translateY(-6px);opacity:1} }

/* ── INPUT ── */
.input-area { padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--glass-border); background: var(--surface); flex-shrink: 0; }

/* Preview do arquivo */
.file-preview {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin-bottom: 8px;
  background: rgba(0,229,255,0.06); border: 1px solid rgba(0,229,255,0.2);
  font-size: 12px; color: var(--text-dim);
  clip-path: polygon(0 0,calc(100% - 8px) 0,100% 8px,100% 100%,8px 100%,0 calc(100% - 8px));
}
.file-preview svg { stroke: var(--cyan); flex-shrink: 0; }
.file-nome { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.file-size { color: var(--text-muted); flex-shrink: 0; }
.file-remove { background: transparent; border: none; color: rgba(255,100,100,0.6); cursor: pointer; font-size: 14px; padding: 0 2px; flex-shrink: 0; line-height: 1; }
.file-remove:hover { color: #ff7070; }

.input-wrap { display: flex; gap: 10px; align-items: flex-end; background: rgba(0,229,255,0.03); border: 1px solid rgba(0,229,255,0.18); padding: 10px 14px; clip-path: polygon(0 0,calc(100% - 14px) 0,100% 14px,100% 100%,14px 100%,0 calc(100% - 14px)); transition: border-color 0.3s, box-shadow 0.3s; }
.input-wrap:focus-within { border-color: rgba(0,229,255,0.45); box-shadow: 0 0 20px rgba(0,229,255,0.1); }

/* Botão anexar */
.btn-attach { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex-shrink: 0; cursor: pointer; color: var(--text-dim); transition: color 0.2s; }
.btn-attach:hover { color: var(--cyan); }

textarea { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-family: 'Rajdhani', sans-serif; font-size: 15px; font-weight: 500; resize: none; line-height: 1.5; max-height: 100px; overflow-y: auto; -webkit-appearance: none; }
textarea::placeholder { color: var(--text-muted); }

.btn-send { width: 38px; height: 38px; flex-shrink: 0; background: var(--cyan-dim); border: 1px solid var(--cyan); cursor: pointer; display: flex; align-items: center; justify-content: center; clip-path: polygon(0 0,calc(100% - 8px) 0,100% 8px,100% 100%,8px 100%,0 calc(100% - 8px)); transition: all 0.2s; }
.btn-send:hover, .btn-send:active { background: var(--cyan); box-shadow: 0 0 20px var(--cyan-glow); }
.btn-send:hover svg, .btn-send:active svg { stroke: var(--bg); }
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-send svg { width: 16px; height: 16px; stroke: var(--cyan); fill: none; stroke-width: 2; }
.input-hint { font-size: 10px; color: var(--text-muted); letter-spacing: 1px; margin-top: 6px; text-align: center; }

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

/* ── MOBILE ── */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { height: 100dvh; height: -webkit-fill-available; }
  .topbar { padding: 12px 16px; }
  .topbar-title { font-size: 10px; }
  .messages { padding: 16px 12px; gap: 12px; }
  .bubble { max-width: 88%; font-size: 14px; }
  .welcome h2 { font-size: 18px; }
  .welcome p { font-size: 14px; }
  .input-area { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .input-hint { display: none; }
}

@supports (-webkit-touch-callout: none) {
  .main { height: -webkit-fill-available; }
  body { height: -webkit-fill-available; }
}

/* ── Imagem gerada ── */
.bubble-imagem { max-width: 320px; }
.img-label { font-size: 10px; letter-spacing: 2px; color: var(--text-dim); margin-bottom: 8px; text-transform: uppercase; }
.msg-imagem { width: 100%; max-width: 300px; display: block; cursor: pointer; border: 1px solid var(--glass-border); transition: opacity 0.2s; }
.msg-imagem:hover { opacity: 0.85; }
.btn-download-img { display: inline-block; margin-top: 8px; font-size: 11px; letter-spacing: 1px; color: var(--cyan); text-decoration: none; padding: 5px 10px; border: 1px solid rgba(0,229,255,0.25); transition: all 0.2s; }
.btn-download-img:hover { background: var(--cyan-dim); }
.typing-label { font-size: 11px; color: var(--text-dim); letter-spacing: 1px; margin-top: 6px; animation: blink 1.5s ease-in-out infinite; }
