/* --- Modern PDA-CFG Equivalence Visualization Styles (Based on exp7 theme) --- */

/* 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: 10px;
  overflow-x: hidden;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 10px;
}

/* 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;
  margin-bottom: 12px;
  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;
  margin-bottom: 8px;
}

.guide-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
}

.guide-steps {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.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;
  padding: 8px 6px;
  width: 23%;
}

.step-number {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white !important;
  font-size: 0.75rem;
}

/* Step number colors matching reference exactly */
.step-number.blue {
  background: #3B82F6;
}

.step-number.green {
  background: #10B981;
}

.step-number.purple {
  background: #6366F1;
}

.step-number.red {
  background: #EF4444;
}

.step-text {
  font-size: 0.75rem;
  text-align: center;
  color: #1e293b;
  font-weight: 500;
}

/* Main Content Layout */
.main-content {
  max-width: 100%;
}

/* Tab Navigation */
.tab-navigation {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  background: rgba(243, 244, 246, 0.7);
  border-radius: 12px;
  padding: 4px;
}

.tab-button {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.95rem;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tab-button:hover {
  background: rgba(255, 255, 255, 0.5);
  color: #374151;
}

.tab-button.active {
  background: #fff;
  color: #3B82F6;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  font-weight: 600;
}

.tab-button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Tab Content */
.tab-content-container {
  position: relative;
  min-height: 500px;
  margin-bottom: 20px;
}

.tab-content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-content.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
}

.tab-main-area {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 20px;
}

/* Simulation Section */
.simulation-section {
  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: 20px;
}

.section-header {
  margin-bottom: 20px;
}

.section-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}

.mode-indicator {
  font-size: 0.875rem;
  color: #6b7280;
  font-weight: 500;
}

/* Steps Sidebar */
.steps-sidebar {
  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;
}

.steps-sidebar h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Remove the two-column layout for steps since each panel now has one derivation */
.steps-columns {
  display: block;
}

.steps-column {
  width: 100%;
}

.steps-column-title {
  display: none;
}

/* Active derivation indicator styling - same style as parse tree highlighting */
.current-derivation.active {
  background: rgba(59, 130, 246, 0.08);
  border: 2px solid #3b82f6;
  border-radius: 8px;
  padding: 8px 12px;
  transition: all 0.3s ease;
}

.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;
  color: #1e293b;
  margin-bottom: 0.5rem;
}

/* 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: #3B82F6; /* Matching exp7/new Show Hint button */
  color: #fff;
  border: none;
}

.button.purple {
  background: #6366F1; /* Matching exp7/new Change Grammar button */
  color: #fff;
  border: none;
}

.button.green {
  background: #10B981; /* Matching exp7/new Previous Step button */
  color: #fff;
  border: none;
}

.button.red {
  background: #EF4444; /* Matching exp7/new Auto Step button */
  color: #fff;
  border: none;
}

.button.orange {
  background: #fb923c;
  color: #fff;
  border: none;
}

.button.yellow {
  background: #EF4444; /* Change yellow to red to match exp7 Auto Step */
  color: #fff;
  border: none;
}

/* Shared Input Container */
.shared-input-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: 16px 20px;
  margin-bottom: 15px;
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto 1fr;
  gap: 16px;
  align-items: center;
}

.input-string-label {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0;
  white-space: nowrap;
}

.language-info, .input-string {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 16px;
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0;
  text-align: left;
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* Visualization Container Styles */
.visualization-container {
  display: flex;
  gap: 10px;
  min-height: 320px;
  max-height: 320px;
  min-width: 0; /* Prevent overflow */
}

.pda-diagram-area {
  flex: 1;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  min-width: 0; /* Prevent overflow */
  height: 320px;
  overflow: hidden;
}

.pda-stack-area {
  width: 80px; /* Reduced from 100px */
  background: rgba(243, 244, 246, 0.7);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  flex-shrink: 0;
  height: 320px;
  overflow: hidden;
}

.stack-header {
  font-weight: 600;
  font-size: 0.875rem;
  color: #374151;
  text-align: center;
  margin-bottom: 8px;
}

.visual-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Steps and Status Information */
.current-derivation-indicator {
  background: rgba(243, 244, 246, 0.7);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 12px;
}

.current-derivation {
  font-weight: 600;
  color: #374151;
  font-size: 0.9rem;
  text-align: center;
}

.trace-container {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.current-state-info, .current-derivation-info {
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.state-row, .derivation-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.875rem;
  padding: 4px 0;
}

.state-row:last-child, .derivation-row:last-child {
  margin-bottom: 0;
}

.label {
  font-weight: 600;
  color: #4a5568;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.state-value, .input-value, .stack-value, .derivation-value, .target-value {
  font-family: 'Courier New', monospace;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 4px 8px;
  border-radius: 4px;
  color: #2d3748;
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 50px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Production Rules Display */
.production-rules-display {
  margin-bottom: 12px;
}

.production-rules-display h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}

.rules-container {
  background: rgba(243, 244, 246, 0.7);
  border-radius: 8px;
  padding: 8px;
  max-height: 150px;
  overflow-y: auto;
}

/* Steps Container */
.steps-container {
  margin-top: 12px;
}

.steps-container h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.steps-list {
  background: linear-gradient(135deg, #ffffff, #f7fafc);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.steps-list .step-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 6px 8px;
  margin-bottom: 4px;
  font-size: 0.8rem;
  color: #4a5568;
  transition: all 0.15s ease;
  line-height: 1.3;
}

.steps-list .step-item:hover {
  background: #f7fafc;
  border-color: #cbd5e0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.steps-list .step-item:last-child {
  margin-bottom: 0;
}

.steps-list .step-item.completed {
  background: #f0fff4;
  border-color: #9ae6b4;
  color: #2f855a;
}

.steps-list .step-item.current {
  background: #ebf8ff;
  border-color: #90cdf4;
  color: #2b6cb0;
  font-weight: 600;
}

/* Action Selection Panel */
.action-selection-panel {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 15px;
  margin-top: 15px;
  position: relative;
  z-index: 10;
}

.selection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.selection-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
}

.mode-badge {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #3b82f6;
}

.action-choices {
  margin-bottom: 12px;
}

.choices-label {
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}

.choices-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  position: relative;
  z-index: 11;
}

/* Choice Button Styles - Matching exp7 rule styling exactly */
.choice-button {
  padding: 8px 12px;
  background: rgba(140, 90, 255, 0.18);
  border: none;
  border-radius: 6px;
  font-family: monospace;
  font-size: 1.1rem;
  color: #5b21b6;
  font-weight: 500;
  box-shadow: 0 2px 8px 0 rgba(124, 58, 237, 0.04);
  transition: all 0.2s;
  cursor: pointer;
  display: inline-block;
  margin: 0;
  position: relative;
  z-index: 12;
}

.choice-button:hover {
  background: rgba(140, 90, 255, 0.25);
  box-shadow: 0 3px 6px rgba(124, 58, 237, 0.1);
  transform: translateY(-2px);
}

.choice-button:active {
  transform: translateY(0);
  background: rgba(140, 90, 255, 0.35);
}

.choice-button.selected {
  background: rgba(140, 90, 255, 0.35);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(124, 58, 237, 0.15);
}

.choice-button.correct {
  background: rgba(16, 185, 129, 0.2);
  color: #047857;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.15);
}

.choice-button.incorrect {
  background: rgba(239, 68, 68, 0.2);
  color: #dc2626;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(239, 68, 68, 0.15);
}

.feedback-area {
  background: rgba(243, 244, 246, 0.7);
  border-radius: 8px;
  padding: 12px;
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.feedback-area.correct {
  background: rgba(16, 185, 129, 0.1);
  border-color: #10B981;
  animation: feedbackSuccess 0.5s ease-out;
}

.feedback-area.incorrect {
  background: rgba(239, 68, 68, 0.1);
  border-color: #EF4444;
  animation: feedbackError 0.5s ease-out;
}

.feedback-message {
  color: #374151;
  font-size: 0.95rem;
  text-align: center;
  transition: all 0.3s ease;
  animation: fadeIn 0.3s ease-in;
}

.feedback-message.correct {
  color: #065F46;
  font-weight: 600;
}

.feedback-message.incorrect {
  color: #991B1B;
  font-weight: 600;
}

/* Feedback animations */
@keyframes feedbackSuccess {
  0% {
    background: rgba(243, 244, 246, 0.7);
    border-color: transparent;
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10B981;
    transform: scale(1);
  }
}

@keyframes feedbackError {
  0% {
    background: rgba(243, 244, 246, 0.7);
    border-color: transparent;
    transform: scale(1);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
  100% {
    background: rgba(239, 68, 68, 0.1);
    border-color: #EF4444;
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes hintHighlight {
  0% {
    background: rgba(243, 244, 246, 0.7);
    border-color: transparent;
    transform: scale(1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
  }
  25% {
    background: rgba(59, 130, 246, 0.15);
    border-color: #3B82F6;
    transform: scale(1.02);
    box-shadow: 0 12px 40px 0 rgba(59, 130, 246, 0.2);
  }
  50% {
    background: rgba(99, 102, 241, 0.2);
    border-color: #6366F1;
    transform: scale(1.03);
    box-shadow: 0 16px 48px 0 rgba(99, 102, 241, 0.25);
  }
  75% {
    background: rgba(59, 130, 246, 0.15);
    border-color: #3B82F6;
    transform: scale(1.02);
    box-shadow: 0 12px 40px 0 rgba(59, 130, 246, 0.2);
  }
  100% {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3B82F6;
    transform: scale(1);
    box-shadow: 0 8px 32px 0 rgba(59, 130, 246, 0.1);
  }
}

.feedback-area.hint-highlight {
  animation: hintHighlight 1.2s ease-in-out;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .container {
    max-width: 100%;
    padding: 0 8px;
  }
  
  .tab-main-area {
    grid-template-columns: 1fr 220px;
    gap: 15px;
  }
}

@media (max-width: 1024px) {
  .tab-main-area {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .visualization-container {
    flex-direction: column;
  }
  
  .pda-stack-area {
    width: auto;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 5px;
  }
  
  .tab-button {
    padding: 8px 12px;
    font-size: 0.875rem;
  }
  
  .guide-steps {
    flex-direction: column;
    gap: 8px;
  }
  
  .guide-step {
    width: 100%;
  }
  
  .horizontal-controls {
    flex-direction: column;
    gap: 8px;
  }
  
  .button {
    width: 100%;
    justify-content: center;
  }
}
