/* Quantum Field Kit - Modern CSS Styles
 * A comprehensive styling system for the quantum simulation web interface
 */
/* =====================
   Base Styles
   ===================== */
   :root {
    /* Color Palette */
    --primary: #3c56b0;
    --primary-dark: #273875;
    --primary-light: #6d83d3;
    --secondary: #2e3047;
    --accent: #7c3aed;
    --success: #10b981;
    --info: #3b82f6;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #111827;
    --gray-dark: #1f2937;
    --gray-medium: #6b7280;
    --gray-light: #e5e7eb;
    --light: #f9fafb;
    
    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-mono: 'Space Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2.5rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Borders */
    --border-radius-sm: 0.25rem;
    --border-radius-md: 0.375rem;
    --border-radius-lg: 0.5rem;
    --border-radius-xl: 0.75rem;
    --border-radius-full: 9999px;
  }
  
  body {
    font-family: var(--font-primary);
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
    padding-top: 56px;
  }
  
  main {
    flex-grow: 1;
  }
  
  a {
    text-decoration: none;
    transition: color 0.3s ease;
  }
  
  a:hover {
    text-decoration: none;
  }
  
  pre, code {
    font-family: var(--font-mono);
  }
  
  /* Typography enhancements */
  h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
  }
  
  .lead {
    font-weight: 300;
  }
  
  .text-gradient {
    background: linear-gradient(45deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent; /* Fallback */
  }
  
  /* =====================
     Navigation - FIXED HEADER
     ===================== */
  #mainNav {
    transition: background-color 0.3s ease;
    background-color: var(--dark);
    box-shadow: var(--shadow-md);
    z-index: 1030; /* Ensure navbar is above other content */
    padding: 0.5rem 1rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
  }
  
  #mainNav.scrolled {
    background-color: var(--dark);
  }
  
  /* Brand styling */
  #mainNav .navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
  }
  
  #mainNav .navbar-brand i {
    font-size: 1.5rem;
    margin-right: 0.5rem;
  }
  
  /* Navbar structure fix */
  #mainNav .navbar-nav {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    margin-left: auto;
  }
  
  /* Nav item styling */
  #mainNav .nav-item {
    margin-right: 0.5rem;
    position: relative;
  }
  
  /* Critical fix for nav-link display */
  #mainNav .nav-link {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    white-space: nowrap !important;
    padding: 0.5rem 0.75rem !important;
    position: relative;
  }
  
  /* Ensure icons display properly */
  #mainNav .nav-link i,
  #mainNav .nav-link .fas,
  #mainNav .nav-link .fab {
    display: inline-block !important;
    vertical-align: middle !important;
    margin-right: 0.4rem !important;
    margin-top: 0 !important;
    font-size: 1rem !important;
  }
  
  /* Nav link hover effect */
  #mainNav .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background-color: var(--primary-light);
    transition: width 0.3s ease;
  }
  
  #mainNav .nav-link:hover::after {
    width: 80%;
  }
  
  /* Dropdown styling */
  .dropdown-menu {
    padding: 0.7rem 0;
    margin-top: 0.5rem;
    font-size: 0.95rem;
    border: none;
    box-shadow: 0 15px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    background-color: rgba(25, 25, 35, 0.95);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    border-radius: var(--border-radius-lg);
    animation: dropdown-fade 0.2s ease-out forwards;
    min-width: 220px;
  }
  
  @keyframes dropdown-fade {
    from {
      opacity: 0;
      transform: translateY(-8px) scale(0.98);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }
  
  /* Dropdown toggle caret */
  .dropdown-toggle::after {
    transition: transform 0.2s ease;
    vertical-align: middle !important;
    margin-left: 0.4em !important;
    margin-top: 0.1em;
  }
  
  .dropdown-toggle[aria-expanded="true"]::after {
    transform: rotate(180deg);
  }
  
  /* Dropdown items with hover effects */
  .dropdown-item {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    padding: 0.7rem 1.3rem;
    border-radius: var(--border-radius-md);
    margin: 0 0.5rem;
    width: calc(100% - 1rem);
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
    display: flex;
    align-items: center;
  }
  
  .dropdown-item i, 
  .dropdown-item svg {
    margin-right: 0.7rem;
    font-size: 1rem;
    opacity: 0.7;
    width: 20px;
    text-align: center;
    transition: all 0.2s ease;
  }
  
  .dropdown-item:hover {
    background-color: rgba(80, 70, 230, 0.15);
    color: var(--accent);
    transform: translateX(5px);
  }
  
  .dropdown-item:hover i,
  .dropdown-item:hover svg {
    opacity: 1;
    color: var(--accent);
  }
  
  .dropdown-item:active {
    background-color: var(--accent);
    color: white;
  }
  
  /* Dropdown section dividers */
  .dropdown-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 0.5rem 1rem;
  }
  
  /* Dropdown show/hide states */
  .navbar-nav .dropdown:hover > .nav-link {
    color: var(--accent);
  }
  
  /* Hover indicator for dropdown toggles */
  .nav-item.dropdown .nav-link:hover::after {
    background-color: var(--accent);
  }
  
  /* Focus styles for keyboard navigation */
  .dropdown-item:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent);
  }
  
  /* Highlight active dropdown item */
  .dropdown-item.active, 
  .dropdown-item:active {
    background-color: var(--accent);
    color: white;
  }
  
  /* Mobile navbar toggler */
  .navbar-toggler {
    padding: 0.25rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.25rem;
  }
  
  .navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.15);
  }
  
  .navbar-toggler-icon {
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    vertical-align: middle;
  }
  
  /* =====================
     Hero Section
     ===================== */
  .hero-container {
    height: 100vh;
    min-height: 500px;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    position: relative;
    overflow: hidden;
  }
  
  #quantum-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
  }
  
  .hero-content {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    padding: 0 1rem;
  }
  
  .hero-subtitle {
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
  }
  
  .hero-title {
    background: linear-gradient(45deg, #a78bfa, #4f46e5);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    margin-bottom: 1.5rem;
    font-size: 3.5rem;
    text-shadow: 0 0 20px rgba(167, 139, 250, 0.5);
  }
  
  .hero-subtitle {
    font-size: 1.25rem;
    max-width: 600px;
    margin: 0 auto 2rem;
  }
  
  /* Animation keyframes */
  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(40px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .animate-fade-in-up {
    animation: fadeInUp 0.8s ease forwards;
  }
  
  .animate-fade-in-up-delayed {
    animation: fadeInUp 1.2s ease forwards;
  }
  
  .animate-fade-in-up-delayed2 {
    animation: fadeInUp 1.6s ease forwards;
  }
  
  /* =====================
     Cards & Plugins
     ===================== */
  .plugin-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background-color: #fff;
    overflow: hidden;
    border-radius: var(--border-radius-lg);
  }
  
  .plugin-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
  }
  
  .plugin-card .card-body {
    padding: 1.5rem;
  }
  
  .icon-wrapper {
    transition: transform 0.3s ease;
    width: 48px;
    height: 48px;
  }
  
  .plugin-card:hover .icon-wrapper {
    transform: scale(1.1) rotate(5deg);
  }
  
  .tilt-card {
    transform-style: preserve-3d;
    perspective: 1000px;
  }
  
  /* =====================
     Simulation Controls
     ===================== */
  .form-range::-webkit-slider-thumb {
    background-color: var(--primary);
  }
  
  .form-range::-moz-range-thumb {
    background-color: var(--primary);
  }
  
  .form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
  }
  
  .terminal-log {
    background-color: var(--gray-dark);
    color: #e2e8f0;
    padding: 1rem;
    border-radius: var(--border-radius-md);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
  }
  
  /* Stylized tabs */
  .nav-tabs {
    border-bottom: 1px solid #dee2e6;
  }
  
  .nav-tabs .nav-link {
    border: none;
    color: var(--gray-medium);
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    border-radius: 0;
    transition: color 0.2s ease;
  }
  
  .nav-tabs .nav-link:hover {
    color: var(--primary);
    border-color: transparent;
  }
  
  .nav-tabs .nav-link.active {
    color: var(--primary);
    border-bottom: 3px solid var(--primary);
    background-color: transparent;
  }
  
  /* =====================
     Visualizations
     ===================== */
  .circuit-svg {
    position: relative;
    background-color: #fff;
    padding: 1rem;
    border-radius: var(--border-radius-md);
    margin-bottom: 1.5rem;
    text-align: center;
    overflow: auto;
    max-width: 100%;
  }
  
  .chart-container {
    height: 300px;
  }
  
  #bloch-sphere-container, 
  #circuit-demo-container {
    background-color: #141414;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
  }
  
  #bloch-sphere-container, #quantum-state-viz {
    height: 400px !important;
    width: 100%;
    background-color: #141424;
    border-radius: 8px;
    overflow: hidden;
  }
  
  .demo-container {
    height: 400px;
  }
  
  /* Download button styling */
  .circuit-download-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    opacity: 0.8;
    transition: opacity 0.2s ease;
    background-color: var(--primary);
    border-color: var(--primary);
    font-size: 0.85rem;
  }
  
  .circuit-download-btn:hover {
    opacity: 1;
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
  }
  
  /* Ensure SVG responsiveness */
  .circuit-svg svg {
    max-width: none;
    height: auto;
  }
  
  .circuit-svg-wrapper {
    width: 100%;
    overflow-x: auto;
    position: relative;
  }
  
  /* BB84 Visualization Styles */
  .pipeline-step {
    position: relative;
  }
  
  .step-header {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
  }
  
  .key-pipeline .progress {
    height: 24px;
  }
  
  .key-pipeline .progress-bar {
    color: #fff;
    font-weight: bold;
    text-shadow: 0 0 3px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* =====================
     Utility Classes
     ===================== */
  .bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  }
  
  .bg-gradient-dark {
    background: linear-gradient(135deg, #0f172a, #1e1b4b);
  }
  
  .shadow-hover {
    transition: box-shadow 0.3s ease;
  }
  
  .shadow-hover:hover {
    box-shadow: var(--shadow-lg);
  }
  
  .smooth-scroll {
    cursor: pointer;
  }
  
  /* Back to top button */
  .back-to-top-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99;
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    transition: opacity 0.3s ease, transform 0.3s ease;
  }
  
  .back-to-top-btn:hover {
    background-color: var(--primary-dark);
  }
  
  /* Glossary styles */
  .loading-glossary::before {
    content: "Loading glossary...";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    font-size: 1.5rem;
  }
  
  .highlight-term {
    animation: highlight-pulse 2s ease-in-out;
  }
  
  
  @keyframes highlight-pulse {
    0% { background-color: transparent; }
    30% { background-color: rgba(124, 58, 237, 0.2); }
    100% { background-color: transparent; }
  }
  
  /* Hide download button when printing */
  @media print {
    .circuit-download-btn {
      display: none;
    }
  }
  
  /* =====================
     Media Queries
     ===================== */
  @media (max-width: 1200px) {
    #mainNav .navbar-brand span {
      display: none; /* Hide brand text on medium screens */
    }
  }
  
  @media (max-width: 991.98px) {
    /* Mobile navigation adjustments */
    #mainNav .navbar-nav {
      flex-direction: column !important;
      padding: 1rem 0;
      overflow-x: visible;
    }
    
    #mainNav .nav-link {
      padding: 0.7rem !important;
      justify-content: flex-start !important;
    }
    
    #mainNav .nav-link::after {
      display: none;
    }
    
    /* Mobile dropdown styles */
    .dropdown-menu {
      background-color: rgba(30, 30, 45, 0.5);
      box-shadow: none;
      padding: 0.5rem;
      margin-top: 0;
      animation: none;
    }
    
    .dropdown-item {
      padding: 0.6rem 1rem;
      margin: 0.2rem 0;
      border-radius: var(--border-radius-sm);
    }
    
    .dropdown-item:hover {
      transform: none;
    }
  }
  
  @media (max-width: 767.98px) {
    /* Small screen adjustments */
    .hero-title {
      font-size: 2.5rem;
    }
    
    .hero-subtitle {
      font-size: 1rem;
    }
  }
  
  @media (min-width: 992px) {
    /* Desktop adjustments */
    .hero-content {
      padding: 0 2rem;
    }
    
    .plugin-card .card-body {
      padding: 2rem;
    }
    
    /* Ensure desktop navigation stays horizontal */
    #mainNav .navbar-nav {
      flex-direction: row !important;
    }
  }