/* Jarvis UI — modern dark, glass, precise */

:root {
  --bg: #070a10;
  --bg-glow-1: rgba(28, 96, 138, 0.16);
  --bg-glow-2: rgba(64, 42, 130, 0.12);
  --surface: rgba(255, 255, 255, 0.035);
  --surface-solid: #0e131c;
  --surface-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e6edf6;
  --text-dim: #8b98ab;
  --text-faint: #5c6879;
  --accent: #38e1ff;
  --accent-2: #6a8bff;
  --accent-grad: linear-gradient(135deg, #38e1ff 0%, #6a8bff 100%);
  --accent-dim: rgba(56, 225, 255, 0.1);
  --user-bubble: linear-gradient(135deg, rgba(56, 225, 255, 0.13), rgba(106, 139, 255, 0.13));
  --danger: #ff7a7a;
  --ok: #3ddc84;
  --radius: 14px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background:
    radial-gradient(900px 600px at 12% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(800px 600px at 95% 110%, var(--bg-glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

::selection { background: rgba(56, 225, 255, 0.28); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 99px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Orb (arc reactor) ---------- */
.core {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #d8fbff, var(--accent) 55%, #0f6f8c);
  box-shadow:
    0 0 10px rgba(56, 225, 255, 0.9),
    0 0 28px rgba(56, 225, 255, 0.45),
    0 0 64px rgba(106, 139, 255, 0.35);
}
.core.pulse { animation: pulse 3.2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(56,225,255,.9), 0 0 28px rgba(56,225,255,.4), 0 0 60px rgba(106,139,255,.3); transform: scale(1); }
  50% { box-shadow: 0 0 16px rgba(56,225,255,1), 0 0 46px rgba(56,225,255,.6), 0 0 90px rgba(106,139,255,.5); transform: scale(1.06); }
}

/* ---------- Login ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  text-align: center; padding: 52px 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  backdrop-filter: blur(24px);
  width: min(380px, 92vw);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  animation: rise 0.5s cubic-bezier(.2,.9,.3,1);
}
.login-logo .core { width: 26px; height: 26px; }
.login-card h1 {
  font-weight: 650; letter-spacing: 0.22em; margin: 18px 0 6px;
  font-size: 22px; text-transform: uppercase;
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-card p { color: var(--text-dim); font-size: 13px; margin-bottom: 28px; }
.login-card input {
  width: 100%; padding: 13px 16px; margin-bottom: 12px;
  background: rgba(0,0,0,.3); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); font-size: 14px; outline: none; font-family: var(--font);
  transition: border-color .15s;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%; padding: 13px; border: none; border-radius: 12px;
  background: var(--accent-grad); color: #041722; font-weight: 650;
  font-size: 14px; cursor: pointer; font-family: var(--font);
  transition: filter .15s, transform .1s;
}
.login-card button:hover { filter: brightness(1.12); }
.login-card button:active { transform: scale(0.98); }
.login-error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ---------- Layout ---------- */
.app { display: flex; height: 100vh; height: 100dvh; }

.sidebar {
  width: 272px; flex-shrink: 0; display: flex; flex-direction: column;
  background: rgba(10, 14, 21, 0.7);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 16px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-core { width: 13px; height: 13px; }
.brand-name {
  font-weight: 650; letter-spacing: 0.2em; font-size: 14px; text-transform: uppercase;
}
.btn-new {
  width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 18px; cursor: pointer;
  line-height: 1; transition: border-color .15s, background .15s;
}
.btn-new:hover { background: var(--surface-hover); border-color: var(--accent); }

.conversation-list { flex: 1; overflow-y: auto; padding: 4px 10px; }
.conv-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 13px; border-radius: 10px; cursor: pointer;
  color: var(--text-dim); font-size: 13.5px; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden;
  border: 1px solid transparent;
  transition: background .12s, color .12s;
}
.conv-item span.title { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv-item:hover { background: var(--surface-hover); color: var(--text); }
.conv-item.active {
  background: var(--accent-dim); color: var(--text);
  border-color: rgba(56, 225, 255, 0.18);
}
.conv-delete {
  border: none; background: transparent; color: var(--text-faint);
  cursor: pointer; font-size: 15px; padding: 0 2px; visibility: hidden;
}
.conv-item:hover .conv-delete { visibility: visible; }
.conv-delete:hover { color: var(--danger); }

.sidebar-footer {
  padding: 13px 18px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: var(--text-dim);
}
.conn-status .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok); margin-right: 6px;
  box-shadow: 0 0 6px var(--ok);
}
.conn-status.offline .dot { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.btn-ghost {
  border: none; background: transparent; color: var(--text-faint);
  cursor: pointer; font-size: 12.5px; font-family: var(--font);
  transition: color .12s;
}
.btn-ghost:hover { color: var(--text); }

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

.main-header {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 24px;
  font-weight: 500; font-size: 14px; color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  background: rgba(7, 10, 16, 0.6);
  backdrop-filter: blur(12px);
}
.sidebar-toggle { display: none; font-size: 18px; }

.messages { flex: 1; overflow-y: auto; padding: 28px 0 16px; }
.msg-row { max-width: 800px; margin: 0 auto 20px; padding: 0 24px; display: flex; gap: 14px; }
.msg-row { animation: fadeup 0.3s cubic-bezier(.2,.9,.3,1); }
@keyframes fadeup {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.welcome { text-align: center; margin-top: 13vh; padding: 0 24px; }
.welcome-core .core { width: 30px; height: 30px; }
.welcome h2 {
  font-weight: 550; margin: 26px 0 8px; font-size: 24px; letter-spacing: -0.01em;
}
.welcome-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 34px; }
.suggestions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.suggestion {
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim); font-size: 13px;
  cursor: pointer; font-family: var(--font); backdrop-filter: blur(8px);
  transition: border-color .15s, color .15s, background .15s;
}
.suggestion:hover { border-color: var(--accent); color: var(--text); background: var(--accent-dim); }

.msg-row.user { justify-content: flex-end; }
.avatar {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(56, 225, 255, 0.07);
  border: 1px solid rgba(56, 225, 255, 0.22);
  margin-top: 2px;
}
.avatar .core { width: 10px; height: 10px; }

.msg { max-width: 82%; overflow-wrap: break-word; min-width: 0; }
.msg-row.user .msg {
  background: var(--user-bubble);
  border: 1px solid var(--border);
  padding: 12px 17px; border-radius: 18px 18px 6px 18px;
  white-space: pre-wrap;
}
.msg-row.assistant .msg { max-width: 100%; flex: 1; padding-top: 3px; }

.msg h1, .msg h2, .msg h3 { margin: 15px 0 8px; font-size: 1.05em; font-weight: 600; }
.msg p { margin: 8px 0; }
.msg ul, .msg ol { margin: 8px 0 8px 22px; }
.msg li { margin: 4px 0; }
.msg code {
  font-family: var(--mono); font-size: 0.87em;
  background: rgba(255,255,255,.06); border: 1px solid var(--border);
  border-radius: 6px; padding: 1.5px 6px;
}
.msg pre {
  background: rgba(0,0,0,.35); border: 1px solid var(--border);
  border-radius: 12px; padding: 13px 16px; overflow-x: auto; margin: 10px 0;
}
.msg pre code { background: none; border: none; padding: 0; }
.msg a { color: var(--accent); text-decoration: none; }
.msg a:hover { text-decoration: underline; }
.msg table { border-collapse: collapse; margin: 10px 0; }
.msg th, .msg td { border: 1px solid var(--border-strong); padding: 6px 11px; font-size: 0.92em; }

.tool-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; margin: 5px 6px 5px 0; border-radius: 999px;
  background: var(--accent-dim); border: 1px solid rgba(56,225,255,.22);
  color: var(--accent); font-size: 12px; font-family: var(--mono);
}
.tool-chip.done::before { content: "✓"; font-size: 11px; }
.tool-chip.running::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--accent); border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.thinking { display: inline-block; color: var(--text-dim); font-size: 13.5px; }
.thinking::after { content: "…"; animation: dots 1.4s steps(4, end) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.msg-error {
  color: var(--danger); font-size: 13.5px; margin-top: 6px;
  padding: 10px 14px; border: 1px solid rgba(255,122,122,.25);
  background: rgba(255,122,122,.07); border-radius: 10px;
}

/* ---------- Composer ---------- */
.composer { padding: 10px 24px 18px; }
.composer-inner {
  max-width: 800px; margin: 0 auto; display: flex; align-items: flex-end; gap: 10px;
  background: rgba(14, 19, 28, 0.85);
  border: 1px solid var(--border-strong);
  border-radius: 20px; padding: 11px 12px 11px 18px;
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  transition: border-color .15s, box-shadow .15s;
}
.composer-inner:focus-within {
  border-color: rgba(56, 225, 255, 0.55);
  box-shadow: 0 12px 40px rgba(0,0,0,.35), 0 0 0 3px rgba(56, 225, 255, 0.08);
}
#input {
  flex: 1; resize: none; border: none; outline: none; background: transparent;
  color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5;
  max-height: 200px;
}
#input::placeholder { color: var(--text-faint); }
#send-btn {
  width: 38px; height: 38px; flex-shrink: 0; border: none; border-radius: 12px;
  background: var(--accent-grad); color: #041722; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: filter .15s, transform .1s;
}
#send-btn:hover:not(:disabled) { filter: brightness(1.12); }
#send-btn:active:not(:disabled) { transform: scale(0.94); }
#send-btn:disabled { opacity: 0.35; cursor: default; }
.composer-hint {
  max-width: 800px; margin: 8px auto 0; text-align: center;
  font-size: 11.5px; color: var(--text-faint);
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50;
    transform: translateX(-100%); transition: transform 0.22s ease;
    width: 284px; background: rgba(10, 14, 21, 0.96);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,.7); }
  .sidebar-toggle { display: block; }
  .composer-hint { display: none; }
  .msg { max-width: 92%; }
}
