/* Global styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f0f0f0;
    padding: 20px;
}

/* Common button styles */
button {
    padding: 6px 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #0056b3;
}

button:active {
    background-color: #004085;
}

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.button-secondary {
    background-color: #6c757d;
}

.button-secondary:hover {
    background-color: #5a6268;
}

.button-secondary:active {
    background-color: #545b62;
}

/* Input styles */
input[type="text"],
input[type="number"] {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

input[type="checkbox"] {
    cursor: pointer;
    width: 14px;
    height: 14px;
}

input[type="range"] {
    width: 100%;
    cursor: pointer;
}

textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    resize: vertical;
    min-height: 80px;
}

/* Main app layout (index.html) */
#app {
    max-width: 1800px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 10px;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.app-title {
    font-size: 20px;
    font-weight: bold;
    padding: 10px;
    border-bottom: 2px solid #007bff;
    margin-bottom: 10px;
    color: #333;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid #ddd;
    margin-bottom: 10px;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    margin-right: 2px;
    font-weight: 500;
    transition: all 0.2s;
}

.tab:hover {
    background: #e8e8e8;
}

.tab.active {
    background: white;
    border-bottom: 2px solid white;
    margin-bottom: -2px;
    color: #007bff;
}

.tab-content {
    flex: 1;
    overflow: hidden;
    display: none;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Status bar */
.status-bar {
    padding: 8px 10px;
    background: #f5f5f5;
    border-top: 1px solid #ddd;
    font-size: 13px;
    margin-top: 10px;
    border-radius: 4px;
}

.status-bar.error {
    color: red;
    font-weight: bold;
}

.status-bar.warning {
    color: brown;
}

/* Economy Editor Styles */
.economy-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
}

.controls label {
    font-weight: 500;
}

.controls input[type="text"] {
    min-width: 200px;
}

.table-container {
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    flex: 1;
}

.table-scroll {
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #d3d3d3;
}

th {
    padding: 12px 8px;
    text-align: left;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    background-color: #d3d3d3;
    border-bottom: 2px solid #999;
}

th:hover {
    background-color: #c0c0c0;
}

td {
    padding: 8px;
    border-bottom: 1px solid #eee;
}

tbody tr:nth-child(even) {
    background-color: #ffffff;
}

tbody tr:nth-child(odd) {
    background-color: #f5f5f5;
}

tbody tr:hover {
    background-color: #e8f4f8;
}

.col-item {
    width: 50%;
}

.col-value {
    width: 30%;
}

.col-locked {
    width: 20%;
    text-align: center;
}

.no-results {
    padding: 40px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Factory Editor Styles */
.factory-editor {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 20px;
    height: 100%;
    overflow: hidden;
}

.control-panel {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.section-title {
    font-weight: bold;
    font-size: 13px;
    margin-bottom: 2px;
}

.section-hint {
    font-size: 11px;
    color: #666;
}

/* Tree view */
.tree-container {
    border: 1px solid #ccc;
    border-radius: 4px;
    max-height: 250px;
    overflow-y: auto;
    background: white;
}

.tree-node {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    cursor: pointer;
    user-select: none;
}

.tree-node:hover {
    background-color: #f5f5f5;
}

.tree-machine {
    font-weight: 500;
    font-size: 12px;
}

.tree-recipe {
    padding-left: 36px;
    font-size: 12px;
}

.tree-checkbox {
    margin-right: 8px;
    cursor: pointer;
}

.tree-expand {
    width: 16px;
    text-align: center;
    margin-right: 4px;
    font-size: 11px;
    color: #666;
}

/* Sliders */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.slider-label {
    font-weight: 500;
}

.slider-value {
    color: #666;
    font-size: 11px;
}

/* Checkboxes */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

/* Warnings */
.warning {
    color: #d32f2f;
    font-size: 11px;
    padding: 6px;
    background-color: #ffebee;
    border-radius: 4px;
    margin-top: 8px;
}

/* Tooltips */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: left;
    border-radius: 4px;
    padding: 6px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 11px;
    pointer-events: none;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Graphviz Viewer */
.viewer-panel {
    background: #fafafa;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.viewer-container {
    width: 100%;
    height: 100%;
    overflow: auto;
    position: relative;
    cursor: grab;
}

.viewer-container:active {
    cursor: grabbing;
}

.viewer-content {
    display: inline-block;
    min-width: 100%;
    min-height: 100%;
}

.viewer-svg {
    display: block;
    margin: 20px;
}

.viewer-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    color: #999;
    text-align: center;
    pointer-events: none;
}

.zoom-indicator {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: monospace;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-fit-button {
    pointer-events: auto;
    padding: 2px 6px;
    font-size: 11px;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.zoom-fit-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.zoom-fit-button:active {
    background-color: rgba(255, 255, 255, 0.4);
}

/* Standalone editor pages */
body.standalone {
    overflow: hidden;
}

.standalone #app {
    max-width: 1200px;
}

.standalone .factory-editor {
    height: calc(100vh - 40px);
}

/* Documentation Tab Styles */
.docs-content {
    overflow-y: auto;
    padding: 20px;
}

.docs-container {
    max-width: 900px;
    margin: 0 auto;
    line-height: 1.6;
    color: #333;
}

.docs-container h1 {
    font-size: 32px;
    margin-bottom: 20px;
    color: #007bff;
    border-bottom: 3px solid #007bff;
    padding-bottom: 10px;
}

.docs-container h2 {
    font-size: 24px;
    margin-top: 30px;
    margin-bottom: 15px;
    color: #333;
    border-bottom: 2px solid #ddd;
    padding-bottom: 8px;
}

.docs-container h3 {
    font-size: 20px;
    margin-top: 20px;
    margin-bottom: 12px;
    color: #555;
}

.docs-container h4 {
    font-size: 16px;
    margin-top: 15px;
    margin-bottom: 10px;
    color: #666;
    font-weight: 600;
}

.docs-container p {
    margin-bottom: 12px;
}

.docs-container ul, .docs-container ol {
    margin-bottom: 12px;
    padding-left: 30px;
}

.docs-container li {
    margin-bottom: 6px;
}

.docs-container code {
    background-color: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #d63384;
}

.docs-container strong {
    font-weight: 600;
    color: #222;
}

.docs-container em {
    font-style: italic;
    color: #555;
}

/* Documentation intro */
.docs-intro {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    font-size: 16px;
}

.docs-intro p {
    margin: 0;
}

/* Table of Contents */
.toc {
    background-color: #f9f9f9;
    border: 2px solid #007bff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.toc h2 {
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: none;
    color: #007bff;
}

.toc ul {
    list-style-type: none;
    padding-left: 0;
}

.toc > ul > li {
    margin-bottom: 10px;
}

.toc ul ul {
    padding-left: 20px;
    margin-top: 8px;
}

.toc ul ul li {
    margin-bottom: 6px;
}

.toc a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.2s;
}

.toc a:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Documentation sections */
.docs-container section {
    margin-bottom: 40px;
}

/* Example boxes */
.example-box {
    background-color: #e8f5e9;
    border-left: 4px solid #4caf50;
    padding: 12px 15px;
    margin: 15px 0;
    border-radius: 4px;
}

.example-box strong {
    color: #2e7d32;
}

/* Example steps */
.example-steps {
    background-color: #fff3e0;
    border-left: 4px solid #ff9800;
    padding: 12px 15px;
    margin: 15px 0;
    border-radius: 4px;
}

.example-steps ol {
    margin-bottom: 0;
}

/* Diagram boxes */
.diagram-box {
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    margin: 15px 0;
    overflow-x: auto;
}

.diagram-box pre {
    margin: 0;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
    color: #333;
    white-space: pre;
}

/* FAQ section */
.faq {
    background-color: #f0f7ff;
    border-left: 4px solid #2196f3;
    padding: 15px 20px;
    margin: 15px 0;
    border-radius: 4px;
}

.faq p {
    margin-bottom: 10px;
}

.faq p:last-child {
    margin-bottom: 0;
}

.faq strong {
    color: #1976d2;
    display: block;
    margin-top: 12px;
}

.faq strong:first-child {
    margin-top: 0;
}

/* Documentation footer */
.docs-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid #ddd;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.docs-footer p {
    margin-bottom: 8px;
}

/* Smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
}

/* Make links more visible in docs */
.docs-container a:not(.toc a) {
    color: #007bff;
    text-decoration: underline;
}

.docs-container a:not(.toc a):hover {
    color: #0056b3;
}

/* Documentation diagram viewers */
.docs-container .diagram-viewer {
    background: #fafafa;
    border: 2px solid #007bff;
    border-radius: 8px;
    margin: 20px 0;
    height: 500px;
    position: relative;
    overflow: hidden;
}

.docs-container .viewer-container {
    width: 100%;
    height: 100%;
    overflow: auto;
    position: relative;
    cursor: grab;
}

.docs-container .viewer-container:active {
    cursor: grabbing;
}

.docs-container .viewer-content {
    display: inline-block;
    min-width: 100%;
    min-height: 100%;
}

.docs-container .viewer-svg {
    display: block;
    margin: 20px;
}

.docs-container .zoom-indicator {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: monospace;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.docs-container .zoom-fit-button {
    pointer-events: auto;
    padding: 2px 6px;
    font-size: 11px;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.docs-container .zoom-fit-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.docs-container .zoom-fit-button:active {
    background-color: rgba(255, 255, 255, 0.4);
}

/* Button styling in docs */
.docs-container button {
    padding: 10px 20px;
    font-size: 14px;
    margin: 10px 0;
}

.docs-container button:disabled {
    opacity: 0.6;
}

/* Example loading indicator */
.example-loading {
    background: #f0f7ff;
    border: 2px dashed #007bff;
    border-radius: 4px;
    padding: 30px;
    text-align: center;
    color: #007bff;
    font-size: 16px;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

