@font-face {
  font-family: "FactorioFont";
  src: url("https://fonts.cdnfonts.com/s/19687/PressStart2P-Regular.woff") format("woff");
}

:root {
  --factorio-dark: #1a1a1a;    
  --factorio-dark-alt: #242424;
  --factorio-primary: #77b8ed;
  --factorio-secondary: #ffcc00;
  --factorio-accent: #0a0a0a;
  --factorio-green: #4cc237;
  --factorio-red: #e35959;
  --factorio-gray: #888888;
  --terminal-green: #4daf39;
  --blueprint-blue: #888888;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "FactorioFont", monospace;
  background-color: var(--factorio-dark);
  color: #e0e0e0;
  margin: 0;
  padding: 0;
  line-height: 1.6;
  background-image: 
    linear-gradient(rgba(0, 0, 0, 0.2) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.2) 1px, transparent 1px);
  background-size: 20px 20px;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 3px solid var(--factorio-primary);
  padding-bottom: 10px;
}

.header h1 {
  color: var(--factorio-primary);
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
  font-size: 24px;
  margin: 0;
}

.header-logo {
  display: flex;
  align-items: center;
}

.header-logo img {
  margin-right: 15px;
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
}

.blueprint-panel {
  background-color: var(--factorio-dark-alt);
  border: 2px solid var(--factorio-accent);
  padding: 15px;
  margin-bottom: 20px;
  border-radius: 4px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.panel-title {
  color: var(--factorio-primary);
  font-size: 16px;
  margin: 0;
  display: flex;
  align-items: center;
}

.panel-title:before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 16px;
  background-color: var(--factorio-primary);
  margin-right: 8px;
}

textarea, input, select {
  width: 100%;
  background-color: #0a0a0a;
  color: var(--blueprint-blue);
  border: 1px solid #444;
  padding: 10px;
  font-family: monospace;
  margin-bottom: 10px;
  resize: vertical;
  border-radius: 2px;
}

input[type="color"] {
    padding: 0;
    min-width: 40px;
    height: 40px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid #444;
}

select {
    font-family: "FactorioFont", monospace;
    font-size: 12px;
}

textarea {
  min-height: 120px;
}

textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--factorio-primary);
  box-shadow: 0 0 0 2px rgba(255, 151, 0, 0.3);
}

.button-group {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

button {
  background-color: var(--factorio-dark-alt);
  color: var(--factorio-primary);
  border: 2px solid var(--factorio-primary);
  padding: 6px 12px;
  font-family: "FactorioFont", monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

button:hover {
  background-color: var(--factorio-primary);
  color: #000;
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.button-primary {
  background-color: var(--factorio-primary);
  color: #000;
}

.search-container {
  display: flex;
  margin-bottom: 10px;
  gap: 10px;
}

.search-input {
  flex-grow: 1;
  margin-bottom: 0;
}

.json-container {
  position: relative;
}

.line-numbers {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 2px;
  width: 40px;
  background: var(--factorio-dark);
  overflow: hidden;
  padding: 12px 5px 5px 0;
  text-align: right;
  color: var(--factorio-gray);
  font-size: 12px;
  user-select: none;
  border-right: 1px solid var(--factorio-border);
  line-height: 1.5;
  box-sizing: border-box;
}

#jsonDisplay, #jsonEditor {
  transition: height 0.3s ease-in-out;
}

#jsonDisplay {
  background-color: #0a0a0a;
  color: #e0e0e0;
  border: 1px solid #444;
  padding: 8px 8px 8px 45px;
  font-family: monospace;
  font-size: 12px;
  max-height: none;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  overflow-y: auto;
  cursor: pointer;
  line-height: 1.5;
  border-radius: 2px;
  margin-bottom: 0;
}

#jsonDisplay.editing {
  display: none;
}

#jsonEditor {
  display: none;
  padding-left: 45px;
  line-height: 1.5;
  font-family: monospace;
  font-size: 12px;
  width: 100%;
  resize: vertical;
  tab-size: 2;
  border-radius: 2px;
}

#jsonEditor.editing {
  display: block;
}

/* JSON syntax highlighting */
.json-key { color: var(--factorio-primary); }
.json-string { color: var(--terminal-green); }
.json-number { color: #888888; }
.json-boolean { color: var(--factorio-secondary); }
.json-null { color: var(--factorio-red); }
.json-bracket { color: #e0e0e0; }

.highlight-match {
  background-color: rgba(255, 151, 0, 0.3);
  color: white !important;
}

.footer {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
  border-top: 2px solid var(--factorio-primary);
  padding-top: 20px;
  font-size: 10px;
  color: #888888;
}

.footer a { color: #e0e0e0; text-decoration: none; }
.footer a:hover { text-decoration: underline; color: var(--factorio-primary); }
.footer-links { display: flex; flex-direction: column; gap: 5px; }
.footer-links p { margin: 0; }

.factorio-tooltip { position: relative; display: inline-block; }
.factorio-tooltip .tooltip-text {
  visibility: hidden;
  width: 120px;
  background-color: var(--factorio-dark-alt);
  color: var(--factorio-primary);
  text-align: center;
  border: 1px solid var(--factorio-primary);
  padding: 5px;
  border-radius: 2px;
  position: left;
  z-index: 1;
  bottom: 125%;
  left: 100%;
  margin-left: -60px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 10px;
}
.factorio-tooltip:hover .tooltip-text { visibility: visible; opacity: 1; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--factorio-primary); }
