/* Transistor-Level GPU Cellular Automata CPU Simulator */
/* Main stylesheet */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    overflow: hidden;
    height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Toolbar */
#toolbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 8px 16px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    flex-wrap: wrap;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.group-label {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#toolbar button {
    padding: 6px 12px;
    background: #0f3460;
    border: 1px solid #1a4a7a;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
}

#toolbar button:hover {
    background: #1a4a7a;
    border-color: #2a6aaa;
}

#toolbar button:active {
    background: #0a2a50;
}

#toolbar button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#toolbar input[type="range"] {
    width: 100px;
    accent-color: #4fc3f7;
}

#toolbar label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    cursor: pointer;
}

#speed-value {
    min-width: 20px;
    text-align: right;
}

/* Main container */
#main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Tool palette sidebar wrapper */
#tool-palette-wrapper {
    display: flex;
    flex-shrink: 0;
    position: relative;
}

#tool-palette {
    width: 360px;
    min-width: 120px;
    max-width: 500px;
    background: #16213e;
    padding: 12px;
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

#panel-resize-handle {
    width: 4px;
    background: #0f3460;
    cursor: ew-resize;
    flex-shrink: 0;
}

#panel-resize-handle:hover,
#panel-resize-handle.dragging {
    background: #1a4a7a;
}

#tool-palette h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
    margin: 16px 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid #0f3460;
    flex-shrink: 0;
}

#tool-palette h3:first-child {
    margin-top: 0;
}

.palette-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #0f3460;
    border: 1px solid #1a4a7a;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    text-align: left;
}

.tool-btn:hover {
    background: #1a4a7a;
}

.tool-btn.active {
    background: #4fc3f7;
    color: #1a1a2e;
    border-color: #4fc3f7;
}

.tool-icon {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    flex-shrink: 0;
}

.wire-icon { background: linear-gradient(90deg, #4caf50, #8bc34a); }
.path-icon { background: linear-gradient(135deg, #4caf50 25%, #2196f3 50%, #4caf50 75%); }
.trans-icon { background: linear-gradient(135deg, #ff9800, #ff5722); }
.cross-icon { background: linear-gradient(45deg, #9c27b0 25%, transparent 25%, transparent 75%, #9c27b0 75%), linear-gradient(45deg, #9c27b0 25%, #673ab7 25%, #673ab7 75%, #9c27b0 75%); }
.junc-icon { background: #00bcd4; border-radius: 50%; }
.input-hi-icon { background: #f44336; }
.input-lo-icon { background: #333; border: 1px solid #666; }
.output-icon { background: #e91e63; border-radius: 50%; }
.erase-icon { background: repeating-linear-gradient(45deg, #666, #666 2px, #333 2px, #333 4px); }
.annotate-icon { background: #4fc3f7; border-radius: 2px; position: relative; }
.annotate-icon::after { content: 'A'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: bold; color: #1a1a2e; }

/* Direction info */
.direction-info {
    margin: 12px 0;
    padding: 8px;
    background: #0a2040;
    border-radius: 4px;
    font-size: 11px;
    color: #4fc3f7;
    flex-shrink: 0;
}

/* Orientation buttons */
.orientation-group {
    display: flex;
    gap: 4px;
}

.orient-btn {
    flex: 1;
    padding: 8px;
    background: #0f3460;
    border: 1px solid #1a4a7a;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
}

.orient-btn:hover {
    background: #1a4a7a;
}

.orient-btn.active {
    background: #4fc3f7;
    color: #1a1a2e;
    border-color: #4fc3f7;
}

/* Circuit buttons */
.circuit-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.circuit-btn {
    padding: 8px 10px;
    background: #1a4a7a;
    border: 1px solid #2a6aaa;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}

.circuit-btn:hover {
    background: #2a6aaa;
}

/* File buttons */
.file-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.file-buttons button {
    padding: 8px 10px;
    background: #0f3460;
    border: 1px solid #1a4a7a;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}

.file-buttons button:hover {
    background: #1a4a7a;
}

/* Blueprint section */
.blueprint-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.blueprint-save {
    display: flex;
    gap: 4px;
}

.blueprint-save input {
    flex: 1;
    padding: 6px 8px;
    background: #0a2040;
    border: 1px solid #1a4a7a;
    color: #e0e0e0;
    border-radius: 4px;
    font-size: 12px;
}

.blueprint-save input:focus {
    outline: none;
    border-color: #4fc3f7;
}

.blueprint-save button {
    padding: 6px 10px;
    background: #1a4a7a;
    border: 1px solid #2a6aaa;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.blueprint-save button:hover:not(:disabled) {
    background: #2a6aaa;
}

.blueprint-save button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.blueprint-hint {
    font-size: 10px;
    color: #666;
    font-style: italic;
}

#blueprint-list {
    overflow-y: auto;
    max-height: 200px;
}

.no-blueprints {
    font-size: 11px;
    color: #555;
    font-style: italic;
    padding: 8px 0;
}

.blueprint-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: #0a2040;
    border-radius: 4px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.blueprint-item:hover {
    background: #1a3050;
}

.blueprint-name {
    flex: 1;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.blueprint-size {
    font-size: 10px;
    color: #666;
}

.blueprint-paste, .blueprint-delete {
    padding: 2px 6px;
    background: #1a4a7a;
    border: 1px solid #2a6aaa;
    color: #e0e0e0;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
}

.blueprint-paste:hover {
    background: #4fc3f7;
    color: #1a1a2e;
}

.blueprint-delete:hover {
    background: #f44336;
    border-color: #f44336;
}

/* Help section */
.help-section {
    margin-top: 16px;
    flex-shrink: 0;
}

.shortcuts-list {
    font-size: 11px;
    color: #888;
}

.shortcuts-list div {
    margin-bottom: 4px;
}

kbd {
    display: inline-block;
    padding: 2px 5px;
    background: #0a2040;
    border: 1px solid #1a4a7a;
    border-radius: 3px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 10px;
    color: #4fc3f7;
}

/* Canvas container */
#canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #0a0a14;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

#annotation-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#annotation-input-container {
    position: absolute;
    z-index: 100;
    pointer-events: auto;
}

#annotation-input {
    padding: 4px 8px;
    background: #0a2040;
    border: 1px solid #4fc3f7;
    color: #e0e0e0;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Monaco', 'Consolas', monospace;
    outline: none;
    min-width: 160px;
}

#annotation-input:focus {
    border-color: #7dd3f7;
    box-shadow: 0 0 4px rgba(79, 195, 247, 0.4);
}

#canvas.cursor-annotate { cursor: text; }

/* Directional cursors for wire/transistor placement */
#canvas.cursor-n { cursor: url('../cursors/arrow-up.svg') 12 12, crosshair; }
#canvas.cursor-e { cursor: url('../cursors/arrow-right.svg') 12 12, crosshair; }
#canvas.cursor-s { cursor: url('../cursors/arrow-down.svg') 12 12, crosshair; }
#canvas.cursor-w { cursor: url('../cursors/arrow-left.svg') 12 12, crosshair; }

/* Crossing cursors - two directions */
#canvas.cursor-ne { cursor: url('../cursors/corner-double-up-right.svg') 12 12, crosshair; }
#canvas.cursor-nw { cursor: url('../cursors/corner-double-up-left.svg') 12 12, crosshair; }
#canvas.cursor-se { cursor: url('../cursors/corner-double-right-down.svg') 12 12, crosshair; }
#canvas.cursor-sw { cursor: url('../cursors/corner-double-left-down.svg') 12 12, crosshair; }

#canvas.cursor-paste { cursor: copy; }
#canvas.cursor-erase { cursor: not-allowed; }
#canvas.cursor-path { cursor: cell; }

/* Status bar */
#status-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 24px;
    padding: 6px 12px;
    background: rgba(22, 33, 62, 0.9);
    border-top: 1px solid #0f3460;
    font-size: 12px;
    font-family: 'Monaco', 'Consolas', monospace;
}

#status-bar span {
    color: #888;
}

/* Error overlay */
.error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.error-content {
    background: #2a2a3e;
    padding: 32px;
    border-radius: 8px;
    text-align: center;
    max-width: 400px;
}

.error-content h2 {
    color: #f44336;
    margin-bottom: 16px;
}

.error-content p {
    margin-bottom: 12px;
    color: #ccc;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #0f3460;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #1a4a7a;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 20px;
    min-width: 320px;
    max-width: 400px;
}

.modal-content h3 {
    margin: 0 0 16px 0;
    color: #4fc3f7;
    font-size: 16px;
}

.modal-field {
    margin-bottom: 12px;
}

.modal-field label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}

.modal-field input,
.modal-field textarea {
    width: 100%;
    padding: 8px;
    background: #0a2040;
    border: 1px solid #1a4a7a;
    color: #e0e0e0;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
}

.modal-field input:focus,
.modal-field textarea:focus {
    outline: none;
    border-color: #4fc3f7;
}

.modal-field input[readonly] {
    background: #0a1a30;
    color: #888;
}

.modal-field textarea {
    resize: vertical;
    min-height: 60px;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.modal-btn {
    padding: 8px 16px;
    background: #0f3460;
    border: 1px solid #1a4a7a;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}

.modal-btn:hover {
    background: #1a4a7a;
}

.modal-btn.primary {
    background: #4fc3f7;
    color: #1a1a2e;
    border-color: #4fc3f7;
}

.modal-btn.primary:hover {
    background: #7dd3f7;
}

/* Blueprint item with metadata indicator */
.blueprint-item.has-meta::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #4fc3f7;
    border-radius: 50%;
    margin-right: 4px;
}

.blueprint-edit {
    padding: 2px 6px;
    background: #0f3460;
    border: 1px solid #1a4a7a;
    color: #888;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
}

.blueprint-edit:hover {
    background: #1a4a7a;
    color: #e0e0e0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #tool-palette {
        width: 140px;
        padding: 8px;
    }

    .tool-btn {
        padding: 6px 8px;
        font-size: 12px;
    }

    #toolbar {
        padding: 6px 12px;
        gap: 12px;
    }

    #toolbar button {
        padding: 4px 8px;
        font-size: 12px;
    }

    #status-bar {
        gap: 12px;
        font-size: 11px;
    }
}
