/* --- Modern CFG Derivation Visualization Styles --- */

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, sans-serif;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #fff;
  color: #1e293b;
  line-height: 1.5;
  min-height: 100vh;
  padding: 15px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Quick Guide Styles */
.guide-container {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
  padding: 8px; /* Reduced from 10px */
  margin-bottom: 12px; /* Reduced from 15px */
  transform: translateY(0);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.guide-container:hover {
  transform: translateY(-0.25rem);
  box-shadow: 0 1.25rem 2.5rem rgba(59, 130, 246, 0.08);
}

.guide-header {
  display: flex;
  align-items: center;
  gap: 6px; /* Reduced from 8px */
  margin-bottom: 8px; /* Reduced from 10px */
}

.guide-header h2 {
  font-size: 1rem; /* Reduced from 1.125rem to match reference */
  font-weight: 600;
  color: #1e293b;
}

.guide-steps {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px; /* Added small gap */
}

.guide-step {
  background: rgba(243, 244, 246, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px; /* Reduced from 5px */
  padding: 8px 6px; /* Reduced from 12px 8px */
  width: 23%;
}

.step-number {
  width: 1.5rem; /* 24px to match reference w-6 h-6 */
  height: 1.5rem; /* 24px to match reference w-6 h-6 */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white !important; /* Ensure white text like in reference */
  font-size: 0.75rem; /* text-xs to match reference */
}

/* Step number colors matching reference exactly */
.step-number.blue {
  background: #3B82F6; /* primary color from reference */
}

.step-number.green {
  background: #10B981; /* accent color from reference */
}

.step-number.purple {
  background: #6366F1; /* secondary color from reference */
}

.step-number.red {
  background: #EF4444; /* danger color from reference */
}

.step-text {
  font-size: 0.75rem; /* Reduced from 0.85rem to match reference text-xs */
  text-align: center;
  color: #1e293b;
  font-weight: 500;
}

/* Main Content Panels */
.main-panels {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 15px;
  margin-bottom: 10px;
}

.panel {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 1.5rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
  padding: 15px;
  transform: translateY(0);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel:hover {
  transform: translateY(-0.25rem);
  box-shadow: 0 1.25rem 2.5rem rgba(59, 130, 246, 0.08);
}

.panel-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 15px;
  color: #1e293b;
}

/* Control Panel Styles */
.controls-container {
  background: rgba(243, 244, 246, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}

.controls-title {
  font-weight: 600;
  margin-right: 15px;
  margin-bottom: 8px;
  white-space: nowrap;
  color: #1e293b;
}

.horizontal-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  background: #fff;
  color: #374151;
  border: 1px solid #e5e7eb;
  box-shadow: 0 0.125rem 0.5rem rgba(59, 130, 246, 0.06);
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 1rem;
  font-family: 'Inter', system-ui, sans-serif;
  padding: 0.75rem 1.5rem;
  min-width: 110px;
  min-height: 2.5rem;
  border-radius: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.button:hover {
  filter: brightness(0.95);
  box-shadow: 0 0.25rem 1rem rgba(59, 130, 246, 0.10);
  transform: scale(1.05);
}

.button:active {
  filter: brightness(0.90);
  transform: scale(0.95);
}

.button.blue {
  background: #6366F1; /* Changed to match reference DFA "Change Input" button */
  color: #fff;
  border: none;
}

.button.purple {
  background: #3B82F6; /* Changed to match reference DFA "Change DFA" button (primary color) */
  color: #fff;
  border: none;
}

.button.green {
  background: #10B981;
  color: #fff;
  border: none;
}

.button.red {
  background: #EF4444;
  color: #fff;
  border: none;
}

/* Grammar Panel Styles */
.grammar-panel {
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

.grammar-description {
  margin-bottom: 12px;
  text-align: center;
}

.grammar-description h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1e293b;
}

.input-string-container {
  background: rgba(243, 244, 246, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  min-height: 55px;
  align-items: center;
}

.input-string {
  font-size: 1.5rem;
  font-weight: 500;
  color: #2d1e4a;
}

.production-rules-section {
  margin-bottom: 12px;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1e293b;
}

.production-rules {
  background: rgba(243, 244, 246, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.production-rules .rule-button {
  padding: 8px 12px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 600;
  color: #1e40af;
  cursor: pointer;
  transition: all 0.2s ease;
}

.production-rules .rule-button:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.production-rules .rule-button:disabled {
  background: rgba(156, 163, 175, 0.1);
  border-color: rgba(156, 163, 175, 0.2);
  color: #9ca3af;
  cursor: not-allowed;
  opacity: 0.6;
}

.rule {
  padding: 8px 12px;
  background: rgba(243, 244, 246, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1rem;
  transition: all 0.2s;
  color: #1e293b;
  font-weight: 500;
}

.rule:hover {
  background: rgba(219, 234, 254, 0.8);
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateY(-1px);
}

.derivation-graph-title {
  font-size: 1.125rem;
  color: #1e293b;
  margin: 12px 0 8px;
  font-weight: 600;
}

.derivation-tree-container {
  background: rgba(243, 244, 246, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-grow: 1;
  min-height: 180px;
  overflow-x: auto; /* Allow horizontal scrolling for large derivations */
}

/* Style for the SVG elements in the derivation graph */
#derivation_tree text {
  font-family: 'Inter', system-ui, sans-serif;
  fill: #5b21b6;
  font-weight: 600;
  opacity: 0.95;
}

#derivation_tree circle {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  stroke-width: 2.5;
  cursor: pointer;
}

.node-circle {
  will-change: transform;
  transform-origin: center;
}

#derivation_tree circle:hover {
  filter: drop-shadow(0px 4px 6px rgba(124, 58, 237, 0.2));
  transform: translateY(-2px);
}

/* Make sure the arrowhead marker is properly visible */
#derivation_tree marker {
  overflow: visible;
}

/* Add styling to the paths in the derivation tree */
#derivation_tree path {
  stroke: #7c3aed;
  stroke-width: 2.2;
  opacity: 0.85;
  transition: stroke-width 0.2s, opacity 0.2s;
}

/* Add a subtle animation to the current node */
#derivation_tree circle[fill="#34d399"] {
  animation: pulse 2s infinite;
  stroke: #059669;
  stroke-width: 3.5;
}

#derivation_tree circle[fill="#6366f1"] {
  stroke: #3730a3;
  stroke-width: 2.5;
}

@keyframes pulse {
  0% {
    filter: drop-shadow(0px 2px 4px rgba(16, 185, 129, 0.2));
  }
  50% {
    filter: drop-shadow(0px 4px 8px rgba(16, 185, 129, 0.4));
  }
  100% {
    filter: drop-shadow(0px 2px 4px rgba(16, 185, 129, 0.2));
  }
}

/* Steps Panel */
.trace-container {
  background: rgba(243, 244, 246, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 15px;
  max-height: 440px;
  overflow-y: auto;
}

#derivation_steps_list {
  list-style: none;
}

.trace-item {
  padding: 10px;
  border-bottom: 1px solid rgba(124, 58, 237, 0.10);
  font-size: 1rem;
  font-family: 'Inter', system-ui, sans-serif;
  color: #1e293b;
}

.trace-item:last-child {
  border-bottom: none;
}

.trace-item.active {
  background: #e6f2ff;
  border-left: 3px solid #3b82f6;
  font-weight: 600;
}

.rule-applied {
  display: inline-block;
  font-size: 0.8rem;
  color: #6b7280;
  margin-left: 10px;
  font-weight: 500;
}

/* Custom SweetAlert styles */
.swal-modal {
  border-radius: 1.5rem;
  box-shadow: 0 16px 48px 0 rgba(0, 0, 0, 0.08);
}

.swal-title {
  color: #1e293b;
}

.swal-button {
  border-radius: 1rem;
  padding: 0.6rem 1.2rem;
  font-weight: 500;
  transition: all 0.2s;
}

.swal-button--confirm,
.swal-button--green {
  background: #10B981;
}

.swal-button--confirm:hover,
.swal-button--green:hover {
  background: #059669 !important;
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 4px 16px 0 rgba(5, 150, 105, 0.16);
}

.swal-button--blue {
  background: #3B82F6;
}

.swal-button--blue:hover {
  background: #2563EB !important;
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 4px 16px 0 rgba(55, 48, 163, 0.16);
}

/* Responsive Design */
/* Make experiment panel have more space */
.experiment-panel {
  width: 100%;
}

@media (max-width: 1024px) {
  .main-panels {
    grid-template-columns: 1fr;
  }
  
  .guide-step {
    width: 48%;
    margin-bottom: 8px;
  }
  
  .horizontal-controls {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .controls-container {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .controls-title {
    margin-bottom: 10px;
  }
}

@media (max-width: 600px) {
  .guide-step {
    width: 100%;
  }
  
  .panel {
    padding: 15px;
  }
  
  .container {
    padding: 10px;
  }
  
  .button {
    padding: 8px 12px;
    font-size: 0.9rem;
  }
}
