/* --- NFA to Regular Expression Conversion Styles --- */

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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;
}

/* Glass Morphism Effects */
.glass-morphism {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.dark-glass {
  background: rgba(243, 244, 246, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

/* 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: 8px;
}

.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: 6px;
  padding: 10px 8px;
  flex: 1;
  min-width: 150px;
  max-width: 200px;
}

.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.orange {
  background: #F59E0B; /* warning/orange color */
}

.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 Panels Layout */
.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-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e7eb;
}

.panel-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 15px;
  color: #1e293b;
}

.panel-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 15px;
  color: #1e293b;
}

/* Visualization Area */
.visualization-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.canvas-container {
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  background: rgba(249, 250, 251, 0.8);
}

.canvas-container h4 {
  margin-bottom: 8px;
  color: #374151;
  font-size: 0.9rem;
}

.canvas-instruction {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 8px;
  font-style: italic;
  text-align: center;
}

#nfa-canvas {
  width: 100%;
  height: 400px;
  max-width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: white;
  display: block;
}

.regex-display {
  background: rgba(254, 249, 195, 0.8); /* yellow-100 */
  border: 2px solid #fbbf24; /* yellow-400 */
  border-radius: 8px;
  padding: 12px;
}

.regex-display h4 {
  margin-bottom: 8px;
  color: #92400e; /* yellow-800 */
  font-size: 0.9rem;
}

.regex-text {
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  font-weight: 600;
  color: #78350f; /* yellow-900 */
  word-break: break-all;
  min-height: 24px;
}

/* 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;
}

/* NFA Description */
.nfa-description-container {
  margin-bottom: 12px;
  text-align: center;
}

.nfa-description {
  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;
}

.nfa-description h4 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0;
  color: #1e293b;
}





.btn {
  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: 44px; /* Increased for better touch targets */
  border-radius: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  text-align: center;
  touch-action: manipulation; /* Improve touch responsiveness */
  user-select: none; /* Prevent text selection on touch */
}

.btn:hover {
  filter: brightness(0.95);
  box-shadow: 0 0.25rem 1rem rgba(59, 130, 246, 0.10);
  transform: scale(1.05);
}

.btn:active {
  filter: brightness(0.90);
  transform: scale(0.95);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: #6366F1;
  color: #fff;
  border: none;
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(0.95);
  box-shadow: 0 0.25rem 1rem rgba(99, 102, 241, 0.10);
  transform: scale(1.05);
}

.btn.blue {
  background: #3B82F6;
  color: #fff;
  border: none;
}

.btn.blue:hover:not(:disabled) {
  filter: brightness(0.95);
  box-shadow: 0 0.25rem 1rem rgba(59, 130, 246, 0.10);
  transform: scale(1.05);
}

.btn.success {
  background: #10B981;
  color: #fff;
  border: none;
}

.btn.success:hover:not(:disabled) {
  filter: brightness(0.95);
  box-shadow: 0 0.25rem 1rem rgba(16, 185, 129, 0.10);
  transform: scale(1.05);
}

.btn.secondary {
  background: #3B82F6;
  color: #fff;
  border: none;
}

.btn.secondary:hover:not(:disabled) {
  filter: brightness(0.95);
  box-shadow: 0 0.25rem 1rem rgba(59, 130, 246, 0.10);
  transform: scale(1.05);
}

.btn.danger {
  background: #EF4444;
  color: #fff;
  border: none;
}

.btn.danger:hover:not(:disabled) {
  filter: brightness(0.95);
  box-shadow: 0 0.25rem 1rem rgba(239, 68, 68, 0.10);
  transform: scale(1.05);
}

.btn.info {
  background: #0ea5e9;
  color: white;
}

.btn.info:hover:not(:disabled) {
  background: #0284c7;
  transform: translateY(-1px);
}

/* Steps Panel */
.steps-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;
}

.steps-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-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;
  transition: all 0.2s;
}

.step-item:last-child {
  border-bottom: none;
}

.step-item.current {
  background: #e6f2ff;
  border-left: 3px solid #3b82f6;
  font-weight: 600;
}

.step-item.completed {
  background: rgba(220, 252, 231, 0.8); /* green-100 */
  border-color: #10b981;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.step-header .step-number {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #6b7280;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
}

.step-item.current .step-number {
  background: #3b82f6;
}

.step-item.completed .step-number {
  background: #10b981;
}

.step-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}

.step-content {
  font-size: 0.8rem;
  color: #6b7280;
  margin-left: 28px;
}

.final-result {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px solid #e5e7eb;
}

.final-result h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}

.final-regex-display {
  background: rgba(254, 249, 195, 0.8); /* yellow-100 */
  border: 2px solid #fbbf24; /* yellow-400 */
  border-radius: 8px;
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  font-weight: 600;
  color: #78350f; /* yellow-900 */
  word-break: break-all;
  min-height: 40px;
  display: flex;
  align-items: center;
}

/* Responsive Design */
/* Responsive Design */

/* Tablet Landscape (1024px and below) */
@media (max-width: 1024px) {
  .container {
    max-width: 95%;
    padding: 10px;
  }
  
  .main-panels {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .guide-steps {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .guide-step {
    width: calc(50% - 4px);
    margin-bottom: 8px;
  }
  
  .horizontal-controls {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .controls-container {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .controls-title {
    margin-bottom: 8px;
  }
  
  #nfa-canvas {
    height: 350px;
  }
  
  .floating-algorithm-btn {
    padding: 10px 14px;
    font-size: 13px;
  }
}

/* Tablet Portrait (768px and below) */
@media (max-width: 768px) {
  body {
    padding: 8px;
  }
  
  .container {
    padding: 5px;
  }
  
  .guide-container {
    padding: 12px;
    margin-bottom: 10px;
  }
  
  .guide-header h2 {
    font-size: 18px;
  }
  
  .guide-step {
    width: 100%;
    padding: 8px;
  }
  
  .step-text {
    font-size: 13px;
  }
  
  .panel {
    padding: 12px;
    border-radius: 12px;
  }
  
  .horizontal-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .btn {
    padding: 10px 14px;
    font-size: 14px;
    justify-content: center;
  }
  
  .btn svg {
    width: 14px;
    height: 14px;
  }
  
  #nfa-canvas {
    width: 100%;
    height: 300px;
    max-width: 100%;
  }
  
  .canvas-container {
    padding: 8px;
  }
  
  .canvas-container h4 {
    font-size: 16px;
  }
  
  .canvas-instruction {
    font-size: 12px;
  }
  
  .regex-display {
    padding: 10px;
  }
  
  .regex-text {
    font-size: 14px;
    word-break: break-all;
  }
  
  .steps-panel h3 {
    font-size: 18px;
  }
  
  .step-item {
    padding: 8px;
  }
  
  .floating-algorithm-btn span {
    display: none;
  }
  
  .floating-algorithm-btn {
    padding: 8px;
    top: 8px;
    right: 8px;
  }
}

/* Mobile Landscape (600px and below) */
@media (max-width: 600px) {
  .guide-step {
    width: 100%;
    flex-direction: column;
    text-align: center;
    padding: 12px;
  }
  
  .step-number {
    margin-bottom: 8px;
  }
  
  .horizontal-controls {
    gap: 6px;
  }
  
  .btn {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .btn span {
    display: none;
  }
  
  #nfa-canvas {
    height: 250px;
  }
  
  .visualization-area {
    gap: 8px;
  }
  
  .regex-display h4 {
    font-size: 14px;
  }
  
  .final-result h4 {
    font-size: 14px;
  }
  
  .modal-content {
    margin: 5px;
    max-height: 95vh;
  }
  
  .modal-header {
    padding: 12px;
  }
  
  .modal-header h3 {
    font-size: 18px;
  }
  
  .modal-body {
    padding: 12px;
  }
  
  .algo-step {
    padding: 8px;
    flex-direction: column;
    text-align: center;
  }
  
  .step-num {
    margin-bottom: 8px;
  }
}

/* Mobile Portrait (480px and below) */
@media (max-width: 480px) {
  body {
    padding: 4px;
  }
  
  .guide-container {
    padding: 8px;
  }
  
  .guide-header {
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }
  
  .guide-header h2 {
    font-size: 16px;
  }
  
  .guide-step {
    padding: 8px;
  }
  
  .step-text {
    font-size: 12px;
  }
  
  .panel {
    padding: 8px;
  }
  
  .controls-title {
    font-size: 14px;
  }
  
  .btn {
    padding: 6px 8px;
    font-size: 12px;
  }
  
  .btn svg {
    width: 12px;
    height: 12px;
  }
  
  #nfa-canvas {
    height: 200px;
  }
  
  .canvas-container h4 {
    font-size: 14px;
  }
  
  .canvas-instruction {
    font-size: 11px;
  }
  
  .regex-display {
    padding: 6px;
  }
  
  .regex-text {
    font-size: 12px;
    line-height: 1.3;
  }
  
  .steps-panel h3 {
    font-size: 16px;
  }
  
  .step-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  .step-content {
    font-size: 12px;
  }
  
  .floating-algorithm-btn {
    padding: 6px;
    top: 4px;
    right: 4px;
  }
  
  .floating-algorithm-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* Small Mobile (360px and below) */
@media (max-width: 360px) {
  .guide-header h2 {
    font-size: 14px;
  }
  
  .step-number {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
  
  .step-text {
    font-size: 11px;
  }
  
  .btn {
    padding: 4px 6px;
    font-size: 11px;
  }
  
  #nfa-canvas {
    height: 180px;
  }
  
  .canvas-container h4 {
    font-size: 13px;
  }
  
  .modal-content {
    margin: 2px;
  }
  
  .modal-header {
    padding: 8px;
  }
  
  .modal-header h3 {
    font-size: 16px;
  }
  
  .modal-body {
    padding: 8px;
  }
  
  .formula {
    font-size: 12px;
    padding: 8px;
  }
}

/* Animation for state highlighting */
.state-highlight {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

.transition-highlight {
  stroke-width: 3 !important;
  animation: glow 1.5s infinite alternate;
}

@keyframes glow {
  from { filter: drop-shadow(0 0 5px #3b82f6); }
  to { filter: drop-shadow(0 0 15px #3b82f6); }
}

/* Floating Algorithm Button */
.floating-algorithm-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(59, 130, 246, 0.95);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  backdrop-filter: blur(8px);
  z-index: 1000;
}

.floating-algorithm-btn:hover {
  background: rgba(37, 99, 235, 0.95);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.floating-algorithm-btn svg {
  flex-shrink: 0;
}

/* Algorithm Modal */
.algorithm-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.algorithm-modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 16px;
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: modalSlideIn 0.3s ease-out;
}

.modal-header {
  display: flex;
  justify-content: between;
  align-items: center;
  padding: 24px 24px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
  flex: 1;
}

.close-btn {
  background: none;
  border: none;
  font-size: 28px;
  color: #6b7280;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  margin-left: 16px;
}

.close-btn:hover {
  color: #374151;
}

.modal-body {
  padding: 24px;
}

.modal-body p {
  margin: 0 0 20px;
  color: #4b5563;
  line-height: 1.6;
}

.algorithm-steps {
  margin: 24px 0;
}

.algo-step {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(249, 250, 251, 0.8);
  border-radius: 12px;
  border-left: 4px solid #3b82f6;
}

.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: #3b82f6;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.step-content h4 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.step-content p {
  margin: 0;
  font-size: 14px;
  color: #4b5563;
  line-height: 1.5;
}

.formula-section {
  margin-top: 24px;
  padding: 20px;
  background: rgba(254, 249, 195, 0.8);
  border-radius: 12px;
  border-left: 4px solid #f59e0b;
}

.formula-section h4 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: #92400e;
}

.formula {
  font-family: 'Courier New', monospace;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  background: white;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  text-align: center;
}

.formula-note {
  margin: 0;
  font-size: 13px;
  color: #78716c;
  font-style: italic;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .floating-algorithm-btn {
    top: 10px;
    right: 10px;
    padding: 10px 12px;
    font-size: 13px;
  }
  
  .floating-algorithm-btn span {
    display: none;
  }
  
  .modal-content {
    margin: 10px;
    max-height: 90vh;
  }
  
  .modal-header {
    padding: 16px 16px 12px;
  }
  
  .modal-header h3 {
    font-size: 20px;
  }
  
  .modal-body {
    padding: 16px;
  }
  
  .algo-step {
    padding: 12px;
  }
  
  .formula-section {
    padding: 16px;
  }
}
