@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 {
    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;
}

textarea {
    min-height: 120px;
}

textarea:focus,
input: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-bottom: 15px;
    align-items: center;
}

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;
}

.button-danger {
    border-color: var(--factorio-red);
    color: var(--factorio-red);
}

.button-danger:hover {
    background-color: var(--factorio-red);
    color: #000;
}

.history-container {
    background-color: #0a0a0a;
    border: 1px solid #444;
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 2px;
    display: flex;
    align-items: center;
}

.history-label {
    color: var(--factorio-accent);
    margin-right: 10px;
    font-size: 12px;
    white-space: nowrap;
}

.history-items {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--factorio-gray) #0a0a0a;
    padding-bottom: 5px;
    flex-grow: 1;
}

.history-item {
    background-color: var(--factorio-dark-alt);
    color: var(--factorio-gray);
    padding: 4px 8px;
    font-size: 10px;
    cursor: pointer;
    border: 1px solid #444;
    white-space: nowrap;
    border-radius: 2px;
}

.history-item:hover {
    border-color: var(--factorio-primary);
    color: var(--factorio-primary);
}

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

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

.replace-container {
    display: none;
    background-color: #0a0a0a;
    border: 1px solid #444;
    padding: 15px;
    margin-top: 10px;
    border-radius: 2px;
}

.replace-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.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;
}

.json-editor-container {
    border: 1px solid #444;
    border-radius: 2px;
    font-size: 14px;
    margin-bottom: 15px;
}

.CodeMirror {
    background: var(--factorio-accent) !important;
    color: #e0e0e0;
    font-family: monospace;
    height: auto;
    min-height: 250px;
    line-height: 1.5;
}

.CodeMirror-gutters {
    background: var(--factorio-accent);
    border-right: 1px solid #444;
}

.CodeMirror-linenumber {
    color: var(--factorio-gray);
}

.CodeMirror-cursor {
    border-left: 1px solid var(--factorio-primary);
}

.CodeMirror-activeline-background {
    background: rgba(255, 255, 255, 0.05);
}

.CodeMirror-selected {
    background: rgba(119, 184, 237, 0.3);
}

.cm-s-material-darker.CodeMirror {
    background: var(--factorio-accent);
}

.cm-s-material-darker .cm-property {
    color: var(--factorio-primary);
}

.cm-s-material-darker .cm-string {
    color: var(--terminal-green);
}

.cm-s-material-darker .cm-number {
    color: var(--factorio-gray);
}

.cm-s-material-darker .cm-atom {
    color: var(--factorio-secondary);
}

.cm-s-material-darker .cm-keyword {
    color: var(--factorio-red);
}

.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;
}

.CodeMirror-line {
    padding-left: 5px !important;
    box-shadow: inset 0 -1px 0 #141414;
}

.cm-matchhighlight {
    background-color: rgba(255, 151, 0, 0.3) !important;
}

.CodeMirror-focused .cm-matchhighlight {
    background-color: rgba(255, 151, 0, 0.5) !important;
}

::-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);
}
