/* Memory Vector Space Visualization Styles - NewNa.AI Theme */

.memory-vector-container {
  background: #1a1a1a;
  border: 1px solid #6B46C1;
  border-radius: 8px;
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  box-shadow: 0 4px 6px rgba(107, 70, 193, 0.1);
}

.vector-header {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #6B46C1;
}

.vector-header h2 {
  margin: 0;
  font-size: 1.5em;
  color: #e0e0e0;
}

.vector-header p {
  margin: 5px 0 0 0;
  color: #999;
  font-size: 0.9em;
}

/* Controls */
.vector-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: center;
  margin-bottom: 20px;
  padding: 15px;
  background: #0d0d0d;
  border: 1px solid #333;
  border-radius: 8px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #1a1a1a;
  border: 1px solid #6B46C1;
  border-radius: 6px;
}

/* Semantic search input */
.semantic-search-input {
  padding: 6px 12px;
  background: #0d0d0d;
  border: 1px solid #6B46C1;
  color: #e0e0e0;
  border-radius: 4px;
  font-size: 14px;
  width: 250px;
}

.semantic-search-input::placeholder {
  color: #999;
}

.semantic-search-input:focus {
  outline: none;
  border-color: #6B46C1;
  box-shadow: 0 0 0 3px rgba(107, 70, 193, 0.2);
}

.control-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #e0e0e0;
  font-size: 0.9em;
  cursor: pointer;
  user-select: none;
}

.control-group input[type="checkbox"] {
  accent-color: #6B46C1;
}

.control-btn {
  padding: 6px 12px;
  background: #0d0d0d;
  color: #e0e0e0;
  border: 1px solid #6B46C1;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.control-btn:hover {
  background: #6B46C1;
  color: white;
}

.control-btn:active {
  transform: translateY(1px);
}

/* Zoom controls */
#zoom-slider {
  width: 120px;
  accent-color: #6B46C1;
}

.zoom-level {
  color: #e0e0e0;
  font-weight: bold;
  min-width: 80px;
  text-align: center;
}

/* Main visualization area */
.vector-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.vector-graph {
  background: #0d0d0d;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 15px;
}

.vector-graph h3 {
  margin: 0 0 10px 0;
  color: #e0e0e0;
  font-size: 1.1em;
}

#vector-canvas {
  background: #0d0d0d;
  border: 1px solid #6B46C1;
  border-radius: 4px;
  display: block;
  cursor: grab;
}

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

.vector-info {
  margin-top: 10px;
  padding: 10px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  color: #999;
  font-size: 0.9em;
  text-align: center;
}

/* Details panel */
.vector-details {
  background: #0d0d0d;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 15px;
  overflow-y: auto;
  max-height: 500px;
}

#vector-detail-content {
  color: #e0e0e0;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #999;
}

.empty-state p {
  margin: 10px 0;
}

.detail-content {
  animation: fadeIn 0.3s ease;
}

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

.detail-content h3 {
  margin: 0 0 15px 0;
  color: #e0e0e0;
  font-size: 1.2em;
  border-bottom: 2px solid #6B46C1;
  padding-bottom: 10px;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section h4 {
  margin: 0 0 10px 0;
  color: #999;
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.detail-value {
  color: #e0e0e0;
  font-size: 0.95em;
  line-height: 1.5;
}

.observation-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.observation-list li {
  padding: 8px 0;
  border-bottom: 1px solid #333;
  color: #e0e0e0;
}

.observation-list li:last-child {
  border-bottom: none;
}

.observation-list li::before {
  content: '•';
  color: #6B46C1;
  margin-right: 8px;
}

/* Relationship cards */
.relationship-card {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
  transition: all 0.2s;
  cursor: pointer;
}

.relationship-card:hover {
  border-color: #6B46C1;
  transform: translateX(5px);
  box-shadow: 0 2px 8px rgba(107, 70, 193, 0.2);
}

.relationship-type {
  font-size: 0.85em;
  color: #6B46C1;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.relationship-target {
  color: #e0e0e0;
  font-weight: 500;
}

.relationship-metric {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #333;
  font-size: 0.85em;
  color: #999;
}

.metric-label {
  text-transform: uppercase;
  font-size: 0.8em;
}

.metric-value {
  color: #6B46C1;
  font-weight: bold;
}

/* Footer */
.vector-footer {
  background: #0d0d0d;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 15px;
  text-align: center;
}

.vector-footer h3 {
  margin: 0 0 10px 0;
  color: #e0e0e0;
  font-size: 1.1em;
}

.vector-footer p {
  margin: 5px 0;
  color: #999;
  font-size: 0.9em;
  line-height: 1.5;
}

/* Jump buttons */
.jump-btn {
  padding: 6px 12px;
  font-size: 12px;
  min-width: auto;
}

/* Search Results */
.search-results {
  padding: 15px;
}

.search-results h3 {
  margin: 0 0 10px 0;
  color: #e0e0e0;
  font-size: 1.2em;
}

.similar-entities-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.similar-entity {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.similar-entity:hover {
  background: #2a2a2a;
  border-color: #6B46C1;
  transform: translateX(4px);
}

.similarity-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  background: #6B46C1;
  color: white;
  font-weight: bold;
  border-radius: 50%;
  font-size: 0.9em;
}

.entity-info h4 {
  margin: 0 0 4px 0;
  color: #e0e0e0;
  font-size: 1em;
}

.entity-type {
  margin: 0;
  color: #999;
  font-size: 0.85em;
  text-transform: capitalize;
}

.similarity-score {
  margin: 4px 0;
  color: #6B46C1;
  font-weight: 500;
  font-size: 0.9em;
}

.observations {
  margin-top: 8px;
}

.observation {
  margin: 2px 0;
  color: #999;
  font-size: 0.85em;
  line-height: 1.4;
}

/* Scrollbar styling */
.vector-details::-webkit-scrollbar,
.similar-entities-list::-webkit-scrollbar {
  width: 8px;
}

.vector-details::-webkit-scrollbar-track,
.similar-entities-list::-webkit-scrollbar-track {
  background: #0d0d0d;
}

.vector-details::-webkit-scrollbar-thumb,
.similar-entities-list::-webkit-scrollbar-thumb {
  background: #6B46C1;
  border-radius: 4px;
}

.vector-details::-webkit-scrollbar-thumb:hover,
.similar-entities-list::-webkit-scrollbar-thumb:hover {
  background: #8B5CF6;
}

/* Responsive design */
@media (max-width: 768px) {
  .memory-vector-container {
    margin: 10px;
    padding: 15px;
  }
  
  .vector-header {
    padding-bottom: 12px;
    margin-bottom: 15px;
  }
  
  .vector-header h2 {
    font-size: 1.2em;
  }
  
  .vector-header p {
    font-size: 0.85em;
    padding: 0 10px;
  }
  
  .vector-main {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .vector-controls {
    flex-direction: column;
    padding: 12px;
    gap: 10px;
  }
  
  .control-group {
    width: 100%;
    justify-content: space-between;
    padding: 10px 12px;
  }
  
  .semantic-search-input {
    width: 100%;
    font-size: 16px; /* Prevent iOS zoom */
    padding: 10px 12px;
    -webkit-appearance: none;
  }
  
  .control-btn {
    padding: 10px 14px;
    font-size: 14px;
    min-height: 44px; /* iOS touch target */
    min-width: 44px;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Zoom controls mobile */
  #zoom-slider {
    width: 100px;
  }
  
  .zoom-level {
    font-size: 0.85em;
    min-width: 60px;
  }
  
  /* Canvas on mobile */
  #vector-canvas {
    width: 100%;
    height: 400px;
    touch-action: none; /* Enable custom touch handling */
  }
  
  .vector-graph {
    padding: 12px;
  }
  
  .vector-graph h3 {
    font-size: 1em;
    margin-bottom: 8px;
  }
  
  .vector-info {
    font-size: 0.85em;
    padding: 8px;
  }
  
  /* Details panel mobile */
  .vector-details {
    padding: 12px;
    max-height: 400px;
  }
  
  .detail-content h3 {
    font-size: 1.1em;
  }
  
  .detail-section h4 {
    font-size: 0.85em;
  }
  
  .observation-list li {
    padding: 6px 0;
    font-size: 14px;
  }
  
  /* Relationship cards mobile */
  .relationship-card {
    padding: 10px;
    margin-bottom: 8px;
  }
  
  .relationship-metric {
    font-size: 0.8em;
  }
  
  /* Footer mobile */
  .vector-footer {
    padding: 12px;
  }
  
  .vector-footer h3 {
    font-size: 1em;
  }
  
  .vector-footer p {
    font-size: 0.85em;
  }
  
  /* Jump buttons mobile */
  .jump-btn {
    padding: 8px 10px;
    font-size: 11px;
    min-height: 36px;
  }
  
  /* Search results mobile */
  .similar-entities-list {
    max-height: 350px;
  }
  
  .similar-entity {
    padding: 10px;
    gap: 10px;
  }
  
  .similarity-rank {
    min-width: 28px;
    height: 28px;
    font-size: 0.8em;
  }
  
  .entity-info h4 {
    font-size: 0.95em;
  }
  
  .observation {
    font-size: 0.8em;
  }
}

/* iOS-specific optimizations */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari specific */
  .memory-vector-container {
    -webkit-overflow-scrolling: touch;
  }
  
  #vector-canvas {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
  }
  
  .vector-details {
    -webkit-overflow-scrolling: touch;
  }
  
  .similar-entities-list {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Prevent iOS rubber band scrolling on canvas */
  .vector-graph {
    overflow: hidden;
    position: relative;
  }
  
  /* Fix iOS button tap delay */
  .control-btn, .jump-btn {
    touch-action: manipulation;
  }
  
  /* iOS safe areas */
  @supports (padding: max(0px)) {
    .memory-vector-container {
      padding-bottom: max(15px, env(safe-area-inset-bottom));
    }
    
    .vector-controls {
      padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
  }
  
  /* Prevent text selection on controls */
  .control-group label,
  .zoom-level,
  .vector-info {
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  
  /* Fix checkbox styling on iOS */
  input[type="checkbox"] {
    width: 18px;
    height: 18px;
    -webkit-appearance: none;
    appearance: none;
    border: 2px solid #6B46C1;
    border-radius: 3px;
    background: #0d0d0d;
    position: relative;
  }
  
  input[type="checkbox"]:checked {
    background: #6B46C1;
  }
  
  input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: -2px;
    left: 2px;
    color: white;
    font-size: 14px;
  }
}

/* Small mobile (iPhone SE, etc) */
@media (max-width: 375px) {
  .vector-header h2 {
    font-size: 1.1em;
  }
  
  .control-btn {
    padding: 8px 10px;
    font-size: 13px;
    min-height: 40px;
  }
  
  #vector-canvas {
    height: 350px;
  }
  
  .vector-details {
    max-height: 350px;
  }
  
  .control-group {
    padding: 8px 10px;
  }
  
  .semantic-search-input {
    padding: 8px 10px;
  }
}

/* Landscape orientation fixes */
@media (max-width: 768px) and (orientation: landscape) {
  #vector-canvas {
    height: 300px;
  }
  
  .vector-details {
    max-height: 300px;
  }
  
  .vector-main {
    grid-template-columns: 1fr 1fr;
  }
}