.breadcrumb-demo {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 270px;
  border-radius: 16px;
  padding: 30px;
  color: white;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.demo-content {
  text-align: center;
  margin-bottom: 30px;
}
.demo-content h2 {
  margin: 0 0 12px 0;
  font-size: 24px;
  font-weight: 700;
}
.demo-content p {
  margin: 0 0 20px 0;
  opacity: 0.9;
  line-height: 1.6;
}
.demo-scenarios h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
}
.scenario-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.scenario-btn {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  color: white;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}
.scenario-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}
.breadcrumb-container {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}
.breadcrumb-nav {
  margin-bottom: 16px;
}
.breadcrumb {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.breadcrumb-item {
  display: flex;
  align-items: center;
  font-size: 14px;
}
.breadcrumb-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  text-decoration: none;
  color: #4a5568;
  border-radius: 6px;
  transition: all 0.3s ease;
  position: relative;
}
.breadcrumb-link:hover {
  background: #f7fafc;
  color: #2d3748;
  transform: translateY(-1px);
}
.breadcrumb-link:active {
  transform: translateY(0);
}
.breadcrumb-icon {
  font-size: 16px;
}
.breadcrumb-text {
  font-weight: 500;
}
.breadcrumb-separator {
  color: #a0aec0;
  margin: 0 8px;
  font-size: 16px;
  user-select: none;
}
.breadcrumb-current {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  color: #2d3748;
  font-weight: 600;
  background: #ebf8ff;
  border-radius: 6px;
  border: 2px solid #3182ce;
}
.breadcrumb-actions {
  display: flex;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}
.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #4a5568;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}
.action-btn:hover {
  background: #edf2f7;
  border-color: #cbd5e0;
  transform: translateY(-1px);
}
.action-icon {
  font-size: 14px;
}
.breadcrumb-info {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.info-label {
  font-size: 12px;
  opacity: 0.8;
  font-weight: 500;
}
.info-value {
  font-size: 14px;
  font-weight: 600;
}
/* Hover effects for breadcrumb items */
.breadcrumb-link::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}
.breadcrumb-link:hover::before {
  opacity: 0.1;
}
/* Animation for new breadcrumb items */
.breadcrumb-item.new {
  animation: slideIn 0.3s ease;
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
/* Responsive design */
@media (max-width: 768px) {
  .breadcrumb-demo {
    padding: 20px;
  }
  
  .breadcrumb {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .breadcrumb-item {
    width: 100%;
  }
  
  .breadcrumb-separator {
    display: none;
  }
  
  .breadcrumb-item:not(:first-child) {
    padding-left: 20px;
    position: relative;
  }
  
  .breadcrumb-item:not(:first-child)::before {
    content: 'β³';
    position: absolute;
    left: 0;
    color: #a0aec0;
    font-size: 16px;
  }
  
  .scenario-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .scenario-btn {
    width: 120px;
  }
  
  .breadcrumb-actions {
    flex-direction: column;
  }
  
  .action-btn {
    justify-content: center;
  }
  
  .breadcrumb-info {
    flex-direction: column;
    gap: 12px;
  }
}
/* Focus styles for accessibility */
.breadcrumb-link:focus,
.action-btn:focus,
.scenario-btn:focus {
  outline: 2px solid #3182ce;
  outline-offset: 2px;
}
/* Loading state */
.breadcrumb.loading {
  opacity: 0.6;
  pointer-events: none;
}
.breadcrumb.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top: 2px solid #3182ce;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  transform: translate(-50%, -50%);
}
@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}
     document.addEventListener('DOMContentLoaded', function() {
  const breadcrumbList = document.getElementById('breadcrumbList');
  const currentPath = document.getElementById('currentPath');
  const depthLevel = document.getElementById('depthLevel');
  const copyPathBtn = document.getElementById('copyPath');
  const sharePathBtn = document.getElementById('sharePath');
  const scenarioButtons = document.querySelectorAll('.scenario-btn');
  
  // Breadcrumb scenarios
  const scenarios = {
    home: [
      { icon: 'π ', text: 'Home', page: 'home', current: true }
    ],
    category: [
      { icon: 'π ', text: 'Home', page: 'home' },
      { icon: 'π¦', text: 'Products', page: 'products', current: true }
    ],
    product: [
      { icon: 'π ', text: 'Home', page: 'home' },
      { icon: 'π¦', text: 'Products', page: 'products' },
      { icon: 'π»', text: 'Electronics', page: 'electronics' },
      { icon: 'π±', text: 'Smartphones', page: 'smartphones', current: true }
    ],
    deep: [
      { icon: 'π ', text: 'Home', page: 'home' },
      { icon: 'π¦', text: 'Products', page: 'products' },
      { icon: 'π»', text: 'Electronics', page: 'electronics' },
      { icon: 'π±', text: 'Smartphones', page: 'smartphones' },
      { icon: 'π', text: 'Apple', page: 'apple' },
      { icon: 'π²', text: 'iPhone 15 Pro', page: 'iphone-15-pro', current: true }
    ]
  };
  
  // Render breadcrumb
  function renderBreadcrumb(items) {
    breadcrumbList.innerHTML = '';
    
    items.forEach((item, index) => {
      const li = document.createElement('li');
      li.className = 'breadcrumb-item';
      
      if (item.current) {
        li.classList.add('current');
        li.setAttribute('aria-current', 'page');
      }
      
      let content = '';
      
      // Add separator for non-first items
      if (index > 0) {
        content += '<span class="breadcrumb-separator">βΊ</span>';
      }
      
      if (item.current) {
        content += `
          <span class="breadcrumb-current">
            <span class="breadcrumb-icon">${item.icon}</span>
            <span class="breadcrumb-text">${item.text}</span>
          </span>
        `;
      } else {
        content += `
          <a href="#" class="breadcrumb-link" data-page="${item.page}">
            <span class="breadcrumb-icon">${item.icon}</span>
            <span class="breadcrumb-text">${item.text}</span>
          </a>
        `;
      }
      
      li.innerHTML = content;
      li.classList.add('new');
      breadcrumbList.appendChild(li);
      
      // Remove animation class after animation completes
      setTimeout(() => {
        li.classList.remove('new');
      }, 300);
    });
    
    // Update path info
    updatePathInfo(items);
    
    // Add click handlers to new links
    addBreadcrumbClickHandlers();
  }
  
  // Update path information
  function updatePathInfo(items) {
    const pathText = items.map(item => item.text).join(' βΊ ');
    currentPath.textContent = pathText;
    depthLevel.textContent = items.length;
  }
  
  // Add click handlers to breadcrumb links
  function addBreadcrumbClickHandlers() {
    const breadcrumbLinks = document.querySelectorAll('.breadcrumb-link');
    
    breadcrumbLinks.forEach(link => {
      link.addEventListener('click', function(e) {
        e.preventDefault();
        
        const page = this.getAttribute('data-page');
        const text = this.querySelector('.breadcrumb-text').textContent;
        
        // Add loading state
        breadcrumbList.classList.add('loading');
        
        // Simulate navigation delay
        setTimeout(() => {
          breadcrumbList.classList.remove('loading');
          showFeedback(`Navigated to: ${text}`);
        }, 500);
      });
    });
  }
  
  // Scenario button handlers
  scenarioButtons.forEach(button => {
    button.addEventListener('click', function() {
      const scenario = this.getAttribute('data-scenario');
      const items = scenarios[scenario];
      
      // Update active scenario button
      scenarioButtons.forEach(btn => btn.classList.remove('active'));
      this.classList.add('active');
      
      // Render new breadcrumb
      renderBreadcrumb(items);
      
      showFeedback(`Switched to: ${this.textContent}`);
    });
  });
  
  // Copy path functionality
  copyPathBtn.addEventListener('click', function() {
    const pathText = currentPath.textContent;
    
    if (navigator.clipboard) {
      navigator.clipboard.writeText(pathText).then(() => {
        showFeedback('Path copied to clipboard!');
        this.style.background = '#d4edda';
        this.style.borderColor = '#c3e6cb';
        
        setTimeout(() => {
          this.style.background = '';
          this.style.borderColor = '';
        }, 1000);
      });
    } else {
      // Fallback for older browsers
      const textArea = document.createElement('textarea');
      textArea.value = pathText;
      document.body.appendChild(textArea);
      textArea.select();
      document.execCommand('copy');
      document.body.removeChild(textArea);
      showFeedback('Path copied to clipboard!');
    }
  });
  
  // Share path functionality
  sharePathBtn.addEventListener('click', function() {
    const pathText = currentPath.textContent;
    const url = window.location.href;
    
    if (navigator.share) {
      navigator.share({
        title: 'Current Page Path',
        text: pathText,
        url: url
      }).then(() => {
        showFeedback('Path shared successfully!');
      }).catch(() => {
        fallbackShare(pathText, url);
      });
    } else {
      fallbackShare(pathText, url);
    }
  });
  
  function fallbackShare(pathText, url) {
    const shareText = `Current path: ${pathText}\nURL: ${url}`;
    
    if (navigator.clipboard) {
      navigator.clipboard.writeText(shareText).then(() => {
        showFeedback('Share text copied to clipboard!');
      });
    } else {
      showFeedback('Share functionality not available');
    }
  }
  
  // Keyboard navigation
  document.addEventListener('keydown', function(e) {
    if (e.ctrlKey || e.metaKey) {
      switch(e.key) {
        case 'c':
          if (e.target.closest('.breadcrumb-container')) {
            e.preventDefault();
            copyPathBtn.click();
          }
          break;
        case 's':
          if (e.target.closest('.breadcrumb-container')) {
            e.preventDefault();
            sharePathBtn.click();
          }
          break;
      }
    }
  });
  
  // Feedback function
  function showFeedback(message) {
    const existing = document.querySelector('.demo-feedback');
    if (existing) existing.remove();
    
    const feedback = document.createElement('div');
    feedback.className = 'demo-feedback';
    feedback.textContent = message;
    feedback.style.cssText = `
      position: fixed;
      top: 20px;
      left: 50%;
      transform: translateX(-50%);
      background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
      color: white;
      padding: 12px 20px;
      border-radius: 8px;
      font-size: 14px;
      font-weight: 500;
      z-index: 10001;
      box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3);
      opacity: 0;
      transition: opacity 0.3s ease;
    `;
    
    document.body.appendChild(feedback);
    
    requestAnimationFrame(() => {
      feedback.style.opacity = '1';
    });
    
    setTimeout(() => {
      feedback.style.opacity = '0';
      setTimeout(() => feedback.remove(), 300);
    }, 2500);
  }
  
  // Initialize with default scenario
  scenarioButtons[2].click(); // Start with product scenario
  
  // Initial feedback
  setTimeout(() => {
    showFeedback('Try different scenarios and click breadcrumb items!');
  }, 1000);
  
  // Add initial click handlers
  addBreadcrumbClickHandlers();
});