/* Main container */
.simulator-container {
  width: 100%;
  padding: 16px;
  background-color: #0d1117;
  color: #c9d1d9;
}

.simulator-grid {
  display: grid;
  grid-template-columns: minmax(320px, 30%) 1fr;
  gap: 16px;
  min-height: 80vh;
}

/* Controls panel */
.simulator-controls {
  background-color: #161b22;
  border-radius: 6px;
  padding: 16px;
  border: 1px solid #30363d;
}

.simulator-controls h3 {
  margin-top: 0;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-badge {
  background-color: #238636;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: bold;
}

/* Tab navigation */
.tab-navigation {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid #30363d;
  margin-bottom: 16px;
}

.simulator-tab-btn {
  background: none;
  border: none;
  padding: 8px 12px;
  color: #8b949e;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
}

.simulator-tab-btn.active {
  color: #58a6ff;
  border-bottom: 2px solid #58a6ff;
}

.simulator-tab-btn:hover:not(.active) {
  color: #c9d1d9;
}

.simulator-tab-content {
  display: none;
}

.simulator-tab-content[style*="display:block"] {
  display: block !important;
}

.simulator-tab-content:empty::after {
  content: "No configuration options available for this tab yet";
  padding: 20px;
  color: #8b949e;
  font-style: italic;
  display: block;
}

/* Control submenu */
.control-submenu {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
}

.control-submenu-btn {
  background-color: #21262d;
  border: 1px solid #30363d;
  padding: 4px 8px;
  color: #8b949e;
  cursor: pointer;
  font-size: 0.8rem;
  border-radius: 4px;
}

.control-submenu-btn.active {
  background-color: #0d1117;
  color: #58a6ff;
  border-color: #58a6ff;
}

/* Control groups */
.control-group {
  margin-bottom: 20px;
}

.control-group h4 {
  color: #58a6ff;
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.form-group {
  flex: 1;
  min-width: 120px;
}

label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.9rem;
  color: #8b949e;
}

.form-control {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #30363d;
  border-radius: 4px;
  background-color: #0d1117;
  color: #c9d1d9;
}

.form-control:focus {
  outline: none;
  border-color: #58a6ff;
}

.form-control-range {
  width: 100%;
  margin: 6px 0;
  -webkit-appearance: none;
  appearance: none;
  background: #30363d;
  border-radius: 4px;
  height: 6px;
}

.form-control-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #58a6ff;
  cursor: pointer;
}

.form-control-range.danger-range::-webkit-slider-thumb {
  background: #f85149;
}

.form-control-range.success-range::-webkit-slider-thumb {
  background: #3fb950;
}

.slider-value {
  color: #58a6ff;
  font-weight: 500;
}

.danger-value {
  color: #f85149;
}

.success-value {
  color: #3fb950;
}

/* Checkbox styling */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.toggle-input {
  cursor: pointer;
}

.toggle-label {
  color: #c9d1d9;
  font-size: 0.95rem;
}

/* Button styling */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background-color: #238636;
  color: white;
}

.btn-secondary {
  background-color: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
}

.btn-primary:hover {
  background-color: #2ea043;
}

.btn-secondary:hover {
  background-color: #30363d;
}

/* Results container */
.results-container {
  background-color: #161b22;
  border-radius: 6px;
  border: 1px solid #30363d;
  position: relative;
  overflow: hidden;
  min-height: 550px; /* Add minimum height to prevent layout shifts */
}

.loading-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(13, 17, 23, 0.8);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spinner {
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top: 4px solid #58a6ff;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

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

.results-content {
  padding: 16px;
}

.results-tabs {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid #30363d;
  margin-bottom: 16px;
  gap: 4px;
}

.results-tab-btn {
  background: none;
  border: none;
  padding: 8px 12px;
  color: #8b949e;
  cursor: pointer;
  font-size: 0.9rem;
  border-radius: 4px 4px 0 0;
}

.results-tab-btn.active {
  background-color: #0d1117;
  color: #58a6ff;
  border-bottom: 2px solid #58a6ff;
  font-weight: 500;
}

.results-tab-btn:hover:not(.active) {
  color: #c9d1d9;
}

.results-tab-content {
  display: none;
  padding: 16px;
  background-color: #0d1117;
  border-radius: 0 0 4px 4px;
  border: 1px solid #30363d;
  border-top: none;
}

.results-tab-content.active {
  display: block !important; /* Important to override any inline styles */
}

/* Add debugging styles to help troubleshoot plot containers */
.results-plot {
  width: 100%;
  height: 450px !important; /* Force consistent height */
  min-height: 360px;
  background-color: #0d1117;
  border-radius: 4px;
  border: 1px solid #30363d;
  overflow: hidden;
  position: relative; /* For proper positioning of plots */
  margin-bottom: 16px; /* Add margin for spacing */
}

/* Add a loading/placeholder state for empty plots */
.results-plot:empty {
  position: relative;
}

.results-plot:empty::after {
  content: "Loading plot...";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #58a6ff;
  font-style: italic;
}

/* Add a results message container */
.results-message {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid #30363d;
  background-color: #0d1117;
  color: #c9d1d9;
  border-radius: 4px;
}

/* Simulation log */
.simulation-log {
  padding: 10px;
  background-color: #0d1117;
  border-radius: 4px;
  border: 1px solid #30363d;
  margin-top: 16px;
  font-family: monospace;
  color: #8b949e;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* Table styling */
.results-table {
  width: 100%;
  height: 450px !important; /* Match plot height */
  overflow: auto;
  margin-bottom: 16px;
  background-color: #0d1117;
  border-radius: 4px;
  border: 1px solid #30363d;
  padding: 2px; /* Add slight padding */
}

.results-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.results-table th,
.results-table td {
  padding: 8px 12px;
  text-align: left;
  border: 1px solid #30363d;
}

.results-table th {
  background: #21262d;
  color: #58a6ff;
  font-weight: 500;
}

.results-table tr:nth-child(even) {
  background: #161b22;
}

/* Wiki styling */
.wiki-content {
  line-height: 1.6;
  color: #c9d1d9;
  padding: 16px;
  background-color: #0d1117;
  border-radius: 4px;
  border: 1px solid #30363d;
}

.wiki-content h1,
.wiki-content h2 {
  color: #58a6ff;
  margin-top: 24px;
  margin-bottom: 16px;
  padding-bottom: 6px;
  border-bottom: 1px solid #30363d;
}

.wiki-content h3, 
.wiki-content h4, 
.wiki-content h5 {
  color: #58a6ff;
  margin-top: 20px;
  margin-bottom: 10px;
}

.wiki-content p {
  margin-bottom: 16px;
}

.wiki-content ul, 
.wiki-content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.wiki-content li {
  margin-bottom: 4px;
}

.wiki-content code {
  background-color: #161b22;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9em;
  color: #e6edf3;
}

.wiki-content pre {
  background-color: #161b22;
  padding: 16px;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.wiki-content blockquote {
  border-left: 4px solid #30363d;
  padding-left: 16px;
  color: #8b949e;
  margin: 0 0 16px;
}

.wiki-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.wiki-content th,
.wiki-content td {
  padding: 8px 12px;
  border: 1px solid #30363d;
  text-align: left;
}

.wiki-content th {
  background-color: #161b22;
}

.wiki-content tr:nth-child(even) {
  background-color: rgba(22, 27, 34, 0.5);
}

.wiki-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

/* Grid gallery */
.grid-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.grid-gallery img {
  flex: 1 0 calc(33.33% - 8px);
  max-width: calc(33.33% - 8px);
  border-radius: 4px;
}

/* Divider */
.divider {
  border: none;
  height: 1px;
  background-color: #30363d;
  margin: 16px 0;
}

/* Tooltip */
.tooltip-icon {
  cursor: help;
  opacity: 0.7;
}

/* Error message */
.error-message {
  color: #f85149;
  padding: 16px;
  border: 1px solid #f85149;
  border-radius: 4px;
  background-color: rgba(248, 81, 73, 0.1);
}

/* Responsive adjustments */
@media (max-width: 992px) {
  .simulator-grid {
    grid-template-columns: 1fr;
  }
  
  .results-tab-content {
    height: 400px;
  }
}

@media (max-width: 768px) {
  .simulator-grid {
    grid-template-columns: 1fr;
  }
  
  .control-row {
    flex-direction: column;
  }
  
  .form-group {
    width: 100%;
  }
  
  .results-tabs {
    overflow-x: auto;
  }
  
  .results-tab-btn {
    min-width: 100px;
    white-space: nowrap;
  }
  
  .results-tab-content {
    height: 300px;
  }
}

@media (max-width: 576px) {
  .simulator-container {
    padding: 10px;
  }
  
  .simulator-controls, 
  .results-container {
    padding: 12px;
  }
}

/* Add some space under the form */
#sim-form {
  margin-bottom: 20px;
}
