/* ═══════════════════════════════════════════════════════════
   AI RADAR — FRANGLLE.PL
   Dark research lab aesthetic
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --bg:        #04080F;
  --bg2:       #080E1A;
  --bg3:       #0D1525;
  --surface:   #111927;
  --surface2:  #18253A;
  --border:    #1E2E44;
  --border2:   #263B58;
  --text:      #D8E8F8;
  --text2:     #7A9AB8;
  --text3:     #4A6A88;
  --accent:    #00D4FF;
  --accent2:   #FF6B35;
  --accent3:   #7C5CFC;

  /* Category colors */
  --c-fundamentals:  #00D4FF;
  --c-architecture:  #7C5CFC;
  --c-capabilities:  #00E5B4;
  --c-deployment:    #FFB547;
  --c-research:      #FF6B35;

  /* Maturity */
  --m-production:  #00E5B4;
  --m-emerging:    #FFB547;
  --m-research:    #FF6B35;

  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'Space Mono', monospace;

  --topbar-h: 52px;
  --filter-h: 40px;
  --panel-w:  340px;
  --radius:   8px;
  --radius-lg: 12px;
}

/* ─── LIGHT THEME ─────────────────────────────────────────── */
[data-theme="light"] {
  --bg:      #F0F4F8; --bg2: #FFFFFF; --bg3: #E8EDF3;
  --surface: #FFFFFF; --surface2: #F0F4F8;
  --border:  #C8D5E3; --border2: #A0B4C8;
  --text:    #1A2A3A; --text2: #3A5068; --text3: #7A96AA;
}
[data-theme="light"] #graph-container {
  background-image:
    radial-gradient(ellipse 80% 50% at 20% 30%, rgba(0,120,200,.04) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 70%, rgba(100,60,220,.04) 0%, transparent 70%),
    linear-gradient(rgba(160,180,200,.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(160,180,200,.3) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 48px 48px, 48px 48px;
}
[data-theme="light"] .node-label { stroke: #F0F4F8; }
[data-theme="light"] .node-sub   { stroke: #F0F4F8; }
[data-theme="light"] #legend     { background: rgba(240,244,248,.92); }
[data-theme="light"] #minimap    { background: rgba(240,244,248,.85); }

/* Theme + lang toggle buttons */
.topbar-controls { display: flex; align-items: center; gap: 6px; }
.ctrl-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 5px; padding: 0 9px; height: 26px;
  color: var(--text2); font-family: var(--font-mono); font-size: 11px;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.ctrl-btn:hover { border-color: var(--accent); color: var(--accent); }

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

/* ─── TOPBAR ─────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: relative;
  z-index: 100;
}

.topbar-left { flex: 0 0 auto; }
.topbar-center { flex: 1; max-width: 480px; margin: 0 auto; }
.topbar-right { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; }

.logo { display: flex; align-items: center; gap: 8px; }
.logo-mark { font-size: 20px; color: var(--accent); line-height: 1; }
.logo-text { font-family: var(--font-display); font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.logo-accent { color: var(--accent); }
.logo-by { font-family: var(--font-mono); font-size: 10px; color: var(--text3); letter-spacing: .05em; margin-top: 1px; }

.search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0 10px; height: 32px;
  transition: border-color .15s;
}
.search-wrap:focus-within { border-color: var(--accent); }
.search-icon { color: var(--text3); font-size: 16px; }
.search-wrap input {
  background: none; border: none; outline: none;
  color: var(--text); font-family: var(--font-body); font-size: 13px;
  flex: 1; width: 100%;
}
.search-wrap input::placeholder { color: var(--text3); }
.search-wrap kbd {
  font-family: var(--font-mono); font-size: 10px; color: var(--text3);
  border: 1px solid var(--border); border-radius: 3px; padding: 1px 4px;
}

.status-pill {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; color: var(--text3);
}
.pulse-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text3);
  transition: background .3s;
}
.pulse-dot.live {
  background: var(--accent);
  animation: pulse-live 2s ease-in-out infinite;
}
.pulse-dot.scanning { background: var(--accent2); animation: pulse-live .8s ease-in-out infinite; }
@keyframes pulse-live {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 currentColor; }
  50% { opacity: .7; box-shadow: 0 0 0 4px transparent; }
}

.stats-mini { font-family: var(--font-mono); font-size: 11px; color: var(--text3); }

.btn-scan {
  display: flex; align-items: center; gap: 5px;
  background: transparent; border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 0 10px; height: 28px;
  color: var(--text2); font-family: var(--font-mono); font-size: 11px;
  cursor: pointer; transition: all .15s;
}
.btn-scan:hover { border-color: var(--accent); color: var(--accent); }
.btn-scan.scanning span { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── FILTER BAR ─────────────────────────────────────────── */
#filter-bar {
  height: var(--filter-h);
  background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 16px; gap: 6px;
  overflow-x: auto; white-space: nowrap;
}
#filter-bar::-webkit-scrollbar { display: none; }

.filter-btn {
  display: flex; align-items: center; gap: 5px;
  background: none; border: 1px solid transparent;
  border-radius: 5px; padding: 0 10px; height: 26px;
  color: var(--text2); font-size: 12px; cursor: pointer;
  font-family: var(--font-body); transition: all .15s; white-space: nowrap;
}
.filter-btn:hover { border-color: var(--border2); color: var(--text); }
.filter-btn.active { border-color: var(--border2); background: var(--surface); color: var(--text); }
.cat-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.filter-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex-shrink: 0; }

.filter-toggle {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text2); cursor: pointer; white-space: nowrap;
}
.filter-toggle input { accent-color: var(--accent); }

.view-switcher {
  margin-left: auto; display: flex;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 5px; overflow: hidden;
}
.view-btn {
  background: none; border: none; padding: 0 10px; height: 24px;
  color: var(--text3); font-size: 11px; cursor: pointer; font-family: var(--font-mono);
  transition: all .15s;
}
.view-btn.active { background: var(--surface); color: var(--text); }

/* ─── MAIN LAYOUT ───────────────────────────────────────── */
#main {
  display: flex;
  height: calc(100vh - var(--topbar-h) - var(--filter-h));
  overflow: hidden;
}

/* ─── GRAPH ─────────────────────────────────────────────── */
#graph-container {
  flex: 1; position: relative; overflow: hidden;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 20% 30%, rgba(0,212,255,.03) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 70%, rgba(124,92,252,.03) 0%, transparent 70%),
    linear-gradient(rgba(30,46,68,.4) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30,46,68,.4) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 48px 48px, 48px 48px;
}

#graph-svg { width: 100%; height: 100%; cursor: grab; }
#graph-svg:active { cursor: grabbing; }

/* SVG Styles */
.node-group { cursor: pointer; }
.node-circle {
  stroke-width: 1.5;
  transition: filter .2s;
}
.node-group:hover .node-circle { filter: brightness(1.4); }
.node-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  fill: var(--text);
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.node-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--text3);
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 3px;
}
.link-line {
  stroke: var(--border2);
  stroke-opacity: .5;
  stroke-width: 1;
  fill: none;
}
.link-line.highlighted { stroke-opacity: 1; stroke-width: 2; }

.node-pulse {
  animation: node-pulse-anim 2s ease-out infinite;
  pointer-events: none;
}
@keyframes node-pulse-anim {
  0% { transform: scale(1); opacity: .6; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* Tooltip */
#graph-tooltip {
  position: absolute; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 10px 12px;
  font-size: 12px; max-width: 220px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  transition: opacity .1s;
}
#graph-tooltip.hidden { opacity: 0; }
.tt-title { font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--text); }
.tt-sub { color: var(--text3); font-family: var(--font-mono); font-size: 10px; margin-top: 2px; }
.tt-cat { font-size: 10px; margin-top: 6px; opacity: .8; }
.tt-papers { font-family: var(--font-mono); font-size: 10px; color: var(--accent); margin-top: 4px; }

/* Zoom controls */
#zoom-controls {
  position: absolute; bottom: 20px; right: 16px;
  display: flex; flex-direction: column; gap: 2px;
}
#zoom-controls button {
  width: 28px; height: 28px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: 5px; color: var(--text2); cursor: pointer;
  font-size: 16px; line-height: 1; font-family: var(--font-mono);
  transition: all .15s;
}
#zoom-controls button:hover { border-color: var(--accent); color: var(--accent); }

/* Legend */
#legend {
  position: absolute; bottom: 20px; left: 16px;
  background: rgba(8,14,26,.8); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
  font-size: 11px; backdrop-filter: blur(8px);
}
.legend-title { font-family: var(--font-mono); font-size: 9px; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.legend-item { display: flex; align-items: center; gap: 7px; color: var(--text2); margin-bottom: 4px; }
.legend-ring {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--c); background: transparent;
}
.legend-sep { height: 1px; background: var(--border); margin: 6px 0; }

/* Minimap */
#minimap {
  position: absolute; top: 16px; right: 16px;
  width: 120px; height: 80px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: rgba(8,14,26,.7); opacity: .7;
  pointer-events: none;
}

/* ─── RIGHT PANEL ───────────────────────────────────────── */
#right-panel {
  width: var(--panel-w); flex-shrink: 0;
  background: var(--bg2); border-left: 1px solid var(--border);
  overflow-y: auto; display: flex; flex-direction: column;
}
#right-panel::-webkit-scrollbar { width: 4px; }
#right-panel::-webkit-scrollbar-track { background: transparent; }
#right-panel::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.panel-section { padding: 16px; }
.panel-section-head {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--font-display); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: var(--text3);
  margin-bottom: 12px;
}
.panel-icon { color: var(--accent); }

/* Node detail panel */
.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.panel-back {
  font-family: var(--font-mono); font-size: 11px; color: var(--text3);
  cursor: pointer; transition: color .15s;
}
.panel-back:hover { color: var(--accent); }
.node-badge {
  font-family: var(--font-mono); font-size: 10px; padding: 2px 8px;
  border-radius: 20px; font-weight: 400;
  text-transform: uppercase; letter-spacing: .06em;
}

#node-detail h2 {
  font-family: var(--font-display); font-size: 20px; font-weight: 800;
  letter-spacing: -.02em; line-height: 1.2; margin-bottom: 4px;
}
.detail-subtitle {
  font-family: var(--font-mono); font-size: 11px; color: var(--text3);
  margin-bottom: 10px;
}
.maturity-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.maturity-label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
}
.detail-year { font-family: var(--font-mono); font-size: 10px; color: var(--text3); }

.detail-desc { color: var(--text2); font-size: 13px; line-height: 1.65; margin-bottom: 14px; }

details.detail-more {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; margin-bottom: 14px;
}
details.detail-more summary {
  font-family: var(--font-mono); font-size: 11px; color: var(--text3);
  cursor: pointer; list-style: none;
}
details.detail-more p { font-size: 12px; color: var(--text2); margin-top: 8px; line-height: 1.65; }

.detail-section { margin-bottom: 16px; }
.detail-section h4 {
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text3); margin-bottom: 7px;
}

.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  font-family: var(--font-mono); font-size: 10px; padding: 2px 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text2);
}
.app-tag {
  font-size: 11px; padding: 3px 9px;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 5px; color: var(--text);
}

/* Papers list */
.papers-list { display: flex; flex-direction: column; gap: 8px; }
.paper-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 11px;
  cursor: pointer; transition: border-color .15s;
}
.paper-card:hover { border-color: var(--border2); }
.paper-title { font-size: 12px; font-weight: 500; color: var(--text); line-height: 1.4; margin-bottom: 5px; }
.paper-summary { font-size: 11px; color: var(--text3); line-height: 1.5; margin-bottom: 6px; }
.paper-meta {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 10px; color: var(--text3);
}
.paper-source { padding: 1px 5px; border-radius: 3px; font-size: 9px; }
.src-arxiv { background: rgba(255,107,53,.15); color: #FF8C6A; }
.src-huggingface { background: rgba(255,181,71,.15); color: #FFB547; }
.src-paperswithcode { background: rgba(0,229,180,.15); color: #00E5B4; }
.src-semanticscholar { background: rgba(124,92,252,.15); color: #9B7FFC; }
.src-openai { background: rgba(16,163,127,.15); color: #10A37F; }
.src-anthropic { background: rgba(205,149,95,.15); color: #CD956F; }
.src-deepmind { background: rgba(66,133,244,.15); color: #4285F4; }
.src-meta-ai { background: rgba(24,119,242,.15); color: #1877F2; }
.src-huggingface-blog { background: rgba(255,181,71,.15); color: #FFB547; }
.src-google-ai { background: rgba(66,133,244,.15); color: #4285F4; }
.loading-papers { font-family: var(--font-mono); font-size: 11px; color: var(--text3); }

/* Activity Feed */
.activity-feed { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.activity-feed::-webkit-scrollbar { width: 3px; }
.activity-feed::-webkit-scrollbar-thumb { background: var(--border2); }
.activity-item {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 6px 8px; border-radius: var(--radius);
  background: var(--bg3); border: 1px solid var(--border);
  font-size: 11px;
}
.activity-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.activity-text { color: var(--text2); line-height: 1.4; flex: 1; }
.activity-text strong { color: var(--text); font-weight: 500; }
.activity-time { font-family: var(--font-mono); font-size: 9px; color: var(--text3); flex-shrink: 0; margin-top: 2px; }
.feed-loading { font-family: var(--font-mono); font-size: 11px; color: var(--text3); }

/* Stats */
.stats-panel { display: flex; flex-direction: column; gap: 6px; }
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px;
}
.stat-label { color: var(--text3); }
.stat-val { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.sources-breakdown { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.source-chip {
  font-family: var(--font-mono); font-size: 10px; padding: 2px 7px;
  border-radius: 4px; border: 1px solid var(--border);
}

/* Hot nodes */
.hot-nodes { display: flex; flex-direction: column; gap: 5px; }
.hot-node {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border-radius: var(--radius);
  background: var(--bg3); border: 1px solid var(--border);
  cursor: pointer; transition: border-color .15s;
}
.hot-node:hover { border-color: var(--border2); }
.hot-node-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.hot-node-name { font-size: 12px; font-weight: 500; flex: 1; }
.hot-node-count { font-family: var(--font-mono); font-size: 10px; color: var(--text3); }

/* ─── GRID VIEW ─────────────────────────────────────────── */
#grid-container {
  flex: 1; overflow-y: auto; padding: 20px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px;
  align-content: start;
}
.grid-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px;
  cursor: pointer; transition: all .15s;
}
.grid-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.grid-card-header { display: flex; justify-content: space-between; margin-bottom: 8px; }
.grid-card-title { font-family: var(--font-display); font-size: 14px; font-weight: 700; }
.grid-card-sub { font-family: var(--font-mono); font-size: 10px; color: var(--text3); margin-bottom: 8px; }
.grid-card-desc { font-size: 12px; color: var(--text2); line-height: 1.5; }

/* ─── MODAL ─────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(4,8,15,.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }
.modal-inner {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); padding: 24px;
  max-width: 580px; width: 90%; max-height: 80vh; overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; color: var(--text3); font-size: 16px;
  cursor: pointer; padding: 4px 8px; transition: color .15s;
}
.modal-close:hover { color: var(--text); }
.modal-source {
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .1em; margin-bottom: 10px; padding: 2px 8px;
  display: inline-block; border-radius: 4px;
}
.modal-inner h3 {
  font-family: var(--font-display); font-size: 18px; font-weight: 700;
  line-height: 1.3; margin-bottom: 8px;
}
.modal-authors { font-size: 12px; color: var(--text3); margin-bottom: 4px; }
.modal-date { font-family: var(--font-mono); font-size: 11px; color: var(--text3); margin-bottom: 14px; }
.modal-summary {
  background: var(--bg3); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 13px; color: var(--text); line-height: 1.65; margin-bottom: 14px;
}
.modal-abstract details { margin-bottom: 14px; }
.modal-abstract summary { font-family: var(--font-mono); font-size: 11px; color: var(--text3); cursor: pointer; }
.modal-abstract p { font-size: 12px; color: var(--text2); margin-top: 8px; line-height: 1.65; }
.modal-actions { display: flex; gap: 10px; }
.btn-paper {
  display: inline-flex; align-items: center; padding: 8px 16px;
  background: var(--accent); color: var(--bg); border-radius: var(--radius);
  text-decoration: none; font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  transition: opacity .15s;
}
.btn-paper:hover { opacity: .85; }
.btn-paper-outline {
  display: inline-flex; align-items: center; padding: 8px 16px;
  background: transparent; color: var(--text2);
  border: 1px solid var(--border2); border-radius: var(--radius);
  text-decoration: none; font-family: var(--font-mono); font-size: 12px;
  transition: border-color .15s;
}
.btn-paper-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ─── UTILITIES ─────────────────────────────────────────── */
.hidden { display: none !important; }

/* Scrollbar global */
* { scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }

/* Selection highlight ring on graph */
.node-selected .node-circle {
  filter: drop-shadow(0 0 8px currentColor) brightness(1.3) !important;
}

@media (max-width: 768px) {
  :root { --panel-w: 0px; }
  #right-panel { display: none; }
}
