/* ===============================
   HylorAI - preto + verde (gradiente)
   =============================== */
:root {
  --bg: #050706;
  --bg-2: #0b0f0d;
  --bg-3: #121915;
  --bg-hover: #17211b;
  --text: #eaf6ef;
  --text-2: #9db5a8;
  --text-muted: #5d7468;
  --green-1: #b6ffd2;
  --green-2: #34e08a;
  --green-3: #0a8a4c;
  --accent: #34e08a;
  --accent-soft: rgba(52, 224, 138, 0.14);
  --grad: linear-gradient(135deg, #b6ffd2 0%, #34e08a 45%, #0a8a4c 100%);
  --grad-soft: linear-gradient(135deg, rgba(182,255,210,.16), rgba(10,138,76,.10));
  --border: #1b2a22;
  --border-2: #25382d;
  --danger: #ff6b6b;
  --radius: 20px;
  --radius-sm: 14px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

button { font-family: inherit; }

/* Ícones */
.ico { display: inline-flex; width: 22px; height: 22px; }
.ico svg { width: 100%; height: 100%; }

/* Brilho de fundo */
.glow::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 40% at 50% -5%, rgba(52,224,138,.18), transparent 70%),
    radial-gradient(40% 30% at 100% 100%, rgba(10,138,76,.14), transparent 70%);
}

/* ========== LOGIN ========== */
.login-page {
  position: relative;
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
  overflow: auto;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, rgba(18,25,21,.9), rgba(11,15,13,.95));
  border-radius: 28px;
  padding: 40px 28px 32px;
  border: 1px solid var(--border-2);
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 80px rgba(52,224,138,.06);
  animation: fadeUp .5s ease;
}

.orb {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #06100b;
  border: 1px solid var(--border-2);
  position: relative;
}
.orb::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: var(--grad);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: .7;
}
.orb .ico { width: 55%; height: 55%; }

.login-logo { text-align: center; margin-bottom: 30px; }
.login-logo .orb {
  width: 76px; height: 76px; border-radius: 24px;
  margin: 0 auto 18px;
  box-shadow: 0 10px 40px rgba(52,224,138,.25);
}
.login-logo h1 {
  font-size: 26px; font-weight: 700; letter-spacing: -.5px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-logo p { color: var(--text-2); font-size: 14px; margin-top: 6px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 8px; font-weight: 500; }
.form-group input {
  width: 100%; padding: 14px 16px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 16px; outline: none; transition: border .2s, box-shadow .2s;
}
.form-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-group input::placeholder { color: var(--text-muted); }

.btn {
  width: 100%; padding: 14px; border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; cursor: pointer; transition: all .2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background: var(--grad); color: #03140b; margin-top: 8px; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 28px rgba(52,224,138,.35); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: transparent; color: var(--text-2); margin-top: 12px; border: 1px solid var(--border-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.login-footer { text-align: center; margin-top: 22px; font-size: 13px; color: var(--text-muted); }
.login-footer a { color: var(--green-2); text-decoration: none; }

/* ========== CHAT ========== */
.app { position: relative; display: flex; height: 100dvh; background: var(--bg); }

.sidebar {
  width: 290px; background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; transition: transform .3s ease; z-index: 20;
}

.sidebar-header { padding: 18px 18px 14px; display: flex; align-items: center; gap: 12px; }
.sidebar-header .orb { width: 38px; height: 38px; border-radius: 12px; }
.sidebar-header h2 {
  font-size: 18px; font-weight: 700; letter-spacing: -.3px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}

.new-chat-btn {
  margin: 6px 16px 14px; padding: 13px; background: var(--grad-soft);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all .2s; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.new-chat-btn .ico { width: 18px; height: 18px; }
.new-chat-btn:hover { border-color: var(--accent); box-shadow: 0 0 24px rgba(52,224,138,.15); }

.history-label { padding: 4px 22px 8px; font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--text-muted); }

.chat-history { flex: 1; overflow-y: auto; padding: 0 12px; }
.chat-history::-webkit-scrollbar { width: 4px; }
.chat-history::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.chat-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  border-radius: 12px; font-size: 13.5px; color: var(--text-2);
  cursor: pointer; margin-bottom: 3px; transition: background .15s;
}
.chat-item .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ico { width: 16px; height: 16px; flex-shrink: 0; opacity: .8; }
.chat-item .del { opacity: 0; background: none; border: none; cursor: pointer; display: flex; padding: 2px; }
.chat-item:hover .del, .chat-item.active .del { opacity: 1; }
.chat-item:hover, .chat-item.active { background: var(--bg-hover); color: var(--text); }
.chat-item.active { box-shadow: inset 2px 0 0 var(--green-2); }
.chat-empty { padding: 10px 12px; font-size: 13px; color: var(--text-muted); }

.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.user-card { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; cursor: pointer; transition: background .15s; }
.user-card:hover { background: var(--bg-hover); }
.user-avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #03140b;
}
.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .status { font-size: 11.5px; color: var(--text-muted); }
.user-card .ico { width: 18px; height: 18px; opacity: .8; }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

.chat-header {
  height: 60px; padding: 0 14px; display: grid; grid-template-columns: 48px 1fr 48px;
  align-items: center; border-bottom: 1px solid var(--border);
  background: rgba(5,7,6,.85); backdrop-filter: blur(12px); z-index: 5;
}
.chat-header .title { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 16px; font-weight: 600; }
.chat-header .title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 10px var(--green-2); }
.chat-header .title .grad {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; background: none; border: none;
  display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background .15s;
}
.icon-btn:hover { background: var(--bg-hover); }
.menu-btn { display: none; }

/* Mensagens */
.messages { position: relative; flex: 1; overflow-y: auto; padding: 24px; }
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

.empty-state {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px 8px; animation: fadeUp .6s ease;
}
.empty-state .orb { width: 92px; height: 92px; border-radius: 30px; margin-bottom: 26px; animation: float 4s ease-in-out infinite; box-shadow: 0 16px 60px rgba(52,224,138,.28); }
.empty-state h2 {
  font-size: 30px; font-weight: 700; letter-spacing: -.8px; margin-bottom: 10px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.empty-state p { color: var(--text-2); font-size: 15px; max-width: 340px; line-height: 1.55; }

.suggestions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 32px; width: 100%; max-width: 560px; }
.suggestion {
  display: flex; flex-direction: column; gap: 12px; text-align: left; padding: 16px;
  background: linear-gradient(160deg, var(--bg-3), var(--bg-2)); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13.5px; line-height: 1.4; color: var(--text); cursor: pointer; transition: all .2s;
}
.suggestion .ico { width: 22px; height: 22px; }
.suggestion:hover { border-color: var(--green-2); transform: translateY(-2px); box-shadow: 0 8px 30px rgba(52,224,138,.12); }

.message { display: flex; gap: 12px; margin: 0 auto 26px; max-width: 820px; animation: fadeUp .35s ease; }
.message.user { flex-direction: row-reverse; }
.message .avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700;
}
.message.assistant .avatar { background: #06100b; border: 1px solid var(--border-2); }
.message.assistant .avatar .ico { width: 18px; height: 18px; }
.message.user .avatar { background: var(--grad); color: #03140b; }
.message .content { flex: 1; min-width: 0; }
.message.user .content { display: flex; justify-content: flex-end; }

.bubble { padding: 13px 17px; border-radius: 20px; font-size: 15px; line-height: 1.65; max-width: 100%; overflow-wrap: anywhere; }
.message.assistant .bubble { background: var(--bg-2); border: 1px solid var(--border); border-top-left-radius: 6px; }
.message.user .bubble {
  background: linear-gradient(135deg, #123826, #0b2a1b); border: 1px solid #1e4a33;
  border-top-right-radius: 6px; width: fit-content;
}
.bubble.error { border-color: rgba(255,107,107,.4); }

.bubble h1, .bubble h2, .bubble h3 { margin: 16px 0 8px; font-weight: 600; }
.bubble h1 { font-size: 1.4em; } .bubble h2 { font-size: 1.25em; } .bubble h3 { font-size: 1.1em; }
.bubble p { margin-bottom: 12px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 10px 0; padding-left: 22px; } .bubble li { margin-bottom: 6px; }
.bubble code { background: var(--accent-soft); color: var(--green-1); padding: 2px 6px; border-radius: 6px; font-family: 'JetBrains Mono', monospace; font-size: .9em; }
.bubble pre { background: #020403; border: 1px solid var(--border-2); border-radius: 14px; margin: 14px 0; overflow: hidden; }
.bubble pre code { display: block; background: none; color: var(--text); padding: 14px 16px; overflow-x: auto; font-size: 13.5px; line-height: 1.55; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 14px; background: var(--bg-3); font-size: 12px; color: var(--text-2); }
.copy-btn { display: flex; align-items: center; gap: 6px; background: none; border: none; color: var(--text-2); font-size: 12px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.copy-btn .ico { width: 15px; height: 15px; }
.copy-btn:hover { background: var(--bg-hover); color: var(--text); }
.bubble blockquote { border-left: 3px solid var(--green-2); padding-left: 14px; margin: 12px 0; color: var(--text-2); }
.bubble a { color: var(--green-2); text-decoration: none; } .bubble a:hover { text-decoration: underline; }
.bubble table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 14px; display: block; overflow-x: auto; }
.bubble th, .bubble td { border: 1px solid var(--border-2); padding: 8px 12px; text-align: left; }
.bubble th { background: var(--bg-3); }

.typing { display: flex; gap: 5px; padding: 8px 4px; }
.typing span { width: 7px; height: 7px; background: var(--grad); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both; }
.typing span:nth-child(1) { animation-delay: -.32s; } .typing span:nth-child(2) { animation-delay: -.16s; }

/* Input */
.input-area { padding: 10px 20px max(18px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, transparent, var(--bg) 30%); }
.input-wrapper {
  max-width: 820px; margin: 0 auto; background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: 28px; padding: 8px 8px 8px 20px; display: flex; align-items: flex-end; gap: 10px; transition: border .2s, box-shadow .2s;
}
.input-wrapper:focus-within { border-color: var(--green-2); box-shadow: 0 0 0 3px var(--accent-soft), 0 0 40px rgba(52,224,138,.10); }
.input-wrapper textarea {
  flex: 1; background: transparent; border: none; outline: none; color: var(--text);
  font-size: 16px; font-family: inherit; resize: none; max-height: 160px; line-height: 1.5; padding: 9px 0;
}
.input-wrapper textarea::placeholder { color: var(--text-muted); }
.send-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--grad);
  cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .2s; flex-shrink: 0;
}
.send-btn .ico { width: 20px; height: 20px; }
.send-btn svg { stroke: #03140b; }
.send-btn:hover:not(:disabled) { transform: scale(1.06); box-shadow: 0 6px 24px rgba(52,224,138,.4); }
.send-btn:disabled { background: var(--bg-3); cursor: not-allowed; }
.send-btn:disabled svg { stroke: var(--text-muted); }
.send-btn.stop svg { fill: #03140b; stroke: none; }
.input-footer { max-width: 820px; margin: 10px auto 0; text-align: center; font-size: 11.5px; color: var(--text-muted); }

.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(2px); z-index: 15; }
.overlay.show { display: block; }

@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); width: 82%; max-width: 310px; }
  .sidebar.open { transform: translateX(0); box-shadow: 10px 0 50px rgba(0,0,0,.7); }
  .menu-btn { display: flex; }
  .messages { padding: 16px; }
  .input-area { padding: 8px 14px max(16px, env(safe-area-inset-bottom)); }
  .empty-state h2 { font-size: 26px; }
  .message { gap: 10px; }
}

@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
