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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: #1e1e1e;
    color: #d4d4d4;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Toolbar */
.toolbar {
    background: #2d2d30;
    padding: 10px 20px;
    border-bottom: 1px solid #3e3e42;
    display: flex;
    align-items: center;
    gap: 20px;
}

.toolbar h1 {
    font-size: 20px;
    color: #4ec9b0;
    margin-right: 20px;
}

.toolbar-section {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn {
    background: #0e639c;
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.btn:hover {
    background: #1177bb;
}

.btn:active {
    background: #0d5689;
}

.btn-danger {
    background: #d32f2f;
}

.btn-danger:hover {
    background: #f44336;
}

.btn-danger:active {
    background: #b71c1c;
}

#circuit-select {
    background: #3c3c3c;
    color: #d4d4d4;
    border: 1px solid #3e3e42;
    padding: 6px 10px;
    border-radius: 3px;
    font-size: 13px;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Component Palette */
.palette {
    width: 220px;
    min-width: 220px;
    flex-shrink: 0;
    background: #252526;
    border-right: 1px solid #3e3e42;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.palette-tabs {
    display: flex;
    background: #2d2d30;
    border-bottom: 1px solid #3e3e42;
    flex-shrink: 0;
}

.palette-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: #858585;
    padding: 12px 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.palette-tab:hover {
    color: #cccccc;
    background: rgba(255, 255, 255, 0.03);
}

.palette-tab.active {
    color: #4ec9b0;
    border-bottom-color: #4ec9b0;
}

.palette-tab-content {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
}

.palette-tab-content.hidden {
    display: none;
}

.palette h3 {
    color: #4ec9b0;
    margin-bottom: 10px;
    font-size: 16px;
}

.component-search {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 15px;
    background: #3c3c3c;
    border: 1px solid #3e3e42;
    border-radius: 3px;
    color: #d4d4d4;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.component-search:focus {
    border-color: #0e639c;
}

.component-search::placeholder {
    color: #858585;
}

.palette-category {
    margin-bottom: 20px;
}

.palette-category h4 {
    color: #9cdcfe;
    font-size: 13px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.component-item {
    background: #2d2d30;
    padding: 8px 12px;
    margin-bottom: 6px;
    border-radius: 3px;
    cursor: move;
    transition: background 0.2s;
    user-select: none;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.component-item:hover {
    background: #3e3e42;
}

.component-item:active {
    background: #094771;
}

.subcircuit-buttons {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.subcircuit-btn {
    background: #1e1e1e;
    color: #cccccc;
    border: 1px solid #3e3e42;
    padding: 2px 8px;
    font-size: 14px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
    line-height: 1;
}

.subcircuit-btn:hover {
    background: #37373d;
    border-color: #4e4e52;
}

.subcircuit-btn:active {
    background: #2d2d30;
}

.subcircuit-btn-delete {
    color: #f48771;
}

.subcircuit-btn-delete:hover {
    background: #5a1d1d;
    border-color: #f48771;
    color: #f48771;
}

/* Workspace */
.workspace {
    flex: 1;
    position: relative;
    background: #1e1e1e;
    overflow: hidden;
}

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

#canvas.dragging {
    cursor: move;
}

#canvas.drawing-wire {
    cursor: crosshair;
}

.info-panel {
    position: absolute;
    bottom: 10px;
    left: auto;
    right: 10px;
    background: rgba(45, 45, 48, 0.9);
    padding: 8px 12px;
    border-radius: 3px;
    font-size: 12px;
    display: flex;
    gap: 15px;
    border: 1px solid #3e3e42;
    z-index: 10;
    pointer-events: none;
    max-width: calc(100% - 20px);
    box-sizing: border-box;
}

/* Scrollbar Styling */
.palette-tab-content::-webkit-scrollbar {
    width: 8px;
}

.palette-tab-content::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.palette-tab-content::-webkit-scrollbar-thumb {
    background: #3e3e42;
    border-radius: 4px;
}

.palette-tab-content::-webkit-scrollbar-thumb:hover {
    background: #4e4e52;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #2d2d30;
    border: 1px solid #3e3e42;
    border-radius: 6px;
    min-width: 400px;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #3e3e42;
}

.modal-header h3 {
    margin: 0;
    color: #4ec9b0;
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.modal-body p {
    margin: 0 0 15px 0;
    color: #d4d4d4;
    font-size: 14px;
    line-height: 1.5;
}

.modal-input {
    width: 100%;
    padding: 8px 12px;
    background: #1e1e1e;
    border: 1px solid #3e3e42;
    border-radius: 3px;
    color: #d4d4d4;
    font-size: 14px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    outline: none;
}

.modal-input:focus {
    border-color: #569cd6;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #3e3e42;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-footer .btn {
    min-width: 80px;
}

/* Properties Panel */
.properties-panel {
    position: fixed;
    right: 20px;
    top: 80px;
    width: 300px;
    max-height: calc(100vh - 100px);
    background: #252526;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: opacity 0.2s, transform 0.2s;
}

.properties-panel.hidden {
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
}

.properties-header {
    background: #2d2d30;
    padding: 12px 15px;
    border-bottom: 1px solid #3e3e42;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.properties-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #cccccc;
    margin: 0;
}

.properties-header .close-btn {
    background: none;
    border: none;
    color: #cccccc;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.properties-header .close-btn:hover {
    color: #fff;
}

.properties-content {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
}

.component-info {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #3e3e42;
}

.component-info strong {
    display: block;
    color: #4ec9b0;
    font-size: 13px;
    margin-bottom: 5px;
}

.component-info p {
    font-size: 12px;
    color: #858585;
    margin: 5px 0;
}

.no-selection,
.no-properties {
    text-align: center;
    color: #858585;
    font-size: 12px;
    padding: 20px;
}

.properties-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.property-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.property-field label {
    font-size: 12px;
    color: #cccccc;
    font-weight: 500;
}

.property-field input[type="text"],
.property-field input[type="number"],
.property-field select {
    background: #3c3c3c;
    border: 1px solid #3e3e42;
    color: #cccccc;
    padding: 6px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-family: 'Consolas', monospace;
}

.property-field input[type="text"]:focus,
.property-field input[type="number"]:focus,
.property-field select:focus {
    outline: none;
    border-color: #0e639c;
}

.property-field input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.memory-edit-btn {
    background: #0e639c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.memory-edit-btn:hover {
    background: #1177bb;
}
