/* ============================================
   NIA DASHBOARD — Glassmorphism 2.0 + HUD
   Singlemove: Roxo #441E45 + Laranja #FC7C1B
   ============================================ */

:root {
  --bg: #0a0a0a;
  --surface: #1a1a2e;
  --surface-light: #252545;
  --primary: #441E45;
  --primary-light: #6b2d6e;
  --accent: #FC7C1B;
  --accent-glow: rgba(252, 124, 27, 0.35);
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(252, 124, 27, 0.2);
  --glass: rgba(26, 26, 46, 0.72);
  --blur: blur(16px);
  --radius: 14px;
  --radius-sm: 8px;
  --font: 'Space Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

/* ============================================
   ORBE CORE
   ============================================ */

.orb {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.orb-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid transparent;
}

.orb-ring:nth-child(1) { width: 40px; height: 40px; border-color: rgba(68,30,69,0.4); animation: spin 8s linear infinite; }
.orb-ring:nth-child(2) { width: 30px; height: 30px; border-color: rgba(252,124,27,0.3); animation: spin 6s linear infinite reverse; }
.orb-ring:nth-child(3) { width: 20px; height: 20px; border-color: rgba(68,30,69,0.5); animation: spin 4s linear infinite; }

.orb-core {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent), var(--primary));
  box-shadow: 0 0 12px var(--accent-glow);
  animation: pulse 3s ease-in-out infinite;
}

.orb.active .orb-core { animation: pulse 0.8s ease-in-out infinite, glow 1.2s ease-in-out infinite; }
.orb.active .orb-ring { border-color: rgba(252,124,27,0.6); animation-duration: 2s; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { transform:scale(1); opacity:0.8; } 50% { transform:scale(1.15); opacity:1; } }
@keyframes glow { 0%,100% { box-shadow: 0 0 12px var(--accent-glow); } 50% { box-shadow: 0 0 25px var(--accent-glow), 0 0 50px rgba(252,124,27,0.1); } }

/* ============================================
   GLASS
   ============================================ */

.glass { background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--border); }
.glass-strong { background: rgba(26,26,46,0.88); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid rgba(255,255,255,0.08); }

/* ============================================
   LAYOUT
   ============================================ */

.app { display: flex; height: 100vh; }

.sidebar {
  width: 220px; display: flex; flex-direction: column;
  padding: 16px 0; flex-shrink: 0;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px 20px; border-bottom: 1px solid var(--border); margin-bottom: 12px;
}

.logo-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem;
}

.logo-text { font-size: 1.1rem; font-weight: 700; letter-spacing: 1px; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.2s; color: var(--text-dim); font-size: 0.88rem; font-weight: 500;
}

.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active { background: rgba(68,30,69,0.3); color: var(--text); border: 1px solid rgba(68,30,69,0.3); }
.nav-item .icon { font-size: 1rem; width: 22px; text-align: center; }

.sidebar-status {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--border);
  font-size: 0.78rem; color: var(--text-muted);
}

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.4);
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

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

.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: rgba(10,10,10,0.6); backdrop-filter: var(--blur);
  position: sticky; top: 0; z-index: 10;
}

.header h2 { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.header-actions { display: flex; align-items: center; gap: 10px; }

/* ============================================
   MOBILE NAV
   ============================================ */

.mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: rgba(10,10,10,0.95); backdrop-filter: blur(20px); border-top: 1px solid var(--border); z-index: 20; padding: 6px 0; }
.mobile-nav-items { display: flex; justify-content: space-around; }
.mobile-nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 10px; border-radius: var(--radius-sm); color: var(--text-muted); font-size: 0.6rem; cursor: pointer; }
.mobile-nav-item.active { color: var(--accent); }
.mobile-nav-item .icon { font-size: 1.1rem; }

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

.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }

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

.chat-stream::-webkit-scrollbar { width: 3px; }
.chat-stream::-webkit-scrollbar-track { background: transparent; }
.chat-stream::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Message row */
.msg { display: flex; gap: 8px; padding: 3px 0; animation: msgIn 0.2s ease; max-width: 85%; }

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

.msg-icon {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 0.85rem;
  background: rgba(255,255,255,0.04);
}

.msg-body { flex: 1; min-width: 0; }
.msg-bubble { padding: 8px 12px; border-radius: 10px; font-size: 0.85rem; line-height: 1.5; display: inline-block; max-width: 100%; }
.msg-time { font-size: 0.62rem; color: var(--text-muted); margin-top: 2px; }

/* User */
.msg-user { flex-direction: row-reverse; align-self: flex-end; }
.msg-user .msg-icon { background: linear-gradient(135deg, var(--accent), #e06a0a); font-size: 0.75rem; }
.msg-user .msg-bubble { background: rgba(252,124,27,0.15); border: 1px solid rgba(252,124,27,0.2); border-top-right-radius: 4px; }

/* Nia */
.msg-nia { align-self: flex-start; }
.msg-nia .msg-icon { background: linear-gradient(135deg, var(--primary), var(--primary-light)); font-size: 0.75rem; }
.msg-nia .msg-bubble { background: rgba(68,30,69,0.25); border: 1px solid rgba(68,30,69,0.3); border-top-left-radius: 4px; }

/* Thinking */
.msg-thinking { align-self: flex-start; }
.msg-thinking .msg-icon { background: rgba(168,85,247,0.12); border: 1px solid rgba(168,85,247,0.18); }
.msg-thinking .msg-bubble { background: rgba(168,85,247,0.06); border: 1px dashed rgba(168,85,247,0.15); border-top-left-radius: 4px; cursor: pointer; }
.thinking-label { font-size: 0.68rem; font-weight: 600; color: rgba(168,85,247,0.75); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.thinking-label .caret { transition: transform 0.2s; font-size: 0.55rem; }
.thinking-label .caret.open { transform: rotate(90deg); }
.thinking-text { font-size: 0.8rem; color: var(--text-muted); font-style: italic; white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow-y: auto; transition: max-height 0.3s; }
.thinking-text.collapsed { max-height: 0; overflow: hidden; }

/* Tool call */
.msg-tool { align-self: flex-start; }
.msg-tool .msg-icon { background: rgba(252,124,27,0.08); border: 1px solid rgba(252,124,27,0.15); font-size: 0.75rem; }
.msg-bubble-tool { background: rgba(0,0,0,0.4); border: 1px solid rgba(252,124,27,0.12); border-top-left-radius: 4px; overflow: hidden; width: 100%; }
.tool-line { padding: 5px 10px; border-bottom: 1px solid rgba(255,255,255,0.03); display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 0.75rem; }
.tool-line:last-child { border-bottom: none; }
.tool-status { flex-shrink: 0; width: 14px; text-align: center; font-size: 0.65rem; }
.tool-status.running { color: var(--accent); animation: blink 1s ease-in-out infinite; }
.tool-status.done { color: #22c55e; }
.tool-status.error { color: #ef4444; }
.tool-name { font-weight: 600; color: var(--accent); font-family: var(--font); font-size: 0.78rem; min-width: 100px; flex-shrink: 0; }
.tool-args { color: var(--text-muted); font-size: 0.72rem; flex: 1; word-break: break-all; max-height: 50px; overflow-y: auto; }
.tool-output { padding: 5px 10px 5px 26px; background: rgba(34,197,94,0.05); border-top: 1px solid rgba(34,197,94,0.08); font-family: var(--mono); font-size: 0.7rem; color: #22c55e; white-space: pre-wrap; max-height: 80px; overflow-y: auto; }

/* Terminal output */
.msg-terminal { align-self: flex-start; }
.msg-terminal .msg-icon { background: rgba(0,255,0,0.05); border: 1px solid rgba(0,255,0,0.1); font-size: 0.75rem; }
.msg-bubble-terminal { background: #0d1117; border: 1px solid rgba(0,255,0,0.08); border-top-left-radius: 4px; font-family: var(--mono); font-size: 0.75rem; color: #e6edf3; white-space: pre-wrap; word-break: break-all; max-height: 200px; overflow-y: auto; width: 100%; padding: 8px 10px; }

/* Media */
.msg-media { align-self: flex-start; }
.msg-media .msg-icon { background: rgba(68,30,69,0.12); border: 1px solid rgba(68,30,69,0.18); font-size: 0.75rem; }
.msg-bubble-media { background: rgba(68,30,69,0.08); border: 1px solid rgba(68,30,69,0.15); padding: 6px; border-top-left-radius: 4px; }
.msg-img { display: block; max-width: 280px; max-height: 260px; border-radius: 6px; cursor: zoom-in; transition: transform 0.2s; }
.msg-img:hover { transform: scale(1.02); }
.msg-video { display: block; max-width: 280px; border-radius: 6px; }
.msg-media-caption { font-size: 0.68rem; color: var(--text-muted); margin-top: 4px; font-family: var(--mono); }
.msg-media-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; background: rgba(68,30,69,0.15); border: 1px solid rgba(68,30,69,0.25); border-radius: 6px; color: var(--text); text-decoration: none; font-size: 0.8rem; }

/* Processing */
.msg-processing { align-self: flex-start; }
.msg-processing .msg-icon { background: rgba(252,124,27,0.08); border: 1px solid rgba(252,124,27,0.15); font-size: 0.75rem; }
.dots { display: flex; gap: 3px; padding: 4px 0; }
.dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: bounce 1.4s ease-in-out infinite; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,80%,100% { transform:scale(0.5); opacity:0.3; } 40% { transform:scale(1); opacity:1; } }

/* Empty state */
.empty { text-align: center; padding: 50px 20px; color: var(--text-dim); }
.empty .orb { margin: 0 auto 20px; width: 56px; height: 56px; }
.empty .orb-ring:nth-child(1) { width:56px; height:56px; }
.empty .orb-ring:nth-child(2) { width:44px; height:44px; }
.empty .orb-ring:nth-child(3) { width:32px; height:32px; }
.empty .orb-core { width:18px; height:18px; }
.empty p { margin-bottom: 6px; }

/* ============================================
   CHAT INPUT
   ============================================ */

.chat-input {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-top: 1px solid var(--border);
  background: rgba(10,10,10,0.8); backdrop-filter: var(--blur);
}

.chat-input input {
  flex: 1; padding: 10px 14px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--font); font-size: 0.88rem; outline: none;
  transition: border-color 0.3s; min-height: 40px; max-height: 100px;
}

.chat-input input:focus { border-color: var(--accent); }
.chat-input input::placeholder { color: var(--text-muted); }

.send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #e06a0a);
  border: none; color: white; font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s; flex-shrink: 0;
}

.send-btn:hover { transform: scale(1.05); box-shadow: 0 0 15px var(--accent-glow); }
.send-btn:active { transform: scale(0.95); }

.voice-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(252,124,27,0.08); border: 2px solid rgba(252,124,27,0.25);
  color: var(--accent); font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; flex-shrink: 0;
}

.voice-btn:hover { background: rgba(252,124,27,0.15); border-color: var(--accent); }
.voice-btn.recording { background: rgba(252,124,27,0.2); border-color: var(--accent); box-shadow: 0 0 15px var(--accent-glow); animation: recPulse 1.5s ease-in-out infinite; }

@keyframes recPulse { 0%,100% { box-shadow: 0 0 15px var(--accent-glow); } 50% { box-shadow: 0 0 30px var(--accent-glow), 0 0 50px rgba(252,124,27,0.1); } }

/* ============================================
   LIGHTBOX
   ============================================ */

.lightbox {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.95);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out; animation: fadeIn 0.2s;
}

.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: var(--radius); box-shadow: 0 0 50px rgba(68,30,69,0.4); }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

/* ============================================
   PAGES (placeholders)
   ============================================ */

.page { flex: 1; display: flex; align-items: center; justify-content: center; }
.page .empty-state { text-align: center; color: var(--text-dim); }
.page .empty-state .orb { margin: 0 auto 20px; }

/* ============================================
   LOGIN
   */

.login-page { display: flex; align-items: center; justify-content: center; height: 100vh; padding: 20px; }

.login-card {
  width: 100%; max-width: 360px; text-align: center; padding: 40px 32px;
}

.login-card .orb { margin: 0 auto 20px; width: 60px; height: 60px; }
.login-card .orb-ring:nth-child(1) { width:60px; height:60px; }
.login-card .orb-ring:nth-child(2) { width:48px; height:48px; }
.login-card .orb-ring:nth-child(3) { width:36px; height:36px; }
.login-card .orb-core { width:20px; height:20px; }

.login-card h1 { font-size: 1.5rem; margin-bottom: 6px; }
.login-card .subtitle { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 24px; }

.login-input {
  width: 100%; padding: 12px 16px; margin-bottom: 12px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 0.9rem; outline: none;
  transition: border-color 0.3s;
}

.login-input:focus { border-color: var(--accent); }
.login-input::placeholder { color: var(--text-muted); }

.login-btn {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, var(--accent), #e06a0a);
  border: none; border-radius: var(--radius); color: white;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.login-btn:hover { transform: scale(1.02); box-shadow: 0 0 20px var(--accent-glow); }

.login-error { color: #ef4444; font-size: 0.8rem; margin-top: 10px; min-height: 18px; }

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

.msg-bubble code { font-family: var(--mono); background: rgba(0,0,0,0.3); padding: 1px 5px; border-radius: 3px; font-size: 0.82em; }
.msg-bubble pre { background: rgba(0,0,0,0.4); border-radius: 6px; padding: 10px; overflow-x: auto; margin: 6px 0; font-family: var(--mono); font-size: 0.78rem; }
.msg-bubble pre code { background: none; padding: 0; }
.msg-bubble a { color: var(--accent); text-decoration: underline; }
.msg-bubble strong { color: var(--text); }
.msg-bubble table { border-collapse: collapse; margin: 6px 0; font-size: 0.8rem; }
.msg-bubble th, .msg-bubble td { border: 1px solid rgba(255,255,255,0.1); padding: 4px 8px; text-align: left; }
.msg-bubble th { background: rgba(68,30,69,0.3); }

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-nav { display: block; }
  .chat-stream { padding: 12px 10px; padding-bottom: 70px; }
  .chat-input { padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .msg { max-width: 92%; }
  .msg-img, .msg-video { max-width: 220px; }
  .header { padding: 10px 14px; }
}
