/* css/graph.css — Graph page styles */

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --primary: #00ff88;
  --secondary: #00e5ff;
  --accent: #a855f7;
  --warning: #ff6b35;
  --text: #ffffff;
  --text-secondary: #8b8b9a;
  --border: #1e1e2e;
}

body.graph-page {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  overflow: hidden;
}

/* Nav */
.graph-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.graph-nav-left, .graph-nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.graph-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 18px;
}

.logo-icon {
  font-size: 24px;
  color: var(--primary);
}

.graph-badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

/* Search */
.graph-search-container {
  position: relative;
  width: 300px;
}

.graph-search {
  width: 100%;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.15s;
}

.graph-search:focus {
  border-color: var(--primary);
}

.graph-search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.search-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.1s;
}

.search-result:hover {
  background: rgba(0,255,136,0.1);
}

.result-label {
  flex: 1;
  font-size: 13px;
  color: var(--text);
}

.result-type {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.search-no-results {
  padding: 12px 14px;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

/* View toggle */
.view-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.view-btn {
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}

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

.view-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Graph buttons */
.graph-btn {
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}

.graph-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.graph-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.graph-btn.primary {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
  font-weight: 600;
}

.graph-btn.primary:hover {
  background: #00cc6e;
}

/* Layout */
.graph-layout {
  display: flex;
  height: calc(100vh - 56px);
}

/* Sidebar */
.graph-sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  flex-shrink: 0;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.filter-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.filter-checkbox input {
  accent-color: var(--primary);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.small {
  width: 10px;
  height: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* Graph Stats */
.graph-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.stat-label {
  color: var(--text-secondary);
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  font-weight: 600;
}

/* Weight slider */
.weight-slider {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

.weight-value {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

/* Depth selector */
.depth-selector {
  display: flex;
  gap: 6px;
}

.depth-btn {
  flex: 1;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.depth-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.depth-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* Canvas */
.graph-canvas-container {
  flex: 1;
  position: relative;
  background: var(--bg);
  background-image: radial-gradient(circle at 1px 1px, #1a1a2a 1px, transparent 0);
  background-size: 32px 32px;
}

.graph-canvas {
  width: 100%;
  height: 100%;
}

.graph-loading {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(10,10,15,0.85);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  font-size: 14px;
  color: var(--text-secondary);
  z-index: 50;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.graph-controls-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(18,18,26,0.8);
  padding: 6px 12px;
  border-radius: 6px;
  pointer-events: none;
}

/* Node Detail Panel */
.node-panel {
  width: 280px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
  flex-shrink: 0;
  position: relative;
  animation: slideIn 0.2s ease;
}

.node-panel.hidden {
  display: none;
}

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.node-panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.node-panel-close:hover {
  color: var(--text);
}

.node-type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fff;
  margin-bottom: 8px;
}

.node-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
  word-break: break-word;
}

.node-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 16px;
}

.node-panel-meta {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.node-panel-connections h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin: 0 0 10px;
  font-weight: 700;
}

.connections-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.connection-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.connection-type {
  flex: 1;
  color: var(--text);
}

.connection-count {
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.node-panel-actions {
  display: flex;
  gap: 8px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  animation: toast-in 0.3s ease forwards;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.toast-error {
  border-color: var(--warning);
  color: var(--warning);
}

.toast-success {
  border-color: var(--primary);
  color: var(--primary);
}

@keyframes toast-in {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Edge type styles for Cytoscape */
.edge.highlighted {
  opacity: 1 !important;
  line-color: #00ff88 !important;
}

/* Edge hover tooltip */
.cytoscape-edgehandles-hover {
  background-color: var(--primary) !important;
}

/* AI Studies sidebar */
.ai-studies-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-study-item {
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg);
  transition: background 0.1s;
}

.ai-study-item:hover {
  background: rgba(255,255,255,0.05);
}

.ai-study-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.ai-study-label {
  color: var(--text);
  font-weight: 600;
}

.ai-study-count {
  color: var(--text-secondary);
  font-size: 10px;
}

.ai-study-entities {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.ai-study-entities.hidden {
  display: none;
}

.ai-entity-chip {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid;
  color: var(--text);
  background: transparent;
}

.sidebar-empty {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  padding: 8px 0;
}

.sidebar-loading {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .graph-layout {
    flex-direction: column;
  }

  .graph-sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 50vh;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 200;
    transform: translateY(calc(100% - 48px));
    transition: transform 0.3s ease;
    overflow-y: auto;
  }

  .graph-sidebar.expanded {
    transform: translateY(0);
  }

  .graph-sidebar .sidebar-section {
    margin-bottom: 12px;
    padding: 0 16px;
  }

  /* Mobile sidebar toggle handle */
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
  }

  .sidebar-toggle::before {
    content: '⋯ Filters';
    font-size: 14px;
  }

  .graph-sidebar.expanded .sidebar-toggle::before {
    content: '▼ Close';
  }

  .node-panel {
    width: 100%;
    height: 50vh;
    border-left: none;
    border-top: 1px solid var(--border);
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 150;
  }

  .node-panel.hidden {
    transform: translateY(100%);
  }

  .graph-nav {
    padding: 0 12px;
  }

  .graph-nav-center {
    flex: 1;
    display: flex;
    justify-content: center;
  }

  .graph-search-container {
    width: 100%;
    max-width: 200px;
  }

  .view-toggle {
    display: none; /* Hide view toggle on mobile, use single tap */
  }

  .graph-canvas-container {
    height: calc(100vh - 56px);
  }

  .graph-controls-hint {
    display: none;
  }
}
