/* Element Info Panel - Detailed technical information display */

/* Info panel container */
.element-info-panel {
  position: absolute; /* Changed to absolute to scroll with page */
  top: auto;
  left: auto;
  width: 350px;
  background: linear-gradient(135deg, #0a0a14 0%, #050508 100%);
  border: 1px solid var(--color-brand-primary);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 
    0 5px 20px rgba(0, 0, 0, 0.8),
    0 0 30px rgba(0, 212, 255, 0.2);
  z-index: 99999; /* Even higher z-index */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
  font-size: 0.85rem;
}

/* Show panel when active */
.element-info-panel-active {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: all !important;
}

/* Panel header */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 212, 255, 0.3);
}

.panel-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-brand-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel-atomic-mass {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  font-weight: 600;
}

/* Properties grid */
.properties-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.property-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

.property-label {
  font-size: 0.7rem;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.8;
  line-height: 1.2;
}

.property-value {
  font-size: 0.9rem;
  color: var(--color-text-primary);
  font-weight: 600;
  line-height: 1.3;
}

.property-value .unit {
  font-size: 0.7rem;
  opacity: 0.7;
  font-weight: normal;
}

.property-value.temp {
  color: #ff6b6b;
}

.property-value.density {
  color: #4ecdc4;
}

.property-value.conductivity {
  color: #ffe66d;
}

.property-value.abundance {
  color: #a8e6cf;
}

.property-value.state {
  color: #c9a8ff;
}

/* Full width properties */
.property-item.full-width {
  grid-column: 1 / -1;
}

/* Badges section */
.element-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 212, 255, 0.3);
}

.element-badge {
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1.2;
}

/* Badge types */
.badge-toxic {
  background: rgba(255, 0, 0, 0.2);
  border: 1px solid #ff0000;
  color: #ff6b6b;
}

.badge-radioactive {
  background: rgba(255, 215, 0, 0.2);
  border: 1px solid #ffd700;
  color: #ffd700;
}

.badge-dangerous {
  background: rgba(255, 107, 0, 0.2);
  border: 1px solid #ff6b00;
  color: #ff9a00;
}

.badge-unstable {
  background: rgba(189, 0, 255, 0.2);
  border: 1px solid #bd00ff;
  color: #d466ff;
}

.badge-noble {
  background: rgba(0, 255, 136, 0.2);
  border: 1px solid #00ff88;
  color: #00ff88;
}

.badge-essential {
  background: rgba(0, 212, 255, 0.2);
  border: 1px solid #00d4ff;
  color: #00d4ff;
}

.badge-synthetic {
  background: rgba(255, 0, 255, 0.2);
  border: 1px solid #ff00ff;
  color: #ff66ff;
}

.badge-rare {
  background: rgba(255, 215, 0, 0.2);
  border: 1px solid #ffd700;
  color: #ffd700;
}

/* Panel actions */
.panel-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 212, 255, 0.3);
}

.panel-btn {
  flex: 1;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(0, 212, 255, 0.05));
  border: 1px solid rgba(0, 212, 255, 0.5);
  border-radius: 4px;
  color: var(--color-brand-primary);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  line-height: 1.3;
}

.panel-btn:hover {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(0, 212, 255, 0.1));
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
  transform: translateY(-2px);
}

.panel-btn.primary {
  background: linear-gradient(135deg, var(--color-brand-primary), var(--color-brand-secondary));
  border-color: var(--color-brand-primary);
  color: #000;
}

.panel-btn.primary:hover {
  box-shadow: 0 0 30px var(--color-brand-primary);
}

/* Close button */
.panel-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1;
}

.panel-close:hover {
  background: rgba(255, 0, 0, 0.2);
  border-color: #ff6b6b;
  color: #ff6b6b;
  transform: rotate(90deg);
}

/* Adjust panel position for edge cases */
@media (max-width: 768px) {
  .element-info-panel {
    width: 300px;
    padding: 14px;
  }
  
  .properties-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* Animation for panel appearance */
@keyframes panel-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.element-info-panel-active {
  animation: panel-fade-in 0.3s ease forwards;
}

/* Loading state */
.panel-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-secondary);
}

.panel-loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-brand-primary);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
  margin-left: 10px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================================
   SMART POSITIONING SYSTEM
   ======================================== */

/* Position-specific classes for smooth animations */
.element-info-panel.position-right {
  transform: translateX(-30px); /* Increased from -20px to -30px for more spacing effect */
}

.element-info-panel.position-left {
  transform: translateX(30px); /* Increased from 20px to 30px for more spacing effect */
}

.element-info-panel.position-below {
  transform: translateY(-25px); /* Increased from -20px to -25px for more spacing effect */
}

.element-info-panel-active.position-right {
  transform: translateX(0) !important;
}

.element-info-panel-active.position-left {
  transform: translateX(0) !important;
}

.element-info-panel-active.position-below {
  transform: translateY(0) !important;
}

/* Enhanced animation transition */
.element-info-panel {
  transition: 
    opacity 0.3s ease,
    visibility 0.3s ease,
    transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Arrow connectors */
.panel-arrow {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 1000;
}

.panel-arrow-left {
  left: -12px;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-right: 12px solid var(--color-brand-primary);
  filter: drop-shadow(-2px 0 4px rgba(0, 212, 255, 0.4));
}

.panel-arrow-right {
  right: -12px;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-left: 12px solid var(--color-brand-primary);
  filter: drop-shadow(2px 0 4px rgba(0, 212, 255, 0.4));
}

.panel-arrow-up {
  top: -12px;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 12px solid var(--color-brand-primary);
  filter: drop-shadow(0 -2px 4px rgba(0, 212, 255, 0.4));
}

.panel-arrow-down {
  bottom: -12px;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 12px solid var(--color-brand-primary);
  filter: drop-shadow(0 2px 4px rgba(0, 212, 255, 0.4));
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
  .element-info-panel.position-below {
    max-width: calc(100vw - 40px);
    margin: 0 20px;
    font-size: 0.9rem;
  }
  
  .panel-header {
    margin-bottom: 12px;
  }
  
  .panel-title {
    font-size: 1.1rem;
  }
  
  .technical-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .panel-actions {
    flex-direction: column;
    gap: 8px;
  }
  
  .panel-btn {
    width: 100%;
  }
}