/* Quantum Computing Simulator - Mobile-First Responsive Design */

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 100%);
  color: #ffffff;
  line-height: 1.6;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  
  /* Safari/iOS specific fixes */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  padding: 0;
}

/* Navigation - Mobile First */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 255, 255, 0.2);
  z-index: 1000;
  height: 50px;
  box-shadow: 0 2px 20px rgba(0, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Safari/iOS fixes */
  -webkit-backdrop-filter: blur(20px);
  padding-top: env(safe-area-inset-top);
  height: calc(50px + env(safe-area-inset-top));
}

.nav-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 15px;
  height: 100%;
  max-width: 100%;
}

.nav-brand h1 {
  color: #00ffff;
  font-size: 16px;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-link {
  color: #ccc;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  background: transparent;
  cursor: pointer;
  
  /* Safari/iOS touch fixes */
  -webkit-tap-highlight-color: rgba(0, 255, 255, 0.2);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-link:hover {
  color: #00ffff;
  border-color: #00ffff;
}

.nav-link.active {
  color: #000;
  background: #00ffff;
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
}

/* Main content layout - Mobile First */
.main-content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding-top: calc(50px + env(safe-area-inset-top));
  position: relative;
  
  /* Safari/iOS fixes */
  min-height: -webkit-fill-available;
}

/* Mobile-first collapsible panels */
.left-panel {
  position: fixed;
  top: calc(50px + env(safe-area-inset-top));
  left: -100%;
  width: 100%;
  max-width: 350px;
  height: calc(100vh - 50px - env(safe-area-inset-top));
  background: rgba(10, 10, 10, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid rgba(0, 255, 255, 0.2);
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999;
  box-shadow: 2px 0 30px rgba(0, 0, 0, 0.5);
}

.left-panel.open {
  left: 0;
}

.visualization-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: calc(100vh - 50px - env(safe-area-inset-top));
  background: radial-gradient(circle at center, rgba(0, 255, 255, 0.02) 0%, transparent 70%);
  
  /* Safari/iOS fixes */
  min-height: -webkit-fill-available;
}

/* Loading Indicator */
.loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.5s ease-out;
}

.loading-indicator.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 3px solid rgba(0, 255, 255, 0.1);
  border-top: 3px solid #00ffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  color: #00ffff;
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.right-panel {
  position: fixed;
  top: calc(50px + env(safe-area-inset-top));
  right: -100%;
  width: 100%;
  max-width: 350px;
  height: calc(100vh - 50px - env(safe-area-inset-top));
  background: rgba(10, 10, 10, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(0, 255, 255, 0.2);
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999;
  box-shadow: -2px 0 30px rgba(0, 0, 0, 0.5);
}

.right-panel.open {
  right: 0;
}

/* Enhanced panel headers */
.system-selector h3 {
  color: #00ffff;
  margin-bottom: 20px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.system-selector h3::before {
  content: '⚛️';
  font-size: 24px;
}

.system-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.system-btn {
  background: rgba(30, 30, 40, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 18px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
}

.system-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 255, 0.1), transparent);
  transition: left 0.5s ease;
}

.system-btn:hover::before {
  left: 100%;
}

.system-btn:hover {
  border-color: rgba(0, 255, 255, 0.5);
  background: rgba(0, 255, 255, 0.05);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 255, 255, 0.15);
}

.system-btn.active {
  border-color: #00ffff;
  background: rgba(0, 255, 255, 0.15);
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.system-btn:active {
  transform: translateY(0);
  transition: transform 0.1s ease;
}

.system-name {
  font-weight: 600;
  color: #00ffff;
  margin-bottom: 8px;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.system-qubits {
  font-size: 13px;
  color: #888;
  font-weight: 500;
  opacity: 0.8;
}

/* System info */
.system-info {
  margin-top: 30px;
}

.system-info h3 {
  color: #00ffff;
  margin-bottom: 15px;
  font-size: 18px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #333;
}

.label {
  color: #ccc;
}

.value {
  color: #fff;
  font-weight: bold;
}

/* Tetron info */
.tetron-info h3 {
  color: #00ffff;
  margin-bottom: 15px;
  font-size: 18px;
}

.tetron-description p {
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.tetron-description strong {
  color: #00ffff;
}

/* Controls */
.controls {
  margin-top: 30px;
}

.controls h3 {
  color: #00ffff;
  margin-bottom: 15px;
  font-size: 18px;
}

.control-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-btn {
  background: #444;
  border: 1px solid #666;
  color: #fff;
  padding: 10px 15px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.control-btn:hover {
  background: #555;
  border-color: #00ffff;
  color: #00ffff;
}

/* Status */
.status {
  margin-top: 30px;
}

.status h3 {
  color: #00ffff;
  margin-bottom: 15px;
  font-size: 18px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #333;
}

.status-label {
  color: #ccc;
}

.status-value {
  color: #fff;
  font-weight: bold;
}

/* Mobile Controls */
.mobile-controls {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(20px);
  padding: 12px 20px;
  border-radius: 25px;
  border: 1px solid rgba(0, 255, 255, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.mobile-control-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(0, 255, 255, 0.3);
  background: rgba(0, 255, 255, 0.1);
  color: #00ffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 20px;
  touch-action: manipulation;
  user-select: none;
}

.mobile-control-btn:hover,
.mobile-control-btn:active {
  background: rgba(0, 255, 255, 0.2);
  border-color: #00ffff;
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.4);
}

.mobile-control-btn.active {
  background: rgba(0, 255, 255, 0.3);
  border-color: #00ffff;
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}

/* Panel overlay for mobile */
.panel-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: manipulation;
}

.panel-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Enhanced info panels */
.info-item, .status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.info-item:hover, .status-item:hover {
  background: rgba(0, 255, 255, 0.05);
  padding-left: 10px;
  border-radius: 8px;
}

.label, .status-label {
  color: #888;
  font-weight: 500;
  font-size: 14px;
}

.value, .status-value {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

/* Enhanced controls */
.control-btn {
  background: rgba(0, 255, 255, 0.1);
  border: 2px solid rgba(0, 255, 255, 0.3);
  color: #00ffff;
  padding: 14px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
}

.control-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.control-btn:hover::before {
  left: 100%;
}

.control-btn:hover {
  background: rgba(0, 255, 255, 0.2);
  border-color: #00ffff;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 255, 255, 0.2);
}

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

/* Section headers */
.system-info h3, .tetron-info h3, .controls h3, .status h3 {
  color: #00ffff;
  margin-bottom: 20px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(0, 255, 255, 0.2);
}

.system-info h3::before { content: '🔬'; }
.tetron-info h3::before { content: '🧊'; }
.controls h3::before { content: '🎮'; }
.status h3::before { content: '📊'; }

/* Learning Mode Styles */
.learning-info h3 {
  color: #00ffff;
  margin-bottom: 20px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(0, 255, 255, 0.2);
}

.learning-info h3::before {
  content: '🎓';
  font-size: 20px;
}

.progress-indicator {
  background: rgba(0, 0, 0, 0.8);
  border-radius: 20px;
  height: 8px;
  margin: 20px 0;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #00ffff, #ff00ff);
  border-radius: 20px;
  transition: width 0.3s ease;
}

.learning-description {
  max-height: calc(100vh - 400px);
  overflow-y: auto;
  padding-right: 10px;
}

.learning-description::-webkit-scrollbar {
  width: 4px;
}

.learning-description::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.learning-description::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 255, 0.5);
  border-radius: 2px;
}

.stats-box {
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid #333;
  padding: 15px;
  border-radius: 5px;
  margin: 15px 0;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin: 5px 0;
}

.stat-label {
  color: #ccc;
}

.stat-value {
  color: #00ffff;
  font-weight: bold;
}

.learning-objectives {
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(255, 255, 0, 0.1));
  border: 2px solid #00ffff;
  border-radius: 10px;
  padding: 20px;
  margin: 20px 0;
}

.learning-objectives h4 {
  color: #00ffff;
  margin: 0 0 15px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.learning-objectives h4::before {
  content: '🎯';
  font-size: 18px;
}

.objective-list {
  list-style: none;
  padding: 0;
}

.objective-list li {
  background: rgba(255, 255, 255, 0.05);
  margin: 8px 0;
  padding: 12px;
  border-radius: 5px;
  border-left: 3px solid #00ffff;
  position: relative;
  padding-left: 35px;
}

.objective-list li::before {
  content: '✓';
  position: absolute;
  left: 12px;
  color: #00ff00;
  font-weight: bold;
}

.highlight {
  background: rgba(0, 255, 255, 0.2);
  padding: 15px;
  border-left: 4px solid #00ffff;
  margin: 15px 0;
  border-radius: 5px;
}

.advantage {
  background: rgba(0, 255, 0, 0.1);
  border-left: 4px solid #00ff00;
  padding: 10px;
  margin: 10px 0;
  border-radius: 5px;
}

.challenge {
  background: rgba(255, 100, 100, 0.1);
  border-left: 4px solid #ff6464;
  padding: 10px;
  margin: 10px 0;
  border-radius: 5px;
}

.step-list {
  counter-reset: step-counter;
  margin: 15px 0;
}

.step {
  counter-increment: step-counter;
  background: rgba(100, 100, 100, 0.1);
  margin: 10px 0;
  padding: 15px;
  border-radius: 5px;
  position: relative;
  padding-left: 50px;
}

.step::before {
  content: counter(step-counter);
  position: absolute;
  left: 15px;
  top: 15px;
  background: #00ffff;
  color: #000;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.about-info h3 {
  color: #00ffff;
  margin-bottom: 20px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(0, 255, 255, 0.2);
}

.about-info h3::before {
  content: 'ℹ️';
  font-size: 20px;
}

.about-description p {
  margin-bottom: 15px;
  line-height: 1.6;
  color: #ddd;
}

.panel-content {
  animation: fadeIn 0.3s ease-in-out;
}

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

/* Quiz and Interactive Elements */
.quiz-question {
  background: rgba(100, 0, 255, 0.1);
  border: 1px solid #6600ff;
  border-radius: 8px;
  padding: 15px;
  margin: 15px 0;
}

.quiz-question h5 {
  color: #bb88ff;
  margin: 0 0 10px 0;
}

.key-takeaway {
  background: linear-gradient(45deg, rgba(255, 215, 0, 0.1), rgba(255, 140, 0, 0.1));
  border: 2px solid #ffd700;
  border-radius: 12px;
  padding: 20px;
  margin: 25px 0;
  position: relative;
}

.key-takeaway::before {
  content: '💡';
  position: absolute;
  top: -10px;
  left: 20px;
  background: #1a1a1a;
  padding: 0 10px;
  font-size: 20px;
}

.key-takeaway h4 {
  color: #ffd700;
  margin: 0 0 15px 0;
  text-align: center;
}

/* Desktop responsive design */
@media (min-width: 768px) {
  .navbar {
    height: 60px;
    padding-top: 0;
  }
  
  .main-content {
    padding-top: 60px;
    flex-direction: row;
  }
  
  .nav-brand h1 {
    font-size: 20px;
  }
  
  .nav-links {
    gap: 12px;
  }
  
  .nav-link {
    padding: 8px 16px;
    font-size: 15px;
  }
  
  .left-panel {
    position: relative;
    top: 0;
    left: 0;
    width: 320px;
    height: calc(100vh - 60px);
    transform: none;
    transition: none;
  }
  
  .right-panel {
    position: relative;
    top: 0;
    right: 0;
    width: 320px;
    height: calc(100vh - 60px);
    transform: none;
    transition: none;
  }
  
  .visualization-container {
    height: calc(100vh - 60px);
  }
  
  .mobile-controls {
    display: none;
  }
  
  .panel-overlay {
    display: none;
  }
  
  .learning-description {
    max-height: calc(100vh - 300px);
  }
}

@media (min-width: 1200px) {
  .left-panel, .right-panel {
    width: 380px;
  }
  
  .system-btn {
    padding: 20px;
  }
  
  .system-name {
    font-size: 18px;
  }
  
  .system-qubits {
    font-size: 14px;
  }
  
  .learning-description {
    max-height: calc(100vh - 280px);
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
  .system-btn, .control-btn, .mobile-control-btn {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
  body {
    background: linear-gradient(135deg, #000000 0%, #1a1a2e 100%);
  }
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .system-btn::before,
  .control-btn::before {
    display: none;
  }
}
