/* Cortex - Neural Midnight Theme */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Neural Midnight Colors */
  --cortex-bg: #0A0E17;
  --cortex-surface: #141922;
  --cortex-surface-hover: #1C2333;
  --cortex-primary: #00D9FF;
  --cortex-primary-glow: rgba(0, 217, 255, 0.2);
  --cortex-ai: #A855F7;
  --cortex-gradient-ai: linear-gradient(135deg, #A855F7 0%, #00D9FF 100%);
  --cortex-text-primary: #E8EDF5;
  --cortex-text-secondary: #8B95A8;
  --cortex-success: #10B981;
  --cortex-error: #EF4444;
  --cortex-warning: #F59E0B;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--cortex-bg);
  color: var(--cortex-text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
}

code, pre, .tag {
  font-family: 'JetBrains Mono', monospace;
}

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 240px;
  background: var(--cortex-surface);
  border-right: 1px solid rgba(0, 217, 255, 0.1);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.context-panel {
  width: 320px;
  background: var(--cortex-surface);
  border-left: 1px solid rgba(0, 217, 255, 0.1);
  padding: 2rem 1.5rem;
  overflow-y: auto;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--cortex-gradient-ai);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--cortex-gradient-ai);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Navigation */
.nav-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--cortex-text-secondary);
  margin-bottom: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  color: var(--cortex-text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: var(--cortex-surface-hover);
  color: var(--cortex-primary);
}

.nav-item .icon {
  font-size: 1.25rem;
}

/* Capture Button */
.capture-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--cortex-gradient-ai);
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 217, 255, 0.4);
  transition: all 0.3s ease;
  z-index: 1000;
}

.capture-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 32px rgba(0, 217, 255, 0.6);
}

.capture-btn:active {
  transform: scale(0.95);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 14, 23, 0.9);
  backdrop-filter: blur(8px);
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--cortex-surface);
  border-radius: 16px;
  padding: 2rem;
  width: 90%;
  max-width: 600px;
  position: relative;
  border: 2px solid transparent;
  background-clip: padding-box;
  animation: slideUp 0.3s ease;
}

.modal-content::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: var(--cortex-gradient-ai);
  border-radius: 16px;
  z-index: -1;
  opacity: 0.5;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  font-size: 1.5rem;
  color: var(--cortex-text-primary);
}

.close-btn {
  background: none;
  border: none;
  color: var(--cortex-text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.2s ease;
}

.close-btn:hover {
  color: var(--cortex-primary);
}

/* Form */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--cortex-text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group textarea,
.form-group input {
  width: 100%;
  padding: 1rem;
  background: var(--cortex-bg);
  border: 1px solid rgba(0, 217, 255, 0.2);
  border-radius: 8px;
  color: var(--cortex-text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.2s ease;
  resize: vertical;
}

.form-group textarea:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--cortex-primary);
  box-shadow: 0 0 0 3px var(--cortex-primary-glow);
}

.form-group textarea {
  min-height: 120px;
}

.form-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--cortex-gradient-ai);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 217, 255, 0.3);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--cortex-surface-hover);
  color: var(--cortex-text-secondary);
}

.btn-secondary:hover {
  background: var(--cortex-bg);
  color: var(--cortex-text-primary);
}

/* Loading State */
.loading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Thoughts Grid */
.thoughts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.thoughts-header h1 {
  font-size: 2rem;
}

.view-toggle {
  display: flex;
  gap: 0.5rem;
  background: var(--cortex-surface);
  padding: 0.25rem;
  border-radius: 8px;
}

.view-toggle-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  color: var(--cortex-text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.view-toggle-btn.active {
  background: var(--cortex-primary);
  color: white;
}

.thoughts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

/* Thought Card */
.thought-card {
  background: var(--cortex-surface);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid rgba(0, 217, 255, 0.1);
  transition: all 0.3s ease;
  cursor: pointer;
}

.thought-card:hover {
  border-color: var(--cortex-primary);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 217, 255, 0.2);
}

.thought-card.has-ai-insights {
  position: relative;
  overflow: hidden;
}

.thought-card.has-ai-insights::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--cortex-gradient-ai);
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--cortex-ai);
  margin-bottom: 1rem;
}

.thought-content {
  color: var(--cortex-text-primary);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.thought-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.tag {
  padding: 0.25rem 0.75rem;
  background: rgba(0, 217, 255, 0.1);
  border: 1px solid rgba(0, 217, 255, 0.3);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--cortex-primary);
}

.tag.ai-generated {
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.3);
  color: var(--cortex-ai);
}

.thought-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 217, 255, 0.1);
  font-size: 0.75rem;
  color: var(--cortex-text-secondary);
}

.connections-count {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Link Preview */
.link-preview {
  background: var(--cortex-bg);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  border-left: 3px solid var(--cortex-primary);
}

.link-preview-title {
  font-weight: 600;
  color: var(--cortex-primary);
  margin-bottom: 0.5rem;
}

.link-preview-desc {
  font-size: 0.875rem;
  color: var(--cortex-text-secondary);
}

.link-preview-url {
  font-size: 0.75rem;
  color: var(--cortex-text-secondary);
  margin-top: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
}

/* Graph View */
.graph-container {
  background: var(--cortex-surface);
  border-radius: 12px;
  border: 1px solid rgba(0, 217, 255, 0.1);
  height: calc(100vh - 8rem);
  position: relative;
  overflow: hidden;
}

#graph-canvas {
  width: 100%;
  height: 100%;
  cursor: grab;
}

#graph-canvas:active {
  cursor: grabbing;
}

.graph-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
  background: var(--cortex-surface);
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 217, 255, 0.1);
}

.graph-control-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--cortex-bg);
  color: var(--cortex-text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.graph-control-btn:hover {
  background: var(--cortex-surface-hover);
  color: var(--cortex-primary);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--cortex-text-primary);
}

.empty-state p {
  color: var(--cortex-text-secondary);
  margin-bottom: 2rem;
}

/* Status Messages */
.status-message {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.status-message.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--cortex-success);
}

.status-message.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--cortex-error);
}

/* Responsive */
@media (max-width: 1024px) {
  .context-panel {
    display: none;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(0, 217, 255, 0.1);
    padding: 1rem;
  }

  .main-content {
    padding: 1rem;
  }

  .thoughts-grid {
    grid-template-columns: 1fr;
  }

  .capture-btn {
    bottom: 1rem;
    right: 1rem;
    width: 56px;
    height: 56px;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--cortex-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--cortex-surface-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--cortex-primary);
}
