@import url("https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700;900&family=Rajdhani:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap");

:root {
  --bg: #050505;
  --surface: #0a0a0a;
  --border: #1a1a1a;
  --orange: #FF9500;
  --orange-dim: rgba(255,149,0,0.15);
  --orange-glow: rgba(255,149,0,0.4);
  --cyan: #00d4ff;
  --cyan-dim: rgba(0,212,255,0.15);
  --cyan-glow: rgba(0,212,255,0.4);
  --text: #e0e0e0;
  --text-dim: #666;
  --text-muted: #444;
  --danger: #ef4444;
  --success: #34d399;
  --font-display: "Orbitron", sans-serif;
  --font-body: "Rajdhani", sans-serif;
  --font-mono: "JetBrains Mono", "Menlo", monospace;
}

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

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

/* SCANLINE OVERLAY */
.scanline-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.03) 2px,
    rgba(0,0,0,0.03) 4px
  );
}

/* ============ LOGIN ============ */
#tela-login {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--bg);
  overflow: hidden;
}

#login-brain-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

.login-box {
  position: relative;
  z-index: 1;
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,149,0,0.2);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  width: 380px;
  box-shadow:
    0 0 40px rgba(255,149,0,0.08),
    0 0 80px rgba(0,212,255,0.05),
    inset 0 1px 0 rgba(255,255,255,0.05);
  animation: fadeInUp 0.8s ease-out;
}

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

.login-glow {
  position: absolute;
  top: -1px; left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--orange), var(--cyan), transparent);
  border-radius: 2px;
  animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
  0%,100% { opacity:0.5; width:60%; }
  50% { opacity:1; width:80%; }
}

.login-title-group { margin-bottom: 32px; }
.login-logo { margin-bottom: 16px; }
.logo-svg { width: 60px; height: 60px; filter: drop-shadow(0 0 15px rgba(255,149,0,0.3)); }

.pulse-node { animation: nodePulse 2s ease-in-out infinite; }
.pulse-node.d1 { animation-delay: 0.3s; }
.pulse-node.d2 { animation-delay: 0.6s; }
.pulse-node.d3 { animation-delay: 0.9s; }
@keyframes nodePulse {
  0%,100% { opacity:0.6; r: inherit; }
  50% { opacity:1; }
}

.login-box h1 {
  font-family: var(--font-display);
  color: var(--orange);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 4px;
  text-shadow: 0 0 20px rgba(255,149,0,0.3);
}

.login-sub {
  font-family: var(--font-display);
  color: var(--cyan);
  font-size: 10px;
  letter-spacing: 6px;
  opacity: 0.7;
}

.login-line {
  width: 40px;
  height: 1px;
  background: linear-gradient(90deg, var(--orange), var(--cyan));
  margin: 16px auto 0;
}

.input-group {
  position: relative;
  margin-bottom: 12px;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--orange);
  font-size: 10px;
  opacity: 0.5;
}

.login-box input {
  width: 100%;
  padding: 14px 16px 14px 36px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 1px;
  outline: none;
  transition: all 0.3s;
}

.login-box input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 20px rgba(255,149,0,0.1), inset 0 0 20px rgba(255,149,0,0.03);
}

.login-box input::placeholder {
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 3px;
}

.login-box button {
  position: relative;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--orange), #FF7B00);
  border: none;
  border-radius: 8px;
  color: #000;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  cursor: pointer;
  margin-top: 8px;
  overflow: hidden;
  transition: all 0.3s;
}

.login-box button:hover {
  box-shadow: 0 0 30px rgba(255,149,0,0.4);
  transform: translateY(-1px);
}

.btn-glow {
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: btnGlowSlide 3s ease-in-out infinite;
}

@keyframes btnGlowSlide {
  0% { left:-100%; }
  50% { left:100%; }
  100% { left:100%; }
}

#login-erro {
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 8px;
}

.login-footer {
  margin-top: 24px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.blink-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  display: inline-block;
  animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
  0%,100% { opacity:0.3; }
  50% { opacity:1; box-shadow: 0 0 8px var(--cyan); }
}

/* ============ HEADER ============ */
header {
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 60px;
  background: rgba(10,10,10,0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

header::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--orange-glow), var(--cyan-glow), transparent);
  opacity: 0.5;
}

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

.header-logo-svg { width:28px; height:28px; }

.header-title h1 {
  font-family: var(--font-display);
  color: var(--orange);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  line-height: 1;
}

.header-version {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 2px;
}

/* BADGE */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.badge.online {
  background: rgba(52,211,153,0.1);
  border: 1px solid rgba(52,211,153,0.3);
  color: var(--success);
}
.badge.online .badge-dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: blink 1.5s ease-in-out infinite;
}

.badge.offline {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger);
}
.badge.offline .badge-dot {
  background: var(--danger);
}

/* NAV */
nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.nav-btn {
  position: relative;
  padding: 8px 18px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.3s;
}

.nav-icon {
  font-size: 8px;
  margin-right: 4px;
  opacity: 0.5;
}

.nav-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.03);
}

.nav-btn.active {
  color: var(--orange);
  background: rgba(255,149,0,0.05);
  border-color: rgba(255,149,0,0.2);
}

.nav-btn.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 20%;
  width: 60%;
  height: 2px;
  background: var(--orange);
  border-radius: 2px;
  box-shadow: 0 0 10px var(--orange-glow);
  animation: navGlow 2s ease-in-out infinite;
}

@keyframes navGlow {
  0%,100% { opacity:0.7; box-shadow: 0 0 10px var(--orange-glow); }
  50% { opacity:1; box-shadow: 0 0 20px var(--orange-glow); }
}

.btn-sair {
  padding: 6px 14px;
  background: rgba(239,68,68,0.05);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s;
}
.btn-sair:hover {
  background: rgba(239,68,68,0.15);
  box-shadow: 0 0 15px rgba(239,68,68,0.2);
}

/* ============ MAIN ============ */
main { padding:24px; max-width:1600px; margin:0 auto; }

/* DASHBOARD SPLIT */
.dashboard-split {
  display: grid;
  grid-template-columns: 40% 1fr;
  gap: 24px;
  min-height: calc(100vh - 120px);
}

/* BRAIN PANEL */
.brain-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.brain-panel::before {
  content: "";
  position: absolute;
  top: -1px; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan-glow), transparent);
}

.brain-panel-header,
.brain-panel-footer {
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
}

.panel-tag {
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 2px;
}

.panel-status {
  color: var(--success);
  font-family: var(--font-mono);
}

.brain-panel-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

.brain-panel-footer strong {
  color: var(--cyan);
}

#neural-canvas {
  flex: 1;
  width: 100%;
  min-height: 300px;
}

/* DATA PANELS */
.data-panels {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* STATS GRID */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(circle at top left, var(--orange-dim), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.stat-card:hover::before { opacity: 1; }
.stat-card:hover { border-color: rgba(255,149,0,0.3); box-shadow: 0 0 20px rgba(255,149,0,0.05); }

.stat-card.accent {
  border-color: rgba(255,149,0,0.3);
  background: rgba(255,149,0,0.03);
}

.stat-icon {
  font-size: 18px;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}

.stat-icon.orange {
  color: var(--orange);
  background: var(--orange-dim);
}

.stat-icon.cyan {
  color: var(--cyan);
  background: var(--cyan-dim);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.stat-card.accent .stat-value { color: var(--orange); text-shadow: 0 0 15px var(--orange-glow); }

.stat-label {
  font-family: var(--font-display);
  color: var(--text-dim);
  font-size: 9px;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* SECTION */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.section::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: linear-gradient(180deg, var(--orange), var(--cyan));
  opacity: 0.5;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.section-header h2 {
  font-family: var(--font-display);
  color: var(--orange);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  white-space: nowrap;
}

.section-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255,149,0,0.3), transparent);
}

.hint {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 12px;
  font-family: var(--font-body);
}

/* FORMS */
label {
  display: block;
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 500;
  margin-bottom: 4px;
  margin-top: 14px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

input[type="text"], select, textarea {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  resize: vertical;
  transition: all 0.3s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 20px rgba(255,149,0,0.08);
}

textarea { min-height: 80px; }

#system-prompt {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  min-height: 400px;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2712%27 height=%278%27 viewBox=%270 0 12 8%27%3E%3Cpath fill=%27%23FF9500%27 d=%27M6 8L0 0h12z%27/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

/* BUTTONS */
.btn-primary {
  position: relative;
  padding: 12px 28px;
  background: linear-gradient(135deg, var(--orange), #FF7B00);
  border: none;
  border-radius: 8px;
  color: #000;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  margin-top: 14px;
  overflow: hidden;
  transition: all 0.3s;
}

.btn-primary:hover {
  box-shadow: 0 0 25px rgba(255,149,0,0.4);
  transform: translateY(-1px);
}

.actions { display:flex; align-items:center; gap:12px; }
.save-status { color: var(--success); font-family: var(--font-mono); font-size: 12px; margin-top: 14px; }

/* CONFIG GRID */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 16px;
}
.full-width { grid-column: 1/-1; }

/* QUALIFICATIONS */
.qual-bars { display:flex; gap:16px; flex-wrap:wrap; }
.qual-bar {
  flex: 1;
  min-width: 100px;
  text-align: center;
  padding: 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.3s;
}
.qual-bar:hover { border-color: rgba(255,149,0,0.3); }
.qual-bar-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
}
.qual-bar-label {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* CONVERSAS */
.conversas-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 16px;
  min-height: 75vh;
}

.conversas-lista {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-y: auto;
  max-height: 80vh;
}

.lista-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.conv-item {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.conv-item:hover { background: rgba(255,255,255,0.02); }
.conv-item.active {
  background: rgba(255,149,0,0.05);
  border-left: 3px solid var(--orange);
}
.conv-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, rgba(255,149,0,0.05), transparent);
  pointer-events: none;
}

.conv-name {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.conv-phone {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 11px;
}
.conv-time {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 10px;
  float: right;
}

.conv-qual {
  font-family: var(--font-display);
  font-size: 9px;
  padding: 2px 10px;
  border-radius: 10px;
  display: inline-block;
  margin-top: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.conv-qual.new { background:rgba(59,130,246,0.1); color:#60a5fa; border: 1px solid rgba(59,130,246,0.2); }
.conv-qual.qualified { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(255,149,0,0.2); }
.conv-qual.interested { background:rgba(52,211,153,0.1); color: var(--success); border: 1px solid rgba(52,211,153,0.2); }
.conv-qual.closed { background:rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.conv-qual.prospecting { background:rgba(168,85,247,0.1); color:#a78bfa; border: 1px solid rgba(168,85,247,0.2); }

.conversa-chat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  overflow-y: auto;
  max-height: 80vh;
}

.chat-placeholder {
  text-align: center;
  padding-top: 180px;
  color: var(--text-muted);
}
.placeholder-icon {
  font-size: 48px;
  color: var(--cyan);
  opacity: 0.2;
  margin-bottom: 12px;
}
.chat-placeholder p {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--text-dim);
}
.chat-placeholder span {
  font-size: 12px;
  color: var(--text-muted);
}

.msg { margin-bottom: 8px; max-width: 80%; }
.msg.user { margin-left: auto; }
.msg .bubble {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  font-family: var(--font-body);
}
.msg.user .bubble {
  background: rgba(52,211,153,0.08);
  border: 1px solid rgba(52,211,153,0.15);
  color: #d1fae5;
  border-bottom-right-radius: 2px;
}
.msg.assistant .bubble {
  background: rgba(0,212,255,0.05);
  border: 1px solid rgba(0,212,255,0.12);
  color: #dbeafe;
  border-bottom-left-radius: 2px;
}
.msg .time {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 2px;
}
.msg.user .time { text-align: right; }

/* ============ ANIMATIONS ============ */
@keyframes dataLoad {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

.tab { animation: dataLoad 0.4s ease-out; }

/* Flash effect on brain */
@keyframes brainFlash {
  0% { opacity: 1; }
  50% { opacity: 0.3; }
  100% { opacity: 1; }
}

.brain-flash #neural-canvas {
  animation: brainFlash 0.3s ease-out;
}

/* ============ RESPONSIVE ============ */
@media(max-width: 1024px) {
  .dashboard-split {
    grid-template-columns: 1fr;
  }
  .brain-panel {
    max-height: 300px;
  }
  #neural-canvas { min-height: 200px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media(max-width: 768px) {
  header {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 16px;
  }
  nav {
    width: 100%;
    overflow-x: auto;
    order: 3;
    margin-left: 0;
    padding-top: 8px;
  }
  .conversas-layout { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-split { grid-template-columns: 1fr; }
  .brain-panel { max-height: 250px; }
  main { padding: 16px; }
  .login-box { width: 90%; padding: 32px 24px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #333; }
